Skip to content

quantpylib.simulator.performance

performance_measures(r, w, periods_in_year=252, plot=False, path=FOLDER_STRUCTURE.images_dir)

Calculate and visualize various performance measures of a trading strategy.

Parameters:

Name Type Description Default
r Series

Time series of returns.

required
w DataFrame

DataFrame of weights corresponding to each asset over time, with same index as r.

required
periods_in_year int

Number of time periods in a year for the granularity of return series passed in. Defaults to 252, the number of trading days in a year.

252
plot bool

Whether to generate and save plots. Defaults to True.

False
path str

Path to save generated plots, if plot=True

images_dir

Returns:

Type Description
dict

A dictionary containing various performance metrics:

  • "cum_ret": Cumulative returns over time.
  • "log_ret": Logarithmic returns.
  • "max_dd": Maximum drawdown.
  • "1y_roll_dd": One-year rolling drawdown.
  • "1y_roll_max_dd": One-year rolling maximum drawdown.
  • "sortino": Sortino ratio.
  • "sharpe": Sharpe ratio.
  • "mean_ret": Mean return per annum.
  • "median_ret": Median return per annum.
  • "stdev_ret": Standard deviation of returns per annum.
  • "var_ret": Variance of returns per annum.
  • "skew_ret": Skewness of returns.
  • "kurt_exc": Excess kurtosis of returns.
  • "cagr": Compound annual growth rate.
  • "3y_roll_cagr": Three-year rolling compound annual growth rate.
  • "3y_roll_calmar": Three-year rolling Calmar ratio.
  • "omega(0)": Omega ratio.
  • "ulcer": Ulcer index.
  • "VaR95": Value at Risk at 95% confidence level.
  • "cVaR95": Conditional Value at Risk at 95% confidence level.
  • "gain_to_pain": Gain-to-pain ratio.
  • "w_summary": Summary statistics of weights.
  • "directionality": Market long bias directionality.
  • "parity_distance": Distance from a 1/n equal weight portfolio.