@header@
 
 
matplotlib.finance
index
/usr/lib/python2.4/site-packages/matplotlib/finance.py

A collection of modules for collecting, analyzing and plotting
financial data.   User contributions welcome!

 
Modules
       
datetime
md5
matplotlib.numerix
os
time
warnings

 
Functions
       
Value(...)
Value(x)
candlestick(ax, quotes, width=0.20000000000000001, colorup='k', colordown='r', alpha=1.0)
quotes is a list of (time, open, close, high, low, ...)  tuples.
As long as the first 5 elements of the tuples are these values,
the tuple can be as long as you want (eg it may store volume).
 
time must be in float days format - see date2num
 
Plot the time, open, close, high, low as a vertical line ranging
from low to high.  Use a rectangular bar to represent the
open-close span.  If close >= open, use colorup to color the bar,
otherwise use colordown
 
ax          : an Axes instance to plot to
width       : fraction of a day for the rectangle width
colorup     : the color of the rectangle where close >= open
colordown   : the color of the rectangle where close <  open    
alpha       : the rectangle alpha level
 
return value is lines, patches where lines is a list of lines
added and patches is a list of the rectangle patches added
candlestick2(ax, opens, closes, highs, lows, width=4, colorup='k', colordown='r', alpha=0.75)
Represent the open, close as a bar line and high low range as a
vertical line.
 
 
ax          : an Axes instance to plot to
width       : the bar width in points
colorup     : the color of the lines where close >= open
colordown   : the color of the lines where close <  open    
alpha       : bar transparency
 
return value is lineCollection, barCollection
fetch_historical_yahoo(ticker, date1, date2, cachename=None)
Fetch historical data for ticker between date1 and date2.  date1 and
date2 are datetime instances
 
Ex:
fh = fetch_historical_yahoo('^GSPC', d1, d2)
 
cachename is the name of the local file cache.  If None, will
default to the md5 hash or the url (which incorporates the ticker
and date range)
 
a file handle is returned
index_bar(ax, vals, facecolor='b', edgecolor='l', width=4, alpha=1.0)
Add a bar collection graph with height vals (-1 is missing).
 
ax          : an Axes instance to plot to
width       : the bar width in points
alpha       : bar transparency
parse_yahoo_historical(fh, asobject=False, adjusted=True)
Parse the historical data in file handle fh from yahoo finance and return
results as a list of
 
d, open, close, high, low, volume
 
where d is a floating poing representation of date, as returned by date2num
 
if adjust=True, use adjusted prices
plot_day_summary(ax, quotes, ticksize=3, colorup='k', colordown='r')
quotes is a list of (time, open, close, high, low, ...) tuples
 
Represent the time, open, close, high, low as a vertical line
ranging from low to high.  The left tick is the open and the right
tick is the close.
 
time must be in float date format - see date2num
 
ax          : an Axes instance to plot to
ticksize    : open/close tick marker in points
colorup     : the color of the lines where close >= open
colordown   : the color of the lines where close <  open    
return value is a list of lines added
plot_day_summary2(ax, opens, closes, highs, lows, ticksize=4, colorup='k', colordown='r')
Represent the time, open, close, high, low as a vertical line
ranging from low to high.  The left tick is the open and the right
tick is the close.
 
ax          : an Axes instance to plot to
ticksize    : size of open and close ticks in points
colorup     : the color of the lines where close >= open
colordown   : the color of the lines where close <  open    
 
return value is a list of lines added
quotes_historical_yahoo(ticker, date1, date2, asobject=False, adjusted=True, cachename=None)
Get historical data for ticker between date1 and date2.  date1 and
date2 are datetime instances
 
results are a list of tuples
 
  (d, open, close, high, low, volume)
 
where d is a floating poing representation of date, as returned by date2num
 
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
 
Ex:
sp = f.quotes_historical_yahoo('^GSPC', d1, d2, asobject=True, adjusted=True)
returns = (sp.open[1:] - sp.open[:-1])/sp.open[1:]
[n,bins,patches] = hist(returns, 100)
mu = mean(returns)
sigma = std(returns)
x = normpdf(bins, mu, sigma)
plot(bins, x, color='red', lw=2)
 
cachename is the name of the local file cache.  If None, will
default to the md5 hash or the url (which incorporates the ticker
and date range)
volume_overlay(ax, opens, closes, volumes, colorup='k', colordown='r', width=4, alpha=1.0)
Add a volume overlay to the current axes.  The opens and closes
are used to determine the color of the bar.  -1 is missing.  If a
value is missing on one it must be missing on all
 
ax          : an Axes instance to plot to
width       : the bar width in points
colorup     : the color of the lines where close >= open
colordown   : the color of the lines where close <  open    
alpha       : bar transparency
volume_overlay2(ax, closes, volumes, colorup='k', colordown='r', width=4, alpha=1.0)
Add a volume overlay to the current axes.  The closes are used to
determine the color of the bar.  -1 is missing.  If a value is
missing on one it must be missing on all
 
ax          : an Axes instance to plot to
width       : the bar width in points
colorup     : the color of the lines where close >= open
colordown   : the color of the lines where close <  open
alpha       : bar transparency
 
nb: first point is not displayed - it is used only for choosing the
right color
volume_overlay3(ax, quotes, colorup='k', colordown='r', width=4, alpha=1.0)
Add a volume overlay to the current axes.  quotes is a list of (d,
open, close, high, low, volume) and close-open is used to
determine the color of the bar
 
kwarg
width       : the bar width in points
colorup     : the color of the lines where close1 >= close0
colordown   : the color of the lines where close1 <  close0    
alpha       : bar transparency

 
Data
        TICKLEFT = 0
TICKRIGHT = 1
cachedir = '/home/jdhunter/.matplotlib/finance.cache'
colorConverter = <matplotlib.colors.ColorConverter instance>
configdir = '/home/jdhunter/.matplotlib'
verbose = <matplotlib.Verbose instance>
@footer@