Closed ranaroussi closed 1 year ago
I did, but it still says an older version: Collecting yfinance Downloading yfinance-0.1.61.tar.gz (26 kB) Downloading yfinance-0.1.60.tar.gz (26 kB) Downloading yfinance-0.1.59.tar.gz (25 kB) Downloading yfinance-0.1.58.tar.gz (25 kB) Downloading yfinance-0.1.57.tar.gz (25 kB) Downloading yfinance-0.1.56.tar.gz (24 kB) Downloading yfinance-0.1.55.tar.gz (23 kB) Downloading yfinance-0.1.54.tar.gz (19 kB) Requirement already satisfied: pytz>=2017.3 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from pandas>=0.24->yfinance) (2021.1) Requirement already satisfied: python-dateutil>=2.7.3 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from pandas>=0.24->yfinance) (2.8.1) Requirement already satisfied: six>=1.5 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from python-dateutil>=2.7.3->pandas>=0.24->yfinance) (1.16.0) Requirement already satisfied: idna<3,>=2.5 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from requests>=2.20->yfinance) (2.10) Requirement already satisfied: certifi>=2017.4.17 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from requests>=2.20->yfinance) (2021.5.30) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from requests>=2.20->yfinance) (1.26.6) Requirement already satisfied: chardet<5,>=3.0.2 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from requests>=2.20->yfinance) (4.0.0) Using legacy 'setup.py install' for yfinance, since package 'wheel' is not installed. Installing collected packages: yfinance Running setup.py install for yfinance ... done Successfully installed yfinance-0.1.54
Thanks so much for this @ranaroussi!. pip install yfinance -U worked for me both on windows and linux. Thanks.
I'm getting the following error:
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-49jbf0/lxml
Just me or is anyone else getting this?
I'm getting the following error:
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-49jbf0/lxml
Just me or is anyone else getting this?
Okay, it turns out that this was a just-me problem... I updated successfully but am still getting the same errors from before I updated. My test code:
import yfinance as yf
handle = yf.Ticker("AOS")
data = handle.info
for thing in data:
print(thing)
Where this segment of code used to return everything from company name, address, current price, etc., now just returns one single piece of data, tagged "logo_url."
Thank you so much, updating to pip install yfinance==0.1.62
fixed the issue.
I was going mad because my code was the exact same as yesterday! Thank you!
I did, but it still says an older version: Collecting yfinance Downloading yfinance-0.1.61.tar.gz (26 kB) Downloading yfinance-0.1.60.tar.gz (26 kB) Downloading yfinance-0.1.59.tar.gz (25 kB) Downloading yfinance-0.1.58.tar.gz (25 kB) Downloading yfinance-0.1.57.tar.gz (25 kB) Downloading yfinance-0.1.56.tar.gz (24 kB) Downloading yfinance-0.1.55.tar.gz (23 kB) Downloading yfinance-0.1.54.tar.gz (19 kB) Requirement already satisfied: pytz>=2017.3 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from pandas>=0.24->yfinance) (2021.1) Requirement already satisfied: python-dateutil>=2.7.3 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from pandas>=0.24->yfinance) (2.8.1) Requirement already satisfied: six>=1.5 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from python-dateutil>=2.7.3->pandas>=0.24->yfinance) (1.16.0) Requirement already satisfied: idna<3,>=2.5 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from requests>=2.20->yfinance) (2.10) Requirement already satisfied: certifi>=2017.4.17 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from requests>=2.20->yfinance) (2021.5.30) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from requests>=2.20->yfinance) (1.26.6) Requirement already satisfied: chardet<5,>=3.0.2 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from requests>=2.20->yfinance) (4.0.0) Using legacy 'setup.py install' for yfinance, since package 'wheel' is not installed. Installing collected packages: yfinance Running setup.py install for yfinance ... done Successfully installed yfinance-0.1.54
Solved
Ranaroussi advised updating yfinance with "$ pip install yfinance -U--no-cache-dir"
Didn't work for me but I had luck with "pip install --upgrade yfinance"
My program is back to working. Thanks.
This is awesome thank you. I had no problem updating it for PyCharm, but i can't get it in my Conda environment. For some reason i cannot find it. Any suggestions? Thanks
Still observe the issue in 0.1.62
import yfinance as yf
handle = yf.Ticker("AOS")
data = handle.history()
print(data)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads return _default_decoder.decode(s) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I had the same error with @kevinvud's above. I think it has something to do with the server. Also the newest version of yfinance I could access was 0.1.61
ERROR: No matching distribution found for yfinance==0.1.62
got it for Anaconda..just needed to use the Anaconda prompt
Still observe the issue in 0.1.62
import yfinance as yf handle = yf.Ticker("AOS") data = handle.history() print(data)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads return _default_decoder.decode(s) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Try adding a user agent in base.py and modify the requests.get to include it in headers.. Pl see below:
self._scrape_url = 'https://finance.yahoo.com/quote' self._user_agent = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'} self._fundamentals = False ... data = _requests.get(url=url, params=params, proxies=proxy, headers=self._user_agent) ...
Yes, I'm still seeing the json error on 0.1.63. Edit: Tried yahoo_fin and that works for the same data, so I don't know if I have some misconfiguration or if there is still something with the yfinance package. yfínance is incredibly easy and useful so I hope I get it working soon. Edit 2: It works (0.1.63)! I don't know if it was the fiddling with yahoo_fin or a re-import somewhere, but now it scrapes flawlessly! Again, thanks to ranaroussi for this superb package!
Same error with python 3.8 and 0.1.63 ... :( simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Successfully installed yfinance-0.1.63
import yfinance as yf
df_ = yf.download('aapl')
Exception in thread Thread-7:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/Users/pavel/.virtualenvs/Finance/lib/python3.9/site-packages/multitasking/__init__.py", line 102, in _run_via_pool
return callee(*args, **kwargs)
File "/Users/pavel/.virtualenvs/Finance/lib/python3.9/site-packages/yfinance/multi.py", line 167, in _download_one_threaded
rounding=False):
File "/Users/pavel/.virtualenvs/Finance/lib/python3.9/site-packages/yfinance/multi.py", line 179, in _download_one
prepost=False, proxy=None, rounding=False):
File "/Users/pavel/.virtualenvs/Finance/lib/python3.9/site-packages/yfinance/base.py", line 157, in history
)
File "/Users/pavel/.virtualenvs/Finance/lib/python3.9/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/Users/pavel/.virtualenvs/Finance/lib/python3.9/site-packages/simplejson/__init__.py", line 525, in loads
return _default_decoder.decode(s)
File "/Users/pavel/.virtualenvs/Finance/lib/python3.9/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/Users/pavel/.virtualenvs/Finance/lib/python3.9/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
KeyboardInterrupt
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-5-64a558a62a31> in <module>
1 import yfinance as yf
----> 2 df_ = yf.download('aapl')
~/.virtualenvs/Finance/lib/python3.9/site-packages/yfinance/multi.py in download(tickers, start, end, actions, threads, group_by, auto_adjust, back_adjust, progress, period, interval, prepost, proxy, rounding, **kwargs)
93 back_adjust=back_adjust,
94 progress=(progress and i > 0), proxy=proxy,
---> 95 rounding=rounding)
96 while len(shared._DFS) < len(tickers):
97 _time.sleep(0.01)
KeyboardInterrupt:
Installed yfinance-0.1.63 and still getting JSON error. Bummed. Any other ideas? Thank you
0162 works better than 0163. Using 0163 I have randomly missing data entries.
Using 0163:
Using 0162:
Now everything woks fine! But I did't know what is it. I didn't change anything. Maybe it was yahoo problems?
Upgraded to 1.63. Here's my example code. Still getting JSON error. Any ideas? Please. thank you
import yfinance as yf import pandas as pd import numpy as np import statistics
tickerStrings = ['A','AA','AACG','AACQU','AACQW','AAIC','AAL']
for ticker in tickerStrings: try: data = yf.download(ticker, group_by="Ticker", period="3Y", interval="1wk",prepost = True) data['ticker'] = ticker data = data.json() data['SMA_20'] = data['Close'].rolling(20, min_periods=1).mean() data.tocsv(f'data{ticker}.csv') except: Exception
here I post my debugging code here which can show the problem of 0163. 0162 is fine as I showed in the above post.
import pandas as pd import os, sys, warnings from pandas_datareader import data as pdr import datetime as dt import yfinance as yf
def GetSingleStock( ticker=['FGCKX','VWILX','FXAIX',], startyear=2018, startmonth=5, startday=1,
):
yf.pdr_override() #Activate yahoo finance workaround
now=dt.datetime.now()
start= dt.datetime(startyear, startmonth,startday) #Set starting time for datasample
cwd=r'C:\temp\StockData'
for t in ticker:
FILENAME = '%s.csv' % (t)
cname = cwd + os.sep + FILENAME
df=pdr.get_data_yahoo(t,start,now,auto_adjust = True) #create panda dataframe with stock data
df.to_csv(cname, mode='w', header=True,index=True)
cname = cwd + os.sep +'FXAIX.csv'
dataset = pd.read_csv(cname, index_col=0, parse_dates=True)
dat_fund = dataset[['Close',]]
dat_fund=dat_fund.rename(columns={"Close":'FXAIX'})
for fund in ['VWILX','FGCKX']:
cname = cwd + os.sep +fund+'.csv'
temp = pd.read_csv(cname, index_col=0, parse_dates=True)
dat_fund=dat_fund.join(temp['Close']).rename(columns={"Close": fund})
print (dat_fund[-10:])
dat_fund.to_csv ('debug.csv', mode='w',header=True,index=True)
used pip install --upgrade yfinance upgrade to 0.1.63 resolved the issue for me.
make sure you reset your kernel
Got the 1.63 to work. the yfinance upgrade folder saved to C:\Python\Lib\site-packages. But the python sessions I'm using were referencing another site-packages folder. So I had to drag the new yfinance over the old. Whew. Got the groove back. Thank you
got it for Anaconda..just needed to use the Anaconda prompt
Matt: what are the exact steps that you used to install the latest yfinance via Anaconda Terminal?
In my response to another post, I mention that I use the Anaconda Terminal and in it execute
conda install -c ranaroussi yfinance
but that this now fails for me with a PackagesNotFoundError.
After upgrading to 0.1.63, It worked for the first time but afterwards, it stopped working again!
This worked for me:
pip uninstall yfinance
pip uninstall pandas-datareader
pip install yfinance --upgrade --no-cache-dir
pip install pandas-datareader
SSL error while using 0.1.63 with HTTP/S Proxy. Separate issue here #781
I am still getting this json.decoder.JSONDecodeError
error ,even after upgrading yfinance , in pycharm which is using python 3.8 interpreter.
And upon using Anaconda python interpreter I am getting
AttributeError: module 'pandas' has no attribute 'DataFrame'
when calling yf.Ticker() method.
I am still getting this
json.decoder.JSONDecodeError
error ,even after upgrading yfinance , in pycharm which is using python 3.8 interpreter. And upon using Anaconda python interpreter I am gettingAttributeError: module 'pandas' has no attribute 'DataFrame'
when calling yf.Ticker() method.
try this: pip uninstall pandas-datareader pip install pandas-datareader
upgraded to yfinance-0.1.63. Pandas-datareader is up to date.
I am still experiencing several json.decoder.JSONDecodeError (4/726 stocks). Worst issue is that the yf.download call freezes the program so exception management is not possible and my program becomes useless.
See output below. Input stocks list here:
['AIR.PA', 'ALV.DE', 'ABI.BR', 'ASML.AS', 'BBVA.MC', 'BAYN.DE', 'BMW.DE', 'BNP.PA', 'BN.PA', 'DPW.DE', 'DTE.DE', 'ENEL.MI', 'ENGI.PA', 'ENI.MI', 'EI.PA', 'FRE.DE', 'IBE.MC', 'ITX.MC', 'INGA.AS', 'PHIA.AS', 'AI.PA', 'OR.PA', 'MC.PA', 'ORA.PA', 'SAF.PA', 'SAN.PA', 'SU.PA', 'ADS.DE', 'AD.AS', 'AMS.MC', 'CS.PA', 'BAS.DE', 'SAN.MC', 'CRG.IR', 'DAI.DE', 'DB1.DE', 'GLE.PA', 'ISP.MI', 'KER.PA', 'LIN.DE', 'MUV2.DE', 'NOKIA.HE', 'SAP.DE', 'SIE.DE', 'TEF.MC', 'FP.PA', 'UNA.AS', 'DG.PA', 'VIV.PA', 'VOW.DE', 'DSM.AS', 'TKWY.AS', 'PHIA.AS', 'NN.AS', 'REN.AS', 'RAND.AS', 'KPN.AS', 'ASM.AS', 'ASML.AS', 'UNA.AS', 'ASRNL.AS', 'MT.AS', 'URW.AS', 'WKL.AS', 'AKZA.AS', 'RDSA.AS', 'AGN.AS', 'AD.AS', 'HEIA.AS', 'ABN.AS', 'ADYEN.AS', 'IMCD.AS', 'INGA.AS', 'PRX.AS', 'GLPG.AS', 'BLG.BR', 'AGB.BR', 'TNO.BR', 'UCB.BR', 'AVH.BR', 'GBL.BR', 'SOL.BR', 'INT.BR', 'GLS.BR', 'KBC.BR', 'UMC.BR', 'DEL.BR', 'ENGI.BR', 'COFB.BR', 'ONTEX.BR', 'ES6.BR', 'BEK.BR', 'BPO.BR', 'COL.BR', 'INGA.BR', 'AI.PA', 'HO.PA', 'CA.PA', 'ORA.PA', 'AC.PA', 'AIR.PA', 'CAP.PA', 'EN.PA', 'WLN.PA', 'KER.PA', 'ENGI.PA', 'BNP.PA', 'ACA.PA', 'FP.PA', 'SAN.PA', 'RI.PA', 'SU.PA', 'GLE.PA', 'BN.PA', 'OR.PA', 'MC.PA', 'ML.PA', 'VIV.PA', 'VIE.PA', 'ATO.PA', 'SW.PA', 'UG.PA', 'LR.PA', 'DG.PA', 'SGO.PA', 'MT.AS', 'CS.PA', 'DSY.PA', 'EL.PA', 'RMS.PA', 'PUB.PA', 'RNO.PA', 'SAF.PA', 'STM.PA', 'URW.AS', 'WDI.DE', 'VNA.DE', 'DB1.DE', 'BAYN.DE', 'DBK.DE', 'SAP.DE', 'ALV.DE', 'ADS.DE', 'IFX.DE', 'MRK.DE', 'LHA.DE', 'FME.DE', '1COV.DE', 'EOAN.DE', 'TKA.DE', 'DPW.DE', 'VOW3.DE', 'BAS.DE', 'RWE.DE', 'FRE.DE', 'LIN.DE', 'MUV2.DE', 'HEN3.DE', 'BEI.DE', 'DTE.DE', 'BMW.DE', 'SIE.DE', 'DAI.DE', 'CON.DE', 'HEI.DE', 'BATS.L', 'VOD.L', 'RTO.L', 'SSE.L', 'RB.L', 'TSCO.L', 'CPG.L', 'SMT.L', 'ANTO.L', 'PSN.L', 'CCH.L', 'CNA.L', 'RR.L', 'MGGT.L', 'EZJ.L', 'PRU.L', 'AHT.L', 'RDSB.L', 'RDSA.L', 'SDR.L', 'SPX.L', 'CCL.L', 'AUTO.L', 'MNG.L', 'STJ.L', 'SMIN.L', 'BA.L', 'JET.L', 'RMV.L', 'EXPN.L', 'BARC.L', 'BDEV.L', 'BKG.L', 'BHP.L', 'BP.L', 'BATS.L', 'BLND.L', 'BT.A.L', 'BNZL.L', 'BRBY.L', 'CCL.L', 'CNA.L', 'CCH.L', 'CPG.L', 'CRH.L', 'CRDA.L', 'DCC.L', 'DGE.L', 'SMDS.L', 'EZJ.L', 'EVR.L', 'EXPN.L', 'FERG.L', 'FLTR.L', 'FRES.L', 'GSK.L', 'GLEN.L', 'HLMA.L', 'HL.L', 'HIK.L', 'HSBA.L', 'IMB.L', 'INF.L', 'IHG.L', 'ICP.L', 'IAG.L', 'ITRK.L', 'ITV.L', 'JD.L', 'JMAT.L', 'JET.L', 'LAND.L', 'LGEN.L', 'LLOY.L', 'LSE.L', 'MNG.L', 'MGGT.L', 'MRO.L', 'MNDI.L', 'MRW.L', 'NG.L', 'NXT.L', 'OCDO.L', 'PSON.L', 'PNN.L', 'PSN.L', 'PHNX.L', 'POLY.L', 'PRU.L', 'RB.L', 'REL.L', 'RTO.L', 'RMV.L', 'RIO.L', 'RR.L', 'RBS.L', 'RDSA.L', 'RSA.L', 'SGE.L', 'SBRY.L', 'SDR.L', 'SMT.L', 'SGRO.L', 'SVT.L', 'SN.L', 'SMIN.L', 'SKG.L', 'SPX.L', 'SSE.L', 'STJ.L', 'STAN.L', 'SLA.L', 'TW.L', 'TSCO.L', 'ULVR.L', 'UU.L', 'VOD.L', 'WTB.L', 'WPP.L', 'MMM', 'AXP', 'AAPL', 'BA', 'CAT', 'CVX', 'CSCO', 'KO', 'DIS', 'DOW', 'XOM', 'GS', 'HD', 'IBM', 'INTC', 'JNJ', 'JPM', 'MCD', 'MRK', 'MSFT', 'NKE', 'PFE', 'PG', 'RTX', 'TRV', 'UNH', 'VZ', 'V', 'WMT', 'WBA', 'MMM', 'ABT', 'ABBV', 'ABMD', 'ACN', 'ATVI', 'ADBE', 'AMD', 'AAP', 'AES', 'AFL', 'A', 'APD', 'AKAM', 'ALK', 'ALB', 'ARE', 'ALXN', 'ALGN', 'ALLE', 'AGN', 'ADS', 'LNT', 'ALL', 'GOOGL', 'GOOG', 'MO', 'AMZN', 'AMCR', 'AEE', 'AAL', 'AEP', 'AXP', 'AIG', 'AMT', 'AWK', 'AMP', 'ABC', 'AME', 'AMGN', 'APH', 'ADI', 'ANSS', 'ANTM', 'AON', 'AOS', 'APA', 'AIV', 'AAPL', 'AMAT', 'APTV', 'ADM', 'ANET', 'AJG', 'AIZ', 'T', 'ATO', 'ADSK', 'ADP', 'AZO', 'AVB', 'AVY', 'BKR', 'BLL', 'BAC', 'BK', 'BAX', 'BDX', 'BRK.B', 'BBY', 'BIIB', 'BLK', 'BA', 'BKNG', 'BWA', 'BXP', 'BSX', 'BMY', 'AVGO', 'BR', 'BF.B', 'CHRW', 'COG', 'CDNS', 'CPB', 'COF', 'CPRI', 'CAH', 'KMX', 'CCL', 'CARR', 'CAT', 'CBOE', 'CBRE', 'CDW', 'CE', 'CNC', 'CNP', 'CTL', 'CERN', 'CF', 'SCHW', 'CHTR', 'CVX', 'CMG', 'CB', 'CHD', 'CI', 'CINF', 'CTAS', 'CSCO', 'C', 'CFG', 'CTXS', 'CLX', 'CME', 'CMS', 'KO', 'CTSH', 'CL', 'CMCSA', 'CMA', 'CAG', 'CXO', 'COP', 'ED', 'STZ', 'COO', 'CPRT', 'GLW', 'CTVA', 'COST', 'COTY', 'CCI', 'CSX', 'CMI', 'CVS', 'DHI', 'DHR', 'DRI', 'DVA', 'DE', 'DAL', 'XRAY', 'DVN', 'FANG', 'DLR', 'DFS', 'DISCA', 'DISCK', 'DISH', 'DG', 'DLTR', 'D', 'DOV', 'DOW', 'DTE', 'DUK', 'DRE', 'DD', 'DXC', 'ETFC', 'EMN', 'ETN', 'EBAY', 'ECL', 'EIX', 'EW', 'EA', 'EMR', 'ETR', 'EOG', 'EFX', 'EQIX', 'EQR', 'ESS', 'EL', 'EVRG', 'ES', 'RE', 'EXC', 'EXPE', 'EXPD', 'EXR', 'XOM', 'FFIV', 'FB', 'FAST', 'FRT', 'FDX', 'FIS', 'FITB', 'FE', 'FRC', 'FISV', 'FLT', 'FLIR', 'FLS', 'FMC', 'F', 'FTNT', 'FTV', 'FBHS', 'FOXA', 'FOX', 'BEN', 'FCX', 'GPS', 'GRMN', 'IT', 'GD', 'GE', 'GIS', 'GM', 'GPC', 'GILD', 'GL', 'GPN', 'GS', 'GWW', 'HRB', 'HAL', 'HBI', 'HOG', 'HIG', 'HAS', 'HCA', 'PEAK', 'HP', 'HSIC', 'HSY', 'HES', 'HPE', 'HLT', 'HFC', 'HOLX', 'HD', 'HON', 'HRL', 'HST', 'HWM', 'HPQ', 'HUM', 'HBAN', 'HII', 'IEX', 'IDXX', 'INFO', 'ITW', 'ILMN', 'INCY', 'IR', 'INTC', 'ICE', 'IBM', 'IP', 'IPG', 'IFF', 'INTU', 'ISRG', 'IVZ', 'IPGP', 'IQV', 'IRM', 'JKHY', 'J', 'JBHT', 'SJM', 'JNJ', 'JCI', 'JPM', 'JNPR', 'KSU', 'K', 'KEY', 'KEYS', 'KMB', 'KIM', 'KMI', 'KLAC', 'KSS', 'KHC', 'KR', 'LB', 'LHX', 'LH', 'LRCX', 'LW', 'LVS', 'LEG', 'LDOS', 'LEN', 'LLY', 'LNC', 'LIN', 'LYV', 'LKQ', 'LMT', 'L', 'LOW', 'LYB', 'MTB', 'MRO', 'MPC', 'MKTX', 'MAR', 'MMC', 'MLM', 'MAS', 'MA', 'MKC', 'MXIM', 'MCD', 'MCK', 'MDT', 'MRK', 'MET', 'MTD', 'MGM', 'MCHP', 'MU', 'MSFT', 'MAA', 'MHK', 'TAP', 'MDLZ', 'MNST', 'MCO', 'MS', 'MOS', 'MSI', 'MSCI', 'MYL', 'NDAQ', 'NOV', 'NTAP', 'NFLX', 'NWL', 'NEM', 'NWSA', 'NWS', 'NEE', 'NLSN', 'NKE', 'NI', 'NBL', 'JWN', 'NSC', 'NTRS', 'NOC', 'NLOK', 'NCLH', 'NRG', 'NUE', 'NVDA', 'NVR', 'ORLY', 'OXY', 'ODFL', 'OMC', 'OKE', 'ORCL', 'OTIS', 'PCAR', 'PKG', 'PH', 'PAYX', 'PAYC', 'PYPL', 'PNR', 'PBCT', 'PEP', 'PKI', 'PRGO', 'PFE', 'PM', 'PSX', 'PNW', 'PXD', 'PNC', 'PPG', 'PPL', 'PFG', 'PG', 'PGR', 'PLD', 'PRU', 'PEG', 'PSA', 'PHM', 'PVH', 'QRVO', 'PWR', 'QCOM', 'DGX', 'RL', 'RJF', 'RTX', 'O', 'REG', 'REGN', 'RF', 'RSG', 'RMD', 'RHI', 'ROK', 'ROL', 'ROP', 'ROST', 'RCL', 'SPGI', 'CRM', 'SBAC', 'SLB', 'STX', 'SEE', 'SRE', 'NOW', 'SHW', 'SPG', 'SWKS', 'SLG', 'SNA', 'SO', 'LUV', 'SWK', 'SBUX', 'STT', 'STE', 'SYK', 'SIVB', 'SYF', 'SNPS', 'SYY', 'TMUS', 'TROW', 'TTWO', 'TPR', 'TGT', 'TEL', 'FTI', 'TFX', 'TXN', 'TXT', 'TMO', 'TIF', 'TJX', 'TSCO', 'TT', 'TDG', 'TRV', 'TFC', 'TWTR', 'TSN', 'UDR', 'ULTA', 'USB', 'UAA', 'UA', 'UNP', 'UAL', 'UNH', 'UPS', 'URI', 'UHS', 'UNM', 'VFC', 'VLO', 'VAR', 'VTR', 'VRSN', 'VRSK', 'VZ', 'VRTX', 'VIAC', 'V', 'VNO', 'VMC', 'WRB', 'WAB', 'WMT', 'WBA', 'DIS', 'WM', 'WAT', 'WEC', 'WFC', 'WELL', 'WDC', 'WU', 'WRK', 'WY', 'WHR', 'WMB', 'WLTW', 'WYNN', 'XEL', 'XRX', 'XLNX', 'XYL', 'YUM', 'ZBRA', 'ZBH', 'ZION', 'ZTS']
program line:
stocks_df_hist = yf.download(stocks_list_in, period="2y", group_by="ticker", threads=8)
Program output (I have to kill the program, else it freezes):
[**73%** ] 527 of 726 completedException in thread Thread-541: Traceback (most recent call last): File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "/usr/lib/python3.7/threading.py", line 865, in run self._target(*self._args, *self._kwargs) File "/home/pi/.local/lib/python3.7/site-packages/multitasking/init.py", line 102, in _run_via_pool return callee(args, kwargs) File "/home/pi/.local/lib/python3.7/site-packages/yfinance/multi.py", line 170, in _download_one_threaded actions, period, interval, prepost, proxy, rounding) File "/home/pi/.local/lib/python3.7/site-packages/yfinance/multi.py", line 185, in _download_one rounding=rounding, many=True) File "/home/pi/.local/lib/python3.7/site-packages/yfinance/base.py", line 162, in history data = data.json() File "/home/pi/.local/lib/python3.7/site-packages/requests/models.py", line 900, in json return complexjson.loads(self.text, kwargs) File "/usr/lib/python3.7/json/init.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[**73%** ] 529 of 726 completedException in thread Thread-544: Traceback (most recent call last): File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "/usr/lib/python3.7/threading.py", line 865, in run self._target(*self._args, *self._kwargs) File "/home/pi/.local/lib/python3.7/site-packages/multitasking/init.py", line 102, in _run_via_pool return callee(args, kwargs) File "/home/pi/.local/lib/python3.7/site-packages/yfinance/multi.py", line 170, in _download_one_threaded actions, period, interval, prepost, proxy, rounding) File "/home/pi/.local/lib/python3.7/site-packages/yfinance/multi.py", line 185, in _download_one rounding=rounding, many=True) File "/home/pi/.local/lib/python3.7/site-packages/yfinance/base.py", line 162, in history data = data.json() File "/home/pi/.local/lib/python3.7/site-packages/requests/models.py", line 900, in json return complexjson.loads(self.text, kwargs) File "/usr/lib/python3.7/json/init.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[**73%** ] 531 of 726 completedException in thread Thread-545: Traceback (most recent call last): File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner self.run() File "/usr/lib/python3.7/threading.py", line 865, in run self._target(*self._args, *self._kwargs) File "/home/pi/.local/lib/python3.7/site-packages/multitasking/init.py", line 102, in _run_via_pool return callee(args, kwargs) File "/home/pi/.local/lib/python3.7/site-packages/yfinance/multi.py", line 170, in _download_one_threaded actions, period, interval, prepost, proxy, rounding) File "/home/pi/.local/lib/python3.7/site-packages/yfinance/multi.py", line 185, in _download_one rounding=rounding, many=True) File "/home/pi/.local/lib/python3.7/site-packages/yfinance/base.py", line 162, in history data = data.json() File "/home/pi/.local/lib/python3.7/site-packages/requests/models.py", line 900, in json return complexjson.loads(self.text, kwargs) File "/usr/lib/python3.7/json/init.py", line 348, in loads return _default_decoder.decode(s) File "/usr/lib/python3.7/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.7/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[**99%***] 722 of 726 completed^CTraceback (most recent call last): File "/home/pi/camila/bin/camila_core8_3.py", line 402, in
indexes_df_hist, stocks_df_hist = get_historical_data(index_list, stocks_list) File "/home/pi/camila/bin/camila_core8_3.py", line 124, in get_historical_data stocks_df_hist = yf.download(stocks_list_in, period="2y", group_by="ticker", threads=8) File "/home/pi/.local/lib/python3.7/site-packages/yfinance/multi.py", line 97, in download _time.sleep(0.01) KeyboardInterrupt
Got a bunch of json.decoder.JSONDecodeError errors today when trying - it was very inconsistent, though, some of my batches (I'll run about 100 tickers at a time) worked fine, others produced the error every time.
July 9, 2021
If you're getting an
json.decoder.JSONDecodeError
related error, please upgrade toyfinance 0.1.62
.Upgrade using:
Best, - Ran Aroussi