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
Copy file name to clipboardExpand all lines: src/portfolio.jl
+67-1Lines changed: 67 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
module Portfolio
2
2
3
-
using JuMP, Statistics, LinearAlgebra
3
+
using JuMP, HiGHS, Statistics, LinearAlgebra
4
4
5
5
import..OperationsResearchModels: solve
6
6
@@ -50,4 +50,70 @@ end
50
50
51
51
52
52
53
+
"""
54
+
solve(problem)
55
+
56
+
# Description
57
+
58
+
Solves a portfolio optimization problem given by an object of in type `PortfolioProblem`.
59
+
The optimization problem is formulated as a quadratic programming problem where the objective
60
+
is to minimize the portfolio variance (risk) subject to constraints on the expected return and the weights.
61
+
62
+
Mathematically, the problem can be stated as:
63
+
64
+
Minimize: w' * Covmat * w
65
+
Subject to:
66
+
- sum(w) == 1 (the weights must sum to 1)
67
+
- sum(w[i] * means[i] for i in 1:m) >= thresholdreturn
68
+
- 0 <= w[i] <= 1 for all i (weights must be between 0 and 1)
69
+
70
+
Where:
71
+
- w is the vector of asset weights
72
+
- Covmat is the covariance matrix of asset returns
73
+
- means is the vector of expected returns for each asset
74
+
- thresholdreturn is the minimum expected return required for the portfolio
75
+
76
+
77
+
# Arguments
78
+
79
+
- `problem::PortfolioProblem`: The problem in type of PortfolioProblem
80
+
81
+
# Returns
82
+
83
+
- `PortfolioResult`: The result of the portfolio optimization problem, containing the optimal weights, expected return, and the JuMP model used to solve the problem.
0 commit comments