Skip to content

[ENH] Remove yfinance from notebooks and examples #716

Open

Description

@fkiraly

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.

Activity

  1. shuvam586 commented on Mar 1, 2026

    @shuvam586

    hi @fkiraly

    I would like to start working on this issue.

    1. there are existing csv files in cookbook/data, that can be used as example files.
    2. create a data_loader.py file in pypfopt, to setup the data_loader.
    3. either update the tickers mentioned in the notebooks, or update the csv files to contain all the tickers.
    4. remove yfinance as a dependency
  2. fkiraly commented on Mar 1, 2026

    @fkiraly
    CollaboratorAuthor

    great, feel free to go ahead, @shuvam586!

    I would not put the data_loader directly in root of the package, I would instead make a data dir.

  3. shuvam586 commented on Mar 1, 2026

    @shuvam586

    @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?

  4. fkiraly commented on Mar 1, 2026

    @fkiraly
    CollaboratorAuthor

    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.

  5. amishverma05 commented on Apr 23, 2026

    @amishverma05

    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?

  6. shuvam586 commented on Apr 23, 2026

    @shuvam586

    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.

  7. amishverma05 commented on Apr 23, 2026

    @amishverma05

    hi @shuvam586
    Sure i will be looking to the code and will let you know if i feel anything can be made better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions