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
-1
votes
1 answer

Function to export multiple yfinance stocks to csv

I'm trying to define a function to allow me to extract information on stocks over the past 12 months and export it to a CSV file. I'm not sure where it's going wrong as it prints 'bad'. Any thoughts? Thanks. import pandas as py import numpy as…
Reid
  • 1
  • 1
-1
votes
1 answer

how I display yfinancedata witout the Date

import yfinance as yf data = yf.download('AAPL') print(data['Open'].tail(1).to_string()) the result is Date Open 2022-06-09 36.849998 I want to remove the date can anyone help me please?
mansour32
  • 1
  • 4
-1
votes
1 answer

pandas.Series.replace not working with yfinance

I'm having issues to remove the dollar symbol from a Series after importing data from Yahoo Finance (yfinance). Does anyone know what I am doing wrong? Here is my code. import yfinance as yf start_date = '2016-01-01' yf_eth_df =…
-1
votes
1 answer

How would I remove "

How do I properly fix the main function? How would I remove "" from my output? My output works fine but I get The following output: function main at 0x7f2dba025d30> AAPL 155.09 MSFT 287.15 AMD 109.33 import yfinance…
God
  • 19
  • 5
-1
votes
3 answers

Market cap of all tickers in stock exchanges using python

I need to get the current market cap of all the tickers in the stock exchanges (NYSE and NASDAQ) along with their other information such as close, open, and etc (but these are optional). Is there any way like a csv file or api request that can give…
MOH
  • 43
  • 1
  • 8
-1
votes
2 answers

How to pass a variable as an argument of another function in python

I have a list (chart_list) and I want to call them one by one and plot the chart but I face an error. How can I deal with this problem? I know that they are strings but I don't know how to give it to the tickerDf. import streamlit as st …
8Simon8
  • 141
  • 9
-1
votes
1 answer

Annoying yfinance error and incompatibility with numpy/pandas

I have the latest numpy and pandas installed and yfinance too, since I just installed them recently. (like a couple of days ago) Now right now I am getting the error: TypeError: Cannot interpret '' as a…
Steveit
  • 51
  • 1
  • 9
-1
votes
1 answer

column calculation based on a value

using yfinance to get the below df, How do I calculate the "Day_Delta" column with +/-% delta from beginning day's Open_Value symbol Datetime Value_Type Open_Value Day_Delta AAPL 2021-09-20 09:30:00-04:00 Close …
spartanboy
  • 44
  • 11
-1
votes
1 answer

Jupyter Notebook Doesn't Ever Finish Running Script When time.sleep() Introduced

I'd like this script to show me the dataframe and then generate a new one w/ the latest data 1 min later. Problem is when I run this script in Jupyter notebook, it doesn't ever complete the first iteration of this. This code works in idle and a few…
-1
votes
1 answer

The same code that used to work is now returning an exception

I'm trying to do a simple correlation between a few stock symbols. I've run the same code before and it worked. Now, it's returning an exception that references a bunch of files and contains other messages that I don't understand. Also, the command…
-1
votes
2 answers

How to rename each dataframe as stock name from yfinance

Here is my code, but it doesn't work. import pandas as pd import yfinance as yf stock_list = ['TSLA','DDOG','NET','MSFT','AAPL'] df_list=[] for stock in stock_list: str(stock)_df = yf.download(stock, '2020-01-01') df_list =…
-1
votes
1 answer

Gathering rate of return from yfinance API

Picture of data Looking at my data I am trying to create a new column in a separate dataset that gives the ticker and the rate of return calculated by taking the open price of the first observation for a ticker and the last observation for that same…
Pat
  • 1
-1
votes
1 answer

Is it possible to calculate yearly beta, alpha and rsquared with a dataframe of multiple years?

I am working on the following project and I am having issues with calculating the yearly beta, alpha and rsquared instead of a single one of each one for the whole 6 years of data I have. import numpy as np import matplotlib.pyplot as plt import…
David A.
  • 25
  • 4
-1
votes
1 answer

'numpy.ndarray' object has no attribute 'replace' : When running yfinance (Yahoo Finance) to read stock data i am getting error for a list of stocks

I am running this code to get stock data for a list of stocks and getting an error import yfinance as yf start = datetime.datetime(2018,5,1) end = datetime.datetime(2020,8,31) yfdata = yf.download(stocks, start = start, end =…
bazooka720
  • 21
  • 4
-1
votes
3 answers

Does anyone know how to get Weekly data from yahoo finance using yfinance

I am using yfinance and ta-lib to pull in and manipulate index data from yahoo finance. The daily data looks good but when I switch to weekly in yfinance i get some weird values. I looked at the historical data on yahoo finance and indeed they for…
trustory
  • 215
  • 3
  • 13
1 2 3
37
38