Fill data client sockaddr in feed status as `data_ep` field

ib_dedicated_data_client
Tyler Goodlet 2022-06-05 22:05:53 -04:00
parent 55a453a710
commit 051680e259
1 changed files with 15 additions and 5 deletions

View File

@ -948,13 +948,13 @@ async def load_aio_clients(
'ports', 'ports',
# default order is to check for gw first # default order is to check for gw first
[4002, 7497,] [4002, 7497]
) )
if isinstance(try_ports, dict): if isinstance(try_ports, dict):
log.warning( log.warning(
'`ib.ports` in `brokers.toml` should be a `list` NOT a `dict`' '`ib.ports` in `brokers.toml` should be a `list` NOT a `dict`'
) )
try_ports = list(ports.values()) try_ports = list(try_ports.values())
_err = None _err = None
accounts_def = config.load_accounts(['ib']) accounts_def = config.load_accounts(['ib'])
@ -1725,8 +1725,6 @@ async def backfill_bars(
with trio.CancelScope() as cs: with trio.CancelScope() as cs:
# async with open_history_client(fqsn) as proxy:
# async with open_client_proxy() as proxy:
async with open_data_client() as proxy: async with open_data_client() as proxy:
out, fails = await get_bars(proxy, fqsn) out, fails = await get_bars(proxy, fqsn)
@ -1961,6 +1959,11 @@ async def stream_quotes(
# print(f'first quote: {first_quote}') # print(f'first quote: {first_quote}')
def mk_init_msgs() -> dict[str, dict]: def mk_init_msgs() -> dict[str, dict]:
'''
Collect a bunch of meta-data useful for feed startup and
pack in a `dict`-msg.
'''
# pass back some symbol info like min_tick, trading_hours, etc. # pass back some symbol info like min_tick, trading_hours, etc.
syminfo = asdict(details) syminfo = asdict(details)
syminfo.update(syminfo['contract']) syminfo.update(syminfo['contract'])
@ -1982,6 +1985,9 @@ async def stream_quotes(
# a float # a float
syminfo['lot_tick_size'] = 0.0 syminfo['lot_tick_size'] = 0.0
ibclient = proxy._aio_ns.ib.client
host, port = ibclient.host, ibclient.port
# TODO: for loop through all symbols passed in # TODO: for loop through all symbols passed in
init_msgs = { init_msgs = {
# pass back token, and bool, signalling if we're the writer # pass back token, and bool, signalling if we're the writer
@ -1989,7 +1995,11 @@ async def stream_quotes(
sym: { sym: {
'symbol_info': syminfo, 'symbol_info': syminfo,
'fqsn': first_quote['fqsn'], 'fqsn': first_quote['fqsn'],
} },
'status': {
'data_ep': f'{host}:{port}',
},
} }
return init_msgs return init_msgs