[R-SIG-Finance] bug on to.monthly?

Ulrich Staudinger ustaudinger at activequant.com
Mon Feb 4 11:58:15 CET 2013


Gents,

I want to convert the following xts NAV series from daily to monthly.

Browse[1]> navSeries
[..]
2013-01-21 1089.233
2013-01-22 1088.627
2013-01-23 1086.648
2013-01-24 1095.522
2013-01-25 1100.402
2013-01-28 1098.846
2013-01-29 1105.938
2013-01-30 1102.504
2013-01-31 1102.386
2013-02-01 1111.651

So I call ...
monthlyNAV = to.monthly(navSeries)[,4]

and it yields:

Oct 2012        1034.037
Nov 2012        1039.267
Dec 2012        1055.666
Jan 2013        1102.386
Jan 2013        1111.651
Browse[1]>


As you can see, the Jan2013 exists twice!

I also had a look at the index already:
Browse[1]> tail(index(navSeries))
[1] "2013-01-25 CET" "2013-01-28 CET" "2013-01-29 CET" "2013-01-30 CET"
[5] "2013-01-31 CET" "2013-02-01 CET"
Browse[1]>


For reproduction, I made a little script:

Here's test.csv:
2013-01-30;100
2013-01-31;101
2013-02-01;102

> x1 = read.zoo("/opt/reports/etl/test.csv", sep=";")
> index(x1)
[1] "2013-01-30" "2013-01-31" "2013-02-01"
> as.POSIXct(index(x1))
[1] "2013-01-30 01:00:00 CET" "2013-01-31 01:00:00 CET"
[3] "2013-02-01 01:00:00 CET"
> to.monthly(x1)
         x1.Open x1.High x1.Low x1.Close
Jan 2013     100     101    100      101
Jan 2013     102     102    102      102
Warning message:
In zoo(xx, order.by = index(x), ...) :
  some methods for “zoo” objects do not work if the index entries in
‘order.by’ are not unique
>

Can someone shed some light?

Thanks
Ulrich





-- 
Ulrich Staudinger

P: +41 79 702 05 95
E: ustaudinger at activequant.com

http://www.activequant.com

AQ-R user? Join our mailing list:
http://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/aqr-user



More information about the R-SIG-Finance mailing list