I am working on a simulated back-testing algorithm. I'm making an assumption that if you place an order of type "market", which means you ask to purchase the stock at the price of the market, the night before the market opens, your order will be filled and you will get the stock at the open price of the next day. However, I'm not sure how realistic is this assumption.

  • 1
    Why not check if you can do MOO orders (investopedia.com/terms/m/… with your broker? You don't give a country but some markets (particularly US) allow trading out of hours and some brokers will internalize overnight trading, you may not even know that they do this until you trade if you don't ask and check.
    – MD-Tech
    Commented Oct 3, 2023 at 7:45
  • 1
    As I understand it, opening price is just the price the first trade of the day was made at. There's no way to guarantee that yours is the first trade of the day except by making a spectacularly bad trade and moving the opening price to that number, which is probably not what you had in mind.
    – keshlam
    Commented Oct 3, 2023 at 13:31
  • @keshlam if there is an auction in the market being traded it may be the result of that auction but the OP doesn't tell us which markets they are interested in.
    – MD-Tech
    Commented Oct 3, 2023 at 14:36
  • @keshlam - In a US NBBO market at the open, you can't make a "spectacularly bad trade and moving the opening price to that number" unless the market is totally illiquid and there are no orders on the order book between those two prices. Commented Oct 5, 2023 at 3:38

1 Answer 1


It may be good enough for a backtest, but in reality there's no way to guarantee that you get filled at exactly the open price. The opening trade of the day will be filled at the best price, which may be the bid or the ask depending on the type of the initial trade. If you put in an overnight market order, If there are other market orders that were placed before yours and were not already filled, they would be executed in the order that they were placed, which may move the bid/ask prices from the initial trade.

It's the same as trading during hours. Placing a market order does not guarantee that you get filled at the last traded price, or even at the current bid/ask if your order is larger than the size of the current best offer.

So the actual price you trade at should be close except in extraordinary circumstances, but not guaranteed.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .