Accurate OPG and CLS prices for Paper trading

It would be very helpful if the paper trade order prices accurately reflected the market for OPG (Market On Open, MOO) and CLS (Market On Close, MOC) orders. Right now it looks as if the OPG and CLS orders are grabbing some price near the open or close rather than the actual open or close price and this can often vary significantly. For example, one of my paper trades this morning was to short VIAC at the open. The market open was $36.81 but the paper trade had the trade open price with a short at $36.70 or 0.3% lower than it would have been in the real world.

I would think that it would be very easy from a programming perspective to use the actual market opening and closing prices for OPG and CLS orders with paper trading. Unless an OPG or CLS trade was large enough in size to affect the initial price auction (say, more than ~2% of the average daily volume), you can pretty much guarantee that, in the real world, an OPG or CLS order would be filled at a stock’s Open or Closing price.

Now, I’m not saying that the paper trade should look at the trade’s volume compared to the average volume; let the programmer understand that. But, anyone with a reasonable number of shares for a trade should get the Open and Closing price with OPG or CLS orders and this would be very easy to code into the paper trading engine.



I cannot say for certain if the Alpaca API is returning the correct opening auction price. However you should note that there is a difference between the first print on the NMS tape and the opening auction print at the primary exchange.

For example, looking at VIAC on Yahoo Finance for Dec 29th, 2020, it shows the first NMS price at $36.81. However there’s no guarantee that the market maker on the Nasdaq opened at exactly that price in their opening auction. In fact, looking at the opening 1-minute high/low bar, it seems like there was a lot of selling pressure. It’s likely that there was an order imbalance during the Nasdaq opening auction which meant the market maker would have printed the opening lower to allow for all the buying they had to do.

Short answer: Never assume the opening price from NMS will be the price you get on an MOO/LOO order. You’ll get close on Nasdaq. But if it’s a NYSE/AMEX listed name, you could easily see a price deviation of 2%.

We may have to agree to disagree here. Talking with my trader who has 20+ years of experience on the street with large and institutional investors, he says that if you put in a MOO order and you don’t get the opening price, then something is wrong. (Note that Alpaca uses Market → OPG instead of MOO.)

Prior to the open, all MOO, LOO, or GTC limit orders are tabulated and based upon the order prices, an opening price is generated. All MOO orders should receive that price. Depending on that opening price, GTC Limit or LOO orders may or may not be filled. But Market On Open orders should always be filled and at that opening price. My trader said that if he didn’t get the market price for a MOO order, he’d be on the phone to get that price changed.

After watching the Alpaca paper trading engine work for awhile, I can say that it doesn’t work this way…essentially ever. The Alpaca engine is looking at MOO orders as if they’re normal market orders during the trading day. If you have a market sell order, it should go off at the highest bid providing that there are enough shares in the bid to fill your order. If not, the price should go down to the next highest bid…and so on until your sell order is filled.

If your market order is to buy some shares, then your buy order price will be the lowest asking price, again providing that there are enough shares on the ask to fill your buy.

But that’s not the way a MOO / Market-OPG order is supposed to work as I’ve outlined above.

It’s become pretty apparent after watching weeks worth of paper Market-OPG orders, that Alpaca never put any effort into the paper trading engine code to have Market-OPG orders function as they would in the real world. I mean, it does make sense from their perspective; paper trades don’t directly equate into real order flow selling or other revenue generating opportunities. So they skimped on the coding a little bit…though the coding for this capability would be extremely minor. Just have a Market-OPG order price automatically equal the market’s actual opening price.

This would cost a little programmer time (a very little time) but it would then allow more than functional testing of a trading algorithm; it would allow anyone using MOO or LOO orders to actually test the logic behind their algo’s trades.

Their current method for Market-OPG orders creates really bizarre artifacts. For example, about 10 to 15% of the time, my test Market-OPG orders receive partial fills…and I’m talking partial fills on $4k paper money orders. Also, since bid / ask volume can be pretty slow immediately after the open, you can get some strange results. For example, one of my algos had a MOO buy on for KLAC and it paper filled at the lowest ask after the open…at $305.71. The real market open was $301.60…which also was the HOD. So, with this flawed / lazy way of doing Market-OPG orders, my algorithm’s opening buy came in at 1.36% above the HOD.

Let’s just say that my trader is very unimpressed with how the paper trading engine works and it makes him question why we’re using Alpaca for our programs. He wonders if we’re going to see the same ridiculous differences with live money trades. And while I try to explain to him how this is a non sequitur when it comes to programming, I can understand how someone whose career has been focused within the street rather than directly in technology would lose some confidence when seeing paper trades go off so inaccurately. If our initial investors saw these trade prices, I suspect they also would be far less confident in trusting us and Alpaca with their money. And because of this, I’m pretty surprised that Alpaca wouldn’t put a very small amount of programmer time into fixing how their Market-OPG orders work. And, I suspect, Market-CLS orders have this issue but none of my algorithms use MOC / LOC orders currently.


This is a huge problem. Alpaca should really look into it. There was a 0.76% price difference between my OPG order ($69.01) and the real market open price ($69.54). 0.76% return loss per day can result into 85% yoy loss.