Revision: 8392
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8392&view=rev
Author:   jdh2358
Date:     2010-06-07 13:04:24 +0000 (Mon, 07 Jun 2010)

Log Message:
-----------
fix adjusted prices so divs are included propely; closes sf 2949906

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/lib/matplotlib/finance.py

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2010-06-07 01:03:54 UTC (rev 8391)
+++ trunk/matplotlib/CHANGELOG  2010-06-07 13:04:24 UTC (rev 8392)
@@ -1,3 +1,12 @@
+2010-06-06 Change the way we do split/dividend adjustments in
+           finance.py to handle dividends and fix the zero division bug 
reported
+           in sf bug 2949906.  Note that volume is not adjusted
+           because the Yahoo CSV does not distinguish between share
+           split and dividend adjustments making it near impossible to
+           get volume adjustement right (unless we want to guess based
+           on the size of the adjustment or scrape the html tables,
+           which we don't) - JDH
+
 2010-06-06 Updated dateutil to 1.5 and pytz to 2010h.
 
 2010-06-02 Add error_kw kwarg to Axes.bar(). - EF

Modified: trunk/matplotlib/lib/matplotlib/finance.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/finance.py  2010-06-07 01:03:54 UTC (rev 
8391)
+++ trunk/matplotlib/lib/matplotlib/finance.py  2010-06-07 13:04:24 UTC (rev 
8392)
@@ -42,7 +42,10 @@
 
     where d is a floating poing representation of date, as returned by date2num
 
-    if adjusted=True, use adjusted prices
+    if adjusted=True, use adjusted prices.  Note that volume is not
+    adjusted and we are not able to handle volume adjustments properly
+    because the Yahoo CSV does not distinguish between split and
+    dividend adjustments.
     """
     results = []
 
@@ -68,10 +71,10 @@
         volume = int(vals[5])
         if adjusted:
             aclose = float(vals[6])
-            m = aclose/close
-            open *= m
-            high *= m
-            low *= m
+            delta = aclose-close
+            open += delta
+            high += delta
+            low += delta
             close = aclose
 
         results.append((d, open, close, high, low, volume))
@@ -146,7 +149,10 @@
     if asobject is True, the return val is an object with attrs date,
     open, close, high, low, volume, which are equal length arrays
 
-    if adjust=True, use adjusted prices
+    if adjusted=True, use adjusted prices.  Note that volume is not
+    adjusted and we are not able to handle volume adjustments properly
+    because the Yahoo CSV does not distinguish between split and
+    dividend adjustments.
 
     Ex:
     sp = f.quotes_historical_yahoo('^GSPC', d1, d2, asobject=True, 
adjusted=True)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to