Add draft, commented tickbytick for ib
parent
8d432e1988
commit
e3c46a5d4d
|
@ -1076,6 +1076,10 @@ def normalize(
|
||||||
|
|
||||||
new_ticks.append(td)
|
new_ticks.append(td)
|
||||||
|
|
||||||
|
tbt = ticker.tickByTicks
|
||||||
|
if tbt:
|
||||||
|
print(f'tickbyticks:\n {ticker.tickByTicks}')
|
||||||
|
|
||||||
ticker.ticks = new_ticks
|
ticker.ticks = new_ticks
|
||||||
|
|
||||||
# some contracts don't have volume so we may want to calculate
|
# some contracts don't have volume so we may want to calculate
|
||||||
|
@ -1088,6 +1092,11 @@ def normalize(
|
||||||
# serialize for transport
|
# serialize for transport
|
||||||
data = asdict(ticker)
|
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
|
# add time stamps for downstream latency measurements
|
||||||
data['brokerd_ts'] = time.time()
|
data['brokerd_ts'] = time.time()
|
||||||
|
|
||||||
|
@ -1274,6 +1283,11 @@ async def _setup_quote_stream(
|
||||||
'375', # RT trade volume (excludes utrades)
|
'375', # RT trade volume (excludes utrades)
|
||||||
'233', # RT trade volume (includes utrades)
|
'233', # RT trade volume (includes utrades)
|
||||||
'236', # Shortable shares
|
'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
|
'294', # Trade rate / minute
|
||||||
'295', # Vlm rate / minute
|
'295', # Vlm rate / minute
|
||||||
),
|
),
|
||||||
|
@ -1294,6 +1308,12 @@ async def _setup_quote_stream(
|
||||||
contract = contract or (await client.find_contract(symbol))
|
contract = contract or (await client.find_contract(symbol))
|
||||||
ticker: Ticker = client.ib.reqMktData(contract, ','.join(opts))
|
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
|
# # define a simple queue push routine that streams quote packets
|
||||||
# # to trio over the ``to_trio`` memory channel.
|
# # to trio over the ``to_trio`` memory channel.
|
||||||
# to_trio, from_aio = trio.open_memory_channel(2**8) # type: ignore
|
# to_trio, from_aio = trio.open_memory_channel(2**8) # type: ignore
|
||||||
|
|
Loading…
Reference in New Issue