0
$\begingroup$

If the amount of capital that has to be allocated for each asset given the "long only" optimized portfolio weights is:

weights = [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 3.205
   0., 0., 0., 0., 1.84, 11.168, 0., 0., 0., 0.
   0., 12.297, 11.339, 0., 0., 0., 0., 0., 0., 0.
   0., 0., 11.489, 0., 6.807, 18.372, 0., 0., 0., 0.
   0., 4.54, 0., 0., 0., 0., 0., 0., 0., 0.
   0., 0., 14.06, 0., 0., 0., 0., 4.882]

#Sum of all weights is equal to 99.99900000000001% (all weights are in %)
#11 of 58 assets processed has been added to the portfolio

which is the "correct" approach to calculate how much capital has to be allocated for each asset according to "long and short" optimized portfolio weights?.

weights = [-16.236, 42.662, 9.071, -3.043, -30.727, 11.649, 9.688        
21.987, 6.123, 37.917, -12.818, -17.302, 3.501, 56.237, 8.001, 18.2,         
-9.894, -4.824, -7.25, -1.315, 0.673, 37.075, 35.864, -9.306, -21.19  
-53.798, -22.175, -41.449, -15.007, -12.847, -56.741, 19.637, 21.805      
-4.066, 25.44, 27.779, 10.321, 4.372, 7.127, 10.733, 13.87, 16.277  
-9.371, -4.053, -22.877, 1.631, 8.721, -24.908, -6.497, -16.44, -11.304  
-2.084, 24.29, 23.836, 5.427, -11.143, 4.654, 24.099]

#Sum of all weights is equal to 100.0020000000000% (all weights are in %)
#58 of 58 assets processed has been added to the portfolio

Following the code for the optimization.

def negative_sharpe(weights, average_annual_return, covariance_matrix, 
     risk_free = 0.02):
      mu = weights.dot(average_annual_return)
      sigma = np.sqrt(np.dot(weights, np.dot(cov_matrice, weights.T)))
      L2_reg = (weights ** 2).sum()
      return -(mu - risk_free) / sigma + L2_reg

def optimized_tangency_portfolio(n_assets, risk_free = 0.02,
     average_annual_return, covariance_matrix, short = False):

      if short:
          b = (-1, 1)
      else:
          b = (0, 1)

      init = np.array([1 / n_assets] * n_assets)
      constraints = [{"type": "eq", "fun": lambda x: np.sum(x) - 1}]
      bounds = tuple(b for x in range(n_assets))
      args = (average_annual_return, covariance_matrix, risk_free)

      result = sco.minimize(negative_sharpe,
          x0 = init,
          args = args,
          method = "SLSQP",
          bounds = bounds,
          constraints = constraints,
      )
      #Output is an array of weights
      return result["x"]
$\endgroup$
  • $\begingroup$ I don’t understand the weights your showing, what’s their relation? How did you obtain them? Why not run the optimization twice, once with shorting, once without? $\endgroup$ – Bob Jansen Jan 8 at 18:29
  • $\begingroup$ Both the arrays of weights are the result of the same portfolio optimization function I written. The first array has been obtained by performing an portfolio optimization using time series data that consists in minimize the negative Sharpe ratio (same as maximize) considering the risk free rate (the result are weights for an optimal tangency portfolio). $\endgroup$ – Nipper Jan 8 at 18:56
  • $\begingroup$ The second array has been obtain performing the same optimization function with the same time series data but with different bounds (not 0 to 1 but -1 to 1 thus allowing short selling) given as input to the optimization module (spicy.optimization.minimize). Hoping that this is a good way to calculate weights considering both long and short selling of assets I’d like to know how calculate the allocation given i.e 100000 capital. $\endgroup$ – Nipper Jan 8 at 18:56
  • $\begingroup$ Your second array appears longer to me. However, given the information, your approach seems to work for both? $\endgroup$ – Bob Jansen Jan 8 at 19:27
  • $\begingroup$ Sorry I do not understand exactly what you mean with "longer". I performed the two optimizations using the same time series data of circa 50 assets (stock only). Only 7 has been considered to obtain an optimized long only portfolio (43.1% annual return, 19.6% annual volatility, Sharpe-ratio 2.10 as I recall) and 18 has been considered to obtain an optimized long/short portfolio. Changing bounds from (0, 1) to (-1, 1) allows the optimization module to consider negatives weights in order to perform the minimizing of negative Sharp Ratio. $\endgroup$ – Nipper Jan 8 at 19:59
