flumine icon indicating copy to clipboard operation
flumine copied to clipboard

Multiple orders for single trade simulation

Open joeledwardson opened this issue 4 years ago • 1 comments

I have come across an unusual bug: When backtesting, if a situation is created for a historical event where:

  1. Trade created, back Order created with trade
  2. back Order reaches EXECUTION_COMPLETE
  3. New Trade created, lay Order created with new trade
  4. lay Order reaches EXECUTION_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?

joeledwardson avatar Dec 26 '20 22:12 joeledwardson

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

joeledwardson avatar Dec 26 '20 22:12 joeledwardson