Question: One of the hardest portfolio problem I have come across..... I doubt anyone can solve it?!

 

ok, let me see if I can explain. If we run the below code we will get a matrix with nstock stock price, a matrix with returns, a

correlation matrix of returns and a plot of the nstock stock prices. (the code work I hace checked it by copy past)
 

######################################################

restart:
randomize():
with(Statistics):
with(plots):
with(LinearAlgebra):
 a := .1:  b := 1:   n := 100:   nstock := 12:

for k to nstock do

r := Sample(RandomVariable(Normal(0, 1)), n):
tt := [seq(i, i = 1 .. n)]:

for i from 2 to n do
s[1] := 100;
s[i] := a+b*s[i-1]+r[i]
end do;

ss[k] := [seq(s[i], i = 1 .. n)]

end do:

# Our stock prices are given by
sss := Transpose(Matrix(nstock, n, [seq(ss[k], k = 1 .. nstock)]));

for j to nstock do
for i from 2 to n do
B[i, j] := sss[i, j]-sss[i-1, j]
end do  end do:

# Our returns P(t)-P(t-1) are given by
r := Matrix([seq([seq(B[i, j], j = 1 .. nstock)], i = 2 .. n)]);

# Our correlation matrix is given by
CorrelationMatrix(r);

# Our nstock plot is given by
for kk to nstock do
x1[kk] := plot([seq(i, i = 1 .. n)], sss[1 .. n, kk], color = black, thickness = 1, style = line, labels = ["time", "Stock Price"]) end do:
display({seq(x1[k], k = 1 .. nstock)}, font = [Times, Roman, 14]);

 

######################################################

 

ok so far so good !! :-)    Now I want to calculate the sharpe ratio which is given by:
 

Sharpe-Ratio = Expected Return ( return stock i + return stock j) /  sqrt ( sum Covariance matrix for stock i and stock j)

which in maple code could be somthing like

Sharpe-Ratio = ExpectedValue(Column(r, 1)+Column(r, 2))/sqrt(add(i, `in`(i, CovarianceMatrix(r))))

 

Here is where the problem starts because I dont want to calculate the sharpe ratio for each of the individual stocks but rather

the sharpe ratio for all portfolio permutations. For simplicity we can assume that all portfolios are equal weighted

which means that we can simply add the expected return and add the elements in the covariance matrix of the stocks in the

portfolio. We can also assume for simplicity that all portfolios only contain long positions in the stocks and that we are only

interested in portfolios that have 3 stocks included. ( would be nice if we could adjust the portfolio size with an parameter

for example instead of a portfiolio of 3 stocks we could have a 2 stock portfolio etc etc)

 

So my question is how can we find the 3-stock portfolio that has the highest Sharpe ratio out of all different permutations ???

 

for example:

 

EV (return stock 1+ return stock 2 + return stock 6) / (sum covariance matrix stock 1,2,6)  = Sharpe Ratio Portfolio 1

EV (return stock 10 + return stock 12 + return stock 1) / ( sum covariance matrix stock 10,12,1)  = Sharpe Ratio Portfolio 2

EV(return stock 3 + return stock 8 + return stock 1) / (sum covariance matrix stock 3,8,1) = Sharpe Ratio Portfolio 3

etc etc

 

I find this quite hard and would be grateful if anyone could solve it ......:-)

Please Wait...