diff --git a/piker/brokers/ib.py b/piker/brokers/ib.py index 3572683c..4139d60d 100644 --- a/piker/brokers/ib.py +++ b/piker/brokers/ib.py @@ -1076,6 +1076,10 @@ def normalize( new_ticks.append(td) + tbt = ticker.tickByTicks + if tbt: + print(f'tickbyticks:\n {ticker.tickByTicks}') + ticker.ticks = new_ticks # some contracts don't have volume so we may want to calculate @@ -1088,6 +1092,11 @@ def normalize( # serialize for transport data = asdict(ticker) + # convert named tuples to dicts for transport + tbts = data.get('tickByTicks') + if tbts: + data['tickByTicks'] = [tbt._asdict() for tbt in tbts] + # add time stamps for downstream latency measurements data['brokerd_ts'] = time.time() @@ -1274,6 +1283,11 @@ async def _setup_quote_stream( '375', # RT trade volume (excludes utrades) '233', # RT trade volume (includes utrades) '236', # Shortable shares + + # these all appear to only be updated every 25s thus + # making them mostly useless and explains why the scanner + # is always slow XD + # '293', # Trade count for day '294', # Trade rate / minute '295', # Vlm rate / minute ), @@ -1294,6 +1308,12 @@ async def _setup_quote_stream( contract = contract or (await client.find_contract(symbol)) ticker: Ticker = client.ib.reqMktData(contract, ','.join(opts)) + # NOTE: it's batch-wise and slow af but I guess could + # be good for backchecking? Seems to be every 5s maybe? + # ticker: Ticker = client.ib.reqTickByTickData( + # contract, 'Last', + # ) + # # define a simple queue push routine that streams quote packets # # to trio over the ``to_trio`` memory channel. # to_trio, from_aio = trio.open_memory_channel(2**8) # type: ignore