@@ -56,43 +56,68 @@ Free registration is required to get an API key. Free accounts are rate
5656limited and can access a limited number of symbols (500 at the time of
5757writing).
5858
59- .. ipython :: python
60-
61- import os
62- import pandas_datareader as pdr
59+ .. code-block :: ipython
6360
64- df = pdr.get_data_tiingo( ' GOOG ' , api_key = os.getenv( ' TIINGO_API_KEY ' ))
65- df.head()
61+ In [1]: import os
62+ In [2]: import pandas_datareader as pdr
6663
64+ In [3]: df = pdr.get_data_tiingo('GOOG', api_key=os.getenv('TIINGO_API_KEY'))
65+ In [4]: df.head()
66+ close high low open volume adjClose adjHigh adjLow adjOpen adjVolume divCash splitFactor
67+ symbol date
68+ GOOG 2014-03-27 00:00:00+00:00 558.46 568.00 552.92 568.000 13100 558.46 568.00 552.92 568.000 13100 0.0 1.0
69+ 2014-03-28 00:00:00+00:00 559.99 566.43 558.67 561.200 41100 559.99 566.43 558.67 561.200 41100 0.0 1.0
70+ 2014-03-31 00:00:00+00:00 556.97 567.00 556.93 566.890 10800 556.97 567.00 556.93 566.890 10800 0.0 1.0
71+ 2014-04-01 00:00:00+00:00 567.16 568.45 558.71 558.710 7900 567.16 568.45 558.71 558.710 7900 0.0 1.0
72+ 2014-04-02 00:00:00+00:00 567.00 604.83 562.19 565.106 146700 567.00 604.83 562.19 565.106 146700 0.0 1.0
6773
6874 .. _remote_data.iex :
6975
7076IEX
7177===
7278
73- .. warning :: Usage of all IEX readers now requries an API key. See
79+ .. warning :: Usage of all IEX readers now requires an API key. See
7480 below for additional information.
7581
7682The Investors Exchange (IEX) provides a wide range of data through an
7783`API <https://iexcloud.io/api/docs/ >`__. Historical stock
7884prices are available for up to 15 years. The usage of these readers requires the publishable API key from IEX Cloud Console, which can be stored in the ``IEX_API_KEY `` environment variable.
7985
80- .. ipython :: python
86+ .. code-block :: ipython
8187
82- os.environ[" IEX_API_KEY" ] = " pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
83- import pandas_datareader.data as web
84- from datetime import datetime
85- start = datetime(2016 , 9 , 1 )
86- end = datetime(2018 , 9 , 1 )
87- f = web.DataReader(' F' , ' iex' , start, end)
88- f.loc[' 2018-08-31' ]
88+ In [1]: import pandas_datareader.data as web
89+
90+ In [2]: from datetime import datetime
91+
92+ In [3]: start = datetime(2016, 9, 1)
93+
94+ In [4]: end = datetime(2018, 9, 1)
95+
96+ In [5]: f = web.DataReader('F', 'iex', start, end)
97+
98+ In [6]: f.loc['2018-08-31']
99+ Out[6]:
100+ open 9.64
101+ high 9.68
102+ low 9.40
103+ close 9.48
104+ volume 76424884.00
105+ Name: 2018-08-31, dtype: float64
106+
107+ .. note ::
108+
109+ You must provide an API Key when using IEX. You can do this using
110+ ``os.environ["IEX_API_KEY"] = "pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ``
111+ or by exporting the key before starting the IPython session.
89112
90113There are additional interfaces to this API that are
91114directly exposed: tops (`'iex-tops' `) and last (`'iex-lasts' `).
92115A third interface to the deep API is exposed through
93116`Deep ` class or the `get_iex_book ` function.
94117
95- .. ipython :: python
118+ .. todo :: Execute block when markets are open
119+
120+ .. code-block :: ipython
96121
97122 import pandas_datareader.data as web
98123 f = web.DataReader('gs', 'iex-tops')
@@ -123,16 +148,27 @@ symbols. The following endpoints are available:
123148* ``av-monthly `` - Monthly Time Series
124149* ``av-monthly-adjusted `` - Monthly Time Series (Adjusted)
125150
126- .. ipython :: python
151+ .. code-block :: ipython
127152
128- import os
129- from datetime import datetime
130- import pandas_datareader.data as web
153+ In [1]: import os
154+
155+ In [2]: from datetime import datetime
156+
157+ In [3]: import pandas_datareader.data as web
158+
159+ In [4]: f = web.DataReader("AAPL", "av-daily", start=datetime(2017, 2, 9),
160+ ...: end=datetime(2017, 5, 24),
161+ ...: access_key=os.getenv('ALPHAVANTAGE_API_KEY'))
162+
163+ In [5]: f.loc["2017-02-09"]
164+ Out[5]:
165+ open 1.316500e+02
166+ high 1.324450e+02
167+ low 1.311200e+02
168+ close 1.324200e+02
169+ volume 2.834990e+07
170+ Name: 2017-02-09, dtype: float64
131171
132- f = web.DataReader(" AAPL" , " av-daily" , start = datetime(2017 , 2 , 9 ),
133- end = datetime(2017 , 5 , 24 ),
134- access_key = os.getenv(' ALPHAVANTAGE_API_KEY' ))
135- f.loc[" 2017-02-09" ]
136172
137173 The top-level function ``get_data_alphavantage `` is also provided. This
138174function will
@@ -147,13 +183,21 @@ endpoint allows the retrieval of realtime stock quotes for up to 100 symbols at
147183once. These quotes are accessible through the top-level function
148184``get_quote_av ``.
149185
150- .. ipython :: python
186+ .. code-block :: ipython
151187
152- import os
153- from datetime import datetime
154- import pandas_datareader.data as web
188+ In [1]: import os
189+
190+ In [2]: from datetime import datetime
191+
192+ In [3]: import pandas_datareader.data as web
193+
194+ In [4]: web.get_quote_av(["AAPL", "TSLA"])
195+ Out[4]:
196+ price volume timestamp
197+ symbol
198+ AAPL 219.87 NaN 2019-09-16 15:59:59
199+ TSLA 242.80 NaN 2019-09-16 15:59:57
155200
156- web.get_quote_av([" AAPL" , " TSLA" ])
157201
158202
159203 .. note :: Most quotes are only available during market hours.
@@ -167,23 +211,54 @@ currency exchange rates (for physical and digital currencies).
167211To request the exchange rate of physical or digital currencies, simply format
168212as "FROM/TO" as in "USD/JPY".
169213
170- .. ipython :: python
214+ .. code-block :: ipython
171215
172- import os
173- import pandas_datareader.data as web
216+ In [1]: import os
217+
218+ In [2]: import pandas_datareader.data as web
219+
220+ In [3]: f = web.DataReader("USD/JPY", "av-forex",
221+ ...: access_key=os.getenv('ALPHAVANTAGE_API_KEY'))
222+
223+ In [4]: f
224+ Out[4]:
225+ USD/JPY
226+ From_Currency Code USD
227+ From_Currency Name United States Dollar
228+ To_Currency Code JPY
229+ To_Currency Name Japanese Yen
230+ Exchange Rate 108.17000000
231+ Last Refreshed 2019-09-17 10:43:36
232+ Time Zone UTC
233+ Bid Price 108.17000000
234+ Ask Price 108.17000000
174235
175- f = web.DataReader(" USD/JPY" , " av-forex" ,
176- access_key = os.getenv(' ALPHAVANTAGE_API_KEY' ))
177236
178237 Multiple pairs are are allowable:
179238
180- .. ipython :: python
239+ .. code-block :: ipython
181240
182- import os
183- import pandas_datareader.data as web
241+ In [1]: import os
242+
243+ In [2]: import pandas_datareader.data as web
244+
245+ In [3]: f = web.DataReader(["USD/JPY", "BTC/CNY"], "av-forex",
246+ ...: access_key=os.getenv('ALPHAVANTAGE_API_KEY'))
247+
248+
249+ In [4]: f
250+ Out[4]:
251+ USD/JPY BTC/CNY
252+ From_Currency Code USD BTC
253+ From_Currency Name United States Dollar Bitcoin
254+ To_Currency Code JPY CNY
255+ To_Currency Name Japanese Yen Chinese Yuan
256+ Exchange Rate 108.17000000 72230.38039500
257+ Last Refreshed 2019-09-17 10:44:35 2019-09-17 10:44:01
258+ Time Zone UTC UTC
259+ Bid Price 108.17000000 72226.26407700
260+ Ask Price 108.17000000 72230.02554000
184261
185- f = web.DataReader([" USD/JPY" , " BTC/CNY" ], " av-forex" ,
186- access_key = os.getenv(' ALPHAVANTAGE_API_KEY' ))
187262
188263
189264 Sector Performance
@@ -192,12 +267,21 @@ Sector Performance
192267`Alpha Vantage <https://www.alphavantage.co/documentation >`__ provides sector
193268performances through the top-level function ``get_sector_performance_av ``.
194269
195- .. ipython :: python
270+ .. code-block :: ipython
196271
197- import os
198- import pandas_datareader.data as web
272+ In [1]: import os
273+
274+ In [2]: import pandas_datareader.data as web
275+
276+ In [3]: web.get_sector_performance_av().head()
277+ Out[4]:
278+ RT 1D 5D 1M 3M YTD 1Y 3Y 5Y 10Y
279+ Energy 3.29% 3.29% 4.82% 11.69% 3.37% 9.07% -15.26% -7.69% -32.31% 12.15%
280+ Real Estate 1.02% 1.02% -1.39% 1.26% 3.49% 24.95% 16.55% NaN NaN NaN
281+ Utilities 0.08% 0.08% 0.72% 2.77% 3.72% 18.16% 16.09% 27.95% 48.41% 113.09%
282+ Industrials -0.15% -0.15% 2.42% 8.59% 5.10% 22.70% 0.50% 34.50% 43.53% 183.47%
283+ Health Care -0.23% -0.23% 0.88% 1.91% 0.09% 5.20% -2.38% 26.37% 43.43% 216.01%
199284
200- web.get_sector_performance_av().head()
201285
202286
203287 .. _remote_data.enigma :
@@ -214,7 +298,7 @@ Econdb database of time series aggregated into datasets.
214298 import os
215299 import pandas_datareader.data as web
216300
217- f = web.DataReader(' ticker=RGDPQNO ' , ' econdb' )
301+ f = web.DataReader(' ticker=RGDPUS ' , ' econdb' )
218302 f.head()
219303
220304 .. _remote_data.econdb :
@@ -230,13 +314,24 @@ URL has changed from `app.enigma.io <https://app.enigma.io>`__ as of release
230314Datasets are unique identified by the ``uuid4 `` at the end of a dataset's web address.
231315For example, the following code downloads from `USDA Food Recalls 1996 Data <https://public.enigma.com/datasets/292129b0-1275-44c8-a6a3-2a0881f24fe1 >`__.
232316
233- .. ipython :: python
317+ .. code-block :: ipython
234318
235- import os
236- import pandas_datareader as pdr
319+ In [1]: import os
320+
321+ In [2]: import pandas_datareader as pdr
322+
323+ In [3]: df = pdr.get_data_enigma('292129b0-1275-44c8-a6a3-2a0881f24fe1', os.getenv('ENIGMA_API_KEY'))
324+
325+ In [4]: df.columns
326+ Out[4]:
327+ Index(['case_number', 'recall_notification_report_number',
328+ 'recall_notification_report_url', 'date_opened', 'date_closed',
329+ 'recall_class', 'press_release', 'domestic_est_number', 'company_name',
330+ 'imported_product', 'foreign_estab_number', 'city', 'state', 'country',
331+ 'product', 'problem', 'description', 'total_pounds_recalled',
332+ 'pounds_recovered'],
333+ dtype='object')
237334
238- df = pdr.get_data_enigma(' 292129b0-1275-44c8-a6a3-2a0881f24fe1' , os.getenv(' ENIGMA_API_KEY' ))
239- df.columns
240335
241336 .. _remote_data.quandl :
242337
@@ -258,12 +353,20 @@ As of June 2017, each DB has a different data schema,
258353the coverage in terms of time range is sometimes surprisingly small, and
259354the data quality is not always good.
260355
261- .. ipython :: python
356+ .. code-block :: ipython
357+
358+ In [1]: import pandas_datareader.data as web
359+
360+ In [2]: symbol = 'WIKI/AAPL' # or 'AAPL.US'
361+
362+ In [3]: df = web.DataReader(symbol, 'quandl', '2015-01-01', '2015-01-05')
363+
364+ In [4]: df.loc['2015-01-02']
365+ Out[4]:
366+ Open High Low Close Volume ... AdjOpen AdjHigh AdjLow AdjClose AdjVolume
367+ Date ...
368+ 2015-01-02 111.39 111.44 107.35 109.33 53204626.0 ... 105.820966 105.868466 101.982949 103.863957 53204626.0
262369
263- import pandas_datareader.data as web
264- symbol = ' WIKI/AAPL' # or 'AAPL.US'
265- df = web.DataReader(symbol, ' quandl' , ' 2015-01-01' , ' 2015-01-05' )
266- df.loc[' 2015-01-02' ]
267370
268371 .. _remote_data.fred :
269372
0 commit comments