Hi!
Thank you for your feedback. I’m a software engineer at Alpaca, focused primarily on market data. I’m not an algotrader or a financial / stock market expert. Here’s my best shot to answer your questions:
- in V1 when i want last 200 bars from symbol X i set only the limit at anytime of the day/week/year i know i’m getting that last 200 going backwards (request at sunday morning get you last 200 from friday in V2 you need to know in advance your start and end dates interval and make sure is valid trading hours( market close, holidays,) or else you get (bars:null) that’s alot of IFs in your code
You’re right, you can’t get the last N bars in v2. As @oleg.rakhmatulin already mentioned, this is because of technical limitations. To further clarify: it’s not that it would be slower, it’s that it’s not possible.
Of course one can always do workarounds, but it’s not easy and I personally feel that it wouldn’t even be beneficial. I know this must sound surprising, but here’s what I think: in most scenarios getting the latest N bars doesn’t make sense anyway. If you ask for the last 300 AAPL bars, you’ll most likely get the bars for the same day, but if you do the same for a rarely traded symbol, you can end up with bars days, weeks or even months old. I’m confident that in most scenarios what you really need is the bars for an interval, not “a number of” bars, which is exactly what the API encourages. But let me repeat myself: the reason it’s not supported is a technical one.
- since page_token works in farward mode, you can’t set an end date and go back to get your required N bars (“Give me last N bars” does not work)
This is exactly the same issue: ordering by decreasing timestamps is not supported.
- dates in string format, why? dates in string format requires parsing in any usecase, which is slow in most programming languages, let alone increase in object size 4 bytes* 20 charaters=80byte (1000 bar is over 100kb) (in v1 1000 bar is arround 60kb), timetamp is more standard
Both of your arguments are valid: the string representation is harder to parse and slightly larger than the unix timestamp. The reason we went for RFC 3339 is human readability. But I honestly agree with you here. What would you think about adding an option to choose unix timestamp over RFC 3339 on the REST API?
- API params not mentioned in documentation like symbol can be formated in URL or you can use the symbols (plural) param to fetch multiple symbols this isn’t mentioned anywhere
Strongly agreed here. We have a lot of work to do on our documentation, and many we’re doing it, but we’re not quite there yet.
- breaking changes should be announced, V1 for paid plans doesn’t work (only iex data is returned)
Breaking changes are always announced. This was especially true for the v1 deprecation. Besides, to give you more context, we had no choice but to use IEX only data for v1. Polygon simply stopped providing data for us, which was used for v1.
Finally, let me say that the title of this post is somewhat degrading to the work we did on v2. Here’s a very incomplete list of some features that were added to v2:
- Historical & real-time trades
- Historical & real-time quotes
- Bar aggregation for custom timeframes
- Bar adjustment for splits & dividends
- Trade count & VWAP for bars
- Crypto data
- OTC data
- Proper pagination
Don’t get me wrong, it’s not perfect by any means. The latest N bars is certainly a highly requested feature. We’re doing our utmost to deliver the best possible product for you, so I’m thrilled to have a conversation with you to move to that direction.