Skip to content

Commit e9cbe1b

Browse files
committed
fix adjusted prices so divs are included propely; closes sf 2949906
svn path=/trunk/matplotlib/; revision=8392
1 parent 02861c2 commit e9cbe1b

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

CHANGELOG

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2010-06-06 Change the way we do split/dividend adjustments in
2+
finance.py to handle dividends and fix the zero division bug reported
3+
in sf bug 2949906. Note that volume is not adjusted
4+
because the Yahoo CSV does not distinguish between share
5+
split and dividend adjustments making it near impossible to
6+
get volume adjustement right (unless we want to guess based
7+
on the size of the adjustment or scrape the html tables,
8+
which we don't) - JDH
9+
110
2010-06-06 Updated dateutil to 1.5 and pytz to 2010h.
211

312
2010-06-02 Add error_kw kwarg to Axes.bar(). - EF

lib/matplotlib/finance.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ def parse_yahoo_historical(fh, asobject=False, adjusted=True):
4242
4343
where d is a floating poing representation of date, as returned by date2num
4444
45-
if adjusted=True, use adjusted prices
45+
if adjusted=True, use adjusted prices. Note that volume is not
46+
adjusted and we are not able to handle volume adjustments properly
47+
because the Yahoo CSV does not distinguish between split and
48+
dividend adjustments.
4649
"""
4750
results = []
4851

@@ -68,10 +71,10 @@ def parse_yahoo_historical(fh, asobject=False, adjusted=True):
6871
volume = int(vals[5])
6972
if adjusted:
7073
aclose = float(vals[6])
71-
m = aclose/close
72-
open *= m
73-
high *= m
74-
low *= m
74+
delta = aclose-close
75+
open += delta
76+
high += delta
77+
low += delta
7578
close = aclose
7679

7780
results.append((d, open, close, high, low, volume))
@@ -146,7 +149,10 @@ def quotes_historical_yahoo(ticker, date1, date2, asobject=False, adjusted=True,
146149
if asobject is True, the return val is an object with attrs date,
147150
open, close, high, low, volume, which are equal length arrays
148151
149-
if adjust=True, use adjusted prices
152+
if adjusted=True, use adjusted prices. Note that volume is not
153+
adjusted and we are not able to handle volume adjustments properly
154+
because the Yahoo CSV does not distinguish between split and
155+
dividend adjustments.
150156
151157
Ex:
152158
sp = f.quotes_historical_yahoo('^GSPC', d1, d2, asobject=True, adjusted=True)

0 commit comments

Comments
 (0)