Add all L1 tick types for ib
parent
f438139ad7
commit
9c3850874d
|
@ -460,6 +460,20 @@ async def get_client(
|
||||||
yield get_method_proxy(portal, Client)
|
yield get_method_proxy(portal, Client)
|
||||||
|
|
||||||
|
|
||||||
|
# https://interactivebrokers.github.io/tws-api/tick_types.html
|
||||||
|
tick_types = {
|
||||||
|
77: 'trade',
|
||||||
|
48: 'utrade',
|
||||||
|
0: 'bsize',
|
||||||
|
1: 'bid',
|
||||||
|
2: 'ask',
|
||||||
|
3: 'asize',
|
||||||
|
4: 'last',
|
||||||
|
5: 'size',
|
||||||
|
8: 'volume',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def normalize(
|
def normalize(
|
||||||
ticker: Ticker,
|
ticker: Ticker,
|
||||||
calc_price: bool = False
|
calc_price: bool = False
|
||||||
|
@ -468,27 +482,7 @@ def normalize(
|
||||||
new_ticks = []
|
new_ticks = []
|
||||||
for tick in ticker.ticks:
|
for tick in ticker.ticks:
|
||||||
td = tick._asdict()
|
td = tick._asdict()
|
||||||
|
td['type'] = tick_types.get(td['tickType'], 'n/a')
|
||||||
if td['tickType'] in (77,):
|
|
||||||
td['type'] = 'trade'
|
|
||||||
|
|
||||||
if td['tickType'] in (48,):
|
|
||||||
td['type'] = 'utrade'
|
|
||||||
|
|
||||||
elif td['tickType'] in (0,):
|
|
||||||
td['type'] = 'bsize'
|
|
||||||
|
|
||||||
elif td['tickType'] in (1,):
|
|
||||||
td['type'] = 'bid'
|
|
||||||
|
|
||||||
elif td['tickType'] in (2,):
|
|
||||||
td['type'] = 'ask'
|
|
||||||
|
|
||||||
elif td['tickType'] in (3,):
|
|
||||||
td['type'] = 'asize'
|
|
||||||
|
|
||||||
elif td['tickType'] in (5,):
|
|
||||||
td['type'] = 'size'
|
|
||||||
|
|
||||||
new_ticks.append(td)
|
new_ticks.append(td)
|
||||||
|
|
||||||
|
@ -507,7 +501,7 @@ def normalize(
|
||||||
# add time stamps for downstream latency measurements
|
# add time stamps for downstream latency measurements
|
||||||
data['brokerd_ts'] = time.time()
|
data['brokerd_ts'] = time.time()
|
||||||
|
|
||||||
# stupid stupid shit...don't even care any more
|
# stupid stupid shit...don't even care any more..
|
||||||
# leave it until we do a proper latency study
|
# leave it until we do a proper latency study
|
||||||
# if ticker.rtTime is not None:
|
# if ticker.rtTime is not None:
|
||||||
# data['broker_ts'] = data['rtTime_s'] = float(
|
# data['broker_ts'] = data['rtTime_s'] = float(
|
||||||
|
|
Loading…
Reference in New Issue