Reputation: 497
EDIT
> See my own answer below for how I got it to work.
I'm having an issue using the fix_yahoo_finance library (version 0.0.22). Any help to point me in the right direction would be great.
My goal is to load stock data. Currently, fix_yahoo_finance returns a pandas dataframe which is quite useful for me.
Here is the code I'm using:
import datetime
import psycopg2
import fix_yahoo_finance as yf
import pandas as pd
start_dt = datetime.datetime(2004,12,30)
end_dt = datetime.datetime(2017,12,01)
symbol = 'MMM'
yf.pdr_override()
data = yf.download(symbol, start='2004-12-30', end='2017-12-01')
Here is the error
Traceback (most recent call last):
File "<ipython-input-38-d43dee1dd457>", line 1, in <module>
data = yf.download(symbol, start=start_dt, end=end_dt)
File "C:\Python27\Lib\site-packages\fix_yahoo_finance\__init__.py", line
194, in download
data = _pd.concat(_DFS.values(), axis=1, keys=_DFS.keys())
File "C:\Python27\Lib\site-packages\pandas\tools\merge.py", line 754, in
concat
copy=copy)
File "C:\Python27\Lib\site-packages\pandas\tools\merge.py", line 799, in
__init__
raise ValueError('All objects passed were None')
ValueError: All objects passed were None
Upvotes: 1
Views: 3501
Reputation: 497
@Yash Ghandhe 's answer unfortunately didn't work for me.
I did get it to work by installing Anaconda and running Spyder IDE from there. I installed the Python 3.6 version (I was using Python 2.7 previously).
I'm still not sure which libraries caused the issue, or if using Python 3 made the difference.
Reading the documentation on the fix-yahoo-finance library (link here: https://pypi.org/project/fix-yahoo-finance/) showed two conflicting pieces of info.
The first, is at the top under the Title. It shows Python 2.7, 3.4, 3.5, 3.6. Further below under requirements, it mentions Python >= 3.4.
Upvotes: 1
Reputation: 13
You can try using the pandas-datareader library like so:
from pandas_datareader import data as pdr
import fix_yahoo_finance as yf
yf.pdr_override()
data = pdr.get_data_yahoo("MMM", start="2004-12-30", end="2017-12-01")
You can check out this GitHub Repo for more details on parameters. Hope this helps!
Upvotes: 0