Optimizing Equal-Weight Portfolios with an Asset Selection Limit
Summary
The question concerns portfolio optimization over a large investment universe under long-only, equal-weight, and asset-count restrictions. It seeks both a maximum-Sharpe portfolio and a minimum-standard-deviation portfolio at a target return, and reports that a differential evolution optimizer takes many hours. The proposed code and constraints indicate a combinatorial selection problem: the optimizer must choose a limited subset from thousands of assets while respecting the weight and return conditions.
The response points to a closely related asset-selection problem documented with R code in an optimization package vignette, and suggests adapting its objective function for a Sharpe-ratio goal. It does not provide a direct diagnosis of the posted code, explain why its attempted objective returns a positive value, or demonstrate that the requested runtime is achievable. The vignette is offered as a starting point, so further implementation and performance testing would be needed for this particular dataset and set of constraints.
Key ideas
- Selecting a small subset from a large universe makes equal-weight portfolio optimization a combinatorial problem.
- The question imposes long-only exposure, equal weights, an asset limit, and a target return.
- A related asset-selection example in an R package vignette may provide a more suitable optimization approach.
- A Sharpe-ratio objective can be adapted for asset selection, but the posted answer gives no implementation details.
- The discussion does not establish a runtime guarantee or resolve the sign behavior of the attempted objective.
Tags
Full text
# Portfolio Analytics Optimization
# 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)
> minSDdf <- add.objective(portfolio=df.con,
+ 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
## Answer by Enrico Schumann (score 2)
https://quant.stackexchange.com/a/22304
A problem very similar to yours is described -- including R code -- in a vignette of the NMOF package: http://cran.r-project.org/web/packages/NMOF/vignettes/LSselect.pdf For the Sharpe ratio, you simply need to write a new objective function.Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.