quantopian / zipline

Zipline, a Pythonic Algorithmic Trading Library
https://www.zipline.io
Apache License 2.0
17.26k stars 4.67k forks source link

Provide way to close open positions at end of backtest #170

Open ehebert opened 11 years ago

ehebert commented 11 years ago

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:

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.

MichaelWS commented 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,

llllllllll commented 8 years ago

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.