Charts (pynance.chart)

Since detailed charts are readily available online, the charts generated by this module serve 2 purposes:

  1. Verify data integrity
  2. Visualize events as defined by custom algorithms.

The functions in this submodule wrap pandas and matplotlib for greater ease of use.

pynance.chart.adj_close(df, **kwargs)[source]

Show and optionally save adj_close chart of a DataFrame as retrieved using pynance.data.get().

Examples

>>> pn.chart.adj_close(df, title='GE', fname='foo.png', events=evdf, eventcolors=['r', 'g'], 
        bollinger=bolldf, sma=smadf)
pynance.chart.candlestick(df, **kwargs)[source]

Show and optionally save candlestick chart of a DataFrame as retrieved using pynance.data.get().

Parameters:

df : DataFrame

Source data, containing columns ‘Open’, ‘High’, ‘Low’, ‘Close’ and ‘Volume’.

title : str, optional

Title to be used for the chart.

fname : str, optional

If provided, the chart will be saved to a file named fname. fname should also include the extension ‘.png’ or ‘.pdf’.

events : DataFrame, optional

Must have the same index as df. Up to 4 columns of events will be mapped. The order of the columns will determine the marker to be assigned to the event. The color order is: ['g^', 'ro', 'bs', 'k^'] Non-events in this DataFrame should have a value like np.nan, which matplotlib will not plot. The events DataFrame should use dtype='float'. If not, a bug in numpy (or matplotlib) can lead to a TypeError. Details here.

bollinger : DataFrame, optional

If present, Bollinger bands will be overlaid. bollinger must have the same index as df and must contain columns ‘Upper’ and ‘Lower’.

sma : DataFrame, optional

If present, first column will be overlaid as simple moving average. sma must have same index as df.

Examples

>>> pn.chart.candlestick(df, title='GE', fname='foo.png', events=evdf, eventcolors=['r', 'g'], 
        bollinger=bolldf, sma=smadf)
pynance.chart.close(df, **kwargs)[source]

Show and optionally save close chart of a DataFrame as retrieved using pynance.data.get().

Examples

>>> pn.chart.close(df, title='GE', fname='foo.png', events=evdf, eventcolors=['r', 'g'], 
        bollinger=bolldf, sma=smadf)