Noticed that the pandas.io.data doesn't return the Data Frame on tickers having a '-' in the ticker name , for example: HINDUNILVR-EQ.NS, TATA-MOTORS.NS .
Any ideas ?
Comment From: TomAugspurger
Can you show an actual code example? And could you link to the actual page (yahoo or google) that the data is coming from? Thank.
Comment From: gaurav1086
Hi Tom,
Thanks a lot for your reply. Here's the example code:
import numpy as np import datetime from pandas.io.data import DataReader import pandas as pd start = datetime.datetime(2014, 2, 1) end = datetime.datetime(2014, 8, 21)
Get the Data Frame for "ACC.NS"
X = DataReader("ACC.NS", "yahoo", start, end) X.head() Open High Low Close Volume Adj Close Date
2014-02-03 1004.05 1021.45 998.95 1003.90 243500 978.58 2014-02-04 988.60 1014.40 988.60 1001.10 255300 975.85 2014-02-05 1001.40 1012.50 991.20 1001.00 321700 975.76 2014-02-06 1000.65 1024.90 991.10 1018.95 665600 993.25 2014-02-07 1016.00 1055.00 1006.35 1046.45 363700 1020.06
This works.
Now lets try with a hyphenated one "HINDUNILVR-EQ.NS"
X = DataReader("HINDUNILVR-EQ.NS", "yahoo", start, end) Traceback (most recent call last): File "
", line 1, in File "/root/anaconda/lib/python2.7/site-packages/pandas/io/data.py", line 72, in DataReader retry_count=retry_count, pause=pause) File "/root/anaconda/lib/python2.7/site-packages/pandas/io/data.py", line 390, in get_data_yahoo adjust_price, ret_index, chunksize, 'yahoo', name) File "/root/anaconda/lib/python2.7/site-packages/pandas/io/data.py", line 336, in _get_data_from hist_data = src_fn(symbols, start, end, retry_count, pause) File "/root/anaconda/lib/python2.7/site-packages/pandas/io/data.py", line 190, in _get_hist_yahoo return _retry_read_url(url, retry_count, pause, 'Yahoo!') File "/root/anaconda/lib/python2.7/site-packages/pandas/io/data.py", line 169, in _retry_read_url "return a 200 for url %r" % (retry_count, name, url)) IOError: after 3 tries, Yahoo! did not return a 200 for url 'http://ichart.yahoo.com/table.csv?s=HINDUNILVR-EQ.NS&a=1&b=1&c=2014&d=7&e=21&f=2014&g=d&ignore=.csv'
Doesn't give, while its present on the Yahoo Finance website here: http://finance.yahoo.com/q;_ylt=AhX2cjxJ818rivg1uwmEY0iiuYdG;_ylu=X3oDMTBxdGVyNzJxBHNlYwNVSCAzIERlc2t0b3AgU2VhcmNoIDEx;_ylg=X3oDMTBsdWsyY2FpBGxhbmcDZW4tVVMEcHQDMgR0ZXN0Aw--;_ylv=3;_ylc=X1MDMjE0MjQ3ODk0OARfcgMyBGZyA3VoM19maW5hbmNlX3dlYl9ncwRmcjIDc2EtZ3AEZ3ByaWQDBG5fZ3BzAzEEb3JpZ2luA2ZpbmFuY2UueWFob28uY29tBHBvcwMxBHBxc3RyAwRxdWVyeQNISU5EVU5JTFZSLUVRLk5TLARzYWMDMQRzYW8DMQ--?p=http%3A%2F%2Ffinance.yahoo.com%2Fq%3Fs%3DHINDUNILVR-EQ.NS%26ql%3D0&type=2button&uhb=uhb2&fr=uh3_finance_vert_gs&s=HINDUNILVR-EQ.NS
So this ticker is present on the yahoo finance but its not able to retreive through the DataReader. Any hints ?
Thanks again, Best Regards, Gaurav.
Comment From: TomAugspurger
Perfect, thanks.
We pull the data from the historical section. It looks like either they don't have historical data for that company, or yahoo has an issue with the symbol: http://finance.yahoo.com/q/hp?s=HINDUNILVR-EQ.NS&a=00&b=1&c=2010&d=07&e=25&f=2014&g=w
Compare with google: http://finance.yahoo.com/q/hp?s=GOOG&a=02&b=27&c=2014&d=07&e=25&f=2014&g=w
Let me know if you find an example with historical data on Yahoo's website, but doesn't work with pandas.
Comment From: jreback
pls refere to pandas-datareader
package