`ib`: make commodities search and feeds work again..

Was broken since the `_adhoc_futes_set` rework a while back. Removes the
cmdty symbols from that set into a new one and fixes the contract
case block to catch `Contract(secType='CMDTY')` case. Also makes
`Client.search_symbols()` return details `dict`s so that `piker search`
will work again..
kraken_deposits_fixes
Tyler Goodlet 2023-01-26 12:34:36 -05:00
parent d8bf45b02d
commit af92602027
1 changed files with 26 additions and 10 deletions

View File

@ -161,10 +161,17 @@ _futes_venues = (
'CME', 'CME',
'CMECRYPTO', 'CMECRYPTO',
'COMEX', 'COMEX',
'CMDTY', # special name case.. # 'CMDTY', # special name case..
'CBOT', # (treasury) yield futures 'CBOT', # (treasury) yield futures
) )
_adhoc_cmdty_set = {
# metals
# https://misc.interactivebrokers.com/cstools/contract_info/v3.10/index.php?action=Conid%20Info&wlId=IB&conid=69067924
'xauusd.cmdty', # london gold spot ^
'xagusd.cmdty', # silver spot
}
_adhoc_futes_set = { _adhoc_futes_set = {
# equities # equities
@ -186,16 +193,12 @@ _adhoc_futes_set = {
# raw # raw
'lb.comex', # random len lumber 'lb.comex', # random len lumber
# metals
# https://misc.interactivebrokers.com/cstools/contract_info/v3.10/index.php?action=Conid%20Info&wlId=IB&conid=69067924
'xauusd.cmdty', # london gold spot ^
'gc.comex', 'gc.comex',
'mgc.comex', # micro 'mgc.comex', # micro
# oil & gas # oil & gas
'cl.comex', 'cl.comex',
'xagusd.cmdty', # silver spot
'ni.comex', # silver futes 'ni.comex', # silver futes
'qi.comex', # mini-silver futes 'qi.comex', # mini-silver futes
@ -259,6 +262,7 @@ _exch_skip_list = {
'FUNDSERV', 'FUNDSERV',
'SWB2', 'SWB2',
'PSE', 'PSE',
'PHLX',
} }
_enters = 0 _enters = 0
@ -514,15 +518,18 @@ class Client:
except ConnectionError: except ConnectionError:
return {} return {}
dict_results: dict[str, dict] = {}
for key, deats in results.copy().items(): for key, deats in results.copy().items():
tract = deats.contract tract = deats.contract
sym = tract.symbol sym = tract.symbol
sectype = tract.secType sectype = tract.secType
deats_dict = asdict(deats)
if sectype == 'IND': if sectype == 'IND':
results[f'{sym}.IND'] = tract
results.pop(key) results.pop(key)
key = f'{sym}.IND'
results[key] = tract
# exch = tract.exchange # exch = tract.exchange
# XXX: add back one of these to get the weird deadlock # XXX: add back one of these to get the weird deadlock
@ -559,20 +566,25 @@ class Client:
# if cons: # if cons:
all_deats = await self.con_deats([con]) all_deats = await self.con_deats([con])
results |= all_deats results |= all_deats
for key in all_deats:
dict_results[key] = asdict(all_deats[key])
# forex pairs # forex pairs
elif sectype == 'CASH': elif sectype == 'CASH':
results.pop(key)
dst, src = tract.localSymbol.split('.') dst, src = tract.localSymbol.split('.')
pair_key = "/".join([dst, src]) pair_key = "/".join([dst, src])
exch = tract.exchange.lower() exch = tract.exchange.lower()
results[f'{pair_key}.{exch}'] = tract key = f'{pair_key}.{exch}'
results.pop(key) results[key] = tract
# XXX: again seems to trigger the weird tractor # XXX: again seems to trigger the weird tractor
# bug with the debugger.. # bug with the debugger..
# assert 0 # assert 0
return results dict_results[key] = deats_dict
return dict_results
async def get_fute( async def get_fute(
self, self,
@ -1036,7 +1048,11 @@ def con2fqsn(
# TODO: option symbol parsing and sane display: # TODO: option symbol parsing and sane display:
symbol = con.localSymbol.replace(' ', '') symbol = con.localSymbol.replace(' ', '')
case ibis.Commodity(): case (
ibis.Commodity()
# search API endpoint returns std con box..
| ibis.Contract(secType='CMDTY')
):
# commodities and forex don't have an exchange name and # commodities and forex don't have an exchange name and
# no real volume so we have to calculate the price # no real volume so we have to calculate the price
suffix = con.secType suffix = con.secType