Skip to content

Max ES Ratio with Sortino Covariance Matrix #47

@diegoperoni

Description

@diegoperoni

Dear Brian,

I am using your wonderful package recently updated with CVXR and have found it amazing!

I have modeled most of your portfolio variations using as assets the equity lines of about 25 options strategies that I have been using for a couple of years.

I was looking for some models that increase smoothing without penalizing sudden rises in returns but only drawdowns.

I thought of Sortino and wrote a variation of your work with ESratio.
I am not sure if it is correct what I did and especially I would appreciate your advice/opinion on any alternative solutions that are more effective.

I thank you in advance for your support.

Thank you for all the work you do in RFinance!

Diego Peroni


# Max ESratio using Sortino Moments

custom.sortino_mom = function(R) {
  
  neg_cov_matrix = function(R) {
    matr = zoo::coredata(R)
    matr[matr>0] = 0
    stats::cov(matr)
  }
  
  list(
    mu    = matrix(as.vector(apply(R, 2, 'mean')), ncol=1),
    sigma = neg_cov_matrix(R))
}

pspec = PortfolioAnalytics::portfolio.spec(assets = colnames(R))
pspec = PortfolioAnalytics::add.constraint(pspec, type = "long_only")
pspec = PortfolioAnalytics::add.constraint(pspec, type = "full_investment")
pspec = PortfolioAnalytics::add.constraint(pspec,
  type = 'box',
  min  = c(rep(0.000, 23), 0.000, 0.000),
  max  = c(rep(0.185, 23), 0.278, 0.138))
pspec = PortfolioAnalytics::add.objective(pspec, type="return", name="mean")
pspec = PortfolioAnalytics::add.objective(pspec, type="risk", name="var")

portfolio = PortfolioAnalytics::optimize.portfolio(R, pspec, optimize_method='CVXR',
  momentFUN="custom.sortino_mom", maxSR=TRUE)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions