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

Feature/polygon-stock-quote: Add NBBO Quotes, with historical, to obb.stocks.quote() #5617

Merged
merged 32 commits into from
Nov 8, 2023

Conversation

deeleeramone
Copy link
Contributor

@deeleeramone deeleeramone commented Oct 27, 2023

This PR adds Polygon as a provider to the obb.stocks.nbbo() function. This has a default limit of 25 results, but can return an unstable amount of data if desired. I have put an internal cap at 10M entries. The limit argument becomes important when requesting historical data, especially for the most trafficked tickers.

A typical day of SPY NBBO quotes will be around 5 million rows and nearly 1GB as a raw, uncompressed, CSV file. It is not recommended to go about it this way, but it is possible. Best practice would be to break up the request into smaller chunks - like an hour at a time - using the greater/less than parameters to bracket the period.

Just the default setting with only a ticker entered returns the most recent 25 NBBO Quotes:

Note examples here have a not-current name. The function and model have changed to nbbo, from quote.

obb.stocks.quote("TSLA", provider="polygon").to_df()

Screenshot 2023-10-27 at 3 44 09 PM

I looked into converting the condition and indicator codes but the reference tables in the Polygon documentation appear to be missing some entries and/or are not accurate.

For any query that includes a time, it must be formatted like this:

2023-10-27T16:01:00.000000000-04:00

Example of a bracketed request:

obb.stocks.quote("SPY", provider="polygon", timestamp_gt="2023-10-26T15:00:00.000000000-04:00",timestamp_lt="2023-10-26T15:30:00.000000000-04:00").to_df()

Yields 317,491 records between 3:00 and 3:30 yesterday:

Screenshot 2023-10-27 at 3 38 48 PM

Lower volume stocks are way less heavy, the entire day for CLOV yesterday produces only 11,046 rows.

obb.stocks.quote("CLOV", provider="polygon", timestamp="2023-10-26").to_df()

Screenshot 2023-10-27 at 3 41 53 PM

@reviewpad reviewpad bot added the feat M Medium T-Shirt size feature label Oct 27, 2023
@deeleeramone deeleeramone added platform OpenBB Platform v4 PRs for v4 labels Oct 27, 2023
@reviewpad reviewpad bot added feat L Large T-Shirt size Feature and removed feat M Medium T-Shirt size feature labels Oct 27, 2023
Copy link
Collaborator

@jmaslek jmaslek left a comment

Choose a reason for hiding this comment

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

I would like to see this as a different endpoint than just quote. My biggest reasoning is just the pure amount of data you can get. Trying to just get a clean look, and oops i am now dealing with 6 GB

@deeleeramone deeleeramone requested a review from jmaslek October 31, 2023 22:28
@piiq piiq requested review from hjoaquim and the-praxs November 3, 2023 15:20
@piiq piiq merged commit 82fc6ee into feature/openbb-sdk-v4 Nov 8, 2023
12 checks passed
@piiq piiq deleted the feature/polygon-stock-quote branch November 8, 2023 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat M Medium T-Shirt size feature platform OpenBB Platform v4 PRs for v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants