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
- `returns::Matrix{<:Real}`: A matrix of historical returns for the assets.
22
+
- `thresholdreturn::Real`: The minimum expected return required for the portfolio.
23
+
24
+
"""
25
+
struct PortfolioProblem
26
+
returns::Matrix{<:Real}
27
+
thresholdreturn::Real
28
+
end
29
+
30
+
31
+
32
+
"""
33
+
PortfolioResult
34
+
35
+
# Description
36
+
37
+
A structure to hold the result of the portfolio optimization problem.
38
+
39
+
# Fields
40
+
41
+
- `weights::Vector{Float64}`: The optimal weights for the assets in the portfolio.
42
+
- `expectedreturn::Float64`: The expected return of the optimal portfolio.
43
+
- `model::JuMP.Model`: The JuMP model used to solve the problem.
44
+
"""
45
+
struct PortfolioResult
46
+
weights::Vector{Float64}
47
+
expectedreturn::Float64
48
+
model::JuMP.Model
49
+
end
50
+
51
+
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' * Σ * w
65
+
Subject to:
66
+
- sum(w) == 1 (the weights must sum to 1)
67
+
- sum(w[i] * μ[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
+
- Σ is the covariance matrix of asset returns
73
+
- μ is the vector of expected returns for each asset
74
+
- thresholdreturn is the minimum expected return required for the portfolio
75
+
76
+
# Arguments
77
+
78
+
- `problem::PortfolioProblem`: The problem in type of PortfolioProblem
79
+
80
+
# Returns
81
+
82
+
- `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