[R-SIG-Finance] in xts behavior of to.minutes() and to.period()

Joshua Ulrich josh.m.ulrich at gmail.com
Wed Jun 24 17:02:12 CEST 2009


Hi Kenneth,

to.period() removes NAs before aggregating.  So I would guess WMP has
4 rows with NA, and those same values in VI are zero.

HTH,
Josh
--
http://www.fosstrading.com



On Wed, Jun 24, 2009 at 9:52 AM, Kenneth Spriggs<ksspriggs at gmail.com> wrote:
> Both VI and WMP are derived from the same xts object - they have the
> same rows.  When I use to.minutes() on VI it yields 618 rows but for
> WMP it yields 614 rows.
> (Same thing if I use to.period() but that's not surprising.)  You can
> see both the start times and end times are the same...
>
>> nrow(VI); nrow(WMP)
> [1] 401600
> [1] 401600
>
>> head(VI, 1); tail(VI, 1)
>                        LastPrice
> 2009-06-22 21:41:54.869         0
>                        LastPrice
> 2009-06-23 18:59:59.735     25689
>
>> head(WMP, 1); tail(WMP, 1)
>                        BidPrice
> 2009-06-22 21:41:54.869       NA
>                        BidPrice
> 2009-06-23 18:59:59.735 115.4746
>
>> VI_minute2 <- to.minutes(VI,2)
>> WMP_minute2 <- to.minutes(WMP, 2)
>> nrow(VI_minute2); nrow(WMP_minute2)
> [1] 618
> [1] 614
>
>> VI_minute2p <- to.period(VI, period = "minutes", k=2)
>> WMP_minute2p <- to.period(WMP, period = "minutes", k=2)
>> nrow(VI_minute2p); nrow(WMP_minute2p)
> [1] 618
> [1] 614
>
> _______________________________________________
> 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