cyrix


Total Posts: 5 
Joined: Aug 2016 


I am looking for a formula to calculate the weights of two risky assets that produce the optimal portfolio (i.e highest Sharpe ratio).
So far I have found the following formula from a website of University of Missouri
However, this formula often produces negative weights. For example, it returns a weight of 24% for Asset A when Risk Free Rate=3%, Ra=5%, STDEVa=15%, Rb=10%, STDEVb=20%, CORRab=50%. It is probably because it allows short selling, making it not applicable in my situation. I need to find nonnegative weights.
Does anyone know a formula for nonnegative weights for a twoasset optimal portfolio that does not allow short selling?





goldorak


Total Posts: 979 
Joined: Nov 2004 


> optimal portfolio (i.e highest Sharpe ratio) lol
You are trying to do an optimization WITH constraint. No closed form formula, but usual optimizers apply.
If this may be of any help: portfolio optim, Roncalli 
If you are not living on the edge you are taking up too much space. 



With two assets the only local maximum is the value from the formula you posted. Basic convex optimization would select the boundary of the constraint. (If the optimal point falls in the constraints, then obviously use that). E.g. if the formula says 34% A/134% B, then the optimal constrained solution would be 0% A/100% B. 




cyrix


Total Posts: 5 
Joined: Aug 2016 


This method not reliable if one of the assets has low or negative return. For example, if Risk Free Rate=0%, Ra=20%, STDEVa=13%, Rb=22%, STDEVb=10%, CORRab=16%, it returns 0% for Asset A (from unbounded 59% as you suggested). But in Solver and reality, 100% in Asset A gives highest Sharpe.





The issue with negative returns isn't from the boundary conditions, it's because the formula you're using isn't defined for nonpositive assets. Consider the example you posted. The formula outputs an optimal unconstrained negative weight for Asset A. Does that make sense? Asset A has positive returns and Asset B negative returns. Shorting Asset A to buy Asset B would result in negative expected returns.
Obviously simply buying 100% Asset A and 0% Asset B would be superior to that, so the formula's clearly erroneous in defining optimal allocations under these conditions. As another example consider, two 0return assets (with 0 riskfree rate), the formula isn't even mathematically defined. (The problem comes from the denominator becoming nonpositive).
If you want to properly handle negative return assets, just invert the asset. So in your example transform asset B to asset Bprime:
Rbprime = Rb = 22%. Corr(A, Bprime) = Corr(A, B) = 16%. StdevBprime = StdevB = 10%. Wbprime = Wa  1 Wbprime is constrained in [1, 0]
Then solve normally and inverse the transform. Wb = Wbprime 




cyrix


Total Posts: 5 
Joined: Aug 2016 


I am sorry, but I tried using your method but couldn't get the expected results. Asset A: Ra=20%, STDEVa=13% Asset Bprime: Rbprime=22%, STDEVbprime=10% Corr(A,Bprime)=16%
The formula returns Wa=27%.
Then Wbprime=Wa1=27%1=73% Wb=1*73%=73%.
It's still overweighting asset B with negative return.
Could you please let me know why? Thank you very much.





Sorry, typo in my original formulae:
Wbprime = 1  Wa Wb = Wbprime => Wb = Wa  1
So the unconstrained optimization is 27% Wa, 73% Wb. The constraint boundary is 100% Wa, 0% Wb. 




cyrix


Total Posts: 5 
Joined: Aug 2016 


What if the formula returns a negative number for Wa? For example, Ra=1%, STDEVa=21% Rb=3% (so Rbprime=3%), STDEVb=12% CORR(A,B)=41%.
Formula returns Wa=16% and Wbprime=116%, i.e Wb=116%. After constrains, the portfolios becomes 0% in A and 0% in B.
But shouldn't it be overweighting A instead of 0%, because A has positive returns? Solver also gives 90% A and 10% B with a positive sharpe.
Could you please let me know how to transform them into a positive weight ratio when both Wa and Wb are negative?
Thank you.
Edit: another example is
Ra=35%, STDEVa=15% Rb=2%, STDEVb=10% CORR(A,B)=72%.
It returns Wa=4048%, Wbprime=4148%, Wb=4148%.
The WaSharpe relationship chart is like this, so the optimal weight should be around 50/50, both positive, and I am wondering if there is a way to derive it from the negative four thousands.





First Example
The constraints on Wbprime is [1, 0]. So once you enforce the constraint
Wbprime > 0. Wa = Wbprime + 1 Wa = 0 + 1 = 1 Wb = 1  Wa = 0
Constrained solution is 100% Wa, 0% Wb.
I think you may have an error in your solver program. 100% Wa has a Sharpe of 0.0476. (Ra/StdevA = .01/.21).
90% Wa/10% Wb has a lower Sharpe of 0.0325 by my calculations:
E(Returnportfolio) = .9 * Ra + .1 * Rb = 0.6% Stdev(Portfolio) = Sqrt((.9 * StdevA)^2 + (.1 * StdevB)^2 + 2 * .9 * .1 * StdevA * StdevB * Corr) = 18.4% Sharpe(Portfolio) = 0.0325
Second example
Inverting the asset is technically a hack as it shifts the unconstrained solution domain. The optimal weight formula solves within the domain of [Wa, Wb] such that Wa + Wb = 1. By inverting the asset you're solving in the domain of [Wa, Wb] such that Wa  Wb = 1.
Once you enforce the constraint, in most scenarios the two solutions project to the same boundary. In this example the assumption fails.
Another approach you can take is by checking the denominator of optimal weight formula. If the denominator is nonnegative (as is the case here), the formula's properly defined. Even if the asset returns are nonpositive. If the denominator's negative, there's a singularity in the optimization. 




cyrix


Total Posts: 5 
Joined: Aug 2016 


Thank you very much for your detailed explanation.
I apologize as there is a couple of things that I want to clarify
1. "as is the case here" did you mean the first example or the second? I calculated the denominator for the second example and it's negative rather than nonnegative. 2. By "Singularity" did you mean a curve with a single max point somewhere in between like in the chart below? If this is the case, is there a way to convert the 4048%/4148% from the formula into positive weights of 0100%?
I am sorry that I keep asking questions. Thank you so much for your time and answers.





1. I'm surprised that no one has as yet mentioned that this (homework?) should be in Basics. 2. WTF! https://forum.W****tt.com/viewtopic.php?f=34&t=100046 https://www.elitetrader.com/et/threads/formulaforoptimalportfolioof2assetswhennoshortingallowed.301631/ http://quant.stackexchange.com/questions/28419/formulaforoptimalportfolioof2assetswhennoshortingallowed 





1) Yes, meant the second case. I think you have a miscalculation. Denominator is positive:
Ra = .35 Sa = .15 Rb = .02 Sa = .1 Sab = .72 * .1 * .15 = .0108
Ra * Sb^2 + Rb*Sa^2  (Ra+Rb)*Sab = .35 * .1^2 + .02*.15^2  (.35.02) * .0108 = .0035  .00045 + 0.003564 = .006614 > 0
2) The optimal weight formula forms a hyperbola with respect to the asset returns. Try it yourself with the above example. Calculate the optimal weight while varying Ra from 25% to 35%. You'll see the plot forms a hyperbola with a singularity around .032. As Ra approaches this value from the right, the optimal (unconstrained) weight goes to +Infinity.
For anything at or below the singularity, the optimal weight is still +Infinity. In fact anytime the denominator is negative the optimal value will be +/ Inf.



