Hello,
i have downloaded daily data for a set of tickers (open close) and would like to run an open to open (or open to close) simulation with daily frequency in zipline.
I am struggling to do this however as the simulation always seems to use closing prices and handle_data() on a daily simulation always seems to get called at market close (4pm eastern time/8pm utc time).
If I try to trade a stock zipline always uses the previous closing price (ie if i trade on 08/18 handle_data is called on 08/18 at 4pm and the trade uses the closing price of 08/17 instead of the opening price of 08/18 which is what i would like). I would like the rebalancing to happen in the "morning" of each trading day by using the opening prices.
Moreover, if i close a position it also uses the closing price on the previous day: so for example if i close a position on the on the 08/20 handle_data is called on the 08/20 at 4pm and uses the closing price on the 08/19.
I tried using 'schedule_function(rebalance, date_rules.every_day(), time_rule = AfterOpen(minutes=1) )' but this gives the same results as handle_data so I am guessing (which makes sense) that time_rules is not applied for daily simulations...
How can i force the rebalancing to happen at market open using the opening price without altering the data i import? (ie could, i guess, for example, replace the closing prices on the 08/17 with the opening prices on the 08/20 etc... to 'trick' zipline into using those instead... but would prefer not to)
What if i wanted to run an open to close simulation but close using the closing price of the day i decide to close, and not the previous closing?
Thank you,