Portfolio management

Fill me in

VLQuantitativeFinancePackage.MyMarkowitzRiskyAssetOnlyPortfolioChoiceProblemType
mutable 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 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
source
VLQuantitativeFinancePackage.MyMarkowitzRiskyRiskFreePortfolioChoiceProblemType
mutable 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 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
source
VLQuantitativeFinancePackage.MySingleIndexModelType
mutable 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 market
  • r::Float64: The risk-free rate of return
  • ϵ::Distribution: The random shocks to the model (unexplained return)
source
VLQuantitativeFinancePackage.buildMethod
function 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.
source
VLQuantitativeFinancePackage.buildMethod

function 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 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
source
VLQuantitativeFinancePackage.buildMethod
function 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 market
  • r::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.

source
VLQuantitativeFinancePackage.solveMethod
function 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

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.
source
VLQuantitativeFinancePackage.solveMethod
function 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

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.
source

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.MySharpeRatioPortfolioChoiceProblemType
mutable 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 returns
  • risk_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 market
  • gₘ::Float64: The expected market return
  • τ::Float64: The growth parameter
source
VLQuantitativeFinancePackage.buildMethod
function 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.
source
VLQuantitativeFinancePackage.solveMethod
function 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

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
source