Skip to content

Commit 44ee8c8

Browse files
authored
Merge pull request #577 from bashtage/xfail-yahoo-actions
BUG: Yahoo actions adjustment is incorrect
2 parents 38ef0c7 + 02f1fdf commit 44ee8c8

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

docs/source/whatsnew/v0.7.0.txt

+8-5
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,15 @@ Bug Fixes
6767
- Added support for passing the API KEY to QuandlReader either directly or by
6868
setting the environmental variable QUANDL_API_KEY (:issue:`485`).
6969
- Added support for optionally passing a custom base_url to the EnigmaReader (:issue:`499`).
70-
- Fix Yahoo! price data (:issue:`498`)
70+
- Fix Yahoo! price data (:issue:`498`).
7171
- Added back support for Yahoo! price, dividends, and splits data for stocks
7272
and currency pairs (:issue:`487`).
73-
- Add `is_list_like` to compatibility layer to avoid failure on pandas >= 0.23 (:issue:`520`)
73+
- Add `is_list_like` to compatibility layer to avoid failure on pandas >= 0.23 (:issue:`520`).
7474
- Fixed Yahoo! time offset (:issue:`487`).
75-
- Fix Yahoo! quote reader (:issue: `540`)
75+
- 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
78-
- Removed unused requests-file and requests-ftp dependencies
77+
- Allow full usage of stooq url parameters.
78+
- Removed unused requests-file and requests-ftp dependencies.
79+
- Fix Yahoo! actions issue where the default reporting adjusts dividends. The unadjusted
80+
dividends may lack precision due to accumulated numerical error when converting adjusted
81+
to the original dividend amount. (:issue: `495`)

pandas_datareader/tests/yahoo/test_yahoo.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ def test_get_data_yahoo_actions(self):
201201
start = datetime(1990, 1, 1)
202202
end = datetime(2000, 4, 5)
203203

204-
actions = web.get_data_yahoo_actions('BHP.AX', start, end)
204+
actions = web.get_data_yahoo_actions('BHP.AX', start, end,
205+
adjust_dividends=True)
205206

206207
assert sum(actions['action'] == 'DIVIDEND') == 21
207208
assert sum(actions['action'] == 'SPLIT') == 1
@@ -254,7 +255,7 @@ def test_yahoo_DataReader(self):
254255
3.05, 2.65, 2.65, 2.65]},
255256
index=exp_idx)
256257
exp.index.name = 'Date'
257-
tm.assert_frame_equal(result.reindex_like(exp).round(5), exp.round(5))
258+
tm.assert_frame_equal(result.reindex_like(exp).round(2), exp.round(2))
258259

259260
result = web.get_data_yahoo_actions('AAPL', start, end,
260261
adjust_dividends=True)

pandas_datareader/yahoo/daily.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,11 @@ def _read_one_data(self, url, params):
181181
splits['Splits'] = 1.0 / splits['SplitRatio']
182182
prices = prices.join(splits['Splits'], how='outer')
183183

184-
if 'DIVIDEND' in types and self.adjust_dividends:
184+
if 'DIVIDEND' in types and not self.adjust_dividends:
185185
# Adjust dividends to deal with splits
186186
adj = prices['Splits'].sort_index(ascending=False).fillna(
187187
1).cumprod()
188+
adj = 1.0 / adj
188189
prices['Dividends'] = prices['Dividends'] * adj
189190

190191
return prices

0 commit comments

Comments
 (0)