[R-SIG-Finance] ranking xts objects

Brian G. Peterson brian at braverock.com
Mon Mar 12 22:22:50 CET 2012


On Mon, 2012-03-12 at 13:17 -0700, Gaurav Malhotra wrote:
> Brian and Jeff ,
> 
> Thanks a lot! I did manage to get a whole lot closer to what I wish to achieve. Right now I'm mulling over two things... one is how can you have the weights reflect a "holding" period.. I'm thinking an if else such that if -1, set to 0 in 3 periods, if +1, set to zero in 3 periods, else zero - might do the trick.
> 
> The second thing is related to the first. In Return.rebalancing/Return.portofolio, if the input object is a (past) 3 month return xts, how does one interpret the results? Does it mean that on a 3 month basis, the function gives me my returns? If this is the case, then this would negate the need for the holding period stuff described above I assume.
> 
> However, the results of the function based on the 3 month returns seemed to be ungodly, and I'm still unsure as to what they represent. Should I only be using one-month returns as the inputs here?

You had previously stipulated that you wanted to rank and rebalance
every three months (or something like that).

The rankings at each of your rebalancing periods choose your weights,
top 10% rank, long, bottom 10% rank, short.  I already told you
approximately how to do this with an ifelse statement

Holding period is determined simply by when you no longer have that
weight.  You will change when the rank changes, and not before.

Return.rebalancing takes an xts object of rebalancing dates.  On those
dates, the portfolio is rebalanced to the specified weights.  After
that, the weights float naturally based on their own returns.  Use
whatever you want to create the new weights at the rebalancing periods,
but there's no reason that the object you apply it to couldn't be daily
returns.

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list