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