Open ehebert opened 11 years ago
What would be the advantages of closing out positions at the end of the simulation?
It would be nice to be able to supply a list of delistings at the start of each trading day. I really think there should be some start of day functionality that handles a variety of tasks including removing delistings from the portfolio,
We now have the cancel policy. We could have a new event that is SIMULATION_END
and then close the orders when that is fired.
As suggest by working4coins@gmail.com on the mailing list, provide a way to close out all open positions at the end of the backtest.
There are a couple potential paths to that functionality:
TradingAlgorithm.finalize()
method. (as suggested by working4coins)close_positions_at_end
which can be checked in tradesimulation at the same time that the perf tracker'shandle_simulation_end()
method is called.close_all_positions
.Another question I have here is what should be the price/volume used to calculate the close outs? I'm think the most straight ahead thing would be to use the last pricing/volume from the last bar before the simulation end is triggered.