Lol, handle failed-to-cancel statuses..

dict_differ
Tyler Goodlet 2022-08-05 19:05:05 -04:00
parent 0bd8f2bcd9
commit aa204228ab
1 changed files with 9 additions and 1 deletions

View File

@ -766,6 +766,14 @@ async def deliver_trade_events(
# unwrap needed data from ib_insync internal types
trade: Trade = item
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
# from the execution details event
@ -776,7 +784,7 @@ async def deliver_trade_events(
account=accounts_def.inverse[trade.order.account],
# everyone doin camel case..
status=status.status.lower(), # force lower case
status=status_key, # force lower case
filled=status.filled,
reason=status.whyHeld,