You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# In this problem, we will find the unconstrained portfolio allocation where we introduce the weighting parameter $\lambda \;(0 \leq \lambda \leq$ 1) and minimize $\lambda * \text{risk} - (1-\lambda)* \text{expected return}$. By varying the values of $\lambda$, we trace out the efficient frontier.
3
+
# In this problem, we will find the unconstrained portfolio allocation where we introduce the weighting parameter $\lambda \;(0 \leq \lambda \leq$ 1) and minimize $\lambda * \text{risk} - (1-\lambda)* \text{expected return}$. By varying the values of $\lambda$, we trace out the efficient frontier.
4
4
#
5
5
# Suppose that we know the mean returns $\mu \in \mathbf{R}^n$ of each asset and the covariance $\Sigma \in \mathbf{R}^{n \times n}$ between the assets. Our objective is to find a portfolio allocation that minimizes the *risk* (which we measure as the variance $w^T \Sigma w$) and maximizes the *expected return* ($w^T \mu$) of the portfolio of the simulataneously. We require $w \in \mathbf{R}^n$ and $\sum_i w_i = 1$.
6
6
#
@@ -23,7 +23,7 @@ using Convex, SCS #We are using SCS solver. Install using Pkg.add("SCS")
23
23
34644;
24
24
584100]/100^2
25
25
26
-
n =length(μ) #number of assets
26
+
n =length(μ) #number of assets
27
27
28
28
# If you want to try the optimization with more assets, uncomment and run the next cell. It creates a vector or average returns and a variance-covariance matrix that have scales similar to the numbers above.
29
29
@@ -47,13 +47,13 @@ w = Variable(n)
47
47
ret =dot(w,μ)
48
48
risk =quadform(w,Σ)
49
49
50
-
MeanVarA =zeros(N,2)
50
+
MeanVarA =zeros(N,2)
51
51
for i =1:N
52
52
λ = λ_vals[i]
53
53
p =minimize( λ*risk - (1-λ)*ret,
54
-
sum(w) ==1 )
54
+
sum(w) ==1 )
55
55
solve!(p, SCS.Optimizer(verbose =false))
56
-
MeanVarA[i,:]= [evaluate(ret),evaluate(risk)[1]] #risk is a 1x1 matrix
0 commit comments