Hi,

I am trying to set-up a group constraint within PortfolioAnalytics, but I
run into a problem if the current portfolio doesn't have weights in each of
the groups. As an example, if I set a +/- 5% sector constraint on all 10
sectors, but my current portfolio is only in 7 of the 10 sectors, the
optimization step fails.

The groups within the constraint is a list and the empty groups have an
index of 0, since an empty list can't be accepted.

ex.

sectiors <- c('s1','s2','s3','s4')
sector.weights.max <- list(s1 = 0.3, s2 = 0.25, s3 = 0.40, s4=0.25)
sector.weights.min <- list(s1 = 0.2, s2 = 0.15, s3 = 0.30, s4=0.15)
sector.groups <- list(s1 = list(1,2,5), s2=list(3,4), s3=list(0),
s4=list(6))

pspec <- add.constraint(portfolio = pspec,
                        type = 'group',
                        groups = sector.groups,
                        group_labels = sectors,
                        group_min = sector.weights.min,
                        group_max = sector.weights.max)

Depending on the optimization algorithm I try, a different problem arises.

When I try to generate a sequence of random portfolios, this is the error:
rp = random_portfolios(pspec, permutations = 2000, rp_method = 'sample',
eliminate = TRUE)
Error in seq.default(from = round(min, rounding), to = round(max,
rounding),  :
  'from' cannot be NA, NaN or infinite
In addition: Warning messages:
1: In min(min_box) : no non-missing arguments to min; returning Inf
2: In max(max_box) : no non-missing arguments to max; returning -Inf

How can I specify an empty group in the constraint, but still define a
min/max constraint since a rebalance may include a position within that
group.  Is that possible?

Thank you,
Peter

        [[alternative HTML version deleted]]

_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to