[R-SIG-Finance] Applying quarterly weights on daily returns

Gabor Grothendieck 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:
>
>
> Folks,
>
> I have quarterly weights (4 quarters) and 300 days of daily trading signals and returns for 3 assets.
>
> library(zoo)
> set.seed(123)
>
> 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.
>
> Thanks,
>
> Murali
> _________________________________________________________________
> Instantly invite friends from Facebook and other social networks to join yo
> https://www.invite2messenger.net/im/?source=TXT_EML_WLH_InviteFriends
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>



More information about the R-SIG-Finance mailing list