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

Phil Elsasser paelsasser1 at gmail.com
Mon Feb 4 13:55:43 CET 2013


I am having a very similar issue.

I believe.  Here is some code to reproduce it.


 getSymbols("SPY", src="yahoo", from="2012-06-01")
to.monthly(SPY) # looks correct
indexTZ(SPY) <- "America/Chicago"
to.monthly(SPY) # Missing January Print

SPY[endpoints(SPY, "months")] # Same thing here

 packageVersion("xts")
[1] ‘0.9.2’


On Mon, Feb 4, 2013 at 5:00 AM,  <r-sig-finance-request at r-project.org> wrote:
> Send R-SIG-Finance mailing list submissions to
>         r-sig-finance at r-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> or, via email, send a message with subject or body 'help' to
>         r-sig-finance-request at r-project.org
>
> You can reach the person managing the list at
>         r-sig-finance-owner at r-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-SIG-Finance digest..."
>
>
> Today's Topics:
>
>    1. bug on to.monthly? (Ulrich Staudinger)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 4 Feb 2013 11:58:15 +0100
> From: Ulrich Staudinger <ustaudinger at activequant.com>
> To: R-SIG-Finance <r-sig-finance at r-project.org>
> Subject: [R-SIG-Finance] bug on to.monthly?
> Message-ID:
>         <CAMrz3D1_x4-g2P7xfh7PRJe-DoAHRbAwk8ASPfhCJezYUzd=Hg at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> 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
>
>
>
> ------------------------------
>
> _______________________________________________
> R-SIG-Finance mailing list
> R-SIG-Finance at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>
>
> End of R-SIG-Finance Digest, Vol 105, Issue 4
> *********************************************



More information about the R-SIG-Finance mailing list