@@ -154,6 +154,30 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
154154 ("dummy" , "S3" ), # 3 byte chararray (Adjustment filler for 8-bytes alignment)
155155]
156156
157+ IMBALANCE_MSG : List [Tuple [str , Union [type , str ]]] = RECORD_HEADER + [
158+ ("ts_recv" , np .uint64 ),
159+ ("ref_price" , np .int64 ),
160+ ("auction_time" , np .uint64 ),
161+ ("cont_book_clr_price" , np .int64 ),
162+ ("auct_interest_clr_price" , np .int64 ),
163+ ("ssr_filling_price" , np .int64 ),
164+ ("ind_match_price" , np .int64 ),
165+ ("upper_collar" , np .int64 ),
166+ ("lower_collar" , np .int64 ),
167+ ("paired_qty" , np .uint32 ),
168+ ("total_imbalance_qty" , np .uint32 ),
169+ ("market_imbalance_qty" , np .uint32 ),
170+ ("unpaired_qty" , np .uint32 ),
171+ ("auction_type" , "S1" ),
172+ ("side" , "S1" ),
173+ ("auction_status" , np .uint8 ),
174+ ("freeze_status" , np .uint8 ),
175+ ("num_extensions" , np .uint8 ),
176+ ("unpaired_side" , "S1" ),
177+ ("significant_imbalance" , "S1" ),
178+ ("dummy" , "S1" ),
179+ ]
180+
157181
158182STRUCT_MAP : Dict [Schema , List [Tuple [str , Union [type , str ]]]] = {
159183 Schema .MBO : MBO_MSG ,
@@ -177,6 +201,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
177201 Schema .OHLCV_1D : OHLCV_MSG ,
178202 Schema .STATUS : STATUS_MSG ,
179203 Schema .DEFINITION : DEFINITION_MSG ,
204+ Schema .IMBALANCE : IMBALANCE_MSG ,
180205 Schema .GATEWAY_ERROR : RECORD_HEADER
181206 + [
182207 ("error" , "S64" ),
@@ -277,6 +302,13 @@ def get_deriv_ba_fields(level: int) -> List[str]:
277302 "dummy" ,
278303]
279304
305+ IMBALANCE_DROP_COLUMNS = [
306+ "ts_recv" ,
307+ "length" ,
308+ "rtype" ,
309+ "dummy" ,
310+ ]
311+
280312STATUS_COLUMNS = [
281313 x for x in (np .dtype (STATUS_MSG ).names or ()) if x not in STATUS_DROP_COLUMNS
282314]
@@ -287,6 +319,10 @@ def get_deriv_ba_fields(level: int) -> List[str]:
287319 if x not in DEFINITION_DROP_COLUMNS
288320]
289321
322+ IMBALANCE_COLUMNS = [
323+ x for x in (np .dtype (IMBALANCE_MSG ).names or ()) if x not in IMBALANCE_DROP_COLUMNS
324+ ]
325+
290326
291327COLUMNS = {
292328 Schema .MBO : [
@@ -323,4 +359,5 @@ def get_deriv_ba_fields(level: int) -> List[str]:
323359 Schema .OHLCV_1D : OHLCV_HEADER_COLUMNS ,
324360 Schema .STATUS : STATUS_COLUMNS ,
325361 Schema .DEFINITION : DEFINITION_COLUMNS ,
362+ Schema .IMBALANCE : IMBALANCE_COLUMNS ,
326363}
0 commit comments