BacktestResult¶
Defined in fynance.backtest
- class BacktestResult(equity, returns, gross_returns, positions, costs, index=None, asset_gross_returns=None, cost_components=None)[source]
Bases:
objectOutput of
backtest.- Attributes:
- equitynumpy.ndarray
Equity curve.
- returnsnumpy.ndarray
Net strategy returns (after costs).
- gross_returnsnumpy.ndarray
Strategy returns before costs.
- positionsnumpy.ndarray
Position/weight book used.
- costsnumpy.ndarray
Per-step transaction costs.
- indexnumpy.ndarray, optional
Temporal index carried from the input.
- asset_gross_returnsnumpy.ndarray, optional
Per-asset gross return contributions
(T, N)for a multi-asset book (they sum togross_returns);Nonefor a single-asset run.- cost_componentsdict of str to numpy.ndarray, optional
Per-step cost broken down by component (e.g.
transactionvsmarket_impact); the values sum tocosts. Populated when the cost model exposes the optionalcomponentsconvention, elseNone.
Methods
to_numpy()Return the equity curve as a numpy array.
to_price_series()Return the equity curve as a
PriceSeries.summary([period])Standard performance summary.
- summary(period=252)[source]
Standard performance summary.
Delegates the risk-adjusted ratios and drawdown to
fynance.metrics.summary(computed on the equity curve) and adds, from the strategy’s own data, the hit-rate, total transaction cost and the trading-profile churn (n_sign_changes/trades_per_year, summed over the book — seefynance.metrics.sign_changes).
- to_numpy()[source]
Return the equity curve as a numpy array.
- to_price_series()[source]
Return the equity curve as a
PriceSeries.