ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
14.71k stars 2.44k forks source link

Getting this Error: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) #877

Closed MaximilianPannenbaecker closed 3 years ago

MaximilianPannenbaecker commented 3 years ago

Hallo I am keep getting an Error for different scripts her an exampl script: `tickers = gettickers('mdax') days = 30 returns, symbols = [], [] klines = {} for ticker in tickers[]: klines[ticker] = yf.download(ticker.upper(), interval='1d', period=f'{days}d', threads=False) if len(klines[ticker]) > 0:
cumret = (pd.DataFrame(klines[ticker])['Close'].astype(float).pct_change() + 1).prod() - 1 returns.append(cumret) symbols.append(ticker)

retdf = pd.DataFrame(returns, index=symbols, columns=['Return'])` print(retdf.Return.nlargest(3))

I am getting an Error thrown for different stocks each time. Did yahoo change its site? Is there a fix for the problem? This is the Error: Traceback (most recent call last): File "C:\Users\User\Desktop\Python\pythonProject\stock\test_center.py", line 53, in klines[ticker] = yf.download(ticker.upper(), interval='1d', period=f'{days}d', threads=False) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\multi.py", line 102, in download data = _download_one(ticker, period=period, interval=interval, File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\multi.py", line 181, in _download_one return Ticker(ticker).history(period=period, interval=interval, File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\base.py", line 179, in history data = data.json() File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 910, in json return complexjson.loads(self.text, **kwargs) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\json__init__.py", line 346, in loads return _default_decoder.decode(s) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\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)

Process finished with exit code 1

nexbelgium commented 3 years ago

Having the same issue (script was still working correctly yesterday)

MaximilianPannenbaecker commented 3 years ago

Ah okay so maybe yahoo changed something

lironsamara commented 3 years ago

Also having the same issue - getting it for different stocks each time. Any solution?

Thanks!

matt-wetmore commented 3 years ago

Same issue here

HeadbangerFinance commented 3 years ago

I'm also getting a lot of issues/problems since yesterday - however, seems to be working when I disable threading...

groszek1604 commented 3 years ago

The same problem, threading worked for 5-10 tickers, then the same issue

ftamimi commented 3 years ago

Same issue, seems like most requests work fine but some give this error - looks pretty random, same ticker will work one minute then fail. I can't try and catch - it seems to be stuck and I need to ctrl c to remove the error. I've tried show_errors=False, threading=False but still the same

started yesterday

tavianix commented 3 years ago

Same issue here, I try 0.1.63 and 0.1.64, yesterday everything worked fine...

danieldeconinck commented 3 years ago

Same here. Since yesterday. Works with a couple of tickers but fails randomly after multiple request. "threads=False" does not help

seekingclarity commented 3 years ago

Ditto. Same issue. It worked on a portfolio of tickers a few times then I received a similar error as above and the following error as well on a different portfolio:

timeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

matt-wetmore commented 3 years ago

threading=False seemed to help for me; I run my tickers in batches of 100 and a few of those still crashed on the first try after I added threading=False in, but they all eventually worked, whereas last night they didn't no matter how much I tried.

AlexisMinerscience commented 3 years ago

You can try to use the construction (try: … except: …) together with threading=False, as a temporary measure it works for me.

MaximilianPannenbaecker commented 3 years ago

Well at least it is not just myself. Thanks for the tip

ftamimi commented 3 years ago

I've got try: except: but for some reason I see the error and have to ctrl c, then it gets to the except print message I have, otherwise it doesn't go past the error

angeloconde commented 3 years ago

You can try to use the construction (try: … except: …) together with threading=False, as a temporary measure it works for me.

Thanks. Worked fine for me also

AlexisMinerscience commented 3 years ago

I've got try: except: but for some reason I see the error and have to ctrl c, then it gets to the except print message I have, otherwise it doesn't go past the error

Initially, when threads=True, the (try: except :) construct did not catch this error, the script started working normally only when threads=False, at least for me.

ftamimi commented 3 years ago

I've got try: except: but for some reason I see the error and have to ctrl c, then it gets to the except print message I have, otherwise it doesn't go past the error

