mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-17 17:34:35 +08:00
remove some useless code
This commit is contained in:
@@ -151,10 +151,6 @@ class FundCollector(BaseCollector):
|
|||||||
raise ValueError(f"cannot support {interval}")
|
raise ValueError(f"cannot support {interval}")
|
||||||
return _result
|
return _result
|
||||||
|
|
||||||
def collector_data(self):
|
|
||||||
"""collector data"""
|
|
||||||
super(FundCollector, self).collector_data()
|
|
||||||
|
|
||||||
|
|
||||||
class FundollectorCN(FundCollector, ABC):
|
class FundollectorCN(FundCollector, ABC):
|
||||||
def get_instrument_list(self):
|
def get_instrument_list(self):
|
||||||
@@ -213,12 +209,8 @@ class FundNormalize(BaseNormalize):
|
|||||||
return df
|
return df
|
||||||
|
|
||||||
|
|
||||||
class FundNormalize1d(FundNormalize, ABC):
|
class FundNormalize1d(FundNormalize):
|
||||||
DAILY_FORMAT = "%Y-%m-%d"
|
pass
|
||||||
|
|
||||||
def normalize(self, df: pd.DataFrame) -> pd.DataFrame:
|
|
||||||
df = super(FundNormalize1d, self).normalize(df)
|
|
||||||
return df
|
|
||||||
|
|
||||||
|
|
||||||
class FundNormalizeCN:
|
class FundNormalizeCN:
|
||||||
|
|||||||
@@ -98,9 +98,8 @@ def get_calendar_list(bench_code="CSI300") -> list:
|
|||||||
return calendar
|
return calendar
|
||||||
|
|
||||||
|
|
||||||
def return_date_list(source_dir, date_field_name: str, file_path: Path):
|
def return_date_list(date_field_name: str, file_path: Path):
|
||||||
file_path = Path(file_path)
|
date_list = pd.read_csv(file_path, sep=",", index_col=0)[date_field_name].to_list()
|
||||||
date_list = pd.read_csv(Path(source_dir).joinpath(file_path), sep=",", index_col=0)[date_field_name].to_list()
|
|
||||||
return sorted(map(lambda x: pd.Timestamp(x), date_list))
|
return sorted(map(lambda x: pd.Timestamp(x), date_list))
|
||||||
|
|
||||||
|
|
||||||
@@ -139,10 +138,13 @@ def get_calendar_list_by_ratio(
|
|||||||
|
|
||||||
logger.info(f"count how many funds trade in this day......")
|
logger.info(f"count how many funds trade in this day......")
|
||||||
_dict_count_trade = dict() # dict{date:count}
|
_dict_count_trade = dict() # dict{date:count}
|
||||||
_fun = partial(return_date_list, source_dir, date_field_name)
|
_fun = partial(return_date_list, date_field_name)
|
||||||
|
all_oldest_list = []
|
||||||
with tqdm(total=_number_all_funds) as p_bar:
|
with tqdm(total=_number_all_funds) as p_bar:
|
||||||
with ProcessPoolExecutor(max_workers=max_workers) as executor:
|
with ProcessPoolExecutor(max_workers=max_workers) as executor:
|
||||||
for date_list in executor.map(_fun, file_list[:_number_all_funds]):
|
for date_list in executor.map(_fun, file_list):
|
||||||
|
if date_list:
|
||||||
|
all_oldest_list.append(date_list[0])
|
||||||
for date in date_list:
|
for date in date_list:
|
||||||
if date not in _dict_count_trade.keys():
|
if date not in _dict_count_trade.keys():
|
||||||
_dict_count_trade[date] = 0
|
_dict_count_trade[date] = 0
|
||||||
@@ -154,12 +156,10 @@ def get_calendar_list_by_ratio(
|
|||||||
logger.info(f"count how many funds have founded in this day......")
|
logger.info(f"count how many funds have founded in this day......")
|
||||||
_dict_count_founding = {date: _number_all_funds for date in _dict_count_trade.keys()} # dict{date:count}
|
_dict_count_founding = {date: _number_all_funds for date in _dict_count_trade.keys()} # dict{date:count}
|
||||||
with tqdm(total=_number_all_funds) as p_bar:
|
with tqdm(total=_number_all_funds) as p_bar:
|
||||||
with ProcessPoolExecutor(max_workers=max_workers) as executor:
|
for oldest_date in all_oldest_list:
|
||||||
for date_list in executor.map(_fun, file_list[:_number_all_funds]):
|
for date in _dict_count_founding.keys():
|
||||||
oldest_date = sorted(date_list)[0] # this fund haven't found before this day
|
if date < oldest_date:
|
||||||
for date in _dict_count_founding.keys():
|
_dict_count_founding[date] -= 1
|
||||||
if date < oldest_date:
|
|
||||||
_dict_count_founding[date] -= 1
|
|
||||||
|
|
||||||
calendar = [
|
calendar = [
|
||||||
date
|
date
|
||||||
|
|||||||
Reference in New Issue
Block a user