An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20120808/29363b9a/attachment.pl>
getEndOfMonth and getEndOfBizWeek in RcppBDT broken?
5 messages · David Reiner, Dirk Eddelbuettel
On 8 August 2012 at 11:17, David Reiner wrote:
| At least on my setup, they don't seem to work:
|
| > getEndOfBizWeek(date=as.Date('2012-09-05'))
| [1] "2012-08-10"
| > getEndOfMonth(date=as.Date('2012-09-05'))
| [1] "2012-08-31"
Dang. The functions hang off a package-global instance of the BDT module
class, and that one doesn't seem to get updated from the date you feed. Not
good.
Workaround: init a new object using the explicit constructor with the date
you want and compute off that:
R> mynewdate <- new(bdtDate, 2012,9,5)
R> mynewdate
[1] "2012-09-05"
R> mynewdate$getEndOfBizWeek( )
[1] "2012-09-07"
R> mynewdate$getEndOfMonth( )
[1] "2012-09-30"
R>
R>
Dirk
| > sessionInfo()
| R version 2.15.1 Patched (2012-06-25 r59634)
| Platform: x86_64-pc-mingw32/x64 (64-bit)
|
| locale:
| [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
| [4] LC_NUMERIC=C LC_TIME=English_United States.1252
|
| attached base packages:
| [1] stats graphics grDevices utils datasets methods base
|
| other attached packages:
| [1] RcppBDT_0.2.0 Rcpp_0.9.13
|
| loaded via a namespace (and not attached):
| [1] codetools_0.2-8 tools_2.15.1
|
| Many thanks to Dirk for all of his contributions to our community!
| (and to anyone else who can help here!)
| -- David
|
|
|
| This e-mail and any materials attached hereto, including, without limitation, all content hereof and thereof (collectively, "XR Content") are confidential and proprietary to XR Trading LLC ("XR") and/or its affiliates, and are protected by intellectual property laws. Without the prior written consent of XR, the XR Content may not (i) be disclosed to any third party or (ii) be reproduced or otherwise used by anyone other than current employees of XR or its affiliates, on behalf of XR or its affiliates.
|
| THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY KIND. TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.
|
| [[alternative HTML version deleted]]
|
| _______________________________________________
| R-SIG-Finance at r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-sig-finance
| -- Subscriber-posting only. If you want to post, subscribe first.
| -- Also note that this is not the r-help list where general R questions should go.
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Ok, bug found. In the R file definining the convenience functions
getEndOfBizWeek <- function(date = Sys.Date()) {
stopifnot(inherits(date, "Date"))
bdt$getEndOfBizWeek(date)
}
getEndOfMonth <- function(date = Sys.Date()) {
stopifnot(inherits(date, "Date"))
bdt$getEndOfMonth(date)
}
both of these miss the crucial
bdt$fromDate(date)
to actually set the date you supply. You could write yourself a local
variant til the updated package comes through.
Thanks for spotting this.
Dirk
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Thanks, Dirk. You're the best!
-- David
-----Original Message-----
From: Dirk Eddelbuettel [mailto:edd at debian.org]
Sent: Wednesday, August 08, 2012 1:02 PM
To: David Reiner
Cc: r-sig-finance at r-project.org; dirk at eddelbuettel.com
Subject: Re: [R-SIG-Finance] getEndOfMonth and getEndOfBizWeek in RcppBDT broken?
Ok, bug found. In the R file definining the convenience functions
getEndOfBizWeek <- function(date = Sys.Date()) {
stopifnot(inherits(date, "Date"))
bdt$getEndOfBizWeek(date)
}
getEndOfMonth <- function(date = Sys.Date()) {
stopifnot(inherits(date, "Date"))
bdt$getEndOfMonth(date)
}
both of these miss the crucial
bdt$fromDate(date)
to actually set the date you supply. You could write yourself a local
variant til the updated package comes through.
Thanks for spotting this.
Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
This e-mail and any materials attached hereto, including, without limitation, all content hereof and thereof (collectively, "XR Content") are confidential and proprietary to XR Trading, LLC ("XR") and/or its affiliates, and are protected by intellectual property laws. Without the prior written consent of XR, the XR Content may not (i) be disclosed to any third party or (ii) be reproduced or otherwise used by anyone other than current employees of XR or its affiliates, on behalf of XR or its affiliates.
THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY KIND. TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.
On 8 August 2012 at 16:01, David Reiner wrote:
| Thanks, Dirk. You're the best!
No, that is Uwe -- as the new version 0.2.1 is already on CRAN :)
Thanks again for catching this.
Dirk
|
| -- David
|
|
| -----Original Message-----
| From: Dirk Eddelbuettel [mailto:edd at debian.org]
| Sent: Wednesday, August 08, 2012 1:02 PM
| To: David Reiner
| Cc: r-sig-finance at r-project.org; dirk at eddelbuettel.com
| Subject: Re: [R-SIG-Finance] getEndOfMonth and getEndOfBizWeek in RcppBDT broken?
|
|
| Ok, bug found. In the R file definining the convenience functions
|
| getEndOfBizWeek <- function(date = Sys.Date()) {
| stopifnot(inherits(date, "Date"))
| bdt$getEndOfBizWeek(date)
| }
|
| getEndOfMonth <- function(date = Sys.Date()) {
| stopifnot(inherits(date, "Date"))
| bdt$getEndOfMonth(date)
| }
|
| both of these miss the crucial
|
| bdt$fromDate(date)
|
| to actually set the date you supply. You could write yourself a local
| variant til the updated package comes through.
|
| Thanks for spotting this.
|
| Dirk
|
| --
| Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
|
|
| This e-mail and any materials attached hereto, including, without limitation, all content hereof and thereof (collectively, "XR Content") are confidential and proprietary to XR Trading, LLC ("XR") and/or its affiliates, and are protected by intellectual property laws. Without the prior written consent of XR, the XR Content may not (i) be disclosed to any third party or (ii) be reproduced or otherwise used by anyone other than current employees of XR or its affiliates, on behalf of XR or its affiliates.
|
| THE XR CONTENT IS PROVIDED AS IS, WITHOUT REPRESENTATIONS OR WARRANTIES OF ANY KIND. TO THE MAXIMUM EXTENT PERMISSIBLE UNDER APPLICABLE LAW, XR HEREBY DISCLAIMS ANY AND ALL WARRANTIES, EXPRESS AND IMPLIED, RELATING TO THE XR CONTENT, AND NEITHER XR NOR ANY OF ITS AFFILIATES SHALL IN ANY EVENT BE LIABLE FOR ANY DAMAGES OF ANY NATURE WHATSOEVER, INCLUDING, BUT NOT LIMITED TO, DIRECT, INDIRECT, CONSEQUENTIAL, SPECIAL AND PUNITIVE DAMAGES, LOSS OF PROFITS AND TRADING LOSSES, RESULTING FROM ANY PERSON'S USE OR RELIANCE UPON, OR INABILITY TO USE, ANY XR CONTENT, EVEN IF XR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR IF SUCH DAMAGES WERE FORESEEABLE.
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com