Initially, when threads=True, the (try: except :) construct did not catch this error, the script started working normally only when threads=False, at least for me.

thanks, I tried this already, I have a comment from 3 hours ago where I tried the below as well :( also have try and excepts show_errors=False, threading=False

ftamimi commented 3 years ago

I've got try: except: but for some reason I see the error and have to ctrl c, then it gets to the except print message I have, otherwise it doesn't go past the error

Initially, when threads=True, the (try: except :) construct did not catch this error, the script started working normally only when threads=False, at least for me.

thanks, I tried this already, I have a comment from 3 hours ago where I tried the below as well :( also have try and excepts show_errors=False, threading=False

apologies, I just noticed my typo with threads. I think its running through my code at least now, thanks

D1al-T0ne commented 3 years ago

Is this not a similar issue to #764, that had version 0.1.62 pushed to fix?

danieldeconinck commented 3 years ago

show_errors=False + threading=False + try/except construction: Works like a charm. Loaded 131 tickers in 1 batch. 11 gave an exception and were skipped. Thanks for all tips

MaximilianPannenbaecker commented 3 years ago

D1al-T0ne commented 26 minutes ago

Is this not a similar issue to #764, that had version 0.1.62 pushed to fix?

I think it is

focus8 commented 3 years ago

I have the same issue. I am trying to process 623 different tickers. The error seems to be random. Sometimes the script get data for 20 companies. The last error was the 4th company ticker.

gib-uk commented 3 years ago

sorry, i'm not following the threading = false comments. how do i implement this?

any help appreciated.

here is my code: for x in stock: try: yf.pdr_override() data = pdr.get_data_yahoo(x, start=start_date, end=end_date)

Harry55494 commented 3 years ago

sorry, i'm not following the threading = false comments. how do i implement this?

any help appreciated.

here is my code: for x in stock: try: yf.pdr_override() data = pdr.get_data_yahoo(x, start=start_date, end=end_date)

You can include it as a parameter for the download, for example: data = yf.download(tickers = ticker, start = start_date, end = end_date, threads = False) This will disable using threads. Unfortunately however, disabling them for me has not fixed this issue, nor adding a try-except block.

I would suggest waiting for now - yahoo finance was down for maintenance less than an hour ago I believe (at least my download error message said it was) and given how many of us are having this issue, its probably not something one of us has done. I'd wait and see if either yahoo, or the creator implements a fix for us.

gib-uk commented 3 years ago

ok, i also have a vba script i wrote originally that downloads csv files... that is experiencing the same symptoms so i'm guessing its definitely an issue at yahoos end generating the JSON (i think this uses the JSON outputs).

jcristee commented 3 years ago

Yahoo randomly returns "HTTP Status 404" instead of JSON. Some kind of query limiter?

aronsky commented 3 years ago

Seems like an issue on Yahoo's end. Temporary fix:

while True:
  try:                                                                                         
    data = yf.download(tickers='AMZN GOOG MSFT', start=START_DATE, end=datetime.datetime.today(), actions=True, threads=False)
    break
  except:                
    continue
# Use `data` here...

This will keep retrying until it manages to retrieve all the tickers without an error - for me, it took ~10-15 seconds for 16 tickers, but obviously will be worse the more tickers there are.

Would be great if a retry mechanism could be implemented in yfinance itself, possibly with sane default values and/or possibility to pass a retries number to the download function, to avoid similar issues in the future.

Rafael-Silva-Oliveira commented 3 years ago

Same errors here, seems to be on yahoo's end.

GeoHand commented 3 years ago

Semi automatic solution:

Untitled

Every time JSONDecodeError is thrown, manually interrupt the kernel

JPLCltgs commented 3 years ago

Other libraries are working (pip install yahoofinancials). I've made a quick&dirty implementation to replace the download function and it's working for me. (Please note that most of the arguments are not in use and the interval is hardcoded to daily)

from yahoofinancials import YahooFinancials as YF
import pandas as pd
from datetime import datetime

def download(tickers=[], start=None, end=None, interval='1d',
             threads=False, progress=False, group_by='ticker'):
    if (not isinstance(tickers, list)):
        tickers = [tickers]

    tickers = list(set([ticker.upper() for ticker in tickers]))

    tickersdf = []
    for i in tickers:
        tick = YF(i)
        json = tick.get_historical_price_data(start, end, "daily")
        date = []
        high = []
        low = []
        open = []
        close = []
        adjclose = []
        volume = []
        for j in json[i]['prices']:
            high.append(j['high'])
            low.append(j['low'])
            open.append(j['open'])
            close.append(j['close'])
            adjclose.append(j['adjclose'])
            volume.append(j['volume'])
            date.append(datetime.strptime(j['formatted_date'], "%Y-%m-%d"))

        data = {'Open': open,
                'High': high,
                'Low': low,
                'Adj Close': adjclose,
                'Close': close,
                'Volume': volume}

        tickersdf.append(pd.DataFrame(data, index=date))

    df = pd.concat(tickersdf, axis=1, keys=tickers)

    if(len(tickers) == 1):
        for i in tickers:
            return df[i]

    return(df)
kxdyz commented 3 years ago

Other libraries are working (pip install yahoofinancials). I've made a quick&dirty implementation to replace the download function and it's working for me. (Please note that most of the arguments are not in use and the interval is hardcoded to daily)

from yahoofinancials import YahooFinancials as YF
import pandas as pd
from datetime import datetime

def download(tickers=[], start=None, end=None, interval='1d',
             threads=False, progress=False, group_by='ticker'):
    if (not isinstance(tickers, list)):
        tickers = [tickers]

    tickers = list(set([ticker.upper() for ticker in tickers]))

    tickersdf = []
    for i in tickers:
        tick = YF(i)
        json = tick.get_historical_price_data(start, end, "daily")
        date = []
        high = []
        low = []
        open = []
        close = []
        adjclose = []
        volume = []
        for j in json[i]['prices']:
            high.append(j['high'])
            low.append(j['low'])
            open.append(j['open'])
            close.append(j['close'])
            adjclose.append(j['adjclose'])
            volume.append(j['volume'])
            date.append(datetime.strptime(j['formatted_date'], "%Y-%m-%d"))

        data = {'Open': open,
                'High': high,
                'Low': low,
                'Adj Close': adjclose,
                'Close': close,
                'Volume': volume}

        tickersdf.append(pd.DataFrame(data, index=date))

    df = pd.concat(tickersdf, axis=1, keys=tickers)

    if(len(tickers) == 1):
        for i in tickers:
            return df[i]

    return(df)

Hello, thanks for your share.. I am trying to run it but cant get it work. quite newbie here. Having errors like: AttributeError: 'list' object has no attribute 'download'.. Could you please explain more how to use the function.. ?? Thank you

GeoHand commented 3 years ago

Hi First of all, yfinance now works without problems. End an example with function may be something like this one

import yfinance as yf from yahoofinancials import YahooFinancials as YF import pandas as pd from datetime import datetime from IPython.display import display

my_list = ['AMD', 'AAPL', 'MSFT', 'LCID', 'INTC', 'TSLA', 'FB', 'CRTX', 'HOOD','WISH', 'NVDA', 'CMCSA', 'WTRH', 'AAL', 'FISV', 'SIRI', 'PYPL', 'SOFI', 'VIAC', 'MQ', 'ZNGA', 'CSCO', 'MU', 'VTRS', 'APA', 'CSX', 'TXN', 'HBAN', 'SDC', 'RENT', 'DKNG', 'AFRM', 'JBLU', 'BBBY', 'RUN', 'NVAX', 'KHC', 'UAL', 'OPEN', 'AMAT', 'EBAY']

def download(tickers=[], start=None, end=None, interval='1d', threads=False, progress=False, group_by='ticker'): if (not isinstance(tickers, list)): tickers = [tickers]

tickers = list(set([ticker.upper() for ticker in tickers]))

tickersdf = []
for i in tickers:
    tick = YF(i)
    json = tick.get_historical_price_data(start, end, "daily")
    date = []
    high = []
    low = []
    open = []
    close = []
    adjclose = []
    volume = []
    for j in json[i]['prices']:
        high.append(j['high'])
        low.append(j['low'])
        open.append(j['open'])
        close.append(j['close'])
        adjclose.append(j['adjclose'])
        volume.append(j['volume'])
        date.append(datetime.strptime(j['formatted_date'], "%Y-%m-%d"))

    data = {'Open': open,
            'High': high,
            'Low': low,
            'Adj Close': adjclose,
            'Close': close,
            'Volume': volume}

    tickersdf.append(pd.DataFrame(data, index=date))

#df = pd.concat(tickersdf, axis=1, keys=tickers)

if(len(tickers) == 1):
    for i in tickers:
        return df[i]

return(df)

for i in range(len(my_list)): try: df = download(tickers=my_list, start="2021-10-31", end="2021-11-09", interval='1d', threads=False, group_by='ticker') display(df) except: i=i-1

Στις Πέμ, 11 Νοε 2021 στις 12:23 π.μ., ο/η kxdyz @.***> έγραψε:

Other libraries are working (pip install yahoofinancials). I've made a quick&dirty implementation to replace the download function and it's working for me. (Please note that most of the arguments are not in use and the interval is hardcoded to daily)

from yahoofinancials import YahooFinancials as YF import pandas as pd from datetime import datetime

def download(tickers=[], start=None, end=None, interval='1d', threads=False, progress=False, group_by='ticker'): if (not isinstance(tickers, list)): tickers = [tickers]

tickers = list(set([ticker.upper() for ticker in tickers]))

tickersdf = []
for i in tickers:
    tick = YF(i)
    json = tick.get_historical_price_data(start, end, "daily")
    date = []
    high = []
    low = []
    open = []
    close = []
    adjclose = []
    volume = []
    for j in json[i]['prices']:
        high.append(j['high'])
        low.append(j['low'])
        open.append(j['open'])
        close.append(j['close'])
        adjclose.append(j['adjclose'])
        volume.append(j['volume'])
        date.append(datetime.strptime(j['formatted_date'], "%Y-%m-%d"))

    data = {'Open': open,
            'High': high,
            'Low': low,
            'Adj Close': adjclose,
            'Close': close,
            'Volume': volume}

    tickersdf.append(pd.DataFrame(data, index=date))

df = pd.concat(tickersdf, axis=1, keys=tickers)

if(len(tickers) == 1):
    for i in tickers:
        return df[i]

return(df)

Hello, thanks for your share.. I am trying to run it but cant get it work. quite newbie here. Having errors like: AttributeError: 'list' object has no attribute 'download'.. Could you please explain more how to use the function.. ?? Thank you

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ranaroussi/yfinance/issues/877#issuecomment-965801584, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG76IHSTGYLCDXDVZZVQ5V3ULLWGLANCNFSM5HURDAZA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

GeoHand commented 3 years ago

Hi Sorry. Working code is this one

import yfinance as yf from yahoofinancials import YahooFinancials as YF import pandas as pd from datetime import datetime from IPython.display import display

my_list = ['AMD', 'AAPL', 'MSFT', 'LCID', 'INTC', 'TSLA', 'FB', 'CRTX', 'HOOD','WISH', 'NVDA', 'CMCSA', 'WTRH', 'AAL', 'FISV', 'SIRI', 'PYPL', 'SOFI', 'VIAC', 'MQ', 'ZNGA', 'CSCO', 'MU', 'VTRS', 'APA', 'CSX', 'TXN', 'HBAN', 'SDC', 'RENT', 'DKNG', 'AFRM', 'JBLU', 'BBBY', 'RUN', 'NVAX', 'KHC', 'UAL', 'OPEN', 'AMAT', 'EBAY']

def download(tickers=[], start=None, end=None, interval='1d', threads=False, progress=False, group_by='ticker'): if (not isinstance(tickers, list)): tickers = [tickers]

tickers = list(set([ticker.upper() for ticker in tickers]))

tickersdf = []
for i in tickers:
    tick = YF(i)
    json = tick.get_historical_price_data(start, end, "daily")
    date = []
    high = []
    low = []
    open = []
    close = []
    adjclose = []
    volume = []
    for j in json[i]['prices']:
        high.append(j['high'])
        low.append(j['low'])
        open.append(j['open'])
        close.append(j['close'])
        adjclose.append(j['adjclose'])
        volume.append(j['volume'])
        date.append(datetime.strptime(j['formatted_date'], "%Y-%m-%d"))

    data = {'Open': open,
            'High': high,
            'Low': low,
            'Adj Close': adjclose,
            'Close': close,
            'Volume': volume}

    tickersdf.append(pd.DataFrame(data, index=date))

df = pd.concat(tickersdf, axis=1, keys=tickers)

if(len(tickers) == 1):
    for i in tickers:
        return df[i]

return(df)

df = download(tickers=my_list, start="2021-10-31", end="2021-11-09", interval='1d', threads=False, group_by='ticker') display(df)

Στις Πέμ, 11 Νοε 2021 στις 1:13 μ.μ., ο/η Γεώργιος Ταχμαζίδης < @.***> έγραψε:

Hi First of all, yfinance now works without problems. End an example with function may be something like this one

import yfinance as yf from yahoofinancials import YahooFinancials as YF import pandas as pd from datetime import datetime from IPython.display import display

my_list = ['AMD', 'AAPL', 'MSFT', 'LCID', 'INTC', 'TSLA', 'FB', 'CRTX', 'HOOD','WISH', 'NVDA', 'CMCSA', 'WTRH', 'AAL', 'FISV', 'SIRI', 'PYPL', 'SOFI', 'VIAC', 'MQ', 'ZNGA', 'CSCO', 'MU', 'VTRS', 'APA', 'CSX', 'TXN', 'HBAN', 'SDC', 'RENT', 'DKNG', 'AFRM', 'JBLU', 'BBBY', 'RUN', 'NVAX', 'KHC', 'UAL', 'OPEN', 'AMAT', 'EBAY']

def download(tickers=[], start=None, end=None, interval='1d', threads=False, progress=False, group_by='ticker'): if (not isinstance(tickers, list)): tickers = [tickers]

tickers = list(set([ticker.upper() for ticker in tickers]))

tickersdf = []
for i in tickers:
    tick = YF(i)
    json = tick.get_historical_price_data(start, end, "daily")
    date = []
    high = []
    low = []
    open = []
    close = []
    adjclose = []
    volume = []
    for j in json[i]['prices']:
        high.append(j['high'])
        low.append(j['low'])
        open.append(j['open'])
        close.append(j['close'])
        adjclose.append(j['adjclose'])
        volume.append(j['volume'])
        date.append(datetime.strptime(j['formatted_date'], "%Y-%m-%d"))

    data = {'Open': open,
            'High': high,
            'Low': low,
            'Adj Close': adjclose,
            'Close': close,
            'Volume': volume}

    tickersdf.append(pd.DataFrame(data, index=date))

#df = pd.concat(tickersdf, axis=1, keys=tickers)

if(len(tickers) == 1):
    for i in tickers:
        return df[i]

return(df)

for i in range(len(my_list)): try: df = download(tickers=my_list, start="2021-10-31", end="2021-11-09", interval='1d', threads=False, group_by='ticker') display(df) except: i=i-1

Στις Πέμ, 11 Νοε 2021 στις 12:23 π.μ., ο/η kxdyz @.***> έγραψε:

Other libraries are working (pip install yahoofinancials). I've made a quick&dirty implementation to replace the download function and it's working for me. (Please note that most of the arguments are not in use and the interval is hardcoded to daily)

from yahoofinancials import YahooFinancials as YF import pandas as pd from datetime import datetime

def download(tickers=[], start=None, end=None, interval='1d', threads=False, progress=False, group_by='ticker'): if (not isinstance(tickers, list)): tickers = [tickers]

tickers = list(set([ticker.upper() for ticker in tickers]))

tickersdf = []
for i in tickers:
    tick = YF(i)
    json = tick.get_historical_price_data(start, end, "daily")
    date = []
    high = []
    low = []
    open = []
    close = []
    adjclose = []
    volume = []
    for j in json[i]['prices']:
        high.append(j['high'])
        low.append(j['low'])
        open.append(j['open'])
        close.append(j['close'])
        adjclose.append(j['adjclose'])
        volume.append(j['volume'])
        date.append(datetime.strptime(j['formatted_date'], "%Y-%m-%d"))

    data = {'Open': open,
            'High': high,
            'Low': low,
            'Adj Close': adjclose,
            'Close': close,
            'Volume': volume}

    tickersdf.append(pd.DataFrame(data, index=date))

df = pd.concat(tickersdf, axis=1, keys=tickers)

if(len(tickers) == 1):
    for i in tickers:
        return df[i]

return(df)

Hello, thanks for your share.. I am trying to run it but cant get it work. quite newbie here. Having errors like: AttributeError: 'list' object has no attribute 'download'.. Could you please explain more how to use the function.. ?? Thank you

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ranaroussi/yfinance/issues/877#issuecomment-965801584, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG76IHSTGYLCDXDVZZVQ5V3ULLWGLANCNFSM5HURDAZA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

MaximilianPannenbaecker commented 3 years ago

Seems to be working again. Thanks for the help.

gystar commented 2 years ago

I fixed it.

This problem is due to the server blocking http get requests (for example, requests from China mainland). The following is the url for yfinance to download stock data. If you can open it normally to get the data, the download function of yfinance is generally ok, otherwise the corresponding error will be displayed: [https://query2.finance.yahoo.com/v8/finance/chart/%5EDJI]

I downloaded the json of the corresponding data through vpn, and then modified yfinance to read the cached json file instead of downloading it through http get to solve this problem.

Rabelaiss commented 2 years ago

@MaximilianPannenbaecker I have just installed yfinance, it works fine with commands like yf.download(tickers='AMZN', start='2021-10-10', end=datetime.datetime.today(), actions=True, threads=False)

but with this one doesn't work, do you know how to solve? Thanks

>>> yf.download(tickers='EUR/USD', start='2021-10-10', end=datetime.datetime.today(), actions=True, threads=False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\gianni\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\multi.py", line 117, in download
    data = _download_one(ticker, period=period, interval=interval,
  File "C:\Users\gianni\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\multi.py", line 202, in _download_one
    return Ticker(ticker).history(period=period, interval=interval,
  File "C:\Users\gianni\AppData\Local\Programs\Python\Python39\lib\site-packages\yfinance\base.py", line 194, in history
    data = data.json()
  File "C:\Users\gianni\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 888, in json
    return complexjson.loads(
  File "C:\Users\gianni\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Users\gianni\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\gianni\AppData\Local\Programs\Python\Python39\lib\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)
groszek1604 commented 2 years ago

@MaximilianPannenbaecker check ticker in yahoo finance, for EUR/USD it should be EURUSD=X

Rabelaiss commented 2 years ago

@groszek1604 thank you very much it works! But it seems that the oldest date is 2003-12-01, is there a way to retrieve older data, for example from 80s and 90s? I tried with start='1990-10-10 but it doesn't work Thanks again

>>> yf.download(tickers='EURusd=X', actions=True, threads=False, start='1990-10-10')
[*********************100%***********************]  1 of 1 completed
                Open      High       Low     Close  Adj Close  Volume  Dividends  Stock Splits
Date
2003-12-01  1.203398  1.204007  1.194401  1.196501   1.196501       0          0             0
2003-12-02  1.196101  1.210903  1.194600  1.208897   1.208897       0          0             0
2003-12-03  1.209000  1.213003  1.207700  1.212298   1.212298       0          0             0
2003-12-04  1.212004  1.214403  1.204398  1.208094   1.208094       0          0             0
2003-12-05  1.207802  1.219096  1.206593  1.218695   1.218695       0          0             0
...              ...       ...       ...       ...        ...     ...        ...           ...
2021-11-17  1.131618  1.133400  1.127053  1.132118   1.132118       0          0             0
2021-11-18  1.131811  1.135976  1.131503  1.132118   1.132118       0          0             0
2021-11-19  1.137010  1.137010  1.125239  1.136842   1.136842       0          0             0
2021-11-22  1.127574  1.129050  1.123823  1.127574   1.127574       0          0             0
2021-11-23  1.124101  1.127777  1.122965  1.125113   1.125113       0          0             0

[4663 rows x 8 columns]