-
Notifications
You must be signed in to change notification settings - Fork 538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get-bars changes limit behavior compared to get_barset #519
base: master
Are you sure you want to change the base?
Conversation
@@ -388,7 +388,8 @@ print(api.get_barset(['AAPL', 'GOOG'], 'minute', start=start, end=end).df) | |||
|
|||
``` | |||
|
|||
please note that if you are using limit, it is calculated from the end date. and if end date is not specified, "now" is used. <br>Take that under consideration when using start date with a limit. | |||
(Deprecated: When using `get_barset()`, please note that if you are using limit, it is calculated from the end date. and if end date is not specified, "now" is used. Take that under consideration when using start date with a limit. ) <br> | |||
For `get_bars()`, when you are using limit, it is calculated from the start date. If the end date is not specified, "now" is used. Take that under consideration when using end date with a limit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the end date is not specified, "now" is used.
This isn't completely true: for users with a free plan, actually "now - 15 minutes" is the default end.
Why is there even a behavior change for get_bars vs get_barset. One more annoyance is that get_barset worked when not providing any start or end or limit. However get_bars requires us to enter a start_date. I should logically be able to supply for example, a limit=300 to get_bars and get the last 300 bars for the time-frame requested. |
There are technical reasons why
This isn't true:
Again, "the last N bars" is not something the v2 API provides. By the way, my personal opinion is that in most scenarios it 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. But this argument is subjective, the real answer here too is that this is not supported at this time for technical reasons. |
Having a fixed default of start=beginning of current day is not very app friendly. Explains why I didn't see any bars when querying for daily chart and not supply start and end.
I think you are confusing last 300 trades vs bars.. when you request 300 bars for a stock at a given time-frame, the start date is going to be the same no matter the volatility of the stock. The number of bars is a function of time rather than volatility. @gnvk would you know if this limitation of V2 not supporting descending timestamps, thus limit from an end date, will be bridged in the future? If not, can we continue to use V1 version? Do we run a risk of V1 getting deprecated soon? |
Originally there was no default for the
No, we do not have bars for minutes where no trade happened. And this confusion is exactly my point: you really want the (maximum of) 300 bars in the last 5 hours, which is precisely what the v2 API encourages. You should query for all the bars in the last 5 hours:
I would say it is very unlikely but not completely impossible.
Absolutely not. V1 is already deprecated and will be removed soon. You have to understand that it's a huge burden to maintain two completely separate versions and we have already been doing it for many-many months now. |
I see.. I was under the impression that I would get bars for intervals without trades, just with o,h,l,c pointing to the previous close value. Now this is interesting in that it creates weird pockets if I were to plot this data as is from alpaca. |
Kudos, SonarCloud Quality Gate passed! |
The original README claims that limit is calculated from the end date. This was true with get_barset, but for get_bars, limit is calculated from start instead. I have corrected the README to reflect this.
For example, the following command will get 5 quotes starting from Oct 4, instead of the last 5 quotes ending Oct 20:
api.get_bars("AAPL", TimeFrame.Day, start="2021-10-04", end="2022-10-20", limit=5, adjustment='raw')