# [R] Control number of assets in resulting portfolio with optimizations using package fPortfolio

Enrico Schumann enricoschumann at yahoo.de
Fri Feb 17 07:53:42 CET 2012

```Hi Alex,

I cannot say how to implement such constraints with fPortfolio, but in
general you can use heuristics to solve such problems. An example for
selecting a number of assets from a larger universe is given in a
vignette of the NMOF package (of which I am the author) and in the code
examples on http://nmof.net (even though they do not exactly cover your
problem).

Regards,
Enrico

Am 15.02.2012 20:18, schrieb Alexander Erbse:
> Dear All,
>
>
>
> I am using package fPortfolio to run minimum variance portfolio
> optimizations in R. I already know how to set portfolioSpecs, portfolio
> objects and constraints. Unfortunately I am not able to set the following
> type of constraints.
>
> I have a timeSeries object with returns data for roughly 1.5k assets for 261
> subperiods (workingdays) and want to compute the global minimum variance
> portfolio, considering following constraints:
>
>
>
> -          Leverage = 1 (fully invested)
>
>
>
> -          the lower / upper weights constraints (can be done by box
> constraints) for individual assets are e.g. +0,01 / +0,04
>
>
>
> -          and the problematic part: the minimum weights level for each
> asset is +0,01 OR zero (in order to control outcome portfolio size)
>
>
>
> � Initially, considering that the minimum weight constraint is +0,01 for
> each of the 1.500 assets and the sum of weights constraint (leverage) equals
> 1 would raise an infeasible problem for the optimizer. Given my additional
> restriction that the minimum weight for any asset to get into the portfolio
> should be at least 0,01 would solve the target conflict in between minimum
> asset weights and the leverage of 1. The iteration path of the optimizer
> should consider something like this:
>
>
>
> ifelse(min(weight,0,01)<0,01,0,weight)
>
>
>
> �during the optimization. (iteratively)
>
>
>
> Is there any way to implement that sort of that constraint besides the upper
> / lower weight constraints (box constraints) in order to control for decent
> portfolio sizes?
>
>
>
> Thx&  Regards,
>
> Alex
>
>
> 	[[alternative HTML version deleted]]
>
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help