flumine
flumine copied to clipboard
Multiple orders for single trade simulation
I have come across an unusual bug: When backtesting, if a situation is created for a historical event where:
-
Tradecreated, backOrdercreated with trade - back
OrderreachesEXECUTION_COMPLETE - New
Tradecreated, layOrdercreated with new trade - lay
OrderreachesEXECUTION_COMPLETE
However, if this is exact same execution is modified so that in step 3. the lay Order is created with the same Trade used in step 1. for the back Order, then the lay Order never reaches EXECUTION_COMPLETE?
I think I have found the bug: in FlumineBacktest._process_backtest_orders(), it has
if order.trade.status.value == "Complete":
blotter.complete_order(order)
However, if a Trade has one complete Order then its status will go to Complete, and only after a new Order has been placed will the Trade status go back to LIVE, at which point the blotter has already deemed the Order as Complete