Skip to content
All library documents

Bayesian Performance Analysis for Strategy Returns

Article MQL5 code base

Summary

This pyfolio example explains how Bayesian analysis can express uncertainty around strategy performance estimates. Instead of treating Sharpe ratio, mean return, volatility, alpha, or beta as fixed values, it estimates posterior distributions with Markov chain Monte Carlo sampling. The example builds a Bayesian tear sheet from daily stock returns and separates an in-sample period from an out-of-sample period. It describes comparisons between the distributions, including their differences and an effect size, and shows how posterior samples can be used to estimate the probability that the Sharpe ratio is positive.

The tear sheet also uses a Bayesian cone with a Student t return model, forecasts returns over short horizons, and presents a loss-probability measure analogous to Bayesian value at risk. Stochastic volatility is available but computationally expensive, and its calculation is limited to recent return observations. The example illustrates analysis methods rather than establishing that a strategy is profitable; posterior conclusions depend on the model and the available data, and sampling can take substantial time.

Key ideas

  • Bayesian performance measures represent uncertainty as posterior distributions rather than single estimates.
  • The tear sheet compares in-sample and out-of-sample distributions for returns and risk metrics.
  • A Student t model allows heavier return tails than a normal model in the cone and regression analyses described.
  • Posterior samples can estimate probabilities such as the chance that the Sharpe ratio exceeds zero.
  • Stochastic volatility analysis is computationally expensive and uses a limited recent return history.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.