Attempting to compare daily ohlc data to the same for minute bars on a single day for ticker SPY. Would expect some portion of the two to overlap (ie, open for daily to match open for 0930ET bar) but not able to reconcile.
Running these API calls:
(1min):
import requests
url = “https://data.alpaca.markets/v2/stocks/SPY/bars?timeframe=1Min&start=2022-01-31&end=2022-01-31&limit=10000&adjustment=split&feed=sip&sort=asc”
headers = {
“accept”: “application/json”,
“APCA-API-KEY-ID”:
“APCA-API-SECRET-KEY”:
}
response = requests.get(url, headers=headers)
(1day):
import requests
url = “https://data.alpaca.markets/v2/stocks/SPY/bars?timeframe=1Day&start=2022-01-31&end=2022-01-31&limit=10000&adjustment=split&feed=sip&sort=asc”
headers = {
“accept”: “application/json”,
“APCA-API-KEY-ID”:
“APCA-API-SECRET-KEY”:
}
response = requests.get(url, headers=headers)
I don’t see the daily open price (441.24) returned anywhere by the 1min API call that would seem related, and the place I’d expect it (ie, 09:30+/-) there appear to be missing bars (I presumed due to no trading reported, but that seems unlikely for SPY at market open).
Can anyone explain why that is?
Are you on the free ‘Basic’ plan or ‘Algo trader plus’ plan? See this
1 Like
Hi 
I’m guessing you’re missing that the bar timestamps are in UTC timezone. This is the 09:30 (ET) = 14:30 (UTC) minute bar:
$ curl -s -H "APCA-API-KEY-ID: ${APCA_API_KEY_ID}" -H "APCA-API-SECRET-KEY: ${APCA_API_SECRET_KEY}" \
"https://data.alpaca.markets/v2/stocks/SPY/bars?timeframe=1Min&start=2022-01-31T14:30:00Z&limit=1" | jq .
{
"bars": [
{
"c": 441.15,
"h": 441.44,
"l": 440.57,
"n": 8047,
"o": 441.24,
"t": "2022-01-31T14:30:00Z",
"v": 1283016,
"vw": 441.132744
}
],
"next_page_token": "U1BZfE18MTY0MzYzOTQ2MDAwMDAwMDAwMA==",
"symbol": "SPY"
}
As you expected, it’s open is $441.24.
Maybe it’s worth mentioning however, that this is not always neccessarily the case. Since the aggregating rules for minute and daily bars are different (see this FAQ for details), it is very possible that the opening price of the 9:30 minute bar won’t match the daily bar’s.
1 Like
ah, thanks for this…thought I’d dealt with this in my script but wasn’t working properly.
appreciate link to details