Portfolio management
Fill me in
VLQuantitativeFinancePackage.MyMarkowitzRiskyAssetOnlyPortfolioChoiceProblem
— Typemutable struct MyMarkowitzRiskyAssetOnlyPortfiolioChoiceProblem <: AbstractStochasticChoiceProblem
The MyMarkowitzRiskyAssetOnlyPortfiolioChoiceProblem
mutable struct represents a Minimum Variance portfolio problem with risky assets only.
Required fields
Σ::Array{Float64,2}
: The covariance matrix of the risky asset Returnsμ::Array{Float64,1}
: The expected returns of the risky assetsbounds::Array{Float64,2}
: The bounds on the risky asset weightsR::Float64
: The desired return of the portfolioinitial::Array{Float64,1}
: The initial portfolio weights
VLQuantitativeFinancePackage.MyMarkowitzRiskyRiskFreePortfolioChoiceProblem
— Typemutable struct MyMarkowitzRiskyRiskFreePortfolioChoiceProblem <: AbstractStochasticChoiceProblem
The MyMarkowitzRiskyRiskFreePortfolioChoiceProblem
mutable struct represents a Minimum Variance portfolio problem with a combination of risky and risk-free assets.
Required fields
Σ::Array{Float64,2}
: The covariance matrix of the risky asset returnsμ::Array{Float64,1}
: The expected returns of the risky assetsbounds::Array{Float64,2}
: The bounds on the risky asset weightsR::Float64
: The desired return of the portfolioinitial::Array{Float64,1}
: The initial portfolio weightsrisk_free_rate::Float64
: The risk-free rate of return
VLQuantitativeFinancePackage.MySingleIndexModel
— Typemutable struct MySingleIndexModel <: AbstractReturnModel
The MySingleIndexModel
mutable struct represents a single index model of risky asset returns.
Required fields
α::Float64
: The firm specific unexplained returnβ::Float64
: The relationship between the firm and the marketr::Float64
: The risk-free rate of returnϵ::Distribution
: The random shocks to the model (unexplained return)
VLQuantitativeFinancePackage.build
— Methodfunction build(model::Type{MyMarkowitzRiskyAssetOnlyPortfolioChoiceProblem}, data::NamedTuple) -> MyMarkowitzRiskyAssetOnlyPortfolioChoiceProblem
This build
method constructs an instance of the MyMarkowitzRiskyAssetOnlyPortfolioChoiceProblem
type using the data in a NamedTuple.
Arguments
model::Type{MyMarkowitzRiskyAssetOnlyPortfolioChoiceProblem}
: The type of model to build.data::NamedTuple
: The data to use to build the model.
The data::NamedTuple
must contain the following keys
:
μ::Array{Float64,1}
: The drift rates of the assets.
VLQuantitativeFinancePackage.build
— Methodfunction build(model::Type{MyMarkowitzRiskyRiskFreePortfolioChoiceProblem}, data::NamedTuple) -> MyMarkowitzRiskyRiskFreePortfolioChoiceProblem
This build
method constructs an instance of the MyMarkowitzRiskyRiskFreePortfolioChoiceProblem
type using the data in a NamedTuple.
Arguments
model::Type{MyMarkowitzRiskyRiskFreePortfolioChoiceProblem}
: The type of model to build.data::NamedTuple
: The data to use to build the model.
The data::NamedTuple
must contain the following keys
:
Σ::Array{Float64,2}
: The covariance matrix of the risky asset returnsμ::Array{Float64,1}
: The expected returns of the risky assetsbounds::Array{Float64,2}
: The bounds on the risky asset weightsR::Float64
: The desired return of the portfolioinitial::Array{Float64,1}
: The initial portfolio weightsrisk_free_rate::Float64
: The risk-free rate of return
VLQuantitativeFinancePackage.build
— Methodfunction build(model::Type{MySingleIndexModel}, data::NamedTuple) -> MySingleIndexModel
This build
method constructs an instance of the MySingleIndexModel
type using the data in a NamedTuple.
Arguments
model::Type{MySingleIndexModel}
: The type of model to build.data::NamedTuple
: The data to use to build the model.
The data::NamedTuple
must contain the following keys
:
α::Float64
: The firm specific unexplained returnβ::Float64
: The relationship between the firm and the marketr::Float64
: The risk-free rate of returnϵ::Distribution
: The random shocks to the model (unexplained return)
Return
This function returns an instance of the MySingleIndexModel
type.
See also:
- The unexplained return is modeled as a random variable, and the user can specify the distribution of this variable using the
ϵ::Distribution
argument.
See the Distributions.jl package package for more information on the available distributions.
VLQuantitativeFinancePackage.solve
— Methodfunction solve(problem::MyMarkowitzRiskyAssetOnlyPortfolioChoiceProblem) -> Dict{String,Any}
The solve
function solves the Markowitz risky asset-only portfolio choice problem for a given instance of the MyMarkowitzRiskyAssetOnlyPortfolioChoiceProblem
problem type. The solve
method checks for the optimization's status using an assertion. Thus, the optimization must be successful for the function to return. Wrap the function call in a try
block to handle exceptions.
Arguments
problem::MyMarkowitzRiskyAssetOnlyPortfolioChoiceProblem
: An instance of theMyMarkowitzRiskyAssetOnlyPortfolioChoiceProblem
that defines the problem parameters.
Returns
Dict{String, Any}
: A dictionary with optimization results.
The results dictionary has the following keys:
"reward"
: The reward associated with the optimal portfolio."argmax"
: The optimal portfolio weights."objective_value"
: The value of the objective function at the optimal solution."status"
: The status of the optimization.
VLQuantitativeFinancePackage.solve
— Methodfunction solve(problem::MyMarkowitzRiskyRiskFreePortfolioChoiceProblem) -> Dict{String,Any}
The solve
function solves the Markowitz risky and risk-free portfolio choice problem for a given instance of the MyMarkowitzRiskyRiskFreePortfolioChoiceProblem
problem type. The solve
method checks for the optimization's status using an assertion. Thus, the optimization must be successful for the function to return. Wrap the function call in a try
block to handle exceptions.
Arguments
problem::MyMarkowitzRiskyRiskFreePortfolioChoiceProblem
: An instance of theMyMarkowitzRiskyRiskFreePortfolioChoiceProblem
that defines the problem parameters.
Returns
Dict{String, Any}
: A dictionary with optimization results.
The results dictionary has the following keys:
"reward"
: The reward associated with the optimal portfolio."argmax"
: The optimal portfolio weights."objective_value"
: The value of the objective function at the optimal solution."status"
: The status of the optimization.
Maximizing the Sharpe ratio
The Sharpe ratio is a widely used metric in finance to evaluate the performance of an investment by adjusting for its risk. It is defined as the ratio of the excess return of the investment over the risk-free rate to the standard deviation of the investment's returns. We've implemented some tools to help you build and solve portfolio choice problems that maximize the Sharpe ratio.
VLQuantitativeFinancePackage.MySharpeRatioPortfolioChoiceProblem
— Typemutable struct MySharpeRatioPortfolioChoiceProblem <: AbstractStochasticChoiceProblem
The MySharpeRatioPortfolioChoiceProblem
mutable struct represents a Maximum Sharpe Ratio portfolio problem.
Required fields
Σ::Array{Float64,2}
: The covariance matrix of the risky asset returnsrisk_free_rate::Float64
: The risk-free rate of returnα::Array{Float64,1}
: The firm specific unexplained returnsβ::Array{Float64,1}
: The relationship between the firm and the marketgₘ::Float64
: The expected market returnτ::Float64
: The growth parameter
VLQuantitativeFinancePackage.build
— Methodfunction build(model::Type{MySharpeRatioPortfolioChoiceProblem}, data::NamedTuple) -> MySharpeRatioPortfolioChoiceProblem
This build
method constructs an instance of the MySharpeRatioPortfolioChoiceProblem
type using the data in a NamedTuple.
Arguments
model::Type{MySharpeRatioPortfolioChoiceProblem}
: The type of model to build.data::NamedTuple
: The data to use to build the model.
The data::NamedTuple
must contain the following keys
:
μ::Array{Float64,1}
: The expected returns of the risky assets.bounds::Array{Float64,2}
: The bounds on the risky asset weights.R::Float64
: The desired return of the portfolio.initial::Array{Float64,1}
: The initial portfolio weights.risk_free_rate::Float64
: The risk-free rate of return.
VLQuantitativeFinancePackage.solve
— Methodfunction solve(model::MySharpeRatioPortfolioChoiceProblem)::Dict{String,Any}
This method solves the Sharpe ratio maximization portfolio choice problem for a given instance of the MySharpeRatioPortfolioChoiceProblem
model type. This problem is encoded as a second-order cone program (SOCP) and solved using the COSMO solver via the JuMP modeling interface.
Arguments
model::MySharpeRatioPortfolioChoiceProblem
: An instance of theMySharpeRatioPortfolioChoiceProblem
that defines the problem parameters.
Returns
Dict{String, Any}
: A dictionary containing the optimization results.
The results dictionary has the following keys:
"sharpe_ratio"
: The maximum Sharpe ratio achieved by the optimal portfolio."argmax"
: The optimal portfolio weights that achieve the maximum Sharpe ratio."numerator"
: The numerator of the Sharpe ratio at the optimal solution (excess return over risk-free rate)."denominator"
: The denominator of the Sharpe ratio at the optimal solution (standard deviation of returns)."status"
: The status of the optimization