mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-18 01:44:34 +08:00
provide dtype to empty series to surpress warning; fix type (#1449)
This commit is contained in:
@@ -783,7 +783,7 @@ class LocalPITProvider(PITProvider):
|
|||||||
index_path = C.dpm.get_data_uri() / "financial" / instrument.lower() / f"{field}.index"
|
index_path = C.dpm.get_data_uri() / "financial" / instrument.lower() / f"{field}.index"
|
||||||
data_path = C.dpm.get_data_uri() / "financial" / instrument.lower() / f"{field}.data"
|
data_path = C.dpm.get_data_uri() / "financial" / instrument.lower() / f"{field}.data"
|
||||||
if not (index_path.exists() and data_path.exists()):
|
if not (index_path.exists() and data_path.exists()):
|
||||||
raise FileNotFoundError("No file is found. Raise exception and ")
|
raise FileNotFoundError("No file is found.")
|
||||||
# NOTE: The most significant performance loss is here.
|
# NOTE: The most significant performance loss is here.
|
||||||
# Does the acceleration that makes the program complicated really matters?
|
# Does the acceleration that makes the program complicated really matters?
|
||||||
# - It makes parameters of the interface complicate
|
# - It makes parameters of the interface complicate
|
||||||
@@ -797,14 +797,14 @@ class LocalPITProvider(PITProvider):
|
|||||||
cur_time_int = int(cur_time.year) * 10000 + int(cur_time.month) * 100 + int(cur_time.day)
|
cur_time_int = int(cur_time.year) * 10000 + int(cur_time.month) * 100 + int(cur_time.day)
|
||||||
loc = np.searchsorted(data["date"], cur_time_int, side="right")
|
loc = np.searchsorted(data["date"], cur_time_int, side="right")
|
||||||
if loc <= 0:
|
if loc <= 0:
|
||||||
return pd.Series()
|
return pd.Series(dtype=C.pit_record_type["value"])
|
||||||
last_period = data["period"][:loc].max() # return the latest quarter
|
last_period = data["period"][:loc].max() # return the latest quarter
|
||||||
first_period = data["period"][:loc].min()
|
first_period = data["period"][:loc].min()
|
||||||
period_list = get_period_list(first_period, last_period, quarterly)
|
period_list = get_period_list(first_period, last_period, quarterly)
|
||||||
if period is not None:
|
if period is not None:
|
||||||
# NOTE: `period` has higher priority than `start_index` & `end_index`
|
# NOTE: `period` has higher priority than `start_index` & `end_index`
|
||||||
if period not in period_list:
|
if period not in period_list:
|
||||||
return pd.Series()
|
return pd.Series(dtype=C.pit_record_type["value"])
|
||||||
else:
|
else:
|
||||||
period_list = [period]
|
period_list = [period]
|
||||||
else:
|
else:
|
||||||
@@ -868,7 +868,7 @@ class LocalExpressionProvider(ExpressionProvider):
|
|||||||
# Ensure that each column type is consistent
|
# Ensure that each column type is consistent
|
||||||
# FIXME:
|
# FIXME:
|
||||||
# 1) The stock data is currently float. If there is other types of data, this part needs to be re-implemented.
|
# 1) The stock data is currently float. If there is other types of data, this part needs to be re-implemented.
|
||||||
# 2) The the precision should be configurable
|
# 2) The precision should be configurable
|
||||||
try:
|
try:
|
||||||
series = series.astype(np.float32)
|
series = series.astype(np.float32)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|||||||
Reference in New Issue
Block a user