[Rquantlib-commits] r319 - in pkg/RQuantLib: . R src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Sep 10 15:22:26 CEST 2011
Author: edd
Date: 2011-09-10 15:22:26 +0200 (Sat, 10 Sep 2011)
New Revision: 319
Modified:
pkg/RQuantLib/DESCRIPTION
pkg/RQuantLib/NAMESPACE
pkg/RQuantLib/R/dayCounter.R
pkg/RQuantLib/src/daycounter.cpp
Log:
add a quick function setEvaluationDate() to set the QuantLib-global date
Modified: pkg/RQuantLib/DESCRIPTION
===================================================================
--- pkg/RQuantLib/DESCRIPTION 2011-09-09 15:03:39 UTC (rev 318)
+++ pkg/RQuantLib/DESCRIPTION 2011-09-10 13:22:26 UTC (rev 319)
@@ -1,6 +1,6 @@
Package: RQuantLib
Title: R interface to the QuantLib library
-Version: 0.3.7
+Version: 0.3.7.1
Date: $Date$
Maintainer: Dirk Eddelbuettel <edd at debian.org>
Author: Dirk Eddelbuettel <edd at debian.org> and Khanh Nguyen <knguyen at cs.umb.edu>
Modified: pkg/RQuantLib/NAMESPACE
===================================================================
--- pkg/RQuantLib/NAMESPACE 2011-09-09 15:03:39 UTC (rev 318)
+++ pkg/RQuantLib/NAMESPACE 2011-09-10 13:22:26 UTC (rev 319)
@@ -43,6 +43,7 @@
##--dayCounter.R
"dayCount",
"yearFraction",
+ "setEvaluationDate",
##--discount.R
"DiscountCurve",
"plot.DiscountCurve",
Modified: pkg/RQuantLib/R/dayCounter.R
===================================================================
--- pkg/RQuantLib/R/dayCounter.R 2011-09-09 15:03:39 UTC (rev 318)
+++ pkg/RQuantLib/R/dayCounter.R 2011-09-10 13:22:26 UTC (rev 319)
@@ -1,3 +1,25 @@
+## RQuantLib -- R interface to the QuantLib libraries
+##
+## Copyright (C) 2010 Dirk Eddelbuettel and Khanh Nguyen
+##
+## $Id: calendars.R 293 2010-08-07 15:56:13Z edd $
+##
+## This file is part of the RQuantLib library for GNU R.
+## It is made available under the terms of the GNU General Public
+## License, version 2, or at your option, any later version,
+## incorporated herein by reference.
+##
+## This program is distributed in the hope that it will be
+## useful, but WITHOUT ANY WARRANTY; without even the implied
+## warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+## PURPOSE. See the GNU General Public License for more
+## details.
+##
+## You should have received a copy of the GNU General Public
+## License along with this program; if not, write to the Free
+## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+## MA 02111-1307, USA
+
dayCount <- function(startDates, endDates, dayCounters){
val <- .Call('dayCount', startDates, endDates, dayCounters,
@@ -10,3 +32,8 @@
PACKAGE="RQuantLib")
val
}
+
+setEvaluationDate <- function(evalDate) {
+ val <- .Call("setEvaluationDate", evalDate, PACKAGE="RQuantLib")
+ val
+}
Modified: pkg/RQuantLib/src/daycounter.cpp
===================================================================
--- pkg/RQuantLib/src/daycounter.cpp 2011-09-09 15:03:39 UTC (rev 318)
+++ pkg/RQuantLib/src/daycounter.cpp 2011-09-10 13:22:26 UTC (rev 319)
@@ -79,3 +79,19 @@
return R_NilValue;
}
+
+// this could go into another file too... maybe regroup all calendar / date functions?
+RcppExport SEXP setEvaluationDate(SEXP evalDateSEXP) {
+
+ try {
+
+ // set the date
+ QuantLib::Settings::instance().evaluationDate() = QuantLib::Date(dateFromR(Rcpp::as<Rcpp::Date>(evalDateSEXP)));
+
+ } catch(std::exception &ex) {
+ forward_exception_to_r(ex);
+ } catch(...) {
+ ::Rf_error("c++ exception (unknown reason)");
+ }
+ return R_NilValue;
+}
More information about the Rquantlib-commits
mailing list