1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-11 23:06:58 +08:00

close and reindex

This commit is contained in:
wangwenxi.handsome
2021-09-01 14:48:23 +00:00
committed by you-n-g
parent 4da3f3b104
commit 919380597b
2 changed files with 4 additions and 3 deletions

View File

@@ -424,7 +424,7 @@ class Exchange:
else:
raise NotImplementedError(f"This type of input is not supported")
deal_price = self.quote.get_data(stock_id, start_time, end_time, field=pstr, method=method)
if method is not None and (deal_price is None or np.isclose(deal_price, 0.0) or np.isnan(deal_price)):
if method is not None and (deal_price is None or np.isnan(deal_price) or deal_price <= 1e-08):
self.logger.warning(f"(stock_id:{stock_id}, trade_time:{(start_time, end_time)}, {pstr}): {deal_price}!!!")
self.logger.warning(f"setting deal_price to close price")
deal_price = self.get_close(stock_id, start_time, end_time, method)

View File

@@ -529,7 +529,8 @@ class SingleData(IndexData):
tmp_data = np.full(len(index), fill_value, dtype=np.float64)
for index_id, index_item in enumerate(index):
try:
tmp_data[index_id] = self.loc[index_item]
item_data = self.loc[index_item]
tmp_data[index_id] = item_data if item_data != np.NaN else fill_value
except KeyError:
pass
return SingleData(tmp_data, index)
@@ -541,7 +542,7 @@ class SingleData(IndexData):
common_index, _ = common_index.sort()
tmp_data1 = self.reindex(common_index, fill_value)
tmp_data2 = other.reindex(common_index, fill_value)
return tmp_data1.fillna(fill_value) + tmp_data2.fillna(fill_value)
return tmp_data1 + tmp_data2
def to_dict(self):
"""convert SingleData to dict.