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?

  • 5
    $\begingroup$ Yes, as realistic as bidding at an auction for a Picasso at 5 dollars. Good luck. $\endgroup$
    – Matt Wolf
    Jul 30, 2013 at 5:49
  • 3
    $\begingroup$ As I mentioned here, you'll need to add a slippage. $\endgroup$ Jul 30, 2013 at 10:15
  • $\begingroup$ its a race, first come first serve good luck! $\endgroup$
    – pyCthon
    Sep 22, 2013 at 3:02

4 Answers 4


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.

  • $\begingroup$ Does this mean that order types such as Market On Open(MOO) and Market On Close (MOC) orders also fail to get you a fill at opening price or closing price as claimed? $\endgroup$
    – Aziz
    Jul 30, 2013 at 18:06
  • 1
    $\begingroup$ @Aziz A MOO or MOC just guarantees that you get the auction price; it doesn't guarantee what that price will be until after the auction is over. A big order, by necessity, will move the market even during the closing auction. The whole point of slippage is to account for market impact and transaction costs. $\endgroup$ Jul 30, 2013 at 19:01
  • $\begingroup$ @chrisaycock On a side note, in researching slippage and how to incorporate it into backtesting, I come across descriptions such as "big orders" just like you have used it. In general, what qualifies an order as a "big order?" A certain dollar amount? $\endgroup$ Jul 30, 2013 at 21:41
  • $\begingroup$ @LeeSchmidt Big enough to take-out the top-of-book quote. Once the exchange has to fill an order at the next price level, the price has become worse. That's what causes market impact. $\endgroup$ Jul 30, 2013 at 22:31
  • 2
    $\begingroup$ @MattWolf I ran the other direction :-) they had done well for awhile on the "better lucky than skillful" plan. I had certain...concerns...about its stability. $\endgroup$
    – Brian B
    Aug 1, 2013 at 15:49

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).


@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.


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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.