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

Stock splits and getting dividends, stock splits, and other historical data in one function call #238

Open
advaiyalad opened this issue Jul 13, 2021 · 5 comments · May be fixed by #239
Open

Comments

@advaiyalad
Copy link
Contributor

Hello!

First of all, congratulations for the awesome work! This is a very good API!

I was wondering if it is possible to get the split history, the same way the Yahoo! charts show:

image
image

I am sure this print can help:

image

if you change the "Show" option to Stock Splits, the exported csv shows the information I need.

Looking forward to your reply!
Thanks!

Originally posted by @ZehCoque in #119 (comment)

@advaiyalad
Copy link
Contributor Author

I managed to make it work like this:

const queryOptions = { period1: '2021-06-30', events: 'history split',};
yahooFinance.historical('BPAC11.SA', queryOptions, { validateResult: false })

with this result:

[ { date: 2021-07-01T00:00:00.000Z, stockSplits: '4:1' } ]

But this clearly is not the way this API is supposed to work. In this way, I am only able to get the stockSplits response and I would like to get everything (high, low, open, close, volume AND splits) at once. Is it possible?

Thanks!

Originally posted by @ZehCoque in #119 (reply in thread)

@advaiyalad
Copy link
Contributor Author

@ZehCoque Thanks for asking! The API endpoint used to download the CSV only returns one thing at a time. It isn't exactly great, but I guess it is just a limitation of the YF API. I will send a PR tomorrow that will add stock splits as either an addition to the current historical module or a new module entirely. There is also a charts endpoint that seems to return the desired data in an odd format. I guess I might implement stock splits in both a new module and the historical one (pun not intended). Hopefully, by tomorrow, I will have some sort of a module ready...

@gadicc
Copy link
Owner

gadicc commented Jul 13, 2021

Massive thanks as usual, @PythonCreator27! 🙏 🎉

@gadicc
Copy link
Owner

gadicc commented Jul 13, 2021

If you end up using the data from Yahoo Finance's historical, I favor keeping it historical too. As long as it's an option with the current behaviour the default, it won't be a breaking change.

In the future, we may consider to allow array values, e.g. { filter: [ "prices", "splits", "dividends" ] }, and combine the data for convenience - we'll have to make clear in the docs that this will use multiple network requests. And we'd need to think about error handling if just one of the requests fails. So I wouldn't worry about this now, but it will work nicely if everything is all in the same module.

Thanks again for taking this on!

@advaiyalad
Copy link
Contributor Author

advaiyalad commented Jul 13, 2021

Quick update: I am going to create a new module entirely, as modifying the types in historical to be the way we need would be a breaking change. I am currently going to call this module historical2 (horrible name, I know), but I am open for any suggestions on naming (historicalNew, maybe). I think that the old historical can be deprecated after this I finish up the module, as the new module will return similar data to the old won, except for allowing dividends and stock splits as well.

New update: I have a working implementation, but without tests or docs. It has the same bug as #208, for now.

@advaiyalad advaiyalad linked a pull request Jul 13, 2021 that will close this issue
6 tasks
@advaiyalad advaiyalad changed the title Stock Splits Stock splits and getting dividends, stock splits, and other historical data in one function call Jul 13, 2021
@huned huned mentioned this issue Nov 14, 2021
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants