Skip to content
All library documents

Backtesting Open and Close Executions with Auction Orders and Slippage

Article Quant Q&A · Author: Lee Schmidt

Summary

The document discusses whether a stock backtest can assume execution at daily opening and closing prices. It describes market-on-open and market-on-close orders as ways to target auction prices, while noting that traders must submit orders before the final price is known. A closing signal that uses the closing auction price cannot realistically be used to submit an order in time, creating lookahead bias. Executing at a final tick rather than an auction also requires a meaningful slippage assumption.

The responses add that fills may differ from the reference price, and fees and commissions worsen realized prices. Order size matters relative to nearby liquidity and trading volume: a trade that is modest in a liquid large-cap name can move a thinly traded stock. The discussion gives examples but no systematic execution study, and its historical details should not be treated as universal current market rules. Backtests should model order timing, capacity, slippage, and costs.

Key ideas

  • Market-on-open and market-on-close orders can target auction prices, but orders must be submitted in advance.
  • A signal that depends on the closing auction price creates lookahead bias if it also assumes execution at that price.
  • Backtests should account for missed or worse fills, slippage, commissions, and fees.
  • Market impact depends on order size relative to nearby liquidity and traded volume.
  • Execution assumptions should reflect the stock's liquidity and the timing of available information.

Tags

Full text
# Backtesting - can you buy/sell at open and closing prices?


# Backtesting - can you buy/sell at open and closing prices?












In backtesting (nasdaq stocks), I make the assumption that I have the ability buy/sell each day at the opening and closing prices. Is this realistic?

## Answer by Brian B (score 4)

https://quant.stackexchange.com/a/8600

I do know of a largish prop shop that (as of 2009) had a deal with their prime broker to trade Nasdaq ETFs at the closing price, in size, so long as they gave a few hours' notice of order size and direction and never cancelled. After commissions and fees, the price was naturally worse.

Generally speaking, you have to assume slippage, as mentioned by chrisaycock, and most shops miss the trade with some regularity.

## Answer by kartik_subbarao (score 2)

https://quant.stackexchange.com/a/21940

Yes, you can get the opening print and closing print prices for NASDAQ stocks (and NYSE stocks for that matter) fairly reliably with MOO (market on open) and MOC (market on close) orders. There are some occasional discrepancies, but it tends to be fairly solid for backtesting.

As @ast4 points out, you won't actually know what price you're getting when you place the order -- you'll have to place it several minutes in advance. Where this gets a bit tricky is you won't know precisely how many shares to buy if you want to allocate say, exactly $1000, on a stock. You'll have to make an estimation. But since the variation can be in either direction, it shouldn't introduce a systematic bias over a large number of trades (assuming e.g. that your model places MOC orders independent of any price action near the market close).

## Answer by Jeff (score 1)

https://quant.stackexchange.com/a/8958

@Chrisaycock , It should be noted that taking out the top order doesn't necessarily move the market by a non-negligible amount. For example, on a $150 stock, if there's an open sell order at \$150 X 1000 shares, and another at \$150.10 @ 5000 shares, you're not going to move the market much, and .10 / \$150.10 is less than 0.1% - negligible unless you're doing HFT.

@LeeSchmidt, I think a better indicator of a "big order" is the ratio of your order size relative to all the open orders that are relatively close in price to the NBBO. There's also a dark pool that you should consider, especially on large-cap stocks. The easiest way might be to look at volume vs. time (it's best if you can look at intraday volume vs. time but you could eyeball with daily volume). If the 30-minute volume is 10k, and you want to do even a 2k trade, you'll probably move the market. A \$500,000 trade on a company like AAPL won't make a dent in the price when it's average volume is 15 million shares / \$7 billion... but a \$500k buy could easily cause a short spike in some penny stocks.

## Answer by ast4 (score 1)

https://quant.stackexchange.com/a/8990

First of all you need to be clarify what you mean by 'opening/closing price' are you talking about the last tick? The opening/closing auction price?

Let's say you're talking about closing auction price within the context of a backtest. The big question here is are you computing your trading signal based on that same price? If you are then there's a major issue with this in you've essentially introduced lookahead bias. Remember in order to get the closing auction price for most US equities you have to send out a MOC 15 minutes before the close. Therefore you can't possibly have the closing print to compute on and achieve execution at that price.

Final tick maybe, but you'll have to include a pretty substantial slippage assumption.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.