Skip to content

Commit f36b328

Browse files
fix update bundle (#978)
* fix update bundle * update * update --------- Co-authored-by: Don <lin.dongzhao@ricequant.com>
1 parent 0051735 commit f36b328

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

rqalpha/data/bundle.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@
3939
START_DATE = 20050104
4040
END_DATE = 29991231
4141

42+
CORPORATE_ACTION_EXCLUSIONS = ["Future", "Option", "Spot"]
43+
44+
45+
def _get_oids_with_corporate_action_exclusions():
46+
ints = rqdatac.all_instruments()
47+
ints = ints[~ints.type.isin(CORPORATE_ACTION_EXCLUSIONS)]
48+
return ints.order_book_id.tolist()
49+
4250

4351
def gen_instruments(d):
4452
stocks = sorted(list(rqdatac.all_instruments().order_book_id))
@@ -86,8 +94,8 @@ def __init__(self, d: str):
8694
self.d = d
8795

8896
def _get_dividend(self):
89-
stocks = rqdatac.all_instruments().order_book_id.tolist()
90-
return rqdatac.get_dividend(stocks)
97+
order_book_ids = _get_oids_with_corporate_action_exclusions()
98+
return rqdatac.get_dividend(order_book_ids)
9199

92100
def _write(self, data_iter: Iterable[Tuple[str, np.ndarray]]):
93101
with h5py.File(os.path.join(self.d, 'dividends.h5'), "w") as h5:
@@ -115,8 +123,8 @@ def __init__(self, d: str):
115123
self.d = d
116124

117125
def _get_split(self):
118-
stocks = rqdatac.all_instruments().order_book_id.tolist()
119-
return rqdatac.get_split(stocks)
126+
order_book_ids = _get_oids_with_corporate_action_exclusions()
127+
return rqdatac.get_split(order_book_ids)
120128

121129
def _write(self, data_iter: Iterable[Tuple[str, np.ndarray]]):
122130
with h5py.File(os.path.join(self.d, 'split_factor.h5'), "w") as h5:
@@ -143,8 +151,8 @@ def __init__(self, d: str):
143151
self.d = d
144152

145153
def _get_ex_factor(self):
146-
stocks = rqdatac.all_instruments().order_book_id.tolist()
147-
return rqdatac.get_ex_factor(stocks)
154+
order_book_ids = _get_oids_with_corporate_action_exclusions()
155+
return rqdatac.get_ex_factor(order_book_ids)
148156

149157
def _write(self, data_iter: Iterable[Tuple[str, np.ndarray]]):
150158
with h5py.File(os.path.join(self.d, 'ex_cum_factor.h5'), "w") as h5:

0 commit comments

Comments
 (0)