Skip to content

Commit

Permalink
Fix OrderMatchingEngine contingent order edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Aug 9, 2023
1 parent 7de008e commit 7305047
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nautilus_trader/backtest/matching_engine.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1905,7 +1905,11 @@ cdef class OrderMatchingEngine:
for client_order_id in order.linked_order_ids:
ouo_order = self.cache.order(client_order_id)
assert ouo_order is not None, "OUO order not found"
if ouo_order.order_type != OrderType.MARKET and ouo_order.leaves_qty._mem.raw != order.leaves_qty._mem.raw:
if ouo_order.order_type == OrderType.MARKET or ouo_order.is_closed_c():
continue
if order.leaves_qty._mem.raw == 0:
self.cancel_order(ouo_order)
elif ouo_order.leaves_qty._mem.raw != order.leaves_qty._mem.raw:
self.update_order(
ouo_order,
order.leaves_qty,
Expand Down

0 comments on commit 7305047

Please sign in to comment.