Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions piker/brokers/ib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,35 +167,35 @@ def __init__(self):
_adhoc_futes_set = {

# equities
'nq.globex',
'mnq.globex', # micro
'nq.cme',
'mnq.cme', # micro

'es.globex',
'mes.globex', # micro
'es.cme',
'mes.cme', # micro

# cypto$
'brr.cmecrypto',
'ethusdrr.cmecrypto',
'brr.cme',
'ethusdrr.cme',

# agriculture
'he.nymex', # lean hogs
'le.nymex', # live cattle (geezers)
'gf.nymex', # feeder cattle (younguns)
'he.comex', # lean hogs
'le.comex', # live cattle (geezers)
'gf.comex', # feeder cattle (younguns)

# raw
'lb.nymex', # 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.nymex',
'mgc.nymex', # micro
'gc.comex',
'mgc.comex', # micro

# oil & gas
'cl.nymex',
'cl.comex',

'xagusd.cmdty', # silver spot
'ni.nymex', # silver futes
'ni.comex', # silver futes
'qi.comex', # mini-silver futes
}

Expand Down Expand Up @@ -1031,7 +1031,7 @@ def con2fqsn(
case ibis.Forex() | ibis.Contract(secType='CASH'):
dst, src = con.localSymbol.split('.')
symbol = ''.join([dst, src])
suffix = con.exchange
suffix = con.exchange or 'idealpro'

# no real volume on forex feeds..
calc_price = True
Expand All @@ -1053,7 +1053,10 @@ def con2fqsn(
if 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
return fqsn_key, calc_price

Expand Down
15 changes: 12 additions & 3 deletions piker/brokers/ib/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ async def open_history_client(
mean: float = 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(
timeframe: float,
Expand Down Expand Up @@ -170,7 +175,9 @@ async def get_hist(
)

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}')

Expand Down Expand Up @@ -895,7 +902,9 @@ async def reset_on_feed():
# last = time.time()
async for ticker in stream:
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
ticker.ticks = []
Expand Down