Skip to content

Commit 62f0480

Browse files
mustyoshibashtage
authored andcommitted
Enable stooq dates (#569)
Passthrough start and end dates
1 parent 8eb5655 commit 62f0480

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

docs/source/whatsnew/v0.7.0.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,5 @@ Bug Fixes
7474
- Fixed Yahoo! time offset (:issue:`487`).
7575
- Fix Yahoo! quote reader (:issue: `540`)
7676
- Remove import of deprecated `tm.get_data_path` (:issue: `566`)
77+
- Allow full usage of stooq url parameters
7778
- Removed unused requests-file and requests-ftp dependencies

pandas_datareader/stooq.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class StooqDailyReader(_DailyBaseReader):
1212
symbols : string, array-like object (list, tuple, Series), or DataFrame
1313
Single stock symbol (ticker), array-like object of symbols or
1414
DataFrame with index containing stock symbols.
15+
start: string, date which to start interval at YYYYMMDD.
16+
end: string, date which to end interval at YYYYMMDD.
1517
retry_count : int, default 3
1618
Number of times to retry query request.
1719
pause : int, default 0.1
@@ -21,7 +23,7 @@ class StooqDailyReader(_DailyBaseReader):
2123
Number of symbols to download consecutively before initiating pause.
2224
session : Session, default None
2325
requests.sessions.Session instance to be used
24-
26+
freq: string, d, w, m ,q, y for daily, weekly, monthly, quarterly, yearly
2527
2628
Notes
2729
-----
@@ -33,17 +35,20 @@ def url(self):
3335
"""API URL"""
3436
return 'https://stooq.com/q/d/l/'
3537

36-
def _get_params(self, symbol, country="US"):
38+
def _get_params(self, symbol, country='US'):
3739
symbol_parts = symbol.split(".")
3840
if len(symbol_parts) == 1:
3941
symbol = ".".join([symbol, country])
4042
else:
4143
if symbol_parts[1].lower() not in ['de', 'hk', 'hu', 'jp',
4244
'pl', 'uk', 'us']:
43-
symbol = ".".join([symbol, "US"])
45+
symbol = ".".join([symbol, 'US'])
4446

4547
params = {
4648
's': symbol,
47-
'i': "d"
49+
'i': self.freq or 'd',
50+
'd1': self.start.strftime('%Y%m%d'),
51+
'd2': self.end.strftime('%Y%m%d')
4852
}
53+
4954
return params

pandas_datareader/tests/test_stooq.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ def test_stooq_dji():
1010
def test_get_data_stooq_dji():
1111
f = get_data_stooq('AMZN')
1212
assert f.shape[0] > 0
13+
14+
15+
def test_get_data_stooq_dates():
16+
f = get_data_stooq('SPY', start='20180101', end='20180115')
17+
assert f.shape[0] == 9

0 commit comments

Comments
 (0)