1- from typing import Dict , List , Tuple , Union
1+ from __future__ import annotations
22
33import numpy as np
44
1010################################################################################
1111
1212
13- def get_deriv_ba_types (level : int ) -> List [ Tuple [str , Union [ type , str ] ]]:
13+ def get_deriv_ba_types (level : int ) -> list [ tuple [str , type | str ]]:
1414 return [
1515 (f"bid_px_{ level :02d} " , np .int64 ),
1616 (f"ask_px_{ level :02d} " , np .int64 ),
@@ -37,15 +37,15 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
3737)
3838
3939
40- RECORD_HEADER : List [ Tuple [str , Union [ type , str ] ]] = [
40+ RECORD_HEADER : list [ tuple [str , type | str ]] = [
4141 ("length" , np .uint8 ),
4242 ("rtype" , np .uint8 ),
4343 ("publisher_id" , np .uint16 ),
4444 ("instrument_id" , np .uint32 ),
4545 ("ts_event" , np .uint64 ),
4646]
4747
48- MBO_MSG : List [ Tuple [str , Union [ type , str ] ]] = RECORD_HEADER + [
48+ MBO_MSG : list [ tuple [str , type | str ]] = RECORD_HEADER + [
4949 ("order_id" , np .uint64 ),
5050 ("price" , np .int64 ),
5151 ("size" , np .uint32 ),
@@ -58,7 +58,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
5858 ("sequence" , np .uint32 ),
5959]
6060
61- MBP_MSG : List [ Tuple [str , Union [ type , str ] ]] = RECORD_HEADER + [
61+ MBP_MSG : list [ tuple [str , type | str ]] = RECORD_HEADER + [
6262 ("price" , np .int64 ),
6363 ("size" , np .uint32 ),
6464 ("action" , "S1" ), # 1 byte chararray
@@ -71,15 +71,15 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
7171]
7272
7373
74- OHLCV_MSG : List [ Tuple [str , Union [ type , str ] ]] = RECORD_HEADER + [
74+ OHLCV_MSG : list [ tuple [str , type | str ]] = RECORD_HEADER + [
7575 ("open" , np .int64 ),
7676 ("high" , np .int64 ),
7777 ("low" , np .int64 ),
7878 ("close" , np .int64 ),
7979 ("volume" , np .int64 ),
8080]
8181
82- DEFINITION_MSG : List [ Tuple [str , Union [ type , str ] ]] = RECORD_HEADER + [
82+ DEFINITION_MSG : list [ tuple [str , type | str ]] = RECORD_HEADER + [
8383 ("ts_recv" , np .uint64 ),
8484 ("min_price_increment" , np .int64 ),
8585 ("display_factor" , np .int64 ),
@@ -147,7 +147,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
147147 ("dummy" , "S3" ), # 3 byte chararray (Adjustment filler for 8-bytes alignment)
148148]
149149
150- IMBALANCE_MSG : List [ Tuple [str , Union [ type , str ] ]] = RECORD_HEADER + [
150+ IMBALANCE_MSG : list [ tuple [str , type | str ]] = RECORD_HEADER + [
151151 ("ts_recv" , np .uint64 ),
152152 ("ref_price" , np .int64 ),
153153 ("auction_time" , np .uint64 ),
@@ -171,7 +171,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
171171 ("dummy" , "S1" ),
172172]
173173
174- STATISTICS_MSG : List [ Tuple [str , Union [ type , str ] ]] = RECORD_HEADER + [
174+ STATISTICS_MSG : list [ tuple [str , type | str ]] = RECORD_HEADER + [
175175 ("ts_recv" , np .uint64 ),
176176 ("ts_ref" , np .uint64 ),
177177 ("price" , np .int64 ),
@@ -186,7 +186,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
186186]
187187
188188
189- STRUCT_MAP : Dict [Schema , List [ Tuple [str , Union [ type , str ] ]]] = {
189+ STRUCT_MAP : dict [Schema , list [ tuple [str , type | str ]]] = {
190190 Schema .MBO : MBO_MSG ,
191191 Schema .MBP_1 : MBP_MSG + get_deriv_ba_types (0 ), # 1
192192 Schema .MBP_10 : MBP_MSG
@@ -253,7 +253,7 @@ def get_deriv_ba_types(level: int) -> List[Tuple[str, Union[type, str]]]:
253253################################################################################
254254
255255
256- def get_deriv_ba_fields (level : int ) -> List [str ]:
256+ def get_deriv_ba_fields (level : int ) -> list [str ]:
257257 return [
258258 f"bid_px_{ level :02d} " ,
259259 f"ask_px_{ level :02d} " ,
0 commit comments