Hi Alpaca folks,
It looks like the Alpaca Data API has ceased to observe the time bounding parameters start
/after
& end
/until
.
I’ve posted twice in the Slack here & here but haven’t received any answers.
I’ve tried all kinds of variations on the query parameters for the following URL:
https://data.alpaca.markets/v1/bars/5Min?symbols=AMZN&limit=999&after=2020-01-05&until=2020-01-07
Varying the limit, symbols, after, until, start, end do nothing to modify the dates that the API returns - it only returns rows equal to limit
of the most recent data.
The Alpaca status indicates there’s nothing wrong with the API, but this behavior is very unusual and was not happening just last week.
@hitoshi or others, any ideas?
The bars
API is very sensitive to formatting of the dates. That’s the issue. They must be in ISO format otherwise the API ignores them. Unfortunately, the API doesn’t fail or cause an error if the dates aren’t recognized. Rather, the default date values are used. That is why it seemed varying the dates had no impact on the result. So, try this and you should get the expected results
https://data.alpaca.markets/v1/bars/5Min?symbols=AMZN&limit=999&after=2020-01-05T09:30:00-04:00&until=2020-01-07T09:30:00-04:00
There is a bit longer explanation in this post. It’s specifically about the Python SDK (which calls this API) but the basics are the same.
Thank you @Dan_Whitnable_Alpaca It actually looks like this is an API bug regarding +
in the offset.
Here’s the query I was using:
https://data.alpaca.markets/v1/bars/5Min?symbols=BYND&limit=1000&start=2020-01-06T14:35:00+00:00&end=2020-12-07T15:00:00+00:00
Which returns the most recent timebars.
This however works:
https://data.alpaca.markets/v1/bars/5Min?symbols=BYND&limit=1000&start=2020-01-06T14:35:00-00:00&end=2020-12-07T15:00:00-00:00
But where does that leave us if we’re actually using a timezone with a positive offset in ISO?
https://data.alpaca.markets/v1/bars/5Min?symbols=BYND&limit=1000&start=2020-01-06T14:35:00+01:00&end=2020-12-07T15:00:00+01:00
It falls back to the recent bars again.
It looks like it’s actually a matter of the API not handling positive offsets! I’m going to workaround this in AlpacaforR
and just coerce to the "America/New_York"
timezone for API requests but perhaps this needs to be passed on to the dev team?
Thanks for looking into this!
While we’re talking API formatting nuances, perhaps you can shed some light on how the JSON ought to look when passing symbol
s via POST
method when creating a new Watchlist
. Here’s an unanswered thread with the same issue.
I’m currently using the following for a POST
:
URL: "https://paper-api.alpaca.markets/v2/watchlists"
Body: {"name":"test","symbol":["MRNA","PFE"]}
as per the Docs.
Error message explicitly says
request body is invalid
Looks like after a lot of minor tweaking I figured out that it has to be formatted with line breaks:
{
"name": "test",
"symbols": ["MRNA", "PFE"]
}