Specifically denote no-vlm contracts in symbol info

fix_forex
Tyler Goodlet 2022-07-13 12:25:04 -04:00
parent a7f0adf1cf
commit 04004525c1
1 changed files with 17 additions and 6 deletions

View File

@ -700,6 +700,13 @@ async def stream_quotes(
# TODO: more consistent field translation # TODO: more consistent field translation
atype = syminfo['asset_type'] = asset_type_map[syminfo['secType']] atype = syminfo['asset_type'] = asset_type_map[syminfo['secType']]
if atype in {
'forex',
'index',
'commodity',
}:
syminfo['no_vlm'] = True
# for stocks it seems TWS reports too small a tick size # for stocks it seems TWS reports too small a tick size
# such that you can't submit orders with that granularity? # such that you can't submit orders with that granularity?
min_tick = 0.01 if atype == 'stock' else 0 min_tick = 0.01 if atype == 'stock' else 0
@ -726,9 +733,9 @@ async def stream_quotes(
}, },
} }
return init_msgs return init_msgs, syminfo
init_msgs = mk_init_msgs() init_msgs, syminfo = mk_init_msgs()
# TODO: we should instead spawn a task that waits on a feed to start # TODO: we should instead spawn a task that waits on a feed to start
# and let it wait indefinitely..instead of this hard coded stuff. # and let it wait indefinitely..instead of this hard coded stuff.
@ -766,10 +773,14 @@ async def stream_quotes(
task_status.started((init_msgs, first_quote)) task_status.started((init_msgs, first_quote))
async with aclosing(stream): async with aclosing(stream):
if type(first_ticker.contract) not in ( if syminfo.get('no_vlm', False):
ibis.Commodity,
ibis.Forex # generally speaking these feeds don't
): # include vlm data.
atype = syminfo['asset_type']
log.info(f'Non-volume asset {sym}@{atype}, skipping quote poll.')
else:
# wait for real volume on feed (trading might be closed) # wait for real volume on feed (trading might be closed)
while True: while True:
ticker = await stream.receive() ticker = await stream.receive()