Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tiingo-Python | "No JSON object could be decoded" #157

Closed
2firstnames opened this issue Sep 12, 2018 · 6 comments
Closed

Tiingo-Python | "No JSON object could be decoded" #157

2firstnames opened this issue Sep 12, 2018 · 6 comments

Comments

@2firstnames
Copy link

2firstnames commented Sep 12, 2018

  • Tiingo Python version: 0.8.0
  • Python version: 3.6
  • Operating System: Windows 8.1

Description

I have followed examples and am able to download data for some stocks. But the vast majority return the following error:
"No JSON object could be decoded"

What I Did

from tiingo import TiingoClient
from pprint import pprint
import pandas as pd
import datetime
import json

today = datetime.datetime.today().strftime('%Y-%m-%d')
yesterday = datetime.datetime.today() - datetime.timedelta(1)

config = {}
config['session'] = True
config['api_key'] = "MY_API_KEY"
client = TiingoClient(config)

all_tickers = client.list_stock_tickers()
valid_tickers = [] # list of dicts
valid_exchanges = ['OTCMKTS','NYSE','NASDAQ','AMEX']
for ticker in all_tickers:
    if ticker['exchange'] in valid_exchanges:
        valid_tickers.append(ticker)

elligible_tickers = []
for ticker in valid_tickers:
    print(ticker['ticker'])
    try:
        yesterday_df = client.get_dataframe(ticker['ticker'],
                                      frequency='daily',
                                      startDate=yesterday,
                                      endDate=yesterday)

        yesterday_adj_close = yesterday_df['adjClose'].values[0]
        yesterday_volume = yesterday_df['volume'].values[0]

        min_price = 5
        min_volume = 400000

        if yesterday_adj_close > min_price and yesterday_volume > min_volume:
            elligible_tickers.append(ticker)
    except Exception as e:
        print(e)

# Elligible tickers is a list of ticker dictionaries
dataframe = pd.DataFrame(elligible_tickers)
print(dataframe)

@tiingo
Copy link

tiingo commented Sep 12, 2018

Hi Nick,

To eliminate this possibility,
Are you a subscribed member? Free accounts are limited to 500 tickers.

@2firstnames
Copy link
Author

Hi my friend,

I should have specified. Yes I am a paid member. Assume the string “MY_API_KEY” has been replaced with a valid API key.

@hydrosquall
Copy link
Owner

Hey @2firstnames, thanks for writing in and giving the library a spin!

Would it be possible to share a couple of the tickers which returned this message?

@2firstnames
Copy link
Author

My pleasure! Thank you on behalf of all those using it. I will give it a spin later tonight, but when I ran this exact code snippet (sub in my API key) the majority of them ran into this JSON decoding error. Out of over 10K stocks I’d say between 50-150 tickers were returned as having volume > 400k and a price of over $5, which I know for certain is a tiny fraction of the tickers which should have met the criteria. Again il provide the specifics later on!

Thanks.

@2firstnames
Copy link
Author

@hydrosquall @tiingo sorry for opening the issue gentlemen, my payment had failed and thus the API key was inactive. All is working beautifully now. Thanks again @hydrosquall for creating the library, we will be in touch :) 👍

@hydrosquall
Copy link
Owner

@2firstnames - this is good feedback for the library, I've filed an issue (#159) to investigate whether we can surface this information in an error message sooner :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants