0

Lookup sometimes returns None for actual stocks (the ones I have tried are NFLX, GOOG, and FB). Sometimes lookup works successfully and my code correctly executes updating the database. However, sometimes when I buy/sell/return to index, these companies return back None from Lookup().

I edited helpers.py's lookup function to print UH OH UH OH, if the program enters into the if statement that is only executed if the stock does not exist!

https://i.stack.imgur.com/k1ovo.png

What is happenning??? It get's annoying to stop halfway through testing my code by an error from lookup!

  • I am having this exact same problem... My code seemed to work, and then lookup stopped working; am sometimes receiving(and sometimes not) errors for lines which require lookups input. – WARMACHINEROX Jul 27 '18 at 6:20
0

The problem seems to be with alphavantage. Staff solution gives the same problem (as of 9:21 am et us, 27-july-2017).

Upon reading the alphavantage doc, the High Usage tag got me wondering....

I tried a different API, WEEKLY, which is not tagged "High Usage. It (seems to) works every time, and it passes check50.

Changed helpers.py
From: url = f"https://www.alphavantage.co/query?apikey={os.getenv('API_KEY')}&datatype=csv&function=TIME_SERIES_INTRADAY&interval=1min&symbol=symbol"

To: url = f"https://www.alphavantage.co/query?apikey={os.getenv('API_KEY')}&datatype=csv&function=TIME_SERIES_WEEKLY&symbol={symbol}"

While I do not usually advocate changing supplied code, I don't think this change alters the point and value of the exercise. And it keeps things moving along.......

And as of now (9:28 am) the staff solution (seems to be) is working.

NB: This API will return yesterday's closing price. If your objective is to complete the pset this might be a good solution. It is not a good solution if your objective is to make a killing in the stock market......

| improve this answer | |
  • Thank you for this. This solved my problems. Will I be able to submit the pset with this url? – WARMACHINEROX Jul 28 '18 at 13:21
  • I don't see why not. I only took it as far as check50. – DinoCoderSaurus Jul 28 '18 at 17:01
  • should we use the given API key in the link, or could I still use mine? – faelesterio Jul 28 '18 at 17:12
  • I was using the 2017 version of helpers. I have modified my code, retested, rechecked with the 2018 version that uses os.getenv('API_KEY'). You should probably use that. Of course, you'll have to retest and recheck50. Sorry for the confusion. – DinoCoderSaurus Jul 28 '18 at 18:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .