You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ENH] Remove yfinance from notebooks and examples #716
yfinance regularly downloads data from the internet to run the notebook examples.
Instead, the examples and notebooks should not rely on downloads, but, optimally, on a small csv example file that ships with the package for the purpose of examples. This should be "hidden" behind a load_stockdata loader function or similar.
There are already csv files in the cookbook folder which could be used for that, albeit they may have to be shortened.
Once this is done, it should be possible to entirely remove the dependency on yfinance.
There is already a PR that started to do this - #678 - but it got abandoned and also made some unrelated changes.
@fkiraly i apologise if this is trivial, there are tickers mentioned in the example notebooks, which are not present in the cookbook/data/stock_prices.csv. do you prefer a new example csv file in pypfopt/data/ with all the tickers or stripping down specific tickers to make it compatible with the cookbook notebooks?
I think it is fine to replace them, as long as it is similar. Alternatively, you can use the same tickers, e.g., with synthetic data? As long as the figures etc end up similar.
Hi @fkiraly 👋 I'd like to work on this issue. I'm a newcomer to open source and this looks like a great starting point.
My plan:
Create a load_stockdata() helper function that reads from the existing CSV files in the repo
Replace yfinance calls in all cookbook notebooks with this loader
Remove yfinance from dev dependencies once all notebooks are updated
Add appropriate tests
I also noticed the abandoned PR #678 — I'll reference it for ideas but start fresh to avoid the unrelated changes.
Could you confirm this approach sounds good before I start?
i already opened #721 addressing this issue. it replaces yfinance with a local data loader and updates the cookbook notebooks. lets discuss any ideas or improvements directly on the PR so we don’t duplicate work.
Activity
shuvam586 commentedon Mar 1, 2026
hi @fkiraly
I would like to start working on this issue.
cookbook/data, that can be used as example files.data_loader.pyfile inpypfopt, to setup the data_loader.yfinanceas a dependencyfkiraly commentedon Mar 1, 2026
great, feel free to go ahead, @shuvam586!
I would not put the
data_loaderdirectly in root of the package, I would instead make adatadir.shuvam586 commentedon Mar 1, 2026
@fkiraly i apologise if this is trivial, there are tickers mentioned in the example notebooks, which are not present in the
cookbook/data/stock_prices.csv. do you prefer a new example csv file inpypfopt/data/with all the tickers or stripping down specific tickers to make it compatible with thecookbooknotebooks?fkiraly commentedon Mar 1, 2026
I think it is fine to replace them, as long as it is similar. Alternatively, you can use the same tickers, e.g., with synthetic data? As long as the figures etc end up similar.
amishverma05 commentedon Apr 23, 2026
Hi @fkiraly 👋 I'd like to work on this issue. I'm a newcomer to open source and this looks like a great starting point.
My plan:
Create a load_stockdata() helper function that reads from the existing CSV files in the repo
Replace yfinance calls in all cookbook notebooks with this loader
Remove yfinance from dev dependencies once all notebooks are updated
Add appropriate tests
I also noticed the abandoned PR #678 — I'll reference it for ideas but start fresh to avoid the unrelated changes.
Could you confirm this approach sounds good before I start?
shuvam586 commentedon Apr 23, 2026
hi @amishverma05
i already opened #721 addressing this issue. it replaces yfinance with a local data loader and updates the cookbook notebooks. lets discuss any ideas or improvements directly on the PR so we don’t duplicate work.
amishverma05 commentedon Apr 23, 2026
hi @shuvam586
Sure i will be looking to the code and will let you know if i feel anything can be made better