@@ -48,7 +48,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
4848 ("order_id" , np .uint64 ),
4949 ("price" , np .int64 ),
5050 ("size" , np .uint32 ),
51- ("flags" , np .int8 ),
51+ ("flags" , np .uint8 ),
5252 ("channel_id" , np .uint8 ),
5353 ("action" , "S1" ), # 1 byte chararray
5454 ("side" , "S1" ), # 1 byte chararray
@@ -62,7 +62,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
6262 ("size" , np .uint32 ),
6363 ("action" , "S1" ), # 1 byte chararray
6464 ("side" , "S1" ), # 1 byte chararray
65- ("flags" , np .int8 ),
65+ ("flags" , np .uint8 ),
6666 ("depth" , np .uint8 ),
6767 ("ts_recv" , np .uint64 ),
6868 ("ts_in_delta" , np .int32 ),
@@ -93,7 +93,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
9393 ("price_ratio" , np .int64 ),
9494 ("inst_attrib_value" , np .int32 ),
9595 ("underlying_id" , np .uint32 ),
96- ("cleared_volume " , np . int32 ),
96+ ("_reserved1 " , "S4" ),
9797 ("market_depth_implied" , np .int32 ),
9898 ("market_depth" , np .int32 ),
9999 ("market_segment_id" , np .uint32 ),
@@ -102,11 +102,11 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
102102 ("min_lot_size_block" , np .int32 ),
103103 ("min_lot_size_round_lot" , np .int32 ),
104104 ("min_trade_vol" , np .uint32 ),
105- ("open_interest_qty " , np . int32 ),
105+ ("_reserved2 " , "S4" ),
106106 ("contract_multiplier" , np .int32 ),
107107 ("decay_quantity" , np .int32 ),
108108 ("original_contract_size" , np .int32 ),
109- ("reserved1 " , "S4" ),
109+ ("_reserved3 " , "S4" ),
110110 ("trading_reference_date" , np .uint16 ),
111111 ("appl_id" , np .int16 ),
112112 ("maturity_year" , np .uint16 ),
@@ -125,9 +125,9 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
125125 ("underlying" , "S21" ), # 21 byte chararray
126126 ("strike_price_currency" , "S4" ),
127127 ("instrument_class" , "S1" ),
128- ("reserved2 " , "S2" ),
128+ ("_reserved4 " , "S2" ),
129129 ("strike_price" , np .int64 ),
130- ("reserved3 " , "S6" ),
130+ ("_reserved5 " , "S6" ),
131131 ("match_algorithm" , "S1" ), # 1 byte chararray
132132 ("md_security_trading_status" , np .uint8 ),
133133 ("main_fraction" , np .uint8 ),
@@ -170,6 +170,20 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
170170 ("dummy" , "S1" ),
171171]
172172
173+ STATISTICS_MSG : List [Tuple [str , Union [type , str ]]] = RECORD_HEADER + [
174+ ("ts_recv" , np .uint64 ),
175+ ("ts_ref" , np .uint64 ),
176+ ("price" , np .int64 ),
177+ ("quantity" , np .int32 ),
178+ ("sequence" , np .uint32 ),
179+ ("ts_in_delta" , np .int32 ),
180+ ("stat_type" , np .uint16 ),
181+ ("channel_id" , np .uint16 ),
182+ ("update_action" , np .uint8 ),
183+ ("stat_flags" , np .uint8 ),
184+ ("dummy" , "S6" ),
185+ ]
186+
173187
174188STRUCT_MAP : Dict [Schema , List [Tuple [str , Union [type , str ]]]] = {
175189 Schema .MBO : MBO_MSG ,
@@ -193,6 +207,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
193207 Schema .OHLCV_1D : OHLCV_MSG ,
194208 Schema .DEFINITION : DEFINITION_MSG ,
195209 Schema .IMBALANCE : IMBALANCE_MSG ,
210+ Schema .STATISTICS : STATISTICS_MSG ,
196211}
197212
198213
@@ -208,20 +223,21 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
208223 "security_type" ,
209224 "unit_of_measure" ,
210225 "underlying" ,
226+ "strike_price_currency" ,
227+ "instrument_class" ,
211228 "match_algorithm" ,
212229 "security_update_action" ,
213230 "user_defined_instrument" ,
214- "strike_price_currency" ,
215231]
216232
217233DEFINITION_PRICE_COLUMNS = [
218234 "min_price_increment" ,
219- "display_factor" ,
220235 "high_limit_price" ,
221236 "low_limit_price" ,
222237 "max_price_variation" ,
223238 "trading_reference_price" ,
224239 "min_price_increment_amount" ,
240+ "price_ratio" ,
225241 "strike_price" ,
226242]
227243
@@ -288,6 +304,13 @@ def get_deriv_ba_fields(level: int) -> List[str]:
288304 "dummy" ,
289305]
290306
307+ STATISTICS_DROP_COLUMNS = [
308+ "ts_recv" ,
309+ "length" ,
310+ "rtype" ,
311+ "dummy" ,
312+ ]
313+
291314DEFINITION_COLUMNS = [
292315 x
293316 for x in (np .dtype (DEFINITION_MSG ).names or ())
@@ -298,6 +321,12 @@ def get_deriv_ba_fields(level: int) -> List[str]:
298321 x for x in (np .dtype (IMBALANCE_MSG ).names or ()) if x not in IMBALANCE_DROP_COLUMNS
299322]
300323
324+ STATISTICS_COLUMNS = [
325+ x
326+ for x in (np .dtype (STATISTICS_MSG ).names or ())
327+ if x not in STATISTICS_DROP_COLUMNS
328+ ]
329+
301330COLUMNS = {
302331 Schema .MBO : [
303332 "ts_event" ,
@@ -333,4 +362,5 @@ def get_deriv_ba_fields(level: int) -> List[str]:
333362 Schema .OHLCV_1D : OHLCV_HEADER_COLUMNS ,
334363 Schema .DEFINITION : DEFINITION_COLUMNS ,
335364 Schema .IMBALANCE : IMBALANCE_COLUMNS ,
365+ Schema .STATISTICS : STATISTICS_COLUMNS ,
336366}
0 commit comments