# Portfolio Analytics Optimization

I have a large dataset, 10,000 investments I am trying to create an optimized portfolio for. The portfolio has 3 restrictions. Long Only, Only 50 assets can be selected and every invested asset has the same weight. I would like to find the max sharpe portfolio and the minSD portfolio for a given return.

> funds = colnames(dfxts)
> returns = dfxts
> df.con = portfolio.spec(assets = funds)
> df.con = add.constraint(portfolio = df.con, type = "long_only")
> df.con = add.constraint(portfolio = df.con, type = "box", min = (1/n - .01/n), max = (1/n + .01/n))
>
> df.con = add.constraint(portfolio = df.con, type = "position_limit", max_pos = n)
>
> df.con = add.constraint(portfolio = df.con, type = "return", return_targe = r)
>
> df.con = add.constraint(portfolio = df.con, type = "weight_sum_constraint", min_sum = .99, max_sum = 1.01)
+                                  type="risk",
+                                  name="StdDev")

opt = optimize.portfolio(R = returns, portfolio = df.con, optimize_method = "DEoptim", trace = TRUE)


This is taking over 10 hours to optimize. How can I change the constraints or optimizer to make this faster? I would like it to be under 10 minutes if possible. Thanks,

Not sure if this is working correctly. I edited the objective function in the vignette,

   > OF2 <- function(x, Data) {
+  w <- 1/sum(x)
+  -(sum(r*w))/(sum(w * w * Data\$Sigma[x, x]))
+  }


The objective function should return a negative value, but it keeps giving me a positive value? Why is this happending

• the method of constraining weights to be within an epsilon of (1/n) does not seem a very efficient way to do it. – noob2 Dec 11 '15 at 15:09
• your problem is discrete optimization rather than continuous – noob2 Dec 11 '15 at 15:15
• Do you have any resource I can look into for discrete optimizations? – JB17 Dec 11 '15 at 20:15
• quant.stackexchange.com/questions/22208/… Here is a sample of the dataset I am trying to optimize – JB17 Dec 11 '15 at 20:16
• It seems your question is about computational efficiency. However, choosing a portfolio with ~10K free variables is unlikely to yield good future performance. Perhaps you can solve both problems by applying some domain knowledge about the 10K assets to reduce the problem size. – shabbychef Dec 14 '15 at 23:56