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

Enhances stocks/quote to allow for multiple tickers #4928

Merged
merged 14 commits into from
May 2, 2023

Conversation

deeleeramone
Copy link
Contributor

@deeleeramone deeleeramone commented Apr 28, 2023

Description

This PR is for improving the stocks/quote command to allow for querying multiple tickers. The additional motivation for this change is to facilitate the ability to add watch list functionality.

The SDK has been updated to include, openbb.stocks.quote_chart(), and the docstrings have been updated to reflect the changes to the syntax requiring the tickers to be entered as a list for the model and view.

The Equity Report file has been updated to include the change in syntax to the SDK function.

Note: Additional --source will be included in a future PR to allow this command to operate without any API keys required.

quote AAPL,META,MSFT,GOOG,NFLX,AMZN

Screenshot 2023-04-28 at 11 51 12 AM

The index strings are now formatted as a title.

Screenshot 2023-04-28 at 1 46 53 PM

  • Summary of the change / bug fix.
  • Screenshot of the feature or the bug before/after fix, if applicable.
  • Relevant motivation and context.

How has this been tested?

  • Please describe the tests that you ran to verify your changes.

Additional unit tests have been added capturing multiple tickers, and as well as the handling for a bad ticker.

  • Provide instructions so we can reproduce.

pytest tests/openbb_terminal/stocks/test_stocks_helper.py

  • Please also list any relevant details for your test configuration.

The integration test for the stocks menu has been updated to include multi-ticker quotes.

  • Make sure affected commands still run in terminal
  • Ensure the SDK still works
  • Check any related reports

Checklist:

Others

  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.

@deeleeramone deeleeramone added the enhancement Enhancement label Apr 28, 2023
@reviewpad reviewpad bot added the feat XS Extra small feature label Apr 28, 2023
@reviewpad reviewpad bot added feat M Medium T-Shirt size feature and removed feat XS Extra small feature labels Apr 30, 2023
@deeleeramone deeleeramone marked this pull request as ready for review April 30, 2023 16:19
@deeleeramone
Copy link
Contributor Author

deeleeramone commented Apr 30, 2023

@jmaslek, any idea why running python generate_sdk.py added a bunch of empty lines to sdk_helper.py?

Screenshot 2023-04-30 092511

@jmaslek
Copy link
Collaborator

jmaslek commented May 1, 2023

@jmaslek, any idea why running python generate_sdk.py added a bunch of empty lines to sdk_helper.py?

Screenshot 2023-04-30 092511

not sure. Probably something with formatting. Surprised black didnt get rid of them. Did you have to manually get rid of them ?

@deeleeramone
Copy link
Contributor Author

Probably something with formatting. Surprised black didnt get rid of them. Did you have to manually get rid of them ?

Yes, manually deleted them.

@jmaslek
Copy link
Collaborator

jmaslek commented May 1, 2023

You need to add some logic for if a string is added in. This will split it by letters

In [3]: openbb.stocks.quote("AAPL")
Out[3]: 
Symbol                                          A                           A                    P                    L
Name                   Agilent Technologies, Inc.  Agilent Technologies, Inc.  Pandora Media, Inc.    Loews Corporation
Price                                      136.35                      136.35                  NaN                60.13
Changes Percentage                         0.6793                      0.6793                  NaN               4.4468

@deeleeramone
Copy link
Contributor Author

You need to add some logic for if a string is added in. This will split it by letters

Done! Added a caveat:

symbol = symbols if isinstance(symbols, list) is False else ",".join(symbols)
In [1]: from openbb_terminal.sdk import openbb

In [2]: openbb.stocks.quote('AAPL')
Out[2]: 
Symbol                                AAPL
Name                            Apple Inc.
Price                               169.59
Changes Percentage                  -0.053
Change                               -0.09
Day Low                             168.64
Day High                            170.45
Year High                           176.15
Year Low                            124.17
Market Cap                         2.683 T
Price Avg50                        157.903
Price Avg200                     150.89626
Exchange                            NASDAQ
Volume                            47.584 M
Avg Volume                        61989696
Open                                169.28
Previous Close                      169.68
Eps                                   5.89
Pe                                   28.79
Earnings Announcement  2023-05-04 20:00:00
Shares Outstanding                15.822 B
Timestamp              2023-05-01 13:00:04

In [3]: openbb.stocks.quote('AAPL,MSFT')
Out[3]: 
Symbol                                AAPL                   MSFT
Name                            Apple Inc.  Microsoft Corporation
Price                               169.59                 305.56
Changes Percentage                  -0.053                -0.5533
Change                               -0.09                   -1.7
Day Low                             168.64                 305.15
Day High                            170.45                  308.6
Year High                           176.15                 308.93
Year Low                            124.17                 213.43
Market Cap                         2.683 T                2.272 T
Price Avg50                        157.903               272.9444
Price Avg200                     150.89626               256.1089
Exchange                            NASDAQ                 NASDAQ
Volume                            47.584 M               20.749 M
Avg Volume                        61989696               31388708
Open                                169.28                 306.97
Previous Close                      169.68                 307.26
Eps                                   5.89                   9.22
Pe                                   28.79                  33.14
Earnings Announcement  2023-05-04 20:00:00    2023-07-24 10:59:00
Shares Outstanding                15.822 B                7.435 B
Timestamp              2023-05-01 13:00:04    2023-05-01 13:00:04

In [4]: openbb.stocks.quote(['AAPL,MSFT'])
Out[4]: 
Symbol                                AAPL                   MSFT
Name                            Apple Inc.  Microsoft Corporation
Price                               169.59                 305.56
Changes Percentage                  -0.053                -0.5533
Change                               -0.09                   -1.7
Day Low                             168.64                 305.15
Day High                            170.45                  308.6
Year High                           176.15                 308.93
Year Low                            124.17                 213.43
Market Cap                         2.683 T                2.272 T
Price Avg50                        157.903               272.9444
Price Avg200                     150.89626               256.1089
Exchange                            NASDAQ                 NASDAQ
Volume                            47.584 M               20.749 M
Avg Volume                        61989696               31388708
Open                                169.28                 306.97
Previous Close                      169.68                 307.26
Eps                                   5.89                   9.22
Pe                                   28.79                  33.14
Earnings Announcement  2023-05-04 20:00:00    2023-07-24 10:59:00
Shares Outstanding                15.822 B                7.435 B
Timestamp              2023-05-01 13:00:04    2023-05-01 13:00:04

btw, @jmaslek, every function with a list as an input currently does this.

Screenshot 2023-05-01 at 3 13 19 PM

Screenshot 2023-05-01 at 3 14 33 PM

@jmaslek jmaslek added this pull request to the merge queue May 2, 2023
Merged via the queue into develop with commit 3c41eb6 May 2, 2023
13 checks passed
@piiq piiq deleted the feature/multi-ticker-quote branch June 4, 2023 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement feat M Medium T-Shirt size feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants