Lol, handle failed-to-cancel statuses..

open_order_loading
Tyler Goodlet 2022-08-05 19:05:05 -04:00
parent e34ea94f9f
commit 1cfa04927d
1 changed files with 9 additions and 1 deletions

View File

@ -823,6 +823,14 @@ async def deliver_trade_events(
# unwrap needed data from ib_insync internal types # unwrap needed data from ib_insync internal types
trade: Trade = item trade: Trade = item
status: OrderStatus = trade.orderStatus status: OrderStatus = trade.orderStatus
status_key = status.status.lower()
# double check there is no error when
# cancelling.. gawwwd
if status_key == 'cancelled':
last_log = trade.log[-1]
if last_log.message:
status_key = trade.log[-2].status
# skip duplicate filled updates - we get the deats # skip duplicate filled updates - we get the deats
# from the execution details event # from the execution details event
@ -833,7 +841,7 @@ async def deliver_trade_events(
account=accounts_def.inverse[trade.order.account], account=accounts_def.inverse[trade.order.account],
# everyone doin camel case.. # everyone doin camel case..
status=status.status.lower(), # force lower case status=status_key, # force lower case
filled=status.filled, filled=status.filled,
reason=status.whyHeld, reason=status.whyHeld,