Handle brokerd errors even when no client-side-status found
parent
c43f7eb656
commit
8a61211c8c
|
@ -581,6 +581,7 @@ class Router(Struct):
|
||||||
notify_on_headless: bool = True,
|
notify_on_headless: bool = True,
|
||||||
|
|
||||||
) -> bool:
|
) -> bool:
|
||||||
|
# print(f'SUBSCRIBERS: {self.subscribers}')
|
||||||
to_remove: set[tractor.MsgStream] = set()
|
to_remove: set[tractor.MsgStream] = set()
|
||||||
|
|
||||||
if sub_key == 'all':
|
if sub_key == 'all':
|
||||||
|
@ -611,7 +612,8 @@ class Router(Struct):
|
||||||
and notify_on_headless
|
and notify_on_headless
|
||||||
):
|
):
|
||||||
log.info(
|
log.info(
|
||||||
'No clients attached, firing notification for {sub_key} msg:\n'
|
'No clients attached, '
|
||||||
|
f'firing notification for {sub_key} msg:\n'
|
||||||
f'{msg}'
|
f'{msg}'
|
||||||
)
|
)
|
||||||
await notify_from_ems_status_msg(
|
await notify_from_ems_status_msg(
|
||||||
|
@ -763,8 +765,8 @@ async def translate_and_relay_brokerd_events(
|
||||||
'oid': oid, # ems order-dialog id
|
'oid': oid, # ems order-dialog id
|
||||||
'reqid': reqid, # brokerd generated order-request id
|
'reqid': reqid, # brokerd generated order-request id
|
||||||
'symbol': sym,
|
'symbol': sym,
|
||||||
} if status_msg := book._active.get(oid):
|
}:
|
||||||
|
status_msg = book._active.get(oid)
|
||||||
msg = BrokerdError(**brokerd_msg)
|
msg = BrokerdError(**brokerd_msg)
|
||||||
log.error(fmsg) # XXX make one when it's blank?
|
log.error(fmsg) # XXX make one when it's blank?
|
||||||
|
|
||||||
|
@ -776,11 +778,21 @@ async def translate_and_relay_brokerd_events(
|
||||||
# about. In most default situations, with composed orders
|
# about. In most default situations, with composed orders
|
||||||
# (ex. brackets), most brokers seem to use a oca policy.
|
# (ex. brackets), most brokers seem to use a oca policy.
|
||||||
|
|
||||||
|
# only relay to client side if we have an active
|
||||||
|
# ongoing dialog
|
||||||
|
if status_msg:
|
||||||
status_msg.resp = 'error'
|
status_msg.resp = 'error'
|
||||||
status_msg.brokerd_msg = msg
|
status_msg.brokerd_msg = msg
|
||||||
book._active[oid] = status_msg
|
book._active[oid] = status_msg
|
||||||
|
|
||||||
await router.client_broadcast(sym, status_msg)
|
await router.client_broadcast(
|
||||||
|
status_msg.req.symbol,
|
||||||
|
status_msg,
|
||||||
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
log.error(f'Error for unknown order flow:\n{msg}')
|
||||||
|
continue
|
||||||
|
|
||||||
# BrokerdStatus
|
# BrokerdStatus
|
||||||
case {
|
case {
|
||||||
|
@ -1265,6 +1277,9 @@ async def process_client_order_cmds(
|
||||||
status,
|
status,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
case _:
|
||||||
|
log.warning(f'Rx UNHANDLED order request {cmd}')
|
||||||
|
|
||||||
|
|
||||||
@acm
|
@acm
|
||||||
async def maybe_open_trade_relays(
|
async def maybe_open_trade_relays(
|
||||||
|
|
Loading…
Reference in New Issue