MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Portfolio Optimization

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119425] Re: Portfolio Optimization
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Thu, 2 Jun 2011 19:11:48 -0400 (EDT)
  • Reply-to: comp.soft-sys.math.mathematica at googlegroups.com

There is no difference between row and column vectors in Mathematica, so you don't need to do a Transpose in order to do  a matrix multiplication. The following works:

In[86]:= (*Variance Covariance Matrix*)Covariants = {{0.000572843, 
   0.000223023, 0.000109176}, {0.000223023, 0.000387437, 
   0.0000987402}, {0.000109176, 0.0000987402, 0.007320276}}

(*Asset Weights Vector*)
weights = {w1, w2, w3}

(*Optimize Portfolio Variance*)
NMinimize[{weights.Covariants.weights, w1 + w2 + w3 == 1}, {w1, w2, 
  w3}]

Out[86]= {{0.000572843, 0.000223023, 0.000109176}, {0.000223023, 
  0.000387437, 0.0000987402}, {0.000109176, 0.0000987402, 0.00732028}}

Out[87]= {w1, w2, w3}

Out[88]= {0.000327596, {w1 -> 0.309102, w2 -> 0.659653, 
  w3 -> 0.0312441}}


BTW the NMinimize call could have been written more nicely as:

NMinimize[{weights.Covariants.weights, Total[weights] == 1}, weights]

Cheers-- Sjoerd


  • Prev by Date: Re: FixedPoint[Cos, 1.0]
  • Next by Date: Re: Mathematica plots
  • Previous by thread: Portfolio Optimization
  • Next by thread: Re: Portfolio Optimization