Skip to content

Commit d7f8248

Browse files
peijichebashtage
authored andcommitted
added StooqDailyReader for major index data download
1 parent dbca479 commit d7f8248

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

docs/source/remote_data.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Currently the following sources are supported:
3434
- :ref:`Eurostat<remote_data.eurostat>`
3535
- :ref:`Thrift Savings Plan<remote_data.tsp>`
3636
- :ref:`Nasdaq Trader symbol definitions<remote_data.nasdaq_symbols>`
37+
- :ref:`Stooq<remote_data.stooq>`
3738

3839
It should be noted, that various sources support different kinds of data, so not all sources implement the same methods and the data elements returned might also differ.
3940

@@ -570,3 +571,16 @@ available. More information on the `field <http://www.nasdaqtrader.com/trader.as
570571
NASDAQ Symbol IBM
571572
NextShares False
572573
Name: IBM, dtype: object
574+
575+
576+
.. _remote_data.stooq:
577+
578+
Stooq Index Data
579+
================
580+
Google finance doesn't provide common index data download. The Stooq site has the data for download.
581+
582+
.. ipython:: python
583+
584+
import pandas_datareader.data as web
585+
f = web.DataReader("^DJI", 'stooq')
586+
f[:10]

pandas_datareader/data.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pandas_datareader.eurostat import EurostatReader
1111
from pandas_datareader.famafrench import FamaFrenchReader
1212
from pandas_datareader.fred import FredReader
13+
from pandas_datareader.stooq import StooqDailyReader
1314
from pandas_datareader.google.daily import GoogleDailyReader
1415
from pandas_datareader.google.options import Options as GoogleOptions
1516
from pandas_datareader.google.quotes import GoogleQuotesReader
@@ -150,6 +151,11 @@ def DataReader(name, data_source=None, start=None, end=None,
150151
return BankOfCanadaReader(symbols=name, start=start, end=end,
151152
retry_count=retry_count, pause=pause,
152153
session=session).read()
154+
elif data_source == "stooq":
155+
return StooqDailyReader(symbols=name,
156+
chunksize=25,
157+
retry_count=retry_count, pause=pause,
158+
session=session).read()
153159

154160
elif data_source == "enigma":
155161
return EnigmaReader(dataset_id=name, api_key=access_key).read()

pandas_datareader/stooq.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from pandas_datareader.base import _DailyBaseReader
2+
3+
4+
class StooqDailyReader(_DailyBaseReader):
5+
6+
"""
7+
Returns DataFrame/Panel of historical stock prices from symbols, over date
8+
range, start to end. To avoid being penalized by Google Finance servers,
9+
pauses between downloading 'chunks' of symbols can be specified.
10+
11+
Parameters
12+
----------
13+
symbols : string, array-like object (list, tuple, Series), or DataFrame
14+
Single stock symbol (ticker), array-like object of symbols or
15+
DataFrame with index containing stock symbols.
16+
retry_count : int, default 3
17+
Number of times to retry query request.
18+
pause : int, default 0
19+
Time, in seconds, to pause between consecutive queries of chunks. If
20+
single value given for symbol, represents the pause between retries.
21+
chunksize : int, default 25
22+
Number of symbols to download consecutively before intiating pause.
23+
session : Session, default None
24+
requests.sessions.Session instance to be used
25+
"""
26+
27+
@property
28+
def url(self):
29+
return 'https://stooq.com/q/d/l/'
30+
31+
def _get_params(self, symbol):
32+
params = {
33+
's': symbol,
34+
'i': "d"
35+
}
36+
return params

0 commit comments

Comments
 (0)