Application Center - Maplesoft

App Preview:

Applied Portfolio Optimization

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Image 

 

 

 

 

 

Applied Portfolio Optimization 

 

 

 

The following was implemented in Maple by Marcus Davidsson (2009) davidsson_marcus@hotmail.com 

 

 

 

 

 

 

 

1) Introduction to Permutations 

 

 

 

In this worksheet we assume that we only can take long positions to make things simple. We also assume that all portfolios are equal  

 

weighted which means that the expected return and covariance are simply additive since we are investing an equal fraction in each stock. 

 


Our objective is to maximize the Sharpe Ratio for our P stock portfolio.
 

 

 

We should also note the number of permutations that is required to calculate the "optimal portfolio" where nstock is the total number of stocks

and P is the number of stocks that should be included in the portfolio is given by:
 

 

 

 

restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 1); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 1); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 1); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 1); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 1); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 1); -1; nops(choose(nstock, P)); 1
 

10 (1)
 

 

restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 2); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 2); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 2); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 2); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 2); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 2); -1; nops(choose(nstock, P)); 1
 

45 (2)
 

 

restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 4); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 4); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 4); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 4); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 4); -1; nops(choose(nstock, P)); 1
 

210 (3)
 

 

restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 8); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 8); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 8); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 8); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 8); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 10); -1; `:=`(P, 8); -1; nops(choose(nstock, P)); 1
 

45 (4)
 

 

restart; 1; with(combinat); -1; `:=`(nstock, 20); -1; `:=`(P, 1); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 20); -1; `:=`(P, 1); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 20); -1; `:=`(P, 1); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 20); -1; `:=`(P, 1); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 20); -1; `:=`(P, 1); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 20); -1; `:=`(P, 1); -1; nops(choose(nstock, P)); 1
 

20 (5)
 

 

restart; 1; with(combinat); -1; `:=`(nstock, 40); -1; `:=`(P, 2); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 40); -1; `:=`(P, 2); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 40); -1; `:=`(P, 2); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 40); -1; `:=`(P, 2); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 40); -1; `:=`(P, 2); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 40); -1; `:=`(P, 2); -1; nops(choose(nstock, P)); 1
 

780 (6)
 

 

restart; 1; with(combinat); -1; `:=`(nstock, 200); -1; `:=`(P, 3); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 200); -1; `:=`(P, 3); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 200); -1; `:=`(P, 3); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 200); -1; `:=`(P, 3); -1; nops(choose(nstock, P)); 1
restart; 1; with(combinat); -1; `:=`(nstock, 200); -1; `:=`(P, 3); -1; nops(choose(nstock, P)); 1
 

1313400 (7)
 

 

restart; 1; with(combinat); -1; `:=`(nstock, 20); -1; `:=`(P, 10); -1; nops(choose(nstock, P))
restart; 1; with(combinat); -1; `:=`(nstock, 20); -1; `:=`(P, 10); -1; nops(choose(nstock, P))
restart; 1; with(combinat); -1; `:=`(nstock, 20); -1; `:=`(P, 10); -1; nops(choose(nstock, P))
restart; 1; with(combinat); -1; `:=`(nstock, 20); -1; `:=`(P, 10); -1; nops(choose(nstock, P))
restart; 1; with(combinat); -1; `:=`(nstock, 20); -1; `:=`(P, 10); -1; nops(choose(nstock, P))
restart; 1; with(combinat); -1; `:=`(nstock, 20); -1; `:=`(P, 10); -1; nops(choose(nstock, P))
 

184756 (8)
 

 

 

 

 

We can also plot the number of permutations required for each amount of nstock and P 

 

restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
restart; -1; with(combinat); -1; with(plots); -1; for i to 20 do for j to 10 do `:=`(A[i, j], pointplot3d([i, j, nops(choose(i, j))], symbol = solidsphere, symbolsize = 18, color = black)) end do end ...
 

Plot
 

 

 

 

 

 

2) Portfolio Optimization for a 2 Stock Portfolio 

 

 

 

We can now run the simulations 

 

 

restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 20); -1; `:=`(P, 2); -1; for k to nstock d...
 

 

 

 

Vector[column](%id = 52397948)
Vector[column](%id = 63058864)
Matrix(%id = 144997216)
Plot_2d
 

 

 

 

with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
 

 

 

Plot_2d
Max Portfolio Sharpe
[1, 16] (9)
 

 

 

 

`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
 

 

 

Vector[column](%id = 63522196)
Sharpe Ratio Portfolio
Plot_2d
 

 

 

 

 

 

 

 

3) Portfolio Optimization for a 4 Stock Portfolio 

 

 

 

We can now run the simulations 

 

 

restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
restart; -1; randomize(); -1; with(Statistics); -1; with(plots); -1; with(LinearAlgebra); -1; `:=`(a, .1); -1; `:=`(b, 1); -1; `:=`(n, 100); -1; `:=`(nstock, 12); -1; `:=`(P, 4); -1; for k to nstock d...
 

 

 

 

Vector[column](%id = 64518924)
Vector[column](%id = 63890224)
Matrix(%id = 73747384)
Plot_2d
 

 

 

 

with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
with(combinat); -1; `:=`(A, choose(nstock, P)); -1; `:=`(g, nops(choose(nstock, P))); -1; for i to g do `:=`(rr, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, A[i, j]), j = 1 .. P)])); `:=`(S[i], `/`(`*`(E...
 

 

 

Plot_2d
Max Portfolio Sharpe
[5, 7, 11, 12] (10)
 

 

 

 

`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
`:=`(RB, Matrix(`+`(n, `-`(1)), P, [seq(Column(r, QQQ[i]), i = 1 .. P)])); 1;
 

 

 

Vector[column](%id = 64732412)
Sharpe Ratio Portfolio
Plot_2d
 

 

 

Legal Notice: ? Maplesoft, a division of Waterloo Maple Inc. 2009. Maplesoft and Maple are trademarks of Waterloo Maple Inc. Neither Maplesoft nor the authors are responsible for any errors contained within and are not liable for any damages resulting from the use of this material.  This application is intended for non-commercial, non-profit use only. Contact the authors for permission if you wish to use this application in for-profit activities.