1
$\begingroup$

The long short portfolio you created is highly leveraged. That means it requires investing much more than the amount of capital you have, the additional capital would have to be borrowed.

In your portfolio the sum of the positive weights is 548.667 and the sum of negative weights is -448.665. The sum of these numbers is 100 so you have a 1 to 1 exposure to the market, but with highly leveraged (and therefore highly risky) positions on both the long and the short side.

In practice I know that some hedge fund take positions of 200/-100 or maybe 300/-200, but a position 548/-448 is very unusual and a think real investors would not be interested in something like this, and the prime brokers might not even allow you to take such a leveraged position (they will simply refuse to lend you this much money).

It is well known that Markowitz optimization without shorting constraints often leads to excessive leverage. This is because of unreliable estimates of return and risk; if for example you have two stocks with similar risk but different returns, the optimizer will try to be long one of the stocks and short the other to a very large amount to profit from the apparent discrepancy. But most likely this will not be profitable because the return estimates are not realistic. This is called "the problem of estimation error" in Portfolio Optimization. It is a very important issue.

This issue has been studied in the literature by people like Richard O. Michaud ("The Markowitz optimization enigma") in 1989, and Philippe Jorion in 1986 ("Bayes Stein estimation for Portfolio Analysis"). One possible solution is to change the input estimates of expected return to be very close to each other and almost equal (using so-called Bayes-Stein shrinkage). Then the portfolio weights will be more reasonable. Another approach is to impose constraints on the weights (for example no weight bigger that 0.05 or smaller than -0.05).

In summary the unconstrained allocation you calculated is not usable in practice.

$\endgroup$
  • 1
    $\begingroup$ Just to add to what @Alex C mentioned above, is the stability of the portfolio weights. Just modify the returns the slightest bit and you'll see that the weights of the L-S portfolio change drastically (the longs now may end up becoming shorts). In the practical sense you should run a constrained MV optimization if you've the option of going short, otherwise you may end up with extreme long short positions. $\endgroup$ – user23564 Feb 9 at 18:10
0
$\begingroup$

If the sum of weights is 1 (or 100%) just multiply them by the notional or starting cash of your portfolio.

Allocation = W*Notional. Eg. W = [0.5 0.5] N = 10.000, Allocation = [5000 5000]

$\endgroup$
  • $\begingroup$ Thanks but this was the first thing I written above. One can use that formula for the first array and everything fits. The problem is for the second one (long/short portfolio) which the negative weights have to be considered as absolute values in order to calculate the allocation and even so the sum exceed 100%. At this point I think I have to use different bounds and constraint for short selling rather than only limits possible weights value between (-1, 1). Any suggestion? $\endgroup$ – Nipper Jan 9 at 11:54
  • $\begingroup$ If the sum is truly 1, it doesn't matter if there are long or short positions. The net allocation HAS to be the notional. $\endgroup$ – TomDecimus Jan 9 at 12:11
  • $\begingroup$ Of course the net allocation has to be the notional, thats the point. The minus symbol represents only that the relative asset is added to the portfolio short selling it. If one try apply the formula to compute the allocation with the second set of weights obtained after the optimization (the one obtained allowing short selling) one runs out of the notional only acquiring (long or short whatever) the first 7 assets (leaving 51 assets left). Probably bounds and constraints have to be modified... $\endgroup$ – Nipper Jan 9 at 12:20
  • $\begingroup$ 16.236% short, 42.662% long, 9.071% long, 3.043% short, 30.727% short, 11.649 long, 9.688% long ... one already exceed 100% of notional. $\endgroup$ – Nipper Jan 9 at 12:25
  • $\begingroup$ Thats way another problem. You are struggling with execution order, another topic. If you dont have access to shortable shares so you can have enought cash to buy the long positions, you have to execute the orders in the particular order you can finance the portfolio. As I said, the net allocation is still W*N and has nothing to do with the constraints. $\endgroup$ – TomDecimus Jan 9 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.