How to find a date range for a stock price? Datetime not defined

589 views Asked by At

Okay so i am trying to get a price range for a stock.

import datetime as dt
from datetime import date
from datetime import time

start = datetime.datetime(2010,1,1)
end = datetime.datetime(2016,12,28)
SPWR = pdr.get_data_yahoo('SPWR' start, end)

I am running Python 3.6

1

There are 1 answers

2
andrew_reece On BEST ANSWER

You have imported datetime as dt, but you're trying to refer to datetime in your code. Swap out datetime for dt and you should be good syntactically.

Note, however, that Yahoo recently changed its API endpoints. That means get_data_yahoo() now returns an error. This is a a known issue, currently unresolved.