Max Sharpe Optimization with L2 Regularisation does not yield Max Sharpe Portfolio
What are you trying to do?
I am trying to find the Optimal Max Sharpe Portfolio by using "max_sharpe" method. For diversification purposes I would like to include L2 Regularisation.
I am aware of the fact, that including L2 Regularisation might lead to difficulties in the optimization process (I got the User Warning: "max_sharpe transforms the optimization problem so additional objectives may not work as expected.").
Despite the User Warning, seemingly reasonable results were provided for my dataset. To check the results, I was thinking about an alternative way to come up with the Max Sharpe Portfolio: To first get the efficient frontier and then search for the portfolio on the efficient frontier, that has the highest sharpe ratio.
Interestingly, when searching for the portfolio with the highest Sharpe Ratio on the efficient frontier, it differs from the Max Sharpe Portfolio attained by the "max_sharpe" portfolio optimization and it even has a higher Sharpe Ratio.
The difference between the Portfolio on the Efficient Frontier with Maximum Sharpe Ratio and the Optimal Max Sharpe Portfolio obtained by "max_sharpe" optimization does not exist (or only to a neglectible extent) when the L2 Optimization is not considered in the set-up of the problem.
What have you tried?
In the first step calculated the returns of the efficient frontier (same set of constraints and L2 gamma value as defined in the "max_sharpe" setup) by using the function:
def ef_default_returns_range(ef, points): """ Helper function to generate a range of returns from the GMV returns to the maximum (constrained) returns """ ef_minvol = copy.deepcopy(ef) ef_maxret = copy.deepcopy(ef)
ef_minvol.min_volatility()
ef_min_ret = ef_minvol.portfolio_performance()[0]
ef_max_ret = ef_maxret._max_return()
return np.linspace(ef_min_ret, ef_max_ret-0.001, points)
Afterwards, using the function:
def get_single_target_weights_and_metrics(target_return, ef): ef_i = copy.deepcopy(ef) ef_i.efficient_return(target_return) return ef_i.weights, ef_i.portfolio_performance(risk_free_rate = 0)
I obtained the Mean, Volatility and Sharpe Ratio Metrics as well as the weights for each portfolio on the efficient frontier. Searching for the highest Sharpe Ratio among these portfolios, I found portfolios beating the portfolio obtained by "max_sharpe" optimization.
Do you know, why this is the case? Shouldn't the two ways lead to the same portfolio and which portfolio should I consider as the "true" Max Sharpe Portfolio?
Thanks in advance.
Kind regards Nicole
Hello @Nikolina8 , did you manage to understand what happened? I had a similar problem. When I run Max Sharpe with L2 and use the volatility of this portfolio in the "efficient_risk" function, the portfolio that efficient_risk gives me is different from the Max Sharpe portfolio. Both the weights and the Sharpe are different.
MAX SHARPE Expected annual return: 11.0% Annual volatility: 5.7% Sharpe Ratio: 0.61
TARGET VOLATILITY Expected annual return: 10.5% Annual volatility: 5.7% Sharpe Ratio: 0.54
Can you help us here? @robertmartin8
Let me check the issue, for my convenience would you guys share with me an encoded version of your dataset
Sure! I'll post here some dataset and also my notebook code. And I have another question.
You can see in # 3 that the minimum Vol with L2 has a greater vol than Max Sharpe and Target Vol with L2. This does not makes sense to me. Can you help me in that too?
The results in # 4 are the same, when not using L2, Max Sharpe and Target Vol have both the same answer.
But when we use L2, (in # 5) we have different returns and sharpe ratio, also different weights.
@88d52bdba0366127fffca9dfa93895 hi there! Did you have a chance to check the code I attached?
Hi @HugoAzv and @Nikolina8,
I still haven't finished checking, so I'll give a quick result.
You can see in # 3 that the minimum Vol with L2 has a greater vol than Max Sharpe and Target Vol with L2. This does not makes sense to me. Can you help me in that too?
Yes, your Minimum Variance with L2 has a greater volatility than Max Sharpe with L2, b/c you'r going with L2, not the bare optimization problem. The Minimum Variance with L2 has:
Expected annual return: 11.4%
Annual volatility: 5.9%
Sharpe Ratio: 0.47
and Weight:
AAA BBB CCC DDD EEE FFF GGG HHH
0 0.16736 0.0 0.16686 0.15 0.1 0.16578 0.15 0.1
then it has objective value as 0.059 + np.sum(np.array([0.16736, 0.0, 0.16686, 0.15, 0.1, 0.16578, 0.15, 0.1])**2) = 0.2073346376. Comparing with the Max Sharpe with L2 which has
Expected annual return: 12.2%
Annual volatility: 4.4%
Sharpe Ratio: 0.80
and Weight:
AAA | BBB | CCC | DDD | EEE | FFF | GGG | HHH
-- | -- | -- | -- | -- | -- | -- | --
0.14597 | 0.0 | 0.23074 | 0.025 | 0.1 | 0.24829 | 0.15 | 0.1
then its objective value as 0.044 + np.sum(np.array([0.14597, 0.0, 0.23074, 0.025, 0.1, 0.24829, 0.15, 0.1])**2) = 0.22332111259999998. So in the L2 Regularization, the Minimum Variance is better one. It means that it is more diversified while the Max Sharpe is more concentrated on some assets (CCC and FFF).