PlotBackTest

Defined in fynance.backtest

class PlotBackTest(fig=None, ax=None, size=(9, 6), dynamic=False, **kwargs)[source]

Bases: object

Plot backtest object.

Lightweight wrapper around a Matplotlib Figure / Axes pair used to render the cumulative-performance curve of one or several strategies. Reuse an existing figure by passing fig and ax, or let the constructor create one. Axis labels, scales, ticks and title are configured once at construction via **kwargs; subsequent calls to plot only add data.

For live updates during walk-forward training, use fynance.backtest.dynamic_plot_backtest.BacktestNeuralNet, which builds on the same primitives but refreshes the canvas on each iteration.

Attributes:
figmatplotlib.figure.Figure

Figure to display backtest.

axmatplotlib.axes

Axe(s) to display a part of backtest.

Methods

plot(y, x=None, names=None, col=’Blues’, lw=1., **kwargs)

Plot performances.

See also

DynaPlotBackTest, display_perf, set_text_stats
plot(y, x=None, names=None, col='Blues', lw=1., unit='raw', **kwargs)[source]

Plot performances.

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

Returns or indexes.

xnp.ndarray[ndim=2], with shape (T, 1), optional

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

namesstr, optional

Names y lines for legend.

colstr, optional

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

lwfloat, optional

Line width of lines.

kwargsdict, optional

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

Returns:
pbtPlotBackTest

Self object.

References