1Day bars contains price that doesn't exist in 1Min bars for the same time period (crypto)
MaximZemskov opened this issue · comments
Describe the bug
1Day OHLCV bars have prices which aren't exists in 1Min bars for the same start/end period
To Reproduce
Make 2 requests with the same parameters, but with different timeframes
1Day timeframe
{
"t": "2022-03-08T06:00:00Z",
"x": "CBSE",
"o": 38350.85,
"h": 41899.98,
"l": 38000,
"c": 41524.73,
"v": 24992.67843144,
"n": 658515,
"vw": 39326.1136942713
}
High price for 2022-03-08 is 41899.98
.
1Min
https://data.alpaca.markets/v1beta1/crypto/bars?symbols=BTCUSD&start=2022-03-08T00:00:00.00Z&end=2022-03-09T00:00:00.00Z&timeframe=1Min&limit=10000
As we can see in the search box we have zero h
prices that started with 4
, so all prices are lower than 40000
Is it possible that 1Day
bars may return prices outside start/end
periods?
Hi Maxim,
The explanation is the following:
- The daily bars contain data for 24 hours, starting at the timestamp (
"t"
). So this means that it spans across calendar days (well, depending on the query's timezone). - The
start
andend
parameters restrict the timestamp("t"
)'s range. - So if you query with a timezone not identical to the daily bar's then you might see this.
You can see that the following query will contain the high price found in the daily bar:
https://data.alpaca.markets/v1beta1/crypto/bars?symbols=BTCUSD&start=2022-03-08T00:00:00.00-06:00&end=2022-03-08T23:59:59.00-06:00&timeframe=1Min&limit=10000 (note the changed timezone on start
and end
).
Please let me know if I was in any way unclear or if you're satisfied then let me know and I'll be happy to close the issue.
Hi. Thank you for the explanation!
Should the daily bars timestamps always have the same timezones for the start of a day or can the timezone be random?
I noticed that it's not always the same.
timestamp is 2022-03-01T06:00:00Z
timestamp is 2022-04-01T05:00:00Z
For crypto bars, the timezone is always Central.
The explanation for the change in offset is daylight savings.
Check the following two links to see what happened:
Even though both point to midnight in Central, the offset from UTC (Z
) is different.
Thank you!
You're welcome :)