Merge pull request #421 from pikers/ib_contract_updates

`ib` futes contract consolidation fixes
cz_post_ftx
Guillermo Rodriguez 2022-11-17 18:38:22 -03:00 committed by GitHub
commit 019a6432fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 19 deletions

View File

@ -167,35 +167,35 @@ _futes_venues = (
_adhoc_futes_set = { _adhoc_futes_set = {
# equities # equities
'nq.globex', 'nq.cme',
'mnq.globex', # micro 'mnq.cme', # micro
'es.globex', 'es.cme',
'mes.globex', # micro 'mes.cme', # micro
# cypto$ # cypto$
'brr.cmecrypto', 'brr.cme',
'ethusdrr.cmecrypto', 'ethusdrr.cme',
# agriculture # agriculture
'he.nymex', # lean hogs 'he.comex', # lean hogs
'le.nymex', # live cattle (geezers) 'le.comex', # live cattle (geezers)
'gf.nymex', # feeder cattle (younguns) 'gf.comex', # feeder cattle (younguns)
# raw # raw
'lb.nymex', # random len lumber 'lb.comex', # random len lumber
# metals # metals
# https://misc.interactivebrokers.com/cstools/contract_info/v3.10/index.php?action=Conid%20Info&wlId=IB&conid=69067924 # https://misc.interactivebrokers.com/cstools/contract_info/v3.10/index.php?action=Conid%20Info&wlId=IB&conid=69067924
'xauusd.cmdty', # london gold spot ^ 'xauusd.cmdty', # london gold spot ^
'gc.nymex', 'gc.comex',
'mgc.nymex', # micro 'mgc.comex', # micro
# oil & gas # oil & gas
'cl.nymex', 'cl.comex',
'xagusd.cmdty', # silver spot 'xagusd.cmdty', # silver spot
'ni.nymex', # silver futes 'ni.comex', # silver futes
'qi.comex', # mini-silver futes 'qi.comex', # mini-silver futes
} }
@ -1031,7 +1031,7 @@ def con2fqsn(
case ibis.Forex() | ibis.Contract(secType='CASH'): case ibis.Forex() | ibis.Contract(secType='CASH'):
dst, src = con.localSymbol.split('.') dst, src = con.localSymbol.split('.')
symbol = ''.join([dst, src]) symbol = ''.join([dst, src])
suffix = con.exchange suffix = con.exchange or 'idealpro'
# no real volume on forex feeds.. # no real volume on forex feeds..
calc_price = True calc_price = True
@ -1053,7 +1053,10 @@ def con2fqsn(
if expiry: if expiry:
suffix += f'.{expiry}' suffix += f'.{expiry}'
fqsn_key = '.'.join((symbol, suffix)).lower() fqsn_key = symbol.lower()
if suffix:
fqsn_key = '.'.join((fqsn_key, suffix)).lower()
_cache[con.conId] = fqsn_key, calc_price _cache[con.conId] = fqsn_key, calc_price
return fqsn_key, calc_price return fqsn_key, calc_price

View File

@ -130,7 +130,12 @@ async def open_history_client(
mean: float = 0 mean: float = 0
count: int = 0 count: int = 0
head_dt = await proxy.get_head_time(fqsn=fqsn) head_dt: None | datetime = None
if (
# fx cons seem to not provide this endpoint?
'idealpro' not in fqsn
):
head_dt = await proxy.get_head_time(fqsn=fqsn)
async def get_hist( async def get_hist(
timeframe: float, timeframe: float,
@ -170,7 +175,9 @@ async def open_history_client(
) )
if ( if (
end_dt and end_dt <= head_dt end_dt
and head_dt
and end_dt <= head_dt
): ):
raise DataUnavailable(f'First timestamp is {head_dt}') raise DataUnavailable(f'First timestamp is {head_dt}')
@ -895,7 +902,9 @@ async def stream_quotes(
# last = time.time() # last = time.time()
async for ticker in stream: async for ticker in stream:
quote = normalize(ticker) quote = normalize(ticker)
await send_chan.send({quote['fqsn']: quote}) fqsn = quote['fqsn']
# print(f'sending {fqsn}:\n{quote}')
await send_chan.send({fqsn: quote})
# ugh, clear ticks since we've consumed them # ugh, clear ticks since we've consumed them
ticker.ticks = [] ticker.ticks = []