Portfolio

Minimum Variance with Positive Weights Constraint

The following example uses the same data from the previous posts.
In the real world, sometimes you cannot short an asset easily, so I added another constraint to the optimisation to ensure all weights are positive.

n3

Run the same code but add bounds for the optimiser

# positive weight portfolio
bnd=[(0, 1),(0, 1),(0, 1),(0, 1)] # only positive weights
res2= minimize(calculate_portfolio_var, w0, args=V, bounds = bnd, method='SLSQP',constraints=cons)
w_g_long_only = res2.x

The weights of unconstrained MVP
n31

The weights of long only MVP, Asset 1 has a slightly positive weight
n32

And it’s easy to limit weights on individual holdings
E.g. an asset cannot be more than  50% of the portfolio

bnd=[(0, .5),(0, .5),(0, .5),(0, .5)]

n33.png

Leave a comment