Table of Contents

Previous topic

Tools to backtest module

Next topic

Financial tools package

This Page

Plot object module

Objects to plot backtest or analysis of financial strategies and models.

fynance.backtest.PlotBackTest([fig, ax, …]) Plot backtest object.
fynance.backtest.DynaPlotBackTest([fig, ax, …]) Dynamic plot backtest object.

Static object

class fynance.backtest.PlotBackTest(fig=None, ax=None, size=(9, 6), dynamic=False, **kwargs)

Bases: object

Plot backtest object.

Attributes:
fig : matplotlib.figure.Figure

Figure to display backtest.

ax : matplotlib.axes

Axe(s) to display a part of backtest.

Methods

plot(y, x=None, names=None, col=’Blues’, lw=1., **kwargs) Plot performances.
__init__(self, fig=None, ax=None, size=(9, 6), dynamic=False, **kwargs)

Initialize method.

Sets size of training and predicting period, inital value to backtest, a target filter and training parameters.

Parameters:
fig : matplotlib.figure.Figure, optional

Figure to display backtest.

ax : matplotlib.axes, optional

Axe(s) to display a part of backtest.

size : tuple, optional

Size of figure, default is (9, 6)

dynamic : bool, optional

If True set on interactive plot.

kwargs : dict, optional

Axes configuration, cf matplotlib documentation [1]. Default is {‘yscale’: ‘linear’, ‘xscale’: ‘linear’, ‘ylabel’: ‘’, ‘xlabel’: ‘’, ‘title’: ‘’, ‘tick_params’: {}}

References

[1]https://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes
__weakref__

list of weak references to the object (if defined)

plot(self, y, x=None, names=None, col='Blues', lw=1.0, unit='raw', **kwargs)

Plot performances.

Parameters:
y : np.ndarray[np.float64, ndim=2], with shape (T, N)

Returns or indexes.

x : np.ndarray[ndim=2], with shape (T, 1), optional

x-axis, can be series of int or dates or string.

names : str, optional

Names y lines for legend.

col : str, optional

Color of palette, cf seaborn documentation [2]. Default is ‘Blues’.

lw : float, optional

Line width of lines.

kwargs : dict, optional

Parameters for ax.legend method, cf matplotlib documentation [3].

Returns:
pbt : PlotBackTest

Self object.

References

[2]https://seaborn.pydata.org/api.html
[3]https://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes

Dynamic object

class fynance.backtest.DynaPlotBackTest(fig=None, ax=None, size=(9, 6), dynamic=False, **kwargs)

Bases: fynance.backtest.plot_backtest.PlotBackTest

Dynamic plot backtest object.

Attributes:
fig : matplotlib.figure.Figure

Figure to display backtest.

ax : matplotlib.axes

Axe(s) to display a part of backtest.

Methods

plot(y, x=None, names=None, col=’Blues’, lw=1., **kwargs) Plot performances.
plot(self, y, x=None, names=None, col='Blues', lw=1.0, unit='raw', **kwargs)

Dynamic plot performances.

Parameters:
y : np.ndarray[np.float64, ndim=2], with shape (T, N)

Returns or indexes.

x : np.ndarray[ndim=2], with shape (T, 1), optional

x-axis, can be series of int or dates or string.

names : str, optional

Names y lines for legend.

col : str, optional

Color of palette, cf seaborn documentation [2]. Default is ‘Blues’.

lw : float, optional

Line width of lines.

kwargs : dict, optional

Parameters for ax.legend method, cf matplotlib documentation [3].

Returns:
pbt : PlotBackTest

Self object.

References

[2]https://seaborn.pydata.org/api.html
[3]https://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes