Thank you in advanced for any insights you can offer to my current challenge. I am running Python 3.9.1 and the latest versions of PANDAS and TIINGO libraries.
The problem is a reliable API call has started failing for certain tickers. I assume the problem is with the API provider but find it odd that no one else is reporting the problems.
My (simplified) code:
# Loads historical stock data into files
import datetime
#from pandas_datareader import data
import pandas as pd
import io
import os
#import requests
from tiingo import TiingoClient
os.environ["TIINGO_API_KEY"] = 'MY API KEY'
client = TiingoClient()
ticker = 'PG'
last_load_date = '2020-08-19'
today = '2021-02-12'
#idx = client.get_dataframe(ticker, frequency='daily', startDate=last_load_date, endDate=today)
##history = client.get_dataframe(['GOOGL',],
## frequency='daily',
## metric_name='adjClose',
## startDate='2020-01-01',
## endDate='2021-05-31')
prices = client.get_ticker_price(ticker,
fmt='json',
startDate=last_load_date,
endDate=today,
frequency='daily')
The failed output:
Traceback (most recent call last):
File "V:/woodstock/jobs/tiingo_test.py", line 22, in <module>
prices = client.get_ticker_price(ticker,
File "C:\Users\wood\AppData\Local\Programs\Python\Python39\lib\site-packages\tiingo\api.py", line 241, in get_ticker_price
return response.json()
File "C:\Users\wood\AppData\Local\Programs\Python\Python39\lib\site-packages\requests\models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\wood\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "C:\Users\wood\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\wood\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)
I have tried both the direct JSON method (above) and the leveraging dataframes (preferred but commented out above). This works for a ticker like GE but fails for PG, TSLA and others.
I have contacted Tiingo support but appreciate any insights from the community.
THANK YOU!
Tiingo support answered my question very quickly and professionally. As a "free" customer, I am incredibly impressed by their service.
The answer, for anyone else facing this is that Tiingo has a constraint on the number of calls per hour AND total number of unique symbols requested. The API is failing due to the fact that I have reached my 500 ticker limit and am requesting a ticker outside of that list. I will be upgrading my service to get around this issue.