1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-06-06 05:51:17 +08:00

remove some useless code

This commit is contained in:
wangershi
2021-03-18 21:15:45 +08:00
parent 4e7a147759
commit d3160e9439
2 changed files with 13 additions and 21 deletions

View File

@@ -151,10 +151,6 @@ class FundCollector(BaseCollector):
raise ValueError(f"cannot support {interval}")
return _result
def collector_data(self):
"""collector data"""
super(FundCollector, self).collector_data()
class FundollectorCN(FundCollector, ABC):
def get_instrument_list(self):
@@ -213,12 +209,8 @@ class FundNormalize(BaseNormalize):
return df
class FundNormalize1d(FundNormalize, ABC):
DAILY_FORMAT = "%Y-%m-%d"
def normalize(self, df: pd.DataFrame) -> pd.DataFrame:
df = super(FundNormalize1d, self).normalize(df)
return df
class FundNormalize1d(FundNormalize):
pass
class FundNormalizeCN:

View File

@@ -98,9 +98,8 @@ def get_calendar_list(bench_code="CSI300") -> list:
return calendar
def return_date_list(source_dir, date_field_name: str, file_path: Path):
file_path = Path(file_path)
date_list = pd.read_csv(Path(source_dir).joinpath(file_path), sep=",", index_col=0)[date_field_name].to_list()
def return_date_list(date_field_name: str, file_path: Path):
date_list = pd.read_csv(file_path, sep=",", index_col=0)[date_field_name].to_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......")
_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 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:
if date not in _dict_count_trade.keys():
_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......")
_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 ProcessPoolExecutor(max_workers=max_workers) as executor:
for date_list in executor.map(_fun, file_list[:_number_all_funds]):
oldest_date = sorted(date_list)[0] # this fund haven't found before this day
for date in _dict_count_founding.keys():
if date < oldest_date:
_dict_count_founding[date] -= 1
for oldest_date in all_oldest_list:
for date in _dict_count_founding.keys():
if date < oldest_date:
_dict_count_founding[date] -= 1
calendar = [
date