[R-SIG-Finance] Applying quarterly weights on daily returns
ggrothendieck at gmail.com
Mon Jun 9 18:55:54 CEST 2008
If I understand it then you want to lag rets by one day, mulitply that
by tsig and then sum over the quarter and mulitply that by wts:
z <- tsig * lag(rets)
rowsum(z, as.yearqtr(time(z))) * wts
The rowsum output is a matrix and wts is zoo so
this depends on them having the same shapes.
On Mon, Jun 9, 2008 at 12:19 PM, Murali Menon <feanor0 at hotmail.com> wrote:
> I have quarterly weights (4 quarters) and 300 days of daily trading signals and returns for 3 assets.
> wts <- abs(zoo(matrix(rnorm(36), ncol = 3), yearqtr(1970 + (0 : 3) / 4)) )
> rets <- zoo(matrix(rnorm(900), ncol = 3) / 100, order.by = as.Date(1 : 300))
> tsig <- zoo(rbinom(300, 2, 0.5) - 1, order.by = as.Date(1 : 300))
> In each quarter, the return would be like:
> rowSums(head(tsig, -1) * tail(rets, -1) * wts(of that quarter))
> Where the trading signal is applied today, but its return is observed tomorrow.
> How to apply quarterly series on a daily series, though?
> Please advise.
> Instantly invite friends from Facebook and other social networks to join yo
> R-SIG-Finance at stat.math.ethz.ch mailing list
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
More information about the R-SIG-Finance