mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-18 01:44:34 +08:00
close and reindex
This commit is contained in:
committed by
you-n-g
parent
4da3f3b104
commit
919380597b
@@ -424,7 +424,7 @@ class Exchange:
|
|||||||
else:
|
else:
|
||||||
raise NotImplementedError(f"This type of input is not supported")
|
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)
|
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"(stock_id:{stock_id}, trade_time:{(start_time, end_time)}, {pstr}): {deal_price}!!!")
|
||||||
self.logger.warning(f"setting deal_price to close price")
|
self.logger.warning(f"setting deal_price to close price")
|
||||||
deal_price = self.get_close(stock_id, start_time, end_time, method)
|
deal_price = self.get_close(stock_id, start_time, end_time, method)
|
||||||
|
|||||||
@@ -529,7 +529,8 @@ class SingleData(IndexData):
|
|||||||
tmp_data = np.full(len(index), fill_value, dtype=np.float64)
|
tmp_data = np.full(len(index), fill_value, dtype=np.float64)
|
||||||
for index_id, index_item in enumerate(index):
|
for index_id, index_item in enumerate(index):
|
||||||
try:
|
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:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
return SingleData(tmp_data, index)
|
return SingleData(tmp_data, index)
|
||||||
@@ -541,7 +542,7 @@ class SingleData(IndexData):
|
|||||||
common_index, _ = common_index.sort()
|
common_index, _ = common_index.sort()
|
||||||
tmp_data1 = self.reindex(common_index, fill_value)
|
tmp_data1 = self.reindex(common_index, fill_value)
|
||||||
tmp_data2 = other.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):
|
def to_dict(self):
|
||||||
"""convert SingleData to dict.
|
"""convert SingleData to dict.
|
||||||
|
|||||||
Reference in New Issue
Block a user