Portfolio Optimization
PortfolioProblem
OperationsResearchModels.Portfolio.PortfolioProblem — Type
PortfolioProblemDescription
Defines the portfolio optimization problem.
Fields
returns::Matrix{<:Real}: A matrix of historical returns for the assets.thresholdreturn::Real: The minimum expected return required for the portfolio.
PortfolioResult
OperationsResearchModels.Portfolio.PortfolioResult — Type
PortfolioResultDescription
A structure to hold the result of the portfolio optimization problem.
Fields
weights::Vector{Float64}: The optimal weights for the assets in the portfolio.expectedreturn::Float64: The expected return of the optimal portfolio.model::JuMP.Model: The JuMP model used to solve the problem.
solve
OperationsResearchModels.solve — Method
solve(problem)Description
Solves a portfolio optimization problem given by an object of in type PortfolioProblem. The optimization problem is formulated as a quadratic programming problem where the objective is to minimize the portfolio variance (risk) subject to constraints on the expected return and the weights.
Mathematically, the problem can be stated as:
Minimize: w' * Covmat * w Subject to:
- sum(w) == 1 (the weights must sum to 1)
- sum(w[i] * means[i] for i in 1:m) >= thresholdreturn
- 0 <= w[i] <= 1 for all i (weights must be between 0 and 1)
Where:
- w is the vector of asset weights
- Covmat is the covariance matrix of asset returns
- means is the vector of expected returns for each asset
- thresholdreturn is the minimum expected return required for the portfolio
Arguments
problem::PortfolioProblem: The problem in type of PortfolioProblem
Returns
PortfolioResult: The result of the portfolio optimization problem, containing the optimal weights, expected return, and the JuMP model used to solve the problem.
Example
using OperationsResearchModels
problem = PortfolioProblem(rand(100, 5), 0.01)
result = solve(problem)
println("Optimal Weights: ", result.weights)
println("Expected Return: ", result.expectedreturn)