Tools to backtest module¶
Some tools to plot strategy’s performances, rolling sharpe or drawdowns and to display some metrics and statistics.
fynance.backtest.display_perf (y_idx, y_est) |
Print dynamic plot of performance indicators (perf, rolling sharpe and draw down) of a strategy (raw and iso-volatility) versus its underlying. |
fynance.backtest.set_text_stats (underly[, …]) |
Set a table as string with different indicators (accuracy, perf, vol and sharpe) for underlying and several strategies. |
-
fynance.backtest.
display_perf
(y_idx, y_est, period=252, title='', params_iv={}, plot_drawdown=True, plot_roll_sharpe=True, x_axis=None, underlying='Underlying', win=252, fees=0)¶ Print dynamic plot of performance indicators (perf, rolling sharpe and draw down) of a strategy (raw and iso-volatility) versus its underlying.
Parameters: - y_idx : np.ndarray[np.float64, ndim=1]
Time series of log-returns of the underlying.
- y_est : np.ndarray[np.float64, ndim=1]
Time series of the signal’s strategy.
- period : int, optional
Number of period per year. Default is 252.
- title : str or list of str, optional
Title of performance strategy, default is empty.
- plot_drawdown : bool, optional
If true plot drawdowns, default is True.
- plot_roll_sharpe : bool, optional
If true plot rolling sharpe ratios, default is True.
- x_axis : list or np.asarray, optional
x-axis to plot (e.g. list of dates).
- underlying : str, optional
Name of the underlying, default is ‘Underlying’.
- win : int, optional
Size of the window of rolling sharpe, default is 252.
- fees : float, optional
Fees to apply at the strategy performance.
Returns: - perf_idx : np.ndarray[np.float64, ndim=1]
Time series of underlying performance.
- perf_est : np.ndarray[np.float64, ndim=1]
Time series of raw strategy performance.
- perf_ivo : np.ndarray[np.float64, ndim=1]
Time series of iso-vol strategy performance.
See also
-
fynance.backtest.
set_text_stats
(underly, period=252, accur=True, perf=True, vol=True, sharp=True, calma=True, underlying='Underlying', fees=0, **kwpred)¶ Set a table as string with different indicators (accuracy, perf, vol and sharpe) for underlying and several strategies.
Parameters: - underly : np.ndarray[ndim=1, dtype=np.float64]
Series of underlying prices.
- period : int, optional
Number of period per day, default is 252.
- accur : bool, optional
If true compute accuracy else not, default is True.
- perf : bool, optional
If true compute performance else not, default is True.
- vol : bool, optional
If true compute volatility else not, default is True.
- sharp : bool, optional
If true compute sharpe ratio else not, default is True.
- calma : bool, optional
If true compute calmar ratio else not, default is True.
- underlying : str, optional
Name of the underlying, default is ‘Underlying’.
- kwpred : dict of np.ndarray
Any strategies or predictions that you want to compare.
- fees : float, optional
Fees to apply at the strategy performance.
Returns: - txt : str
Table of results.
See also