I'm Downloading stock prices from Yahoo for the S&P500, which has volume too big for a 32-bit integer.
def yahoo_prices(ticker, start_date=None, end_date=None, data='d'):
csv = yahoo_historical_data(ticker, start_date, end_date, data)
d = [('date', np.datetime64),
('open', np.float64),
('high', np.float64),
('low', np.float64),
('close', np.float64),
('volume', np.int64),
('adj_close', np.float64)]
return np.recfromcsv(csv, dtype=d)
Here's the error:
>>> sp500 = yahoo_prices('^GSPC')
Traceback (most recent call last):
File "<stdin>", line 108, in <module>
File "<stdin>", line 74, in yahoo_prices
File "/usr/local/lib/python2.6/dist-packages/numpy/lib/npyio.py", line 1812, in recfromcsv
output = genfromtxt(fname, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/numpy/lib/npyio.py", line 1646, in genfromtxt
output = np.array(data, dtype=ddtype)
OverflowError: long int too large to convert to int
Why would I still be getting this error if I declared the dtype to use int64? Is this an indication that the io function isn't really using my dtype sequence d?
===Edit ... example csv added===
Date,Open,High,Low,Close,Volume,Adj Close
2012-06-15,1329.19,1343.32,1329.19,1342.84,4401570000,1342.84
2012-06-14,1314.88,1333.68,1314.14,1329.10,3687720000,1329.10
2012-06-13,1324.02,1327.28,1310.51,1314.88,3506510000,1314.88