yFinance Package

Hi, I am new to Python in Excel, but keen to know whether it is possible to use the python yFinance package within Excel either directly or using any of the addins?

Hi @SKRR and welcome!

yfinance is not available in the Python in Excel distribution at this time since it requires access to external websites, which is not currently supported.

If you want to use Excel for this work, you have a couple of options:

  1. use the STOCKHISTORY function
  2. use Power Query to connect to an API like Yahoo Finance or similar

After you’ve pulled the data into the workbook, you can use either Python in Excel or Anaconda Code (available in the Anaconda Toolbox) to do your analysis with Python.

Anaconda Toolbox also comes with access to Anaconda Assistant, an AI chat interface tuned for helping with Python tasks.

Thanks for the update. Sadly none of your suggestions help with getting info such as dividend info or balance sheet, etc. Power Query was working well, but the yahoo link no longer works for anything besides basic info. Hence the hope that this route could be a potential solution.

Anaconda Code would have been a solution, but fc.yahoo.com doesn’t set the right CORS headers to allow a browser add-in to fetch data.

Anaconda Code has the ability to load and run yFinance, but it makes network requests as a browser client with client restrictions like CORS headers. And fc.yahoo.com needs to add some headers to their response to allow client-side fetches to work correctly.

Sad. Thought this would have been a solution. Hope sometime in the future it will work.