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.
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
The weights of long only MVP, Asset 1 has a slightly positive weight
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)]