<a id="general-examples"></a>

<a id="examples"></a>

# Examples

We recommend starting with [Maximum Sharpe Ratio](https://skfolio.org/auto_examples/mean_risk/plot_1_maximum_sharpe_ratio.html.md#sphx-glr-auto-examples-mean-risk-plot-1-maximum-sharpe-ratio-py)
or [Minimum CVaR](https://skfolio.org/auto_examples/mean_risk/plot_2_minimum_CVaR.html.md#sphx-glr-auto-examples-mean-risk-plot-2-minimum-cvar-py) before moving to more advanced examples.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">

</div>

<a id="mean-risk"></a>

## Mean-Risk

Examples using the [`MeanRisk`](https://skfolio.org/generated/skfolio.optimization.MeanRisk.html.md#skfolio.optimization.MeanRisk) optimization.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial uses the MeanRisk optimization to find the maximum Sharpe Ratio portfolio.">  <div class="sphx-glr-thumbnail-title">Maximum Sharpe Ratio</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial uses the MeanRisk optimization to find the minimum CVaR (Conditional Value at Risk) portfolio.">  <div class="sphx-glr-thumbnail-title">Minimum CVaR</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial uses the MeanRisk optimization to find an ensemble of portfolios belonging to the Mean-Variance efficient frontier (Pareto front).">  <div class="sphx-glr-thumbnail-title">Efficient Frontier</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial uses the MeanRisk optimization to find an ensemble of portfolios belonging to the Mean-Variance-CDaR efficient frontier.">  <div class="sphx-glr-thumbnail-title">Mean-Variance-CDaR Surface</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to incorporate weight constraints into the MeanRisk optimization.">  <div class="sphx-glr-thumbnail-title">Weight Constraints</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to incorporate transaction costs (TC) into the MeanRisk optimization.">  <div class="sphx-glr-thumbnail-title">Transaction Costs</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to incorporate management fees (MF) into the MeanRisk optimization.">  <div class="sphx-glr-thumbnail-title">Management Fees</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to incorporate regularization into the MeanRisk optimization.">  <div class="sphx-glr-thumbnail-title">L1 and L2 Regularization</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to incorporate expected returns uncertainty sets into the MeanRisk optimization.">  <div class="sphx-glr-thumbnail-title">Uncertainty Set</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to incorporate a tracking error constraint into the MeanRisk optimization.">  <div class="sphx-glr-thumbnail-title">Tracking Error</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to use the EmpiricalPrior estimator in the MeanRisk optimization.">  <div class="sphx-glr-thumbnail-title">Empirical Prior</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to use the BlackLitterman estimator in the MeanRisk optimization.">  <div class="sphx-glr-thumbnail-title">Black & Litterman</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="skfolio supports time-series factor models through TimeSeriesFactorModel and characteristics-based cross-sectional factor models through CharacteristicsFactorModel.">  <div class="sphx-glr-thumbnail-title">Time-Series Factor Model</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to use the TimeSeriesFactorModel estimator coupled with the BlackLitterman estimator in the MeanRisk optimization.">  <div class="sphx-glr-thumbnail-title">Black & Litterman Factor Model</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to use cardinality constraints with the MeanRisk optimization.">  <div class="sphx-glr-thumbnail-title">Cardinality Constraints</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to use threshold constraints with the MeanRisk optimization.">  <div class="sphx-glr-thumbnail-title">Threshold Constraints</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces the optimization parameters fallback and raise_on_failure.">  <div class="sphx-glr-thumbnail-title">Failure and Fallbacks</div>
</div>
</div>

<a id="factor-models"></a>

## Factor Models

Examples about [`CharacteristicsFactorModel`](https://skfolio.org/generated/skfolio.prior.CharacteristicsFactorModel.html.md#skfolio.prior.CharacteristicsFactorModel): building a
characteristics factor model from an [`AssetPanel`](https://skfolio.org/generated/skfolio.containers.AssetPanel.html.md#skfolio.containers.AssetPanel),
diagnosing it, and using it for portfolio construction, attribution and alpha
integration.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to build a characteristics-based cross-sectional factor model with CharacteristicsFactorModel. The methodology is covered in the Factor Models &lt;factor_models&gt; user guide.">  <div class="sphx-glr-thumbnail-title">Characteristics Factor Model</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to build a dollar-neutral long-short portfolio with factor tilts, using the characteristics-based cross-sectional factor model CharacteristicsFactorModel and the optimizer MeanRisk. The methodology is covered in the Portfolio Construction &lt;factor_model_portfolio_construction&gt; and factor_model_attribution sections of the user guide.">  <div class="sphx-glr-thumbnail-title">Factor-Constrained Portfolio and Attribution</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to research an alpha signal that forecasts the idiosyncratic returns of the characteristics-based cross-sectional factor model CharacteristicsFactorModel, and how to trade it in a factor-neutral long-short portfolio. The methodology is covered in the Alpha Estimators &lt;factor_model_alpha&gt; and Portfolio Construction &lt;factor_model_portfolio_construction&gt; sections of the user guide.">  <div class="sphx-glr-thumbnail-title">Alpha Research and Factor-Neutral Portfolio</div>
</div>
</div>

<a id="risk-budgeting"></a>

## Risk Budgeting

Examples concerning the [`RiskBudgeting`](https://skfolio.org/generated/skfolio.optimization.RiskBudgeting.html.md#skfolio.optimization.RiskBudgeting) optimization.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial uses the RiskBudgeting optimization to find the risk parity portfolio with variance as the risk measure.">  <div class="sphx-glr-thumbnail-title">Risk Parity - Variance</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial uses the RiskBudgeting optimization to build a risk budgeting portfolio by specifying a risk budget on each asset with CVaR as the risk measure.">  <div class="sphx-glr-thumbnail-title">Risk Budgeting - CVaR</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to incorporate covariance shrinkage in the RiskBudgeting optimization.">  <div class="sphx-glr-thumbnail-title">Risk Parity - Covariance shrinkage</div>
</div>
</div>

<a id="synthetic-data-stress-test"></a>

## Synthetic Data & Stress Test

Examples about [`SyntheticData`](https://skfolio.org/generated/skfolio.prior.SyntheticData.html.md#skfolio.prior.SyntheticData) and
[`VineCopula`](https://skfolio.org/generated/skfolio.distribution.VineCopula.html.md#skfolio.distribution.VineCopula).

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces Bivariate Copulas estimators that are the building blocks of VineCopula.">  <div class="sphx-glr-thumbnail-title">Bivariate Copulas</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial presents the VineCopula estimator. An introduction to Bivariate Copulas can be found in this previous tutorial &lt;sphx_glr_auto_examples_synthetic_data_plot_1_bivariate_copulas.py&gt;.">  <div class="sphx-glr-thumbnail-title">Vine Copula & Stress Test</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to bridge scenario generation, factor models and portfolio optimization.">  <div class="sphx-glr-thumbnail-title">Minimize CVaR on Stressed Factors</div>
</div>
</div>

<a id="entropy-opinion-pooling"></a>

## Entropy & Opinion Pooling

Examples about [`EntropyPooling`](https://skfolio.org/generated/skfolio.prior.EntropyPooling.html.md#skfolio.prior.EntropyPooling) and
[`OpinionPooling`](https://skfolio.org/generated/skfolio.prior.OpinionPooling.html.md#skfolio.prior.OpinionPooling).

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces the EntropyPooling estimator.">  <div class="sphx-glr-thumbnail-title">Entropy Pooling</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces the OpinionPooling estimator.">  <div class="sphx-glr-thumbnail-title">Opinion Pooling</div>
</div>
</div>

<a id="hierarchical-clustering-and-nco"></a>

## Hierarchical Clustering and NCO

Examples concerning hierarchical clustering based optimizations.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces the HierarchicalRiskParity optimization.">  <div class="sphx-glr-thumbnail-title">Hierarchical Risk Parity - CVaR</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces the HierarchicalEqualRiskContribution optimization.">  <div class="sphx-glr-thumbnail-title">Hierarchical Equal Risk Contribution - CDaR</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="In this tutorial, we will compare the HierarchicalRiskParity (HRP) optimization with the HierarchicalEqualRiskContribution (HERC) optimization.">  <div class="sphx-glr-thumbnail-title">HRP vs HERC</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces the NestedClustersOptimization optimization.">  <div class="sphx-glr-thumbnail-title">Nested Clusters Optimization</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="The previous tutorial introduced the NestedClustersOptimization.">  <div class="sphx-glr-thumbnail-title">NCO - Combinatorial Purged CV</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces the SchurComplementary allocation.">  <div class="sphx-glr-thumbnail-title">Schur Complementary Allocation</div>
</div>
</div>

<a id="maximum-diversification"></a>

## Maximum Diversification

Examples concerning the [`MaximumDiversification`](https://skfolio.org/generated/skfolio.optimization.MaximumDiversification.html.md#skfolio.optimization.MaximumDiversification) optimization.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial uses the MaximumDiversification optimization to find the portfolio that maximizes the diversification ratio, which is the ratio of the weighted volatilities over the total volatility.">  <div class="sphx-glr-thumbnail-title">Maximum Diversification</div>
</div>
</div>

<a id="distributionally-robust-cvar"></a>

## Distributionally Robust CVaR

Examples concerning the [`DistributionallyRobustCVaR`](https://skfolio.org/generated/skfolio.optimization.DistributionallyRobustCVaR.html.md#skfolio.optimization.DistributionallyRobustCVaR) optimization.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces the DistributionallyRobustCVaR model.">  <div class="sphx-glr-thumbnail-title">Distributionally Robust CVaR</div>
</div>
</div>

<a id="ensemble-optimizations"></a>

## Ensemble Optimizations

Examples concerning ensemble optimizations.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces the StackingOptimization.">  <div class="sphx-glr-thumbnail-title">Stacking Optimization</div>
</div>
</div>

<a id="model-selection"></a>

## Model Selection

Model selection is an integral part of portfolio construction and therefore appears in
most examples.

Tutorials using [`WalkForward`](https://skfolio.org/generated/skfolio.model_selection.WalkForward.html.md#skfolio.model_selection.WalkForward):
: * [Custom Pre-selection Using Volumes](https://skfolio.org/auto_examples/pre_selection/plot_3_custom_pre_selection_volumes.html.md#sphx-glr-auto-examples-pre-selection-plot-3-custom-pre-selection-volumes-py)
  * [HRP vs HERC](https://skfolio.org/auto_examples/clustering/plot_3_hrp_vs_herc.html.md#sphx-glr-auto-examples-clustering-plot-3-hrp-vs-herc-py)
  * [L1 and L2 Regularization](https://skfolio.org/auto_examples/mean_risk/plot_8_regularization.html.md#sphx-glr-auto-examples-mean-risk-plot-8-regularization-py)
  * [NCO - Combinatorial Purged CV](https://skfolio.org/auto_examples/clustering/plot_5_nco_grid_search.html.md#sphx-glr-auto-examples-clustering-plot-5-nco-grid-search-py)
  * [Stacking Optimization](https://skfolio.org/auto_examples/ensemble/plot_1_stacking.html.md#sphx-glr-auto-examples-ensemble-plot-1-stacking-py)

Tutorials using [`CombinatorialPurgedCV`](https://skfolio.org/generated/skfolio.model_selection.CombinatorialPurgedCV.html.md#skfolio.model_selection.CombinatorialPurgedCV):
: * [Drop Highly Correlated Assets](https://skfolio.org/auto_examples/pre_selection/plot_1_drop_correlated.html.md#sphx-glr-auto-examples-pre-selection-plot-1-drop-correlated-py)
  * [HRP vs HERC](https://skfolio.org/auto_examples/clustering/plot_3_hrp_vs_herc.html.md#sphx-glr-auto-examples-clustering-plot-3-hrp-vs-herc-py)
  * [NCO - Combinatorial Purged CV](https://skfolio.org/auto_examples/clustering/plot_5_nco_grid_search.html.md#sphx-glr-auto-examples-clustering-plot-5-nco-grid-search-py)

Below are dedicated Model Selection tutorials.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces MultipleRandomizedCV, which is based on the &quot;Multiple Randomized Backtests&quot; methodology of Palomar in [1]_. This cross-validation strategy performs a resampling-based evaluation by repeatedly sampling distinct asset subsets (without replacement) and contiguous time windows, then applying an inner walk-forward split to each subsample, capturing both temporal and cross-sectional variability in performance.">  <div class="sphx-glr-thumbnail-title">Multiple Randomized Cross-Validation</div>
</div>
</div>

<a id="online-learning"></a>

## Online Learning

Examples demonstrating online covariance evaluation, online hyperparameter
tuning, and online evaluation of portfolio optimization with incremental
estimators.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to evaluate online covariance estimators with online_covariance_forecast_evaluation.">  <div class="sphx-glr-thumbnail-title">Online Covariance Forecast Evaluation</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to tune covariance estimator hyperparameters in an online setting using OnlineGridSearch and OnlineRandomizedSearch.">  <div class="sphx-glr-thumbnail-title">Online Covariance Hyperparameter Tuning</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to tune a MeanRisk estimator with online search and evaluate it out-of-sample with an online walk-forward procedure.">  <div class="sphx-glr-thumbnail-title">Online Evaluation of Portfolio Optimization</div>
</div>
</div>

<a id="pre-selection"></a>

## Pre-selection

Examples of using [pre-selection transformers](https://skfolio.org/user_guide/pre_selection.html.md#pre-selection) with `Pipelines`.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces the  pre-selection transformers &lt;pre_selection&gt; DropCorrelated to remove highly correlated assets before the optimization.">  <div class="sphx-glr-thumbnail-title">Drop Highly Correlated Assets</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial introduces the pre-selection transformers &lt;pre_selection&gt; SelectKExtremes to select the k best or the k worst assets according to a given measure before the optimization.">  <div class="sphx-glr-thumbnail-title">Select Best Performers</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="This tutorial demonstrates how to implement a custom pre-selection transformer &lt;pre_selection&gt; with metadata_routing, integrate it into a Pipeline, and run walk-forward cross-validation.">  <div class="sphx-glr-thumbnail-title">Custom Pre-selection Using Volumes</div>
</div><div class="sphx-glr-thumbcontainer" tooltip="When working with large datasets over long timeframes, we commonly encounter:">  <div class="sphx-glr-thumbnail-title">Handling Incomplete Datasets: Inception, Expiry, and Default</div>
</div>
</div>

<a id="metadata-routing"></a>

## Metadata Routing

Examples about metadata routing.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial shows how to use metadata routing &lt;metadata_routing&gt;.">  <div class="sphx-glr-thumbnail-title">Using Implied Volatility with Metadata Routing</div>
</div>
</div>

<a id="data-preparation"></a>

## Data Preparation

Examples about data preparation.

<div id='sg-tag-list' class='sphx-glr-tag-list'></div><div class="sphx-glr-thumbnails">
<div class="sphx-glr-thumbcontainer" tooltip="This tutorial explores the difference between the general procedure using different investment horizons and the simplified procedure as explained in data preparation &lt;data_preparation&gt;.">  <div class="sphx-glr-thumbnail-title">Investment Horizon</div>
</div>
</div>
