Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #2911

Re: Portfolio Optimization

From "Sjoerd C. de Vries" <sjoerd.c.devries@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Portfolio Optimization
Date 2011-06-02 23:11 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <is95bc$60r$1@smc.vnet.net> (permalink)

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Portfolio Optimization "Sjoerd C. de Vries" <sjoerd.c.devries@gmail.com> - 2011-06-02 23:11 +0000

csiph-web