Forums  > Pricing & Modelling  > Formula for Optimal Portfolio of 2 Assets when No Shorting Allowed?  
Page 1 of 1
Display using:  


Total Posts: 8
Joined: Aug 2016
Posted: 2016-08-01 05:46

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 non-negative weights.

Does anyone know a formula for non-negative weights for a two-asset optimal portfolio that does not allow short selling?


Total Posts: 1024
Joined: Nov 2004
Posted: 2016-08-01 10:20
> optimal portfolio (i.e highest Sharpe ratio)

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.


Total Posts: 285
Joined: Jan 2015
Posted: 2016-08-01 17:54
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.

Good questions outrank easy answers. -Paul Samuelson


Total Posts: 8
Joined: Aug 2016
Posted: 2016-08-01 20:55
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.


Total Posts: 285
Joined: Jan 2015
Posted: 2016-08-01 21:29
The issue with negative returns isn't from the boundary conditions, it's because the formula you're using isn't defined for non-positive 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 0-return assets (with 0 risk-free rate), the formula isn't even mathematically defined. (The problem comes from the denominator becoming non-positive).

If you want to properly handle negative return assets, just invert the asset. So in your example transform asset B to asset B-prime:

Rb-prime = -Rb = 22%.
Corr(A, B-prime) = -Corr(A, B) = 16%.
StdevB-prime = StdevB = 10%.
Wb-prime = Wa - 1
Wb-prime is constrained in [-1, 0]

Then solve normally and inverse the transform. Wb = -Wb-prime

Good questions outrank easy answers. -Paul Samuelson


Total Posts: 8
Joined: Aug 2016
Posted: 2016-08-01 22:14
I am sorry, but I tried using your method but couldn't get the expected results.
Asset A: Ra=20%, STDEVa=13%
Asset B-prime: Rb-prime=22%, STDEVb-prime=10%

The formula returns Wa=27%.

Then Wb-prime=Wa-1=27%-1=-73%

It's still overweighting asset B with negative return.

Could you please let me know why?
Thank you very much.


Total Posts: 285
Joined: Jan 2015
Posted: 2016-08-01 22:49
Sorry, typo in my original formulae:

Wb-prime = 1 - Wa
Wb = -Wb-prime
=> Wb = Wa - 1

So the unconstrained optimization is 27% Wa, -73% Wb. The constraint boundary is 100% Wa, 0% Wb.

Good questions outrank easy answers. -Paul Samuelson


Total Posts: 8
Joined: Aug 2016
Posted: 2016-08-02 00:11
What if the formula returns a negative number for Wa?
For example,
Ra=1%, STDEVa=21%
Rb=-3% (so Rb-prime=3%), STDEVb=12%

Formula returns Wa=-16% and Wb-prime=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%

It returns Wa=-4048%, Wb-prime=4148%, Wb=-4148%.

The Wa-Sharpe 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.


Total Posts: 285
Joined: Jan 2015
Posted: 2016-08-02 00:58
First Example

The constraints on Wb-prime is [-1, 0]. So once you enforce the constraint

Wb-prime -> 0.
Wa = Wb-prime + 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(Return-portfolio) = .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 non-negative (as is the case here), the formula's properly defined. Even if the asset returns are non-positive. If the denominator's negative, there's a singularity in the optimization.

Good questions outrank easy answers. -Paul Samuelson


Total Posts: 8
Joined: Aug 2016
Posted: 2016-08-02 01:48
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 non-negative.
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 0-100%?

I am sorry that I keep asking questions. Thank you so much for your time and answers.


Total Posts: 468
Joined: Mar 2007
Posted: 2016-08-02 13:58
1. I'm surprised that no one has as yet mentioned that this (homework?) should be in Basics.
2. WTF!


Total Posts: 285
Joined: Jan 2015
Posted: 2016-08-05 06:36
1) Yes, meant the second case. I think you have a mis-calculation. 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.

Good questions outrank easy answers. -Paul Samuelson
Previous Thread :: Next Thread 
Page 1 of 1