Skip to content

Commit

Permalink
Make ems relay loop report on brokerd .reqid changes
Browse files Browse the repository at this point in the history
  • Loading branch information
goodboy committed Jul 21, 2022
1 parent 594572c commit a345399
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion piker/clearing/_ems.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def check_lt(price: float) -> bool:

@dataclass
class _DarkBook:
'''EMS-trigger execution book.
'''
EMS-trigger execution book.
Contains conditions for executions (aka "orders" or "triggers")
which are not exposed to brokers and thus the market; i.e. these are
Expand Down Expand Up @@ -645,6 +646,13 @@ async def translate_and_relay_brokerd_events(
else:
# check for existing live flow entry
entry = book._ems_entries.get(oid)
old_reqid = entry.reqid

if old_reqid and old_reqid != reqid:
log.warning(
f'Brokerd order id change for {oid}:\n'
f'{old_reqid} -> {reqid}'
)

# initial response to brokerd order request
if name == 'ack':
Expand All @@ -655,6 +663,10 @@ async def translate_and_relay_brokerd_events(
# a ``BrokerdOrderAck`` **must** be sent after an order
# request in order to establish this id mapping.
book._ems2brokerd_ids[oid] = reqid
log.info(
'Rx ACK for order\n'
f'oid: {oid} -> reqid: {reqid}'
)

# new order which has not yet be registered into the
# local ems book, insert it now and handle 2 cases:
Expand Down

0 comments on commit a345399

Please sign in to comment.