@dpats Excellent questions on open prices. I’ll try to answer.
First, Alpaca uses SIP data for all historical bar calculations. This is the same data most, if not all, data providers use to calculate daily bars. There is a small caveat. As long as the specified end
datetime is not within 15 minutes of the current time, both the free and the paid Alpaca data plans will return bars based upon SIP data. However, due to licensing restrictions, if the end
datetime includes the most current 15 minutes, the free data plan will return bars based only upon trades executed on the IEX exchange. To ensure one is getting bars based upon full market SIP data it’s best to specify feed=SIP
in the request.
Now, a bit about how Open, High, Low, and Close prices are determined. There are two Securities Information Providers (SIPs) and each publishes guidelines of which types of trades to include in the High/Low and the Close/Last calculations. That guidance is on page 64 of the Consolidated Tape System (CTS) Specification and page 43 of the UTP Specification. The glaring omission however, is neither has any guidance on how to calculate Open prices. Each data provider (such as Alpaca) is left to decide that on their own. Alpaca calculates the Open price by filtering for the same trade conditions used to calculate the Close/Last prices then simply takes the first trade of the day. While this often may be an exchange’s opening print it isn’t guaranteed. In case you are interested, there is an article here which explains in detail how bars are calculated.
Other data providers may choose to use an opening auction price or exchange’s opening print as the daily open. This creates several issues. First, not all symbols participate in opening auctions. Additionally, there can be multiple opening auctions on multiple exchanges so choosing which exchange’s price to use can be a bit arbitrary. That is why Alpaca chose to use a very deterministic rule of simply using the first ‘valid’ trade of the day.
If one wants to know the opening auction prices (eg to determine fill prices for MOO orders) there is an endpoint for that called auctions.
Let’s look at the specific XOM example on 2024-05-16 from above. This is the daily bar for that day.
"XOM": [
{
"c": 117.87,
"h": 119.3,
"l": 117.54,
"n": 117965,
"o": 118.54,
"t": "2024-05-16T04:00:00Z",
"v": 15745202,
"vw": 118.232237
}
The OHLC match the example above. Notice the trade count and volume are both a bit higher then those posted above. The reason? Those two values include after hour trades. The request above was apparently made before 20:00 ET when after hour trading was still going on so didn’t include the entire day.
However, lets look at the opening trades.
Notice the first 20 or so trades are all ‘odd lots’ (ie trades under 100 shares with a trade condition I). These are excluded from the bar calculation per SIP guidelines (using the guidelines for Close). Therefore the first ‘valid’ trade after that is 118.54. Alpaca simply uses that first trade as the Open. This was actually the opening auction trade on the NASDAQ Intl exchange (notice trade conditions O, X and exchange T), but it cold have just as easily been a regular market trade too.
Now let’s look at the opening auction trades (sometimes called ‘cross’ on the NASDAQ exchanges).
{
"auctions": {
"XOM": [
"d": "2024-05-16",
"o": [
{
"c": "O",
"p": 118.54,
"s": 124,
"t": "2024-05-16T13:30:01.02339584Z",
"x": "T"
},
{
"c": "Q",
"p": 118.54,
"s": 124,
"t": "2024-05-16T13:30:01.023398912Z",
"x": "T"
},
{
"c": "Q",
"p": 118.95,
"s": 2,
"t": "2024-05-16T13:30:13.56120704Z",
"x": "P"
},
{
"c": "O",
"p": 118.89,
"s": 181275,
"t": "2024-05-16T13:33:00.236880128Z",
"x": "N"
},
{
"c": "Q",
"p": 118.89,
"s": 181275,
"t": "2024-05-16T13:33:00.2368832Z",
"x": "N"
}
The first thing to note is that XOM participated in the opening auctions, or provided opening prints, on three separate exchanges (NASDAQ Int “T”, NYSE Arca “P”, and NYSE “N”). Also note they all have different prices. This illustrates the fundamental problem with using the “official open” from the exchanges. Which exchange to choose?
So, I hope this addresses your issue on opening prices. There is nothing ‘systematically incorrect’ with the open prices. Alpaca simply uses the first ‘valid’ trade. Other data providers, since there are no guidelines provided by the SIPs, may choose other approaches.