0

I'm a high school teacher and have been teaching CS50 AP for about 7 years now. I like to make sure that I have a handle on all of the problem sets before going over them with my students. So, when I saw that the Finance pset had been updated, I went to my working Finance program from years past, and ran the updates in the red box at the top of the pset, and brought over all of my code that had been working in the past into the new app.py from my old application.py. (passed all the check50s back when I first wrote it).

Registering and logging in seem to work just fine, but whenever I do anything that needs to contact the Yahoo stock API, it breaks. Asking for any quote for a new user (DIS, NFLX, AAPL, NYT are all examples I tried) always returns the apology that it is not a real stock. When I test trying to render the portfolios of people already in my database from years past, I get a server error saying that:

DEBUG: https://query1.finance.yahoo.com:443 "GET /v7/finance/download/NYT?period1=1712593199&period2=1713197999&interval=1d&events=history&includeAdjustedClose=true HTTP/1.1" 429 19
ERROR: Exception on / [GET]
(lots of other traceback stuff omitted)
File "/workspaces/30294154/cs50ide/Programs21-22/finance/app.py", line 43, in index price = lookup(row.get("symbol")).get("price")
AttributeError: 'NoneType' object has no attribute 'get'

Because when it tries to lookup that stock symbol (NYT), it gets back None from the API.

I'm really lost here - I haven't made any changes to the new helper.py file, and my functions are exactly the same as the ones that were working before. Attached is one of the functions, quote, that worked fine before but is now returning None to every request.enter image description here

1
  • Solved it! By comparing old and new distribution code, I found that my requirements.txt file was missing the line: pytz Adding that in fixed everything. Commented Apr 15 at 18:31

1 Answer 1

2

Solved it! By comparing old and new distribution code, I found that my requirements.txt file was missing the line:

pytz

Adding that in fixed everything.

1
  • hi, Thank you so much for opening the topic. I got the same problem. My requirements.txt got the pytz but the api wont work. Not sure what's the problem :( Commented Aug 17 at 5:17

You must log in to answer this question.

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