diff --git a/piker/brokers/ib.py b/piker/brokers/ib.py index b378f5f2..4dcf7b14 100644 --- a/piker/brokers/ib.py +++ b/piker/brokers/ib.py @@ -1032,7 +1032,11 @@ async def get_client( # https://interactivebrokers.github.io/tws-api/tick_types.html tick_types = { 77: 'trade', - 48: 'utrade', + + # a "utrade" aka an off exchange "unreportable" (dark) vlm: + # https://interactivebrokers.github.io/tws-api/tick_types.html#rt_volume + 48: 'dark_trade', + 0: 'bsize', 1: 'bid', 2: 'ask', @@ -1046,13 +1050,17 @@ tick_types = { def normalize( ticker: Ticker, calc_price: bool = False + ) -> dict: # convert named tuples to dicts so we send usable keys new_ticks = [] for tick in ticker.ticks: if tick and not isinstance(tick, dict): td = tick._asdict() - td['type'] = tick_types.get(td['tickType'], 'n/a') + td['type'] = tick_types.get( + td['tickType'], + 'n/a', + ) new_ticks.append(td) diff --git a/piker/data/_normalize.py b/piker/data/_normalize.py index 3474879e..56d64b75 100644 --- a/piker/data/_normalize.py +++ b/piker/data/_normalize.py @@ -25,14 +25,18 @@ import numpy as np def iterticks( quote: dict, - types: Tuple[str] = ('trade', 'utrade'), + types: Tuple[str] = ('trade', 'dark_trade'), + ) -> AsyncIterator: - """Iterate through ticks delivered per quote cycle. - """ + ''' + Iterate through ticks delivered per quote cycle. + + ''' # print(f"{quote}\n\n") ticks = quote.get('ticks', ()) if ticks: for tick in ticks: # print(f"{quote['symbol']}: {tick}") - if tick.get('type') in types: + ttype = tick.get('type') + if ttype in types: yield tick