Inconsistent zipline execution price

Hi,

I backtested a stock selection strategy and checked the transactions using ZiplineBacktestResult. In my strategy, my portfolio is rebalanced everyday when the market opens using the following code.

algo.schedule_function(
        rebalance,
        algo.date_rules.every_day(),
        algo.time_rules.market_open(minutes=1),
    )

I set the slippage and commission to be 0 and I compared the execution prices with the daily open/unadjusted open prices obtained from usstock-1d and I found that they were inconsistent. I thought that if the slippage and commission are not taken into account, the execution price would be the same as the open prices since the orders are executed when the market opens. Did I miss some configurations? What could be the reason for this inconsistency and how can I fix it?

With this code, you will get the 9:31 closing price rather than the 9:30 open price. The code algo.time_rules.market_open(minutes=1) means that your algorithm will be called at 9:31:00 and provided with the minute bar representing the first minute of trading (9:30:00 - 9:30:59). If you then place an order, the backtest will fill the order at the next minute price, that is, at the closing price of the 9:31 bar. Try querying the 9:31 close price and see if that matches the execution price:

quantrocket zipline get usstock-1min --sids <sid> -s <date> -e <date> -f Close -t 09:31:00

Thank you so much for the answer, Brain. Is there a way to place orders using 9:30 open price? It seems that zipline does not support that according to the documentation.

Zipline doesn't currently support on-the-open orders, but that enhancement is planned for the next release. Currently only Moonshot can fill orders on the open. To use an on-the-open order with Zipline in the next release, you will have to place the order during or after the previous session.

Thanks a lot. That enhancement would be great.