Efficient Frontier#

This tutorial uses the MeanRisk optimization to find an ensemble of portfolios belonging to the Mean-Variance efficient frontier (pareto font).

Data#

We load the S&P 500 dataset composed of the daily prices of 20 assets from the S&P 500 Index composition starting from 1990-01-02 up to 2022-12-28:

import numpy as np
from plotly.io import show
from sklearn.model_selection import train_test_split

from skfolio import PerfMeasure, RatioMeasure, RiskMeasure
from skfolio.datasets import load_sp500_dataset
from skfolio.optimization import MeanRisk
from skfolio.preprocessing import prices_to_returns

prices = load_sp500_dataset()

X = prices_to_returns(prices)
X_train, X_test = train_test_split(X, test_size=0.33, shuffle=False)

Model#

We create the Mean-Variance model and then fit it on the training set. The parameter efficient_frontier_size=30 is used to find 30 portfolios on the entire efficient frontier:

model = MeanRisk(
    risk_measure=RiskMeasure.VARIANCE,
    efficient_frontier_size=30,
    portfolio_params=dict(name="Variance"),
)
model.fit(X_train)
print(model.weights_.shape)
(30, 20)

Prediction#

We predict this model on both the training set and the test set. The predict method returns the Population of 30 Portfolio:

population_train = model.predict(X_train)
population_test = model.predict(X_test)

Analysis#

For improved analysis, we add a “Train” and “Test” tag to the portfolios and concatenate the training and the test populations:

population_train.set_portfolio_params(tag="Train")
population_test.set_portfolio_params(tag="Test")

population = population_train + population_test

fig = population.plot_measures(
    x=RiskMeasure.ANNUALIZED_STANDARD_DEVIATION,
    y=PerfMeasure.ANNUALIZED_MEAN,
    color_scale=RatioMeasure.ANNUALIZED_SHARPE_RATIO,
    hover_measures=[RiskMeasure.MAX_DRAWDOWN, RatioMeasure.ANNUALIZED_SORTINO_RATIO],
)
show(fig)

Let’s plot the composition of the 30 portfolios:

population_train.plot_composition()


Let’s print the Sharpe Ratio of the 30 portfolios on the test set:

population_test.measures(measure=RatioMeasure.ANNUALIZED_SHARPE_RATIO)
array([0.91785162, 0.93000375, 0.9401232 , 0.95027284, 0.96861483,
       0.98463685, 0.9983657 , 1.00992555, 1.01943433, 1.02702131,
       1.032813  , 1.03704654, 1.03993049, 1.04204356, 1.0430764 ,
       1.04289017, 1.04158213, 1.03774863, 1.02943678, 1.02092595,
       1.01241175, 1.00356473, 0.97964062, 0.93749217, 0.87986871,
       0.78090544, 0.68550154, 0.59858003, 0.53398775, 0.55455742])

Finally, we can show a full summary of the 30 portfolios evaluated on the test set:

