Skip to content
Prev 14641 / 15274 Next

Welcome to the "R-SIG-Finance" mailing list

hi,


I am looking at using PortfolioAnalytics to optimize portfolio with constrained tracking error.


looking at below code I got some questions.


te.target <- function(R, weights, Rb, min.te = 0.02, max.te = 0.05, scale = 12){
  # calculate the portfolio return
  r <- Return.portfolio(R = R, weights = weights)
  # align the indexes
  Rb <- Rb[index(r)]
  te <- sd(r - Rb) * sqrt(scale)
  # penalize tracking error outside of [min.te, max.te] range
  out <- 0
  if(te > max.te)
    out <- (te - max.te) * 10000
  if(te < min.te)
    out <- (min.te - te) * 10000
  out
}

Do I need a series of stock returns as well as their corresponding weights for the time series in order to run this script? I have stock return series, but don't have stock weights history as I think the purpose was to find the weights for the optimization.


Would someone be able to advise where can I find the source data used from Ross's presentation? I am trying to replicate the code and see how the flow works.


https://github.com/rossb34/PortfolioAnalyticsPresentation2017/blob/master/optimization_script.R

[https://avatars1.githubusercontent.com/u/5797430?s=400&v=4]<https://github.com/rossb34/PortfolioAnalyticsPresentation2017/blob/master/optimization_script.R>

rossb34/PortfolioAnalyticsPresentation2017 - GitHub<https://github.com/rossb34/PortfolioAnalyticsPresentation2017/blob/master/optimization_script.R>
github.com
Presentation for R/Finance 2017. Contribute to rossb34/PortfolioAnalyticsPresentation2017 development by creating an account on GitHub.




many thanks

jojo
Message-ID: <AM5P18901MB0242438FABA49A85F07AE814D3F00@AM5P18901MB0242.EURP189.PROD.OUTLOOK.COM>
In-Reply-To: <mailman.14676.958.1540564481.1178.r-sig-finance@r-project.org>