176 lines (173 with data), 16.3 kB
@header@
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="matplotlib.html"><font color="#ffffff">matplotlib</font></a>.finance</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/jdhunter/dev/lib64/python2.5/site-packages/matplotlib/finance.py">/home/jdhunter/dev/lib64/python2.5/site-packages/matplotlib/finance.py</a></font></td></tr></table>
<p><tt>A collection of modules for collecting, analyzing and plotting<br>
financial data. User contributions welcome!</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom> <br>
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="datetime.html">datetime</a><br>
<a href="numpy.html">numpy</a><br>
</td><td width="25%" valign=top><a href="os.html">os</a><br>
<a href="time.html">time</a><br>
</td><td width="25%" valign=top><a href="warnings.html">warnings</a><br>
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#eeaa77">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
<td width="100%"><dl><dt><a name="-candlestick"><strong>candlestick</strong></a>(ax, quotes, width<font color="#909090">=0.20000000000000001</font>, colorup<font color="#909090">='k'</font>, colordown<font color="#909090">='r'</font>, alpha<font color="#909090">=1.0</font>)</dt><dd><tt>quotes is a list of (time, open, close, high, low, ...) tuples.<br>
As long as the first 5 elements of the tuples are these values,<br>
the tuple can be as long as you want (eg it may store volume).<br>
<br>
time must be in float days format - see date2num<br>
<br>
Plot the time, open, close, high, low as a vertical line ranging<br>
from low to high. Use a rectangular bar to represent the<br>
open-close span. If close >= open, use colorup to color the bar,<br>
otherwise use colordown<br>
<br>
ax : an Axes instance to plot to<br>
width : fraction of a day for the rectangle width<br>
colorup : the color of the rectangle where close >= open<br>
colordown : the color of the rectangle where close < open<br>
alpha : the rectangle alpha level<br>
<br>
return value is lines, patches where lines is a list of lines<br>
added and patches is a list of the rectangle patches added</tt></dd></dl>
<dl><dt><a name="-candlestick2"><strong>candlestick2</strong></a>(ax, opens, closes, highs, lows, width<font color="#909090">=4</font>, colorup<font color="#909090">='k'</font>, colordown<font color="#909090">='r'</font>, alpha<font color="#909090">=0.75</font>)</dt><dd><tt>Represent the open, close as a bar line and high low range as a<br>
vertical line.<br>
<br>
<br>
ax : an Axes instance to plot to<br>
width : the bar width in points<br>
colorup : the color of the lines where close >= open<br>
colordown : the color of the lines where close < open<br>
alpha : bar transparency<br>
<br>
return value is lineCollection, barCollection</tt></dd></dl>
<dl><dt><a name="-fetch_historical_yahoo"><strong>fetch_historical_yahoo</strong></a>(ticker, date1, date2, cachename<font color="#909090">=None</font>)</dt><dd><tt>Fetch historical data for ticker between date1 and date2. date1 and<br>
date2 are datetime instances<br>
<br>
Ex:<br>
fh = <a href="#-fetch_historical_yahoo">fetch_historical_yahoo</a>('^GSPC', d1, d2)<br>
<br>
cachename is the name of the local file cache. If None, will<br>
default to the md5 hash or the url (which incorporates the ticker<br>
and date range)<br>
<br>
a file handle is returned</tt></dd></dl>
<dl><dt><a name="-index_bar"><strong>index_bar</strong></a>(ax, vals, facecolor<font color="#909090">='b'</font>, edgecolor<font color="#909090">='l'</font>, width<font color="#909090">=4</font>, alpha<font color="#909090">=1.0</font>)</dt><dd><tt>Add a bar collection graph with height vals (-1 is missing).<br>
<br>
ax : an Axes instance to plot to<br>
width : the bar width in points<br>
alpha : bar transparency</tt></dd></dl>
<dl><dt><a name="-md5"><strong>md5</strong></a> = openssl_md5(...)</dt><dd><tt>Returns a md5 hash object; optionally initialized with a string</tt></dd></dl>
<dl><dt><a name="-parse_yahoo_historical"><strong>parse_yahoo_historical</strong></a>(fh, asobject<font color="#909090">=False</font>, adjusted<font color="#909090">=True</font>)</dt><dd><tt>Parse the historical data in file handle fh from yahoo finance and return<br>
results as a list of<br>
<br>
d, open, close, high, low, volume<br>
<br>
where d is a floating poing representation of date, as returned by date2num<br>
<br>
if adjust=True, use adjusted prices</tt></dd></dl>
<dl><dt><a name="-plot_day_summary"><strong>plot_day_summary</strong></a>(ax, quotes, ticksize<font color="#909090">=3</font>, colorup<font color="#909090">='k'</font>, colordown<font color="#909090">='r'</font>)</dt><dd><tt>quotes is a list of (time, open, close, high, low, ...) tuples<br>
<br>
Represent the time, open, close, high, low as a vertical line<br>
ranging from low to high. The left tick is the open and the right<br>
tick is the close.<br>
<br>
time must be in float date format - see date2num<br>
<br>
ax : an Axes instance to plot to<br>
ticksize : open/close tick marker in points<br>
colorup : the color of the lines where close >= open<br>
colordown : the color of the lines where close < open<br>
return value is a list of lines added</tt></dd></dl>
<dl><dt><a name="-plot_day_summary2"><strong>plot_day_summary2</strong></a>(ax, opens, closes, highs, lows, ticksize<font color="#909090">=4</font>, colorup<font color="#909090">='k'</font>, colordown<font color="#909090">='r'</font>)</dt><dd><tt>Represent the time, open, close, high, low as a vertical line<br>
ranging from low to high. The left tick is the open and the right<br>
tick is the close.<br>
<br>
ax : an Axes instance to plot to<br>
ticksize : size of open and close ticks in points<br>
colorup : the color of the lines where close >= open<br>
colordown : the color of the lines where close < open<br>
<br>
return value is a list of lines added</tt></dd></dl>
<dl><dt><a name="-quotes_historical_yahoo"><strong>quotes_historical_yahoo</strong></a>(ticker, date1, date2, asobject<font color="#909090">=False</font>, adjusted<font color="#909090">=True</font>, cachename<font color="#909090">=None</font>)</dt><dd><tt>Get historical data for ticker between date1 and date2. date1 and<br>
date2 are datetime instances<br>
<br>
results are a list of tuples<br>
<br>
(d, open, close, high, low, volume)<br>
<br>
where d is a floating poing representation of date, as returned by date2num<br>
<br>
if asobject is True, the return val is an object with attrs date,<br>
open, close, high, low, volume, which are equal length arrays<br>
<br>
if adjust=True, use adjusted prices<br>
<br>
Ex:<br>
sp = f.<a href="#-quotes_historical_yahoo">quotes_historical_yahoo</a>('^GSPC', d1, d2, asobject=True, adjusted=True)<br>
returns = (sp.open[1:] - sp.open[:-1])/sp.open[1:]<br>
[n,bins,patches] = hist(returns, 100)<br>
mu = mean(returns)<br>
sigma = std(returns)<br>
x = normpdf(bins, mu, sigma)<br>
plot(bins, x, color='red', lw=2)<br>
<br>
cachename is the name of the local file cache. If None, will<br>
default to the md5 hash or the url (which incorporates the ticker<br>
and date range)</tt></dd></dl>
<dl><dt><a name="-volume_overlay"><strong>volume_overlay</strong></a>(ax, opens, closes, volumes, colorup<font color="#909090">='k'</font>, colordown<font color="#909090">='r'</font>, width<font color="#909090">=4</font>, alpha<font color="#909090">=1.0</font>)</dt><dd><tt>Add a volume overlay to the current axes. The opens and closes<br>
are used to determine the color of the bar. -1 is missing. If a<br>
value is missing on one it must be missing on all<br>
<br>
ax : an Axes instance to plot to<br>
width : the bar width in points<br>
colorup : the color of the lines where close >= open<br>
colordown : the color of the lines where close < open<br>
alpha : bar transparency</tt></dd></dl>
<dl><dt><a name="-volume_overlay2"><strong>volume_overlay2</strong></a>(ax, closes, volumes, colorup<font color="#909090">='k'</font>, colordown<font color="#909090">='r'</font>, width<font color="#909090">=4</font>, alpha<font color="#909090">=1.0</font>)</dt><dd><tt>Add a volume overlay to the current axes. The closes are used to<br>
determine the color of the bar. -1 is missing. If a value is<br>
missing on one it must be missing on all<br>
<br>
ax : an Axes instance to plot to<br>
width : the bar width in points<br>
colorup : the color of the lines where close >= open<br>
colordown : the color of the lines where close < open<br>
alpha : bar transparency<br>
<br>
nb: first point is not displayed - it is used only for choosing the<br>
right color</tt></dd></dl>
<dl><dt><a name="-volume_overlay3"><strong>volume_overlay3</strong></a>(ax, quotes, colorup<font color="#909090">='k'</font>, colordown<font color="#909090">='r'</font>, width<font color="#909090">=4</font>, alpha<font color="#909090">=1.0</font>)</dt><dd><tt>Add a volume overlay to the current axes. quotes is a list of (d,<br>
open, close, high, low, volume) and close-open is used to<br>
determine the color of the bar<br>
<br>
kwarg<br>
width : the bar width in points<br>
colorup : the color of the lines where close1 >= close0<br>
colordown : the color of the lines where close1 < close0<br>
alpha : bar transparency</tt></dd></dl>
</td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom> <br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
<td width="100%"><strong>TICKLEFT</strong> = 0<br>
<strong>TICKRIGHT</strong> = 1<br>
<strong>cachedir</strong> = '/home/jdhunter/.matplotlib/finance.cache'<br>
<strong>colorConverter</strong> = <matplotlib.colors.ColorConverter instance at 0x1e29b90><br>
<strong>configdir</strong> = '/home/jdhunter/.matplotlib'<br>
<strong>verbose</strong> = <matplotlib.Verbose instance at 0x1e4c200></td></tr></table>
@footer@