The BaseResult class captures portfolio data and calculates performance metrics for your investment strategy.
An instance of BaseResult is returned by calling the method generate_positions()
on an instance of BacktestController.
To get a string summary of your backtest result:
result_instance.summary
BaseResult instances have the following properties for performance reporting:
actual_returns
: Dataframe of actual returns for assets.annualized_benchmark_return
: Annualized return for the benchmark over the entire period.annualized_excess_return
: Annualized excess return for the entire period.annualized_return
: Annualized return for the entire period under review.annualized_return_over_cash
: Annualized return over cash for the entire period.benchmark_returns
: Series of returns for the benchmark.benchmark_v
: Series of simulated portfolio values if invested 100% in the benchmark at time 0.cash_column_name
: String of cash column name in holdings and trades.excess_returns
: Series of returns in excess of the benchmark.excess_risk_annualized
: Risk in excess of the benchmark.h
: Dataframe of asset holdings at the beginning of each datetime period.information_ratio
: (Annualized) Information Ratio of the portfolio.num_periods
: Number of periods in the backtest.portfolio_hit_rate
: Proportion of periods in which the portfolio had positive returns.ppy
: Float representing the number of periods per year in the backtest period.returns
: Series of the returns for each datetime period compared to the previous period.returns_over_cash
: Series of returns in excess of risk-free returns.risk_free_returns
: Series of risk-free returns.risk_over_cash_annualized
: Risk in excess of the risk-free rate.sharpe_ratio
: (Annualized) Sharpe Ratio of the portfolio.total_benchmark_return
: Return over the benchmark for the entire period under review.total_excess_return
: Excess return for the entire period (portfolio return minus benchmark return).total_return
: Total return for the entire period under review.total_return_over_cash
: Total returns over cash for the entire period under review.total_risk_free_return
: Total return over the risk-free rate for the entire period.trades
: Series of trades (also available as u
).v
: Series of the value of the portfolio for each datetime period.v_with_benchmark
: Dataframe with simulated portfolio and benchmark values.years_forecast
: Float representing the number of years in the backtest period.If the BaseResult class is missing a property or method you wish it had, you can easily extend the class (i.e. create a new class that inherits from BaseResult) and add your desired functionality!
BacktestController accepts a results_model
kwarg (note: if passed, it expects the model to be instantiated). Don't be afraid to roll out your own custom reporting functionality!
It's possible to backtest a portfolio created outside of InvestOS. Let's review how that works: Analyzing External Portfolios.