Skip to content
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

Add news api #555

Merged
merged 7 commits into from
Jan 26, 2022
Merged

Add news api #555

merged 7 commits into from
Jan 26, 2022

Conversation

ccnlui
Copy link
Contributor

@ccnlui ccnlui commented Jan 10, 2022

Context

Added support for news api, both stream and historical endpoint

TODO

  • Add tests (done)

@ccnlui ccnlui requested a review from a team January 11, 2022 16:16
alpaca_trade_api/entity_v2.py Outdated Show resolved Hide resolved
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
@gnvk gnvk changed the title ENG-8782 add news api Add news api Jan 12, 2022
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
alpaca_trade_api/stream.py Outdated Show resolved Hide resolved
@ccnlui ccnlui force-pushed the ENG-8782-add-news branch from 6e342e2 to 3a8e519 Compare January 12, 2022 21:36
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
@ccnlui ccnlui force-pushed the ENG-8782-add-news branch from 3a8e519 to ffb030c Compare January 12, 2022 22:16
@ccnlui
Copy link
Contributor Author

ccnlui commented Jan 12, 2022

For get_news(), I'm using NEWS_MAX_LIMIT = 50 as a default query limit to prevent fetching too many news articles. no_total_limit can be used to suppress this.

It also acts as a page_limit to minimize api calls for the client if total_limit is more than 50. This mimics behaviour of the other endpoints like get_trades()

The difference is that the other endpoints don't have a default query limit... So get_trades('AAPL') would actually just fetch everything, 10000 data points at a time...

I wonder if I should add total_limit and no_total_limit to the other methods too, but it's a breaking change 🤔

@ccnlui ccnlui requested a review from gnvk January 12, 2022 22:19
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
@ccnlui ccnlui force-pushed the ENG-8782-add-news branch from 4621731 to a062d02 Compare January 13, 2022 15:23
alpaca_trade_api/rest.py Outdated Show resolved Hide resolved
Copy link
Contributor

@gnvk gnvk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you @ccnlui!

@gnvk gnvk merged commit 6132575 into master Jan 26, 2022
@gnvk gnvk deleted the ENG-8782-add-news branch January 26, 2022 10:45
fumoboy007 added a commit to fumoboy007/alpaca-trade-api-python that referenced this pull request Mar 27, 2023
News article events are different from other types of events (e.g. stock trades) because a single news article could be applicable to multiple symbols. For that reason, the streamed event does not have the usual `S` field that contains a single symbol; instead, the event has a `symbols` field that contains a list of symbols.

alpacahq#555 mistakenly assumes that the event has an `S` field. This commit changes the dispatching logic to instead use the `symbols` field.

(There is a similar [commit](alpacahq/alpaca-trade-api-csharp@be67b62) for the C# library.)
fumoboy007 added a commit to fumoboy007/alpaca-trade-api-python that referenced this pull request Mar 27, 2023
News article events are different from other types of events (e.g. stock trades) because a single news article could be applicable to multiple symbols. For that reason, the streamed event does not have the usual `S` field that contains a single symbol; instead, the event has a `symbols` field that contains a list of symbols.

alpacahq#555 mistakenly assumes that the event has an `S` field. This commit changes the dispatching logic to instead use the `symbols` field.

(There is a similar [commit](alpacahq/alpaca-trade-api-csharp@be67b62) for the C# library.)
fumoboy007 added a commit to fumoboy007/alpaca-trade-api-python that referenced this pull request Mar 27, 2023
News article events are different from other types of events (e.g. stock trades) because a single news article could be applicable to multiple symbols. For that reason, the streamed event does not have the usual `S` field that contains a single symbol; instead, the event has a `symbols` field that contains a list of symbols.

alpacahq#555 mistakenly assumes that the event has an `S` field. This commit changes the dispatching logic to instead use the `symbols` field.

(There is a similar [commit](alpacahq/alpaca-trade-api-csharp@be67b62) for the C# library.)
fumoboy007 added a commit to fumoboy007/alpaca-trade-api-python that referenced this pull request Mar 27, 2023
News article events are different from other types of events (e.g. stock trades) because a single news article could be applicable to multiple symbols. For that reason, the streamed event does not have the usual `S` field that contains a single symbol; instead, the event has a `symbols` field that contains a list of symbols.

alpacahq#555 mistakenly assumes that the event has an `S` field. This commit changes the dispatching logic to instead use the `symbols` field.

(There is a similar [commit](alpacahq/alpaca-trade-api-csharp@be67b62) for the C# library.)
fumoboy007 added a commit to fumoboy007/alpaca-trade-api-python that referenced this pull request Mar 27, 2023
News article events are different from other types of events (e.g. stock trades) because a single news article could be applicable to multiple symbols. For that reason, the streamed event does not have the usual `S` field that contains a single symbol; instead, the event has a `symbols` field that contains a list of symbols.

alpacahq#555 mistakenly assumes that the event has an `S` field. This commit changes the dispatching logic to instead use the `symbols` field.

(There is a similar [commit](alpacahq/alpaca-trade-api-csharp@be67b62) for the C# library.)
gnvk pushed a commit that referenced this pull request Mar 27, 2023
News article events are different from other types of events (e.g. stock trades) because a single news article could be applicable to multiple symbols. For that reason, the streamed event does not have the usual `S` field that contains a single symbol; instead, the event has a `symbols` field that contains a list of symbols.

#555 mistakenly assumes that the event has an `S` field. This commit changes the dispatching logic to instead use the `symbols` field.

(There is a similar [commit](alpacahq/alpaca-trade-api-csharp@be67b62) for the C# library.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants