Skip to content

Commit a27a67e

Browse files
authored
ENH: Bug fix for downloading index historicals.
`import pandas_datareader.data as web f = web.DataReader('^DJI', 'stooq')` Above code breaks because country code is pre-appended for any symbol. For index data (^dji, ^spx etc), there is no need to pre-append country code. This patch fixes that.
1 parent 3200d6e commit a27a67e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pandas_datareader/stooq.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ def url(self):
3737

3838
def _get_params(self, symbol, country='US'):
3939
symbol_parts = symbol.split(".")
40-
if len(symbol_parts) == 1:
41-
symbol = ".".join([symbol, country])
42-
else:
43-
if symbol_parts[1].lower() not in ['de', 'hk', 'hu', 'jp',
44-
'pl', 'uk', 'us']:
45-
symbol = ".".join([symbol, 'US'])
40+
if not symbol.startswith('^'):
41+
if len(symbol_parts) == 1:
42+
symbol = ".".join([symbol, country])
43+
else:
44+
if symbol_parts[1].lower() not in ['de', 'hk', 'hu', 'jp',
45+
'pl', 'uk', 'us']:
46+
symbol = ".".join([symbol, 'US'])
4647

4748
params = {
4849
's': symbol,

0 commit comments

Comments
 (0)