population.summary()
ptf0 - Variance ptf1 - Variance ptf2 - Variance ptf3 - Variance ptf4 - Variance ptf5 - Variance ptf6 - Variance ptf7 - Variance ptf8 - Variance ptf9 - Variance ptf10 - Variance ptf11 - Variance ptf12 - Variance ptf13 - Variance ptf14 - Variance ptf15 - Variance ptf16 - Variance ptf17 - Variance ptf18 - Variance ptf19 - Variance ptf20 - Variance ptf21 - Variance ptf22 - Variance ptf23 - Variance ptf24 - Variance ptf25 - Variance ptf26 - Variance ptf27 - Variance ptf28 - Variance ptf29 - Variance ptf0 - Variance ptf1 - Variance ptf2 - Variance ptf3 - Variance ptf4 - Variance ptf5 - Variance ptf6 - Variance ptf7 - Variance ptf8 - Variance ptf9 - Variance ptf10 - Variance ptf11 - Variance ptf12 - Variance ptf13 - Variance ptf14 - Variance ptf15 - Variance ptf16 - Variance ptf17 - Variance ptf18 - Variance ptf19 - Variance ptf20 - Variance ptf21 - Variance ptf22 - Variance ptf23 - Variance ptf24 - Variance ptf25 - Variance ptf26 - Variance ptf27 - Variance ptf28 - Variance ptf29 - Variance
Mean 0.062% 0.065% 0.068% 0.071% 0.074% 0.076% 0.079% 0.082% 0.085% 0.088% 0.091% 0.094% 0.096% 0.099% 0.10% 0.11% 0.11% 0.11% 0.11% 0.12% 0.12% 0.12% 0.13% 0.13% 0.13% 0.13% 0.14% 0.14% 0.14% 0.15% 0.054% 0.055% 0.056% 0.057% 0.059% 0.061% 0.063% 0.064% 0.066% 0.068% 0.070% 0.071% 0.073% 0.075% 0.077% 0.078% 0.080% 0.082% 0.083% 0.085% 0.086% 0.088% 0.088% 0.087% 0.086% 0.083% 0.081% 0.079% 0.078% 0.090%
Annualized Mean 15.66% 16.38% 17.10% 17.82% 18.54% 19.26% 19.99% 20.71% 21.43% 22.15% 22.87% 23.59% 24.32% 25.04% 25.76% 26.48% 27.20% 27.92% 28.65% 29.37% 30.09% 30.81% 31.53% 32.25% 32.98% 33.70% 34.42% 35.14% 35.86% 36.58% 13.68% 13.93% 14.18% 14.46% 14.90% 15.34% 15.78% 16.22% 16.66% 17.10% 17.53% 17.97% 18.41% 18.86% 19.31% 19.74% 20.16% 20.58% 20.95% 21.32% 21.71% 22.10% 22.16% 21.92% 21.59% 20.98% 20.37% 19.78% 19.56% 22.73%
Variance 0.011% 0.011% 0.011% 0.011% 0.012% 0.012% 0.012% 0.013% 0.014% 0.014% 0.015% 0.016% 0.017% 0.018% 0.019% 0.020% 0.022% 0.023% 0.025% 0.026% 0.028% 0.030% 0.032% 0.034% 0.038% 0.044% 0.053% 0.066% 0.084% 0.12% 0.0088% 0.0089% 0.0090% 0.0092% 0.0094% 0.0096% 0.0099% 0.010% 0.011% 0.011% 0.011% 0.012% 0.012% 0.013% 0.014% 0.014% 0.015% 0.016% 0.016% 0.017% 0.018% 0.019% 0.020% 0.022% 0.024% 0.029% 0.035% 0.043% 0.053% 0.067%
Annualized Variance 2.76% 2.78% 2.81% 2.86% 2.94% 3.03% 3.15% 3.28% 3.44% 3.62% 3.82% 4.04% 4.29% 4.55% 4.84% 5.14% 5.47% 5.82% 6.20% 6.60% 7.03% 7.48% 7.98% 8.63% 9.48% 11.00% 13.38% 16.70% 21.22% 29.72% 2.22% 2.24% 2.28% 2.32% 2.37% 2.43% 2.50% 2.58% 2.67% 2.77% 2.88% 3.00% 3.13% 3.28% 3.43% 3.58% 3.75% 3.93% 4.14% 4.36% 4.60% 4.85% 5.12% 5.47% 6.02% 7.22% 8.83% 10.92% 13.41% 16.80%
Semi-Variance 0.0054% 0.0055% 0.0055% 0.0056% 0.0058% 0.0060% 0.0062% 0.0065% 0.0068% 0.0072% 0.0076% 0.0080% 0.0085% 0.0090% 0.0096% 0.010% 0.011% 0.012% 0.012% 0.013% 0.014% 0.015% 0.016% 0.017% 0.019% 0.021% 0.026% 0.032% 0.041% 0.058% 0.0045% 0.0046% 0.0046% 0.0047% 0.0048% 0.0049% 0.0051% 0.0052% 0.0054% 0.0056% 0.0058% 0.0060% 0.0063% 0.0065% 0.0068% 0.0071% 0.0074% 0.0077% 0.0082% 0.0086% 0.0091% 0.0096% 0.010% 0.011% 0.012% 0.014% 0.017% 0.021% 0.026% 0.034%
Annualized Semi-Variance 1.37% 1.37% 1.39% 1.42% 1.46% 1.50% 1.56% 1.63% 1.71% 1.80% 1.90% 2.02% 2.14% 2.27% 2.41% 2.56% 2.73% 2.90% 3.09% 3.28% 3.50% 3.72% 3.97% 4.29% 4.69% 5.41% 6.56% 8.17% 10.39% 14.54% 1.14% 1.16% 1.17% 1.19% 1.22% 1.25% 1.28% 1.32% 1.36% 1.41% 1.46% 1.52% 1.58% 1.65% 1.72% 1.79% 1.87% 1.95% 2.06% 2.16% 2.28% 2.41% 2.54% 2.70% 2.96% 3.52% 4.29% 5.30% 6.55% 8.50%
Standard Deviation 1.05% 1.05% 1.06% 1.07% 1.08% 1.10% 1.12% 1.14% 1.17% 1.20% 1.23% 1.27% 1.30% 1.34% 1.39% 1.43% 1.47% 1.52% 1.57% 1.62% 1.67% 1.72% 1.78% 1.85% 1.94% 2.09% 2.30% 2.57% 2.90% 3.43% 0.94% 0.94% 0.95% 0.96% 0.97% 0.98% 1.00% 1.01% 1.03% 1.05% 1.07% 1.09% 1.12% 1.14% 1.17% 1.19% 1.22% 1.25% 1.28% 1.32% 1.35% 1.39% 1.43% 1.47% 1.55% 1.69% 1.87% 2.08% 2.31% 2.58%
Annualized Standard Deviation 16.62% 16.67% 16.76% 16.92% 17.13% 17.41% 17.74% 18.12% 18.55% 19.03% 19.55% 20.11% 20.70% 21.33% 21.99% 22.68% 23.39% 24.13% 24.90% 25.69% 26.51% 27.35% 28.25% 29.38% 30.80% 33.17% 36.58% 40.87% 46.06% 54.52% 14.91% 14.98% 15.09% 15.22% 15.39% 15.58% 15.81% 16.06% 16.34% 16.65% 16.98% 17.33% 17.71% 18.10% 18.51% 18.93% 19.36% 19.83% 20.35% 20.89% 21.45% 22.02% 22.63% 23.38% 24.53% 26.87% 29.72% 33.05% 36.63% 40.99%
Semi-Deviation 0.74% 0.74% 0.74% 0.75% 0.76% 0.77% 0.79% 0.81% 0.82% 0.85% 0.87% 0.89% 0.92% 0.95% 0.98% 1.01% 1.04% 1.07% 1.11% 1.14% 1.18% 1.22% 1.25% 1.30% 1.36% 1.47% 1.61% 1.80% 2.03% 2.40% 0.67% 0.68% 0.68% 0.69% 0.69% 0.70% 0.71% 0.72% 0.73% 0.75% 0.76% 0.78% 0.79% 0.81% 0.83% 0.84% 0.86% 0.88% 0.90% 0.93% 0.95% 0.98% 1.00% 1.03% 1.08% 1.18% 1.30% 1.45% 1.61% 1.84%
Annualized Semi-Deviation 11.69% 11.72% 11.79% 11.91% 12.07% 12.27% 12.51% 12.78% 13.09% 13.43% 13.80% 14.20% 14.62% 15.06% 15.53% 16.01% 16.51% 17.03% 17.57% 18.12% 18.70% 19.29% 19.92% 20.70% 21.67% 23.27% 25.61% 28.58% 32.23% 38.13% 10.69% 10.75% 10.82% 10.92% 11.03% 11.16% 11.31% 11.48% 11.66% 11.87% 12.08% 12.32% 12.57% 12.83% 13.10% 13.37% 13.66% 13.97% 14.34% 14.71% 15.11% 15.52% 15.92% 16.42% 17.19% 18.77% 20.71% 23.02% 25.59% 29.16%
Mean Absolute Deviation 0.74% 0.74% 0.74% 0.75% 0.76% 0.77% 0.79% 0.81% 0.83% 0.85% 0.87% 0.90% 0.93% 0.96% 0.99% 1.02% 1.06% 1.09% 1.13% 1.16% 1.20% 1.24% 1.28% 1.33% 1.39% 1.49% 1.62% 1.79% 2.00% 2.33% 0.61% 0.61% 0.61% 0.62% 0.62% 0.63% 0.64% 0.66% 0.67% 0.69% 0.70% 0.72% 0.74% 0.76% 0.78% 0.80% 0.82% 0.85% 0.87% 0.90% 0.93% 0.96% 0.99% 1.03% 1.09% 1.19% 1.31% 1.45% 1.59% 1.71%
CVaR at 95% 2.31% 2.32% 2.33% 2.35% 2.38% 2.42% 2.46% 2.51% 2.57% 2.63% 2.70% 2.78% 2.86% 2.94% 3.03% 3.13% 3.23% 3.33% 3.43% 3.53% 3.64% 3.76% 3.88% 4.04% 4.24% 4.57% 5.04% 5.63% 6.34% 7.53% 2.16% 2.17% 2.19% 2.21% 2.23% 2.26% 2.29% 2.32% 2.36% 2.40% 2.44% 2.49% 2.54% 2.59% 2.64% 2.69% 2.74% 2.80% 2.87% 2.94% 3.01% 3.09% 3.17% 3.25% 3.40% 3.69% 4.07% 4.54% 5.06% 5.91%
EVaR at 95% 4.23% 4.19% 4.16% 4.14% 4.14% 4.16% 4.20% 4.27% 4.36% 4.47% 4.59% 4.73% 4.88% 5.03% 5.20% 5.37% 5.55% 5.74% 5.95% 6.16% 6.37% 6.59% 6.80% 7.03% 7.29% 8.36% 10.21% 12.35% 14.79% 18.69% 4.63% 4.66% 4.68% 4.71% 4.75% 4.79% 4.83% 4.87% 4.92% 4.96% 5.01% 5.06% 5.11% 5.17% 5.24% 5.28% 5.34% 5.42% 5.51% 5.61% 5.74% 5.88% 5.88% 5.81% 5.88% 6.72% 7.97% 9.35% 10.93% 13.85%
Worst Realization 8.35% 8.18% 8.00% 7.84% 7.71% 7.58% 7.79% 8.16% 8.53% 8.90% 9.28% 9.65% 10.02% 10.39% 10.76% 11.13% 11.50% 11.91% 12.36% 12.81% 13.26% 13.71% 14.06% 14.33% 14.21% 15.83% 20.22% 24.87% 29.84% 38.78% 8.61% 8.73% 8.84% 8.96% 9.08% 9.20% 9.33% 9.45% 9.57% 9.69% 9.81% 9.93% 10.06% 10.20% 10.34% 10.45% 10.57% 10.73% 10.91% 11.11% 11.38% 11.65% 11.55% 11.08% 10.44% 13.12% 16.01% 18.98% 22.31% 28.58%
CDaR at 95% 18.45% 18.90% 19.43% 20.03% 20.82% 21.66% 22.58% 23.59% 24.67% 25.79% 26.96% 28.16% 29.38% 30.59% 31.79% 32.87% 33.97% 35.11% 36.26% 37.45% 38.74% 40.06% 40.74% 41.06% 41.47% 42.52% 45.87% 52.09% 63.28% 94.87% 13.88% 13.72% 13.59% 13.48% 13.26% 13.10% 12.97% 12.90% 12.99% 13.15% 13.33% 13.55% 13.80% 14.10% 14.44% 14.87% 15.39% 15.98% 16.72% 17.61% 18.56% 19.56% 21.29% 23.95% 26.96% 30.50% 35.00% 39.41% 44.13% 60.36%
MAX Drawdown 33.40% 34.61% 35.81% 37.07% 38.61% 40.15% 41.68% 43.22% 44.77% 47.16% 49.82% 52.48% 55.13% 57.77% 60.37% 62.77% 65.20% 67.75% 70.33% 72.96% 75.82% 78.68% 80.90% 82.54% 83.69% 83.30% 82.91% 81.65% 83.54% 132.38% 33.59% 33.62% 33.65% 33.65% 33.58% 33.50% 33.43% 33.36% 33.29% 33.22% 33.15% 33.08% 33.01% 32.95% 32.88% 32.58% 32.33% 32.34% 32.80% 33.42% 34.05% 34.67% 36.26% 38.75% 41.26% 44.24% 50.08% 54.83% 56.35% 76.40%
Average Drawdown 3.75% 3.71% 3.71% 3.75% 3.83% 3.94% 4.07% 4.24% 4.42% 4.61% 4.81% 5.03% 5.25% 5.48% 5.72% 5.95% 6.19% 6.45% 6.72% 7.00% 7.31% 7.63% 8.00% 8.53% 9.32% 10.31% 11.68% 13.88% 17.25% 25.90% 2.86% 2.83% 2.80% 2.79% 2.74% 2.71% 2.69% 2.68% 2.71% 2.77% 2.83% 2.91% 3.00% 3.11% 3.23% 3.40% 3.57% 3.77% 4.00% 4.25% 4.52% 4.79% 5.21% 5.84% 6.73% 8.12% 10.00% 12.28% 14.52% 16.76%
EDaR at 95% 22.41% 23.02% 23.75% 24.58% 25.70% 26.91% 28.18% 29.51% 30.90% 32.34% 33.82% 35.33% 36.87% 38.43% 39.98% 41.38% 42.83% 44.36% 45.92% 47.52% 49.27% 51.04% 52.30% 53.23% 53.91% 53.67% 54.46% 57.41% 67.13% 106.15% 19.59% 19.56% 19.55% 19.52% 19.41% 19.34% 19.28% 19.25% 19.27% 19.31% 19.37% 19.44% 19.53% 19.65% 19.79% 19.91% 20.08% 20.40% 20.99% 21.72% 22.52% 23.36% 24.90% 27.26% 29.99% 33.30% 38.10% 42.81% 48.14% 64.47%
First Lower Partial Moment 0.37% 0.37% 0.37% 0.38% 0.38% 0.39% 0.39% 0.40% 0.41% 0.42% 0.44% 0.45% 0.46% 0.48% 0.50% 0.51% 0.53% 0.55% 0.56% 0.58% 0.60% 0.62% 0.64% 0.67% 0.70% 0.74% 0.81% 0.89% 1.00% 1.16% 0.30% 0.30% 0.31% 0.31% 0.31% 0.32% 0.32% 0.33% 0.34% 0.34% 0.35% 0.36% 0.37% 0.38% 0.39% 0.40% 0.41% 0.42% 0.44% 0.45% 0.46% 0.48% 0.49% 0.51% 0.54% 0.59% 0.66% 0.73% 0.80% 0.85%
Ulcer Index 0.059 0.060 0.061 0.063 0.065 0.067 0.070 0.073 0.076 0.079 0.083 0.086 0.090 0.094 0.097 0.10 0.10 0.11 0.11 0.12 0.12 0.13 0.13 0.13 0.14 0.15 0.17 0.20 0.24 0.36 0.046 0.046 0.046 0.046 0.045 0.044 0.044 0.044 0.044 0.045 0.046 0.047 0.048 0.049 0.051 0.053 0.055 0.058 0.061 0.065 0.069 0.072 0.079 0.088 0.100 0.12 0.14 0.16 0.19 0.24
Gini Mean Difference 1.09% 1.09% 1.10% 1.11% 1.12% 1.14% 1.16% 1.19% 1.22% 1.25% 1.29% 1.33% 1.37% 1.41% 1.46% 1.50% 1.55% 1.60% 1.66% 1.71% 1.76% 1.82% 1.88% 1.96% 2.05% 2.19% 2.40% 2.66% 2.98% 3.49% 0.91% 0.91% 0.92% 0.93% 0.94% 0.95% 0.97% 0.99% 1.01% 1.03% 1.05% 1.08% 1.11% 1.13% 1.17% 1.20% 1.23% 1.26% 1.30% 1.34% 1.38% 1.42% 1.46% 1.52% 1.60% 1.75% 1.93% 2.13% 2.35% 2.54%
Value at Risk at 95% 1.52% 1.53% 1.54% 1.57% 1.59% 1.59% 1.59% 1.63% 1.68% 1.73% 1.78% 1.84% 1.91% 1.97% 2.03% 2.07% 2.12% 2.19% 2.24% 2.32% 2.40% 2.49% 2.58% 2.66% 2.80% 2.97% 3.20% 3.57% 4.02% 4.82% 1.35% 1.34% 1.36% 1.36% 1.35% 1.38% 1.39% 1.42% 1.45% 1.47% 1.48% 1.51% 1.54% 1.58% 1.64% 1.68% 1.73% 1.78% 1.82% 1.88% 1.93% 2.01% 2.06% 2.12% 2.21% 2.43% 2.71% 2.99% 3.29% 3.60%
Drawdown at Risk at 95% 14.10% 14.49% 14.66% 15.01% 15.22% 15.35% 15.64% 16.40% 17.04% 17.80% 18.37% 19.09% 19.83% 20.52% 21.17% 21.67% 22.41% 23.20% 23.84% 24.89% 25.77% 26.62% 27.20% 27.77% 29.62% 32.92% 37.36% 44.20% 55.01% 79.05% 10.58% 10.54% 10.49% 10.33% 10.22% 10.14% 10.06% 9.94% 9.92% 9.90% 9.74% 10.01% 10.23% 10.50% 10.93% 11.54% 12.15% 12.79% 13.57% 14.42% 15.34% 16.36% 17.62% 19.54% 22.15% 25.98% 29.08% 32.80% 37.57% 51.44%
Entropic Risk Measure at 95% 3.00 3.00 3.00 3.00 3.00 3.00 3.00 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 3.00 2.99 2.99 2.99 2.99 2.99 2.99 2.99 2.99 3.00 3.00 3.00 3.00 3.00
Fourth Central Moment 0.000016% 0.000016% 0.000017% 0.000017% 0.000018% 0.000019% 0.000021% 0.000022% 0.000024% 0.000026% 0.000028% 0.000031% 0.000034% 0.000037% 0.000041% 0.000045% 0.000050% 0.000055% 0.000062% 0.000070% 0.000079% 0.000088% 0.000097% 0.00011% 0.00012% 0.00016% 0.00027% 0.00047% 0.00085% 0.0020% 0.000016% 0.000016% 0.000017% 0.000018% 0.000019% 0.000020% 0.000021% 0.000022% 0.000023% 0.000024% 0.000026% 0.000028% 0.000029% 0.000031% 0.000033% 0.000035% 0.000037% 0.000040% 0.000043% 0.000046% 0.000050% 0.000054% 0.000058% 0.000062% 0.000070% 0.000097% 0.00014% 0.00023% 0.00037% 0.00077%
Fourth Lower Partial Moment 0.000006% 0.000006% 0.000006% 0.000006% 0.000006% 0.000006% 0.000007% 0.000007% 0.000007% 0.000008% 0.000009% 0.000010% 0.000011% 0.000012% 0.000014% 0.000016% 0.000018% 0.000020% 0.000023% 0.000026% 0.000029% 0.000033% 0.000038% 0.000046% 0.000056% 0.000088% 0.00016% 0.00031% 0.00059% 0.0014% 0.000008% 0.000008% 0.000008% 0.000008% 0.000008% 0.000009% 0.000009% 0.000009% 0.000009% 0.000010% 0.000010% 0.000011% 0.000011% 0.000011% 0.000012% 0.000012% 0.000013% 0.000014% 0.000015% 0.000016% 0.000017% 0.000019% 0.000020% 0.000021% 0.000024% 0.000035% 0.000057% 0.000098% 0.00017% 0.00042%
Skew 26.18% 27.63% 28.80% 29.68% 30.29% 30.54% 30.46% 30.07% 29.42% 28.54% 27.50% 26.32% 25.06% 23.76% 22.43% 21.04% 19.81% 18.96% 18.23% 17.47% 16.62% 15.72% 13.34% 9.76% 5.83% -2.14% -11.06% -19.84% -27.79% -37.39% 0.11% 1.66% 3.43% 5.49% 8.23% 11.10% 13.99% 16.88% 19.70% 22.40% 24.93% 27.31% 29.48% 31.32% 33.01% 35.06% 36.87% 37.81% 36.87% 35.75% 34.15% 32.59% 32.96% 34.39% 35.10% 34.55% 32.65% 28.74% 21.77% -2.90%
Kurtosis 1291.65% 1314.19% 1327.57% 1332.93% 1335.68% 1330.10% 1317.27% 1298.53% 1275.27% 1248.90% 1220.76% 1191.72% 1162.62% 1133.92% 1106.01% 1077.58% 1053.12% 1037.16% 1030.03% 1021.73% 1010.78% 999.43% 969.27% 922.64% 869.32% 859.88% 940.30% 1060.15% 1193.52% 1428.95% 2041.35% 2076.87% 2102.02% 2117.46% 2126.55% 2124.76% 2112.60% 2091.31% 2061.98% 2025.82% 1984.31% 1938.84% 1890.89% 1843.01% 1794.00% 1742.88% 1695.44% 1648.82% 1589.85% 1536.43% 1494.34% 1453.67% 1394.40% 1315.91% 1235.13% 1177.90% 1176.14% 1210.04% 1301.37% 1739.55%
Sharpe Ratio 0.059 0.062 0.064 0.066 0.068 0.070 0.071 0.072 0.073 0.073 0.074 0.074 0.074 0.074 0.074 0.074 0.073 0.073 0.072 0.072 0.072 0.071 0.070 0.069 0.067 0.064 0.059 0.054 0.049 0.042 0.058 0.059 0.059 0.060 0.061 0.062 0.063 0.064 0.064 0.065 0.065 0.065 0.066 0.066 0.066 0.066 0.066 0.065 0.065 0.064 0.064 0.063 0.062 0.059 0.055 0.049 0.043 0.038 0.034 0.035
Annualized Sharpe Ratio 0.94 0.98 1.02 1.05 1.08 1.11 1.13 1.14 1.16 1.16 1.17 1.17 1.17 1.17 1.17 1.17 1.16 1.16 1.15 1.14 1.14 1.13 1.12 1.10 1.07 1.02 0.94 0.86 0.78 0.67 0.92 0.93 0.94 0.95 0.97 0.98 1.00 1.01 1.02 1.03 1.03 1.04 1.04 1.04 1.04 1.04 1.04 1.04 1.03 1.02 1.01 1.00 0.98 0.94 0.88 0.78 0.69 0.60 0.53 0.55
Sortino Ratio 0.084 0.088 0.091 0.094 0.097 0.099 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.100 0.098 0.096 0.091 0.085 0.077 0.070 0.060 0.081 0.082 0.083 0.083 0.085 0.087 0.088 0.089 0.090 0.091 0.091 0.092 0.092 0.093 0.093 0.093 0.093 0.093 0.092 0.091 0.091 0.090 0.088 0.084 0.079 0.070 0.062 0.054 0.048 0.049
Annualized Sortino Ratio 1.34 1.40 1.45 1.50 1.54 1.57 1.60 1.62 1.64 1.65 1.66 1.66 1.66 1.66 1.66 1.65 1.65 1.64 1.63 1.62 1.61 1.60 1.58 1.56 1.52 1.45 1.34 1.23 1.11 0.96 1.28 1.30 1.31 1.32 1.35 1.37 1.40 1.41 1.43 1.44 1.45 1.46 1.47 1.47 1.47 1.48 1.48 1.47 1.46 1.45 1.44 1.42 1.39 1.33 1.26 1.12 0.98 0.86 0.76 0.78
Mean Absolute Deviation Ratio 0.084 0.088 0.091 0.094 0.097 0.099 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.10 0.099 0.099 0.098 0.096 0.094 0.090 0.084 0.078 0.071 0.062 0.090 0.091 0.092 0.093 0.095 0.096 0.097 0.098 0.099 0.099 0.099 0.099 0.099 0.099 0.098 0.098 0.097 0.096 0.095 0.094 0.093 0.092 0.089 0.085 0.079 0.070 0.062 0.054 0.049 0.053
First Lower Partial Moment Ratio 0.17 0.18 0.18 0.19 0.19 0.20 0.20 0.20 0.21 0.21 0.21 0.21 0.21 0.21 0.21 0.21 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.19 0.19 0.18 0.17 0.16 0.14 0.12 0.18 0.18 0.18 0.19 0.19 0.19 0.19 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.20 0.19 0.19 0.19 0.19 0.19 0.18 0.18 0.17 0.16 0.14 0.12 0.11 0.098 0.11
Value at Risk Ratio at 95% 0.041 0.042 0.044 0.045 0.046 0.048 0.050 0.050 0.051 0.051 0.051 0.051 0.050 0.050 0.050 0.051 0.051 0.051 0.051 0.050 0.050 0.049 0.049 0.048 0.047 0.045 0.043 0.039 0.035 0.030 0.040 0.041 0.041 0.042 0.044 0.044 0.045 0.045 0.046 0.046 0.047 0.047 0.047 0.047 0.047 0.047 0.046 0.046 0.046 0.045 0.045 0.044 0.043 0.041 0.039 0.034 0.030 0.026 0.024 0.025
CVaR Ratio at 95% 0.027 0.028 0.029 0.030 0.031 0.032 0.032 0.033 0.033 0.033 0.034 0.034 0.034 0.034 0.034 0.034 0.033 0.033 0.033 0.033 0.033 0.033 0.032 0.032 0.031 0.029 0.027 0.025 0.022 0.019 0.025 0.025 0.026 0.026 0.027 0.027 0.027 0.028 0.028 0.028 0.029 0.029 0.029 0.029 0.029 0.029 0.029 0.029 0.029 0.029 0.029 0.028 0.028 0.027 0.025 0.023 0.020 0.017 0.015 0.015
Entropic Risk Measure Ratio at 95% 0.00021 0.00022 0.00023 0.00024 0.00025 0.00026 0.00026 0.00027 0.00028 0.00029 0.00030 0.00031 0.00032 0.00033 0.00034 0.00035 0.00036 0.00037 0.00038 0.00039 0.00040 0.00041 0.00042 0.00043 0.00044 0.00045 0.00046 0.00047 0.00048 0.00048 0.00018 0.00018 0.00019 0.00019 0.00020 0.00020 0.00021 0.00021 0.00022 0.00023 0.00023 0.00024 0.00024 0.00025 0.00026 0.00026 0.00027 0.00027 0.00028 0.00028 0.00029 0.00029 0.00029 0.00029 0.00029 0.00028 0.00027 0.00026 0.00026 0.00030
EVaR Ratio at 95% 0.015 0.016 0.016 0.017 0.018 0.018 0.019 0.019 0.020 0.020 0.020 0.020 0.020 0.020 0.020 0.020 0.019 0.019 0.019 0.019 0.019 0.019 0.018 0.018 0.018 0.016 0.013 0.011 0.0096 0.0078 0.012 0.012 0.012 0.012 0.012 0.013 0.013 0.013 0.013 0.014 0.014 0.014 0.014 0.014 0.015 0.015 0.015 0.015 0.015 0.015 0.015 0.015 0.015 0.015 0.015 0.012 0.010 0.0084 0.0071 0.0065
Worst Realization Ratio 0.0074 0.0079 0.0085 0.0090 0.0095 0.010 0.010 0.010 0.0100 0.0099 0.0098 0.0097 0.0096 0.0096 0.0095 0.0094 0.0094 0.0093 0.0092 0.0091 0.0090 0.0089 0.0089 0.0089 0.0092 0.0084 0.0068 0.0056 0.0048 0.0037 0.0063 0.0063 0.0064 0.0064 0.0065 0.0066 0.0067 0.0068 0.0069 0.0070 0.0071 0.0072 0.0073 0.0073 0.0074 0.0075 0.0076 0.0076 0.0076 0.0076 0.0076 0.0075 0.0076 0.0078 0.0082 0.0063 0.0051 0.0041 0.0035 0.0032
Drawdown at Risk Ratio at 95% 0.0044 0.0045 0.0046 0.0047 0.0048 0.0050 0.0051 0.0050 0.0050 0.0049 0.0049 0.0049 0.0049 0.0048 0.0048 0.0048 0.0048 0.0048 0.0048 0.0047 0.0046 0.0046 0.0046 0.0046 0.0044 0.0041 0.0037 0.0032 0.0026 0.0018 0.0051 0.0052 0.0054 0.0056 0.0058 0.0060 0.0062 0.0065 0.0067 0.0069 0.0071 0.0071 0.0071 0.0071 0.0070 0.0068 0.0066 0.0064 0.0061 0.0059 0.0056 0.0054 0.0050 0.0045 0.0039 0.0032 0.0028 0.0024 0.0021 0.0018
CDaR Ratio at 95% 0.0034 0.0034 0.0035 0.0035 0.0035 0.0035 0.0035 0.0035 0.0034 0.0034 0.0034 0.0033 0.0033 0.0032 0.0032 0.0032 0.0032 0.0032 0.0031 0.0031 0.0031 0.0031 0.0031 0.0031 0.0032 0.0031 0.0030 0.0027 0.0022 0.0015 0.0039 0.0040 0.0041 0.0043 0.0045 0.0046 0.0048 0.0050 0.0051 0.0052 0.0052 0.0053 0.0053 0.0053 0.0053 0.0053 0.0052 0.0051 0.0050 0.0048 0.0046 0.0045 0.0041 0.0036 0.0032 0.0027 0.0023 0.0020 0.0018 0.0015
Calmar Ratio 0.0019 0.0019 0.0019 0.0019 0.0019 0.0019 0.0019 0.0019 0.0019 0.0019 0.0018 0.0018 0.0018 0.0017 0.0017 0.0017 0.0017 0.0016 0.0016 0.0016 0.0016 0.0016 0.0015 0.0016 0.0016 0.0016 0.0016 0.0017 0.0017 0.0011 0.0016 0.0016 0.0017 0.0017 0.0018 0.0018 0.0019 0.0019 0.0020 0.0020 0.0021 0.0022 0.0022 0.0023 0.0023 0.0024 0.0025 0.0025 0.0025 0.0025 0.0025 0.0025 0.0024 0.0022 0.0021 0.0019 0.0016 0.0014 0.0014 0.0012
Average Drawdown Ratio 0.017 0.018 0.018 0.019 0.019 0.019 0.019 0.019 0.019 0.019 0.019 0.019 0.018 0.018 0.018 0.018 0.017 0.017 0.017 0.017 0.016 0.016 0.016 0.015 0.014 0.013 0.012 0.010 0.0083 0.0056 0.019 0.020 0.020 0.021 0.022 0.022 0.023 0.024 0.024 0.025 0.025 0.025 0.024 0.024 0.024 0.023 0.022 0.022 0.021 0.020 0.019 0.018 0.017 0.015 0.013 0.010 0.0081 0.0064 0.0053 0.0054
EDaR Ratio at 95% 0.0028 0.0028 0.0029 0.0029 0.0029 0.0028 0.0028 0.0028 0.0028 0.0027 0.0027 0.0026 0.0026 0.0026 0.0026 0.0025 0.0025 0.0025 0.0025 0.0025 0.0024 0.0024 0.0024 0.0024 0.0024 0.0025 0.0025 0.0024 0.0021 0.0014 0.0028 0.0028 0.0029 0.0029 0.0030 0.0031 0.0032 0.0033 0.0034 0.0035 0.0036 0.0037 0.0037 0.0038 0.0039 0.0039 0.0040 0.0040 0.0040 0.0039 0.0038 0.0038 0.0035 0.0032 0.0029 0.0025 0.0021 0.0018 0.0016 0.0014
Ulcer Index Ratio 0.010 0.011 0.011 0.011 0.011 0.011 0.011 0.011 0.011 0.011 0.011 0.011 0.011 0.011 0.010 0.010 0.010 0.010 0.010 0.010 0.0099 0.0098 0.0097 0.0095 0.0092 0.0087 0.0081 0.0070 0.0058 0.0040 0.012 0.012 0.012 0.013 0.013 0.014 0.014 0.015 0.015 0.015 0.015 0.015 0.015 0.015 0.015 0.015 0.015 0.014 0.014 0.013 0.013 0.012 0.011 0.0099 0.0086 0.0072 0.0059 0.0048 0.0041 0.0038
Gini Mean Difference Ratio 0.057 0.060 0.062 0.064 0.066 0.067 0.068 0.069 0.070 0.070 0.070 0.071 0.071 0.070 0.070 0.070 0.070 0.069 0.069 0.068 0.068 0.067 0.067 0.065 0.064 0.061 0.057 0.052 0.048 0.042 0.060 0.060 0.061 0.062 0.063 0.064 0.065 0.065 0.066 0.066 0.066 0.066 0.066 0.066 0.066 0.066 0.065 0.065 0.064 0.063 0.062 0.062 0.060 0.057 0.054 0.048 0.042 0.037 0.033 0.035
Effective Number of Assets 8.200105310174294 8.59167564989511 8.914061803581202 9.20057593224975 9.669076363624884 10.042905188114835 10.296356964249894 10.407690290603215 10.36833537771513 10.182061194354427 9.864764715987107 9.437583988064256 8.93642825430989 8.39936034148487 7.843069929156864 7.305664213683842 6.7881858925195955 6.322661810342193 5.894001701423032 5.474123745523491 5.083026522037526 4.687782011559598 4.402394853192732 4.022087577333231 3.600838708075875 3.2020819241703986 2.5798056188192846 2.0201935849251913 1.5152184941723117 1.000000132533317 8.200105310174294 8.59167564989511 8.914061803581202 9.20057593224975 9.669076363624884 10.042905188114835 10.296356964249894 10.407690290603215 10.36833537771513 10.182061194354427 9.864764715987107 9.437583988064256 8.93642825430989 8.39936034148487 7.843069929156864 7.305664213683842 6.7881858925195955 6.322661810342193 5.894001701423032 5.474123745523491 5.083026522037526 4.687782011559598 4.402394853192732 4.022087577333231 3.600838708075875 3.2020819241703986 2.5798056188192846 2.0201935849251913 1.5152184941723117 1.000000132533317
Assets Number 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20


Instead of providing efficient_frontier_size=30, you can also provide an array of lower bounds for the expected returns using min_return. In the below example, we find the 5 portfolios that minimize the variance under a minimum return constraint of 15%, 20%, 25%, 30% and 35% (annualized):

model = MeanRisk(
    risk_measure=RiskMeasure.VARIANCE,
    min_return=np.array([0.15, 0.20, 0.25, 0.30, 0.35]) / 252,
    portfolio_params=dict(name="Variance"),
)

population = model.fit_predict(X_train)

population.plot_measures(
    x=RiskMeasure.ANNUALIZED_STANDARD_DEVIATION,
    y=PerfMeasure.ANNUALIZED_MEAN,
    color_scale=RatioMeasure.ANNUALIZED_SHARPE_RATIO,
    hover_measures=[RiskMeasure.MAX_DRAWDOWN, RatioMeasure.ANNUALIZED_SORTINO_RATIO],
)


Total running time of the script: (0 minutes 0.994 seconds)

Gallery generated by Sphinx-Gallery