Examples#

This gallery walks through every public feature of financialkit.portfolio: Markowitz’s frontier, Tobin’s tangency portfolio, Merton’s analytic frontier and the 1/N benchmark; Kelly betting, Merton’s portfolio problem and CPPI; single-index and Ledoit-Wolf covariance estimates; the Sharpe and Sortino ratios and Grinold’s fundamental law; Black-Litterman and Michaud resampling; and CVaR optimization, maximum diversification, risk parity and hierarchical risk parity.

Each script in this gallery is self-contained and can be run directly with python examples/portfolio/<section>/<script>.py.

Sections#

  • mean_variance – the Markowitz frontier, Tobin separation, Merton’s closed form and DeMiguel-Garlappi-Uppal’s 1/N.

  • growth – the Kelly criterion, Merton’s portfolio problem and CPPI.

  • covariance – Sharpe’s single-index model and Ledoit-Wolf shrinkage.

  • performance – the Sharpe ratio, Grinold’s fundamental law and the Sortino ratio.

  • bayesian – Black-Litterman and Michaud’s resampled frontier.

  • risk_based – CVaR optimization, the most-diversified portfolio, risk parity and hierarchical risk parity.

Estimation-aware optimization#

Taming the error in expected returns with a market prior or by resampling.

Black-Litterman: equilibrium plus views

Black-Litterman: equilibrium plus views

Michaud’s resampled efficiency

Michaud's resampled efficiency

Covariance estimation#

Structured and shrunk estimates of the covariance matrix, the input that mean-variance optimizers are most sensitive to after the means.

Sharpe’s single-index model

Sharpe's single-index model

Ledoit-Wolf shrinkage

Ledoit-Wolf shrinkage

Growth and dynamic strategies#

Maximizing the long-run growth of wealth, the continuous-time consumption and investment problem, and portfolio insurance.

The Kelly criterion

The Kelly criterion

Merton’s portfolio problem

Merton's portfolio problem

Black and Jones’s constant proportion portfolio insurance

Black and Jones's constant proportion portfolio insurance

Mean-variance#

Portfolios with the least variance for their mean, with and without short sales and a riskless asset, and the naive benchmark they struggle to beat out of sample.

Markowitz’s mean-variance frontier

Markowitz's mean-variance frontier

Tobin separation and the tangency portfolio

Tobin separation and the tangency portfolio

Merton’s analytic frontier

Merton's analytic frontier

DeMiguel-Garlappi-Uppal: optimal versus 1/N

DeMiguel-Garlappi-Uppal: optimal versus 1/N

Performance measurement#

Return per unit of risk, its sampling error, and where skill comes from.

The Sharpe ratio

The Sharpe ratio

Grinold’s fundamental law of active management

Grinold's fundamental law of active management

The Sortino ratio

The Sortino ratio

Risk-based allocation#

Portfolios built from risk alone: tail risk, diversification and equal risk contributions.

Rockafellar-Uryasev CVaR optimization

Rockafellar-Uryasev CVaR optimization

Choueifaty’s most-diversified portfolio

Choueifaty's most-diversified portfolio

Maillard-Roncalli-Teiletche risk parity

Maillard-Roncalli-Teiletche risk parity

Lopez de Prado’s hierarchical risk parity

Lopez de Prado's hierarchical risk parity

Gallery generated by Sphinx-Gallery