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:
-
Trade
created, backOrder
created with trade - back
Order
reachesEXECUTION_COMPLETE
- New
Trade
created, layOrder
created with new trade - lay
Order
reachesEXECUTION_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