Questions tagged [yfinance]

For issues dealing with the Yahoo! Finance market data downloader. yfinance aims to solve this problem by offering a reliable, threaded, and Pythonic way to download historical market data from Yahoo! finance.

Documentation

How to install

# With Conda at the Anaconda prompt
conda install -c ranaroussi yfinance

# With pip
pip install yfinance --upgrade --no-cache-dir

Answers

  • How to deal with multi-level column names downloaded with yfinance
    • yfinance returns a pandas.DataFrame with multi-level column names, where there is a level for the ticker names and a level for the ticker prices.
    • This answer deals with the following issue:
      • How to correctly read the the multi-level columns after saving the dataframe to a csv with pandas.DataFrame.to_csv
      • How to download single or multiple tickers into a single dataframe with single level column names and a ticker column
  • Pandas column multi-index to rows
    • Shows how to download multiple ticker symbols and flatten the multi-level column names into single level columns with the ticker as one column.
565 questions
21
votes
8 answers

JSON Decode Error with yFinance [JSONDecodeError: Expecting value: line 1 column 1 (char 0)]

I have been using yfinance for the last several weeks to pull historical data on a number of stocks. I normally run the program at the end of each week to store data for that week, but this problem error just randomly starting occurring this past…
17
votes
12 answers

How to get actual stock prices with yfinance?

import yfinance as yf stock = yf.Ticker("ABEV3.SA") data1= stock.info print(data1) There is "bid" and "ask", but no actual stock price.
Tiago Godoy
  • 221
  • 1
  • 2
  • 7
10
votes
4 answers

How to deal with multi-level column names downloaded with yfinance

I have a list of tickers (tickerStrings) that I have to download all at once. When I try to use Pandas' read_csv it doesn't read the CSV file in the way it does when I download the data from yfinance. I usually access my data by ticker like this:…
timbibbs
  • 277
  • 1
  • 4
  • 15
9
votes
3 answers

yfinance json.decoder.JSONDecodeError

It had been working all the time before today. I don't know why it doesn't work today. import yfinance as yf df = yf.Ticker('MMM').history(start='2021-01-01',end='2021-07-10') File "D:\anaconda3\envs\tensorflow\lib\site-packages\yfinance\base.py",…
Xitler
  • 101
  • 6
8
votes
5 answers

Installing LXML, facing a "legacy-install-failure" error

Trying to install lxml on Python 311. Faced with this error. PS C:\Users\chharlie\Desktop\code> pip install lxml Collecting lxml Using cached lxml-4.9.1.tar.gz (3.4 MB) Preparing metadata (setup.py) ... done Building wheels for collected…
siovjio spvjs
  • 81
  • 1
  • 1
  • 2
8
votes
5 answers

Did yfinance and yahoo_fin for Python stop working recently?

yfinance and yahoo_fin no longer seem to work in their entirety. Is anyone else experiencing this problem with no financial data for any company using these packages? Does anyone know if these have been deprecated or blocked or if yfinance and…
Anon Omiss
  • 117
  • 1
  • 1
  • 6
8
votes
1 answer

Yahoo Finance: Search by ISIN or Ticker without Suffix

I have the ISIN, the Ticker symbol (without suffix, e.g. for Samsung 005930 and not 005930.KS) and the country name. When I go to the Yahoo Finance website I am able to search with the ISIN and I get the stock I am looking for. When I try to do it…
quervernetzt
  • 10,311
  • 6
  • 32
  • 51
7
votes
1 answer

Can't save data from yfinance into a CSV file

I found library that allows me to get data from yahoo finance very efficiently. It's a wonderful library. The problem is, I can't save the data into a csv file. I've tried converting the data to a Panda Dataframe but I think I'm doing it…
Peter
  • 91
  • 1
  • 5
6
votes
5 answers

ModuleNotFoundError: No module named 'yfinance' - Importing Yahoo finance & Financials to Python

I'm using Mac OS and receiving an error when doing the following: import pandas as pd import yfinance as yf from yahoofinancials import YahooFinancials ModuleNotFoundError: No module named 'yfinance' I've checked pip is installed to the latest…
user18233539
  • 129
  • 1
  • 2
  • 8
5
votes
3 answers

yfinance not working - receiving json.decoder.JSONDecodeError

I am scraping stock market data from yfinance. My code worked perfectly during the last weeks. For some reason, now I am receiving the following error: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) when executing: import…
5
votes
0 answers

Yahoo finance, filling up the two hour delay

I use yahoo finance (yfinance library in Python) to get the daily open, close, volume, min, max for crypto pairs. I figured out that the data resets at 00:00 UTC (close/open time), but the new row only gets added at 02:00 UTC. I need the data…
dorien
  • 5,265
  • 10
  • 57
  • 116
5
votes
1 answer

How to calculate the most common time for max value per day of week in pandas

Using the yahoo finance package in python, I am able to download the relevant data to show OCHL. What I am aiming to do, is find which time during the day is when the stock is at its highest on average. Here is the code to download the data: import…
Ash
  • 53
  • 5
5
votes
1 answer

Multithreaded download of yahoo stock history with python yfinance

I'm trying to download the historical data for a list of tickers and export each to a csv file. I can make this work as a for loop but that is very slow when the list of stock tickers is in the 1000's. I'm trying to multithread the process but I…
wraith
  • 370
  • 4
  • 16
4
votes
2 answers

Problems with yfinance package in Python

I am currently trying to use the yfinance package in Python, but am running into problems. When I run import yfinance as yf msft = yf.Ticker('MSFT') msft.info However, When I run this code I get the error message of :Exception: yfinance failed to…
Grant Weaver
  • 53
  • 1
  • 1
  • 6
4
votes
0 answers

CircuitBreaker 'redis' is OPEN and does not permit further calls ERROR

I am currently running an algo that uses yfinance to get historical stock data. It works on most stocks, but on some, it prints this error message: LOW: CircuitBreaker 'redis' is OPEN and does not permit further calls AXP: Error occurred while…
Rishab
  • 143
  • 2
  • 8
1
2 3
37 38