[Rquantlib-commits] r264 - in pkg/RQuantLib: . inst man src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 23 22:27:14 CEST 2010


Author: edd
Date: 2010-06-23 22:27:13 +0200 (Wed, 23 Jun 2010)
New Revision: 264

Added:
   pkg/RQuantLib/man/setCalendarContext.Rd
Modified:
   pkg/RQuantLib/DESCRIPTION
   pkg/RQuantLib/inst/ChangeLog
   pkg/RQuantLib/src/bermudan.cpp
   pkg/RQuantLib/src/bonds.cpp
   pkg/RQuantLib/src/calendars.cpp
   pkg/RQuantLib/src/daycounter.cpp
   pkg/RQuantLib/src/discount.cpp
   pkg/RQuantLib/src/hullwhite.cpp
   pkg/RQuantLib/src/rquantlib.hpp
   pkg/RQuantLib/src/utils.cpp
   pkg/RQuantLib/src/zero.cpp
Log:
completes the move to new Rcpp API


Modified: pkg/RQuantLib/DESCRIPTION
===================================================================
--- pkg/RQuantLib/DESCRIPTION	2010-06-21 03:24:55 UTC (rev 263)
+++ pkg/RQuantLib/DESCRIPTION	2010-06-23 20:27:13 UTC (rev 264)
@@ -1,6 +1,6 @@
 Package: RQuantLib
 Title: R interface to the QuantLib library
-Version: 0.3.2.1
+Version: 0.3.2.2
 Date: $Date$
 Maintainer: Dirk Eddelbuettel <edd at debian.org>
 Author: Dirk Eddelbuettel <edd at debian.org> and Khanh Nguyen <knguyen at cs.umb.edu>
@@ -24,10 +24,10 @@
  Note that while RQuantLib's code is licensed under the GPL (v2 or later),
  QuantLib itself is released under a somewhat less restrictive Open Source
  license (see QuantLib-License.txt).
-Depends: R (>= 2.7.0), Rcpp (>= 0.8.2.8)
+Depends: R (>= 2.10.0), Rcpp (>= 0.8.2.12)
 LinkingTo: Rcpp
 SystemRequirements: QuantLib library (>= 0.9.9) from http://quantlib.org, 
- Boost library (>= 1.34.0) from http://www.boost.org
+ Boost library from http://www.boost.org
 License: GPL (>= 2)
 URL: http://quantlib.org http://dirk.eddelbuettel.com/code/rquantlib.html
 Packaged: Wed Jan  2 21:33:23 2008; edd

Modified: pkg/RQuantLib/inst/ChangeLog
===================================================================
--- pkg/RQuantLib/inst/ChangeLog	2010-06-21 03:24:55 UTC (rev 263)
+++ pkg/RQuantLib/inst/ChangeLog	2010-06-23 20:27:13 UTC (rev 264)
@@ -1,3 +1,7 @@
+2010-06-23  Dirk Eddelbuettel  <edd at debian.org>
+
+	* src/*: Converted remainder of code to new Rcpp API
+
 2010-06-20  Dirk Eddelbuettel  <edd at debian.org>
 
 	* R/calendar.R: New helper function setCalendarContext()

Added: pkg/RQuantLib/man/setCalendarContext.Rd
===================================================================
--- pkg/RQuantLib/man/setCalendarContext.Rd	                        (rev 0)
+++ pkg/RQuantLib/man/setCalendarContext.Rd	2010-06-23 20:27:13 UTC (rev 264)
@@ -0,0 +1,32 @@
+% $Id$
+\name{setCalendarContext}
+\alias{setCalendarContext}
+\title{Set global calendar constants}
+\description{
+The \code{setCalendarContext} function sets three values to a singleton
+instance at the C++ layer.}
+\usage{
+setCalendarContext(calendar, fixingDays, settleDate)
+}
+\arguments{
+  \item{calendar}{A string denoting a calendar, default is 'TARGET' or a
+    non-country specific calendar.}
+  \item{fixingDays}{An integer for the fixing day period, defaults to 2.}
+  \item{settleDate}{A date on which trades settles, defaults to two days
+    after the current day.}
+}
+\value{
+  A boolean or NULL in case of error.
+}
+\details{
+  These values are assigned to global 'singleton' instance (of which
+  only one can ever be instantiated) and permit to store these values
+  between calls. 
+}
+\references{\url{http://quantlib.org} for details on \code{QuantLib}.}
+\author{Dirk Eddelbuettel \email{edd at debian.org} for the \R interface;
+  Khanh Nguyen \email{nguyen.h.khanh at gmail.com} for the implementation;
+  the QuantLib Group for \code{QuantLib}}
+\note{The interface might change in future release as \code{QuantLib}
+  stabilises its own API.}
+\keyword{misc}

Modified: pkg/RQuantLib/src/bermudan.cpp
===================================================================
--- pkg/RQuantLib/src/bermudan.cpp	2010-06-21 03:24:55 UTC (rev 263)
+++ pkg/RQuantLib/src/bermudan.cpp	2010-06-23 20:27:13 UTC (rev 264)
@@ -128,23 +128,17 @@
                                                                            Actual365Fixed())));
 
         // Get swaption vol matrix.
-        //RcppMatrix<double> myVols(vols);
         Rcpp::NumericMatrix swaptionVols(vols);
-        int dim1 = swaptionVols.nrow(); //myVols.getDim1();
-        int dim2 = swaptionVols.ncol(); //myVols.getDim2();
-        //swaptionVols = myVols.cMatrix();
+        int dim1 = swaptionVols.nrow(); 
+        int dim2 = swaptionVols.ncol(); 
 	
         // Get swaption maturities
-        //RcppVector<int> myMats(maturities);
         Rcpp::NumericVector swaptionMat(maturities);
-        int numRows = swaptionMat.size(); //myMats.size();
-        //swaptionMat = myMats.cVector();
+        int numRows = swaptionMat.size(); 
 
         // Get swap tenors
-        //RcppVector<int> myLengths(tenors);
         Rcpp::NumericVector swapLengths(tenors);
-        int numCols = swapLengths.size(); //myLengths.size();
-        //swapLengths = myLengths.cVector();
+        int numCols = swapLengths.size(); 
 
         if (numRows*numCols != dim1*dim2) {
             std::ostringstream oss;
@@ -236,8 +230,6 @@
         }
         boost::shared_ptr<Exercise> bermudaExercise(new BermudanExercise(bermudanDates));
 
-        //RcppResultSet rs;
-
         // Price based on method selected.
         if (method.compare("G2Analytic") == 0) {
 

Modified: pkg/RQuantLib/src/bonds.cpp
===================================================================
--- pkg/RQuantLib/src/bonds.cpp	2010-06-21 03:24:55 UTC (rev 263)
+++ pkg/RQuantLib/src/bonds.cpp	2010-06-23 20:27:13 UTC (rev 264)
@@ -38,8 +38,8 @@
         double frequency = Rcpp::as<double>(rparam["frequency"]);
         double businessDayConvention = Rcpp::as<double>(rparam["businessDayConvention"]);
         double compound = Rcpp::as<double>(rparam["compound"]);
-        RcppDate mDate = RcppDate(Rcpp::as<int>(rparam["maturityDate"]));
-        RcppDate iDate = RcppDate(Rcpp::as<int>(rparam["issueDate"]));
+        Rcpp::Date mDate = Rcpp::Date(Rcpp::as<int>(rparam["maturityDate"]));
+        Rcpp::Date iDate = Rcpp::Date(Rcpp::as<int>(rparam["issueDate"]));
         QuantLib::Date maturityDate(dateFromR(mDate));
         QuantLib::Date issueDate(dateFromR(iDate));
         //setup bond
@@ -81,8 +81,8 @@
         double frequency = Rcpp::as<double>(rparam["frequency"]);
         double businessDayConvention = Rcpp::as<double>(rparam["businessDayConvention"]);
         double compound = Rcpp::as<double>(rparam["compound"]);
-        RcppDate mDate = RcppDate(Rcpp::as<int>(rparam["maturityDate"]));
-        RcppDate iDate = RcppDate(Rcpp::as<int>(rparam["issueDate"]));
+        Rcpp::Date mDate = Rcpp::Date(Rcpp::as<int>(rparam["maturityDate"]));
+        Rcpp::Date iDate = Rcpp::Date(Rcpp::as<int>(rparam["issueDate"]));
         QuantLib::Date maturityDate(dateFromR(mDate));
         QuantLib::Date issueDate(dateFromR(iDate));
         //setup bond
@@ -121,8 +121,8 @@
     try {
         Rcpp::List rparam(bondparam);
         double faceAmount = Rcpp::as<double>(rparam["faceAmount"]);
-        RcppDate mDate = RcppDate(Rcpp::as<int>(rparam["maturityDate"]));
-        RcppDate iDate = RcppDate(Rcpp::as<int>(rparam["issueDate"]));
+        Rcpp::Date mDate = Rcpp::Date(Rcpp::as<int>(rparam["maturityDate"]));
+        Rcpp::Date iDate = Rcpp::Date(Rcpp::as<int>(rparam["issueDate"]));
         QuantLib::Date maturityDate(dateFromR(mDate));
         QuantLib::Date issueDate(dateFromR(iDate));
         double redemption = Rcpp::as<double>(rparam["redemption"]);
@@ -131,7 +131,7 @@
         double settlementDays = Rcpp::as<double>(misc["settlementDays"]);
         std::string cal = Rcpp::as<std::string>(misc["calendar"]);
         double businessDayConvention = Rcpp::as<double>(misc["businessDayConvention"]);
-        QuantLib::Date refDate(dateFromR(RcppDate(Rcpp::as<int>(misc["refDate"]))));      
+        QuantLib::Date refDate(dateFromR(Rcpp::Date(Rcpp::as<int>(misc["refDate"]))));      
         Settings::instance().evaluationDate() = refDate;                               
         
         /*
@@ -184,9 +184,9 @@
         Rcpp::List rparam(bondparam);
         
         double faceAmount = Rcpp::as<double>(rparam["faceAmount"]);
-        RcppDate mDate = RcppDate(Rcpp::as<int>(rparam["maturityDate"]));
-        RcppDate eDate = RcppDate(Rcpp::as<int>(rparam["effectiveDate"]));
-        RcppDate iDate = RcppDate(Rcpp::as<int>(rparam["issueDate"]));
+        Rcpp::Date mDate = Rcpp::Date(Rcpp::as<int>(rparam["maturityDate"]));
+        Rcpp::Date eDate = Rcpp::Date(Rcpp::as<int>(rparam["effectiveDate"]));
+        Rcpp::Date iDate = Rcpp::Date(Rcpp::as<int>(rparam["issueDate"]));
         QuantLib::Date maturityDate(dateFromR(mDate));
         QuantLib::Date effectiveDate(dateFromR(eDate));
         QuantLib::Date issueDate(dateFromR(iDate));
@@ -263,9 +263,9 @@
         double dayCounter = Rcpp::as<double>(rparam["dayCounter"]);
         double frequency = Rcpp::as<double>(rparam["period"]);
         
-        RcppDate mDate = RcppDate(Rcpp::as<int>(rparam["maturityDate"]));
-        RcppDate eDate = RcppDate(Rcpp::as<int>(rparam["effectiveDate"]));
-        RcppDate iDate = RcppDate(Rcpp::as<int>(rparam["issueDate"]));
+        Rcpp::Date mDate = Rcpp::Date(Rcpp::as<int>(rparam["maturityDate"]));
+        Rcpp::Date eDate = Rcpp::Date(Rcpp::as<int>(rparam["effectiveDate"]));
+        Rcpp::Date iDate = Rcpp::Date(Rcpp::as<int>(rparam["issueDate"]));
         QuantLib::Date maturityDate(dateFromR(mDate));
         QuantLib::Date effectiveDate(dateFromR(eDate));
         QuantLib::Date issueDate(dateFromR(iDate));
@@ -321,9 +321,9 @@
         double dayCounter = Rcpp::as<double>(rparam["dayCounter"]);
         double frequency = Rcpp::as<double>(rparam["period"]);
         
-        RcppDate mDate = RcppDate(Rcpp::as<int>(rparam["maturityDate"]));
-        RcppDate eDate = RcppDate(Rcpp::as<int>(rparam["effectiveDate"]));
-        RcppDate iDate = RcppDate(Rcpp::as<int>(rparam["issueDate"]));
+        Rcpp::Date mDate = Rcpp::Date(Rcpp::as<int>(rparam["maturityDate"]));
+        Rcpp::Date eDate = Rcpp::Date(Rcpp::as<int>(rparam["effectiveDate"]));
+        Rcpp::Date iDate = Rcpp::Date(Rcpp::as<int>(rparam["issueDate"]));
         QuantLib::Date maturityDate(dateFromR(mDate));
         QuantLib::Date effectiveDate(dateFromR(eDate));
         QuantLib::Date issueDate(dateFromR(iDate));
@@ -376,9 +376,9 @@
     try {
         Rcpp::List rparam(bondparam);        
         double faceAmount = Rcpp::as<double>(rparam["faceAmount"]);     
-        RcppDate mDate = RcppDate(Rcpp::as<int>(rparam["maturityDate"]));
-        RcppDate eDate = RcppDate(Rcpp::as<int>(rparam["effectiveDate"]));
-        RcppDate iDate = RcppDate(Rcpp::as<int>(rparam["issueDate"]));
+        Rcpp::Date mDate = Rcpp::Date(Rcpp::as<int>(rparam["maturityDate"]));
+        Rcpp::Date eDate = Rcpp::Date(Rcpp::as<int>(rparam["effectiveDate"]));
+        Rcpp::Date iDate = Rcpp::Date(Rcpp::as<int>(rparam["issueDate"]));
         QuantLib::Date maturityDate(dateFromR(mDate));
         QuantLib::Date effectiveDate(dateFromR(eDate));
         QuantLib::Date issueDate(dateFromR(iDate));
@@ -651,8 +651,8 @@
         Rcpp::List rparam(bondparams);
         
         //double faceAmount = Rcpp::as<double>(rparam["faceAmount");        
-        RcppDate mDate = RcppDate(Rcpp::as<int>(rparam["maturityDate"]));
-        RcppDate iDate = RcppDate(Rcpp::as<int>(rparam["issueDate"]));
+        Rcpp::Date mDate = Rcpp::Date(Rcpp::as<int>(rparam["maturityDate"]));
+        Rcpp::Date iDate = Rcpp::Date(Rcpp::as<int>(rparam["issueDate"]));
         QuantLib::Date maturityDate(dateFromR(mDate));
         QuantLib::Date issueDate(dateFromR(iDate));
         double redemption = Rcpp::as<double>(rparam["redemption"]);
@@ -759,8 +759,8 @@
 
         Rcpp::List rparam(bondparams);
         //double faceAmount = Rcpp::as<double>(rparam["faceAmount");        
-        RcppDate mDate = RcppDate(Rcpp::as<int>(rparam["maturityDate"]));
-        RcppDate iDate = RcppDate(Rcpp::as<int>(rparam["issueDate"]));
+        Rcpp::Date mDate = Rcpp::Date(Rcpp::as<int>(rparam["maturityDate"]));
+        Rcpp::Date iDate = Rcpp::Date(Rcpp::as<int>(rparam["issueDate"]));
         QuantLib::Date maturityDate(dateFromR(mDate));
         QuantLib::Date issueDate(dateFromR(iDate));
         double redemption = Rcpp::as<double>(rparam["redemption"]);
@@ -878,8 +878,8 @@
         Rcpp::List rparam(bondparams);
         
         //double faceAmount = Rcpp::as<double>(rparam["faceAmount");        
-        RcppDate mDate = RcppDate(Rcpp::as<int>(rparam["maturityDate"]));
-        RcppDate iDate = RcppDate(Rcpp::as<int>(rparam["issueDate"]));
+        Rcpp::Date mDate = Rcpp::Date(Rcpp::as<int>(rparam["maturityDate"]));
+        Rcpp::Date iDate = Rcpp::Date(Rcpp::as<int>(rparam["issueDate"]));
         QuantLib::Date maturityDate(dateFromR(mDate));
         QuantLib::Date issueDate(dateFromR(iDate));
         double redemption = Rcpp::as<double>(rparam["redemption"]);
@@ -1005,8 +1005,8 @@
         Rcpp::List rparam(bondparams);
         
         double faceAmount = Rcpp::as<double>(rparam["faceAmount"]);        
-        RcppDate mDate = RcppDate(Rcpp::as<int>(rparam["maturityDate"]));
-        RcppDate iDate = RcppDate(Rcpp::as<int>(rparam["issueDate"]));
+        Rcpp::Date mDate = Rcpp::Date(Rcpp::as<int>(rparam["maturityDate"]));
+        Rcpp::Date iDate = Rcpp::Date(Rcpp::as<int>(rparam["issueDate"]));
         QuantLib::Date maturityDate(dateFromR(mDate));
         QuantLib::Date issueDate(dateFromR(iDate));
         double redemption = Rcpp::as<double>(rparam["redemption"]);
@@ -1077,123 +1077,121 @@
     return R_NilValue;
 }
 
-/*
-RcppExport SEXP QL_CMSBond(SEXP bondparams, SEXP iborIndex, SEXP swapIndexParam, 
-                           SEXP capsVec, SEXP floorsVec, SEXP gearingsVec, 
-                           SEXP spreadsVec, SEXP swaptionVolSEXP, SEXP atmOptionTenorsSEXP,
-                           SEXP atmSwapTenorsSEXP, SEXP volMatrixSEXP, SEXP pricer,
-                           SEXP iborIndexDate, SEXP iborIndexRates)
-{
-    SEXP rl=R_NilValue;
-    char* exceptionMesg=NULL;
-    try {
+// RcppExport SEXP QL_CMSBond(SEXP bondparams, SEXP iborIndex, SEXP swapIndexParam, 
+//                            SEXP capsVec, SEXP floorsVec, SEXP gearingsVec, 
+//                            SEXP spreadsVec, SEXP swaptionVolSEXP, SEXP atmOptionTenorsSEXP,
+//                            SEXP atmSwapTenorsSEXP, SEXP volMatrixSEXP, SEXP pricer,
+//                            SEXP iborIndexDate, SEXP iborIndexRates)
+// {
+//     SEXP rl=R_NilValue;
+//     char* exceptionMesg=NULL;
+//     try {
 
-        std::vector<double> gearings = getDoubleVector(gearingsVec);
-        std::vector<double> spreads = getDoubleVector(spreadsVec);
-        std::vector<double> caps = getDoubleVector(capsVec);
-        std::vector<double> floors = getDoubleVector(floorsVec);
+//         std::vector<double> gearings = getDoubleVector(gearingsVec);
+//         std::vector<double> spreads = getDoubleVector(spreadsVec);
+//         std::vector<double> caps = getDoubleVector(capsVec);
+//         std::vector<double> floors = getDoubleVector(floorsVec);
 
-        RcppStringVector strVec(atmOptionTenorsSEXP);
-        std::vector<string> atmOptionTenors(strVec.stlVector());
-        RcppStringVector strVec2(atmSwapTenorsSEXP);
-        std::vector<string> atmSwapTenors(strVec2.stlVector());
+//         RcppStringVector strVec(atmOptionTenorsSEXP);
+//         std::vector<string> atmOptionTenors(strVec.stlVector());
+//         RcppStringVector strVec2(atmSwapTenorsSEXP);
+//         std::vector<string> atmSwapTenors(strVec2.stlVector());
 
-        RcppMatrix<double> m(volMatrixSEXP);
+//         RcppMatrix<double> m(volMatrixSEXP);
         
-        Handle<YieldTermStructure> termStructure(rebuildCurveFromZeroRates(
-                                                                           iborIndexDate,iborIndexRates));
-        Rcppparams iborparams(iborIndex);
-        std::string ibortype = iborparams.getStringValue("type");
-        std::string iborlength = iborparams.getStringValue("length");
-        boost::shared_ptr<IborIndex> ibor = getIborIndex(termStructure, ibortype, 
-                                                         iborlength);
-        //fix tenor to make sure it is converted by matchparam
-        Rcppparams swapparams(swapIndexParam);
-        std::string familyName = swapparams.getStringValue("familyName");
-        std::double tenor = swapparams.getDoubleValue("tenor");
-        std::double settlementDays = swapparams.getDoubleValue("settlementDays");
-        std::string currency = swapparams.getStringValue("currency");
-        std::string fixedLegTenor = swapparams.getDoubleValue("fixedLegTenor");
-        std::string fixedLegConvention = swapparams.getDoubleValue("fixedLegConvention");
-        std::string fixedLegDayCounter = swapparams.getDoubleValue("fixedLegDayCounter");
-        std::string cal = swapparams.getStringValue("calendar");
-        Calendar calendar = UnitedStates(UnitedStates::GovernmentBond);
-        if (cal == "us"){
-            calendar = UnitedStates(UnitedStates::GovernmentBond);
-        }
-        else if (cal == "uk"){
-            calendar = UnitedKingdom(UnitedKingdom::Exchange);
-        }
-        BusinessDayConvention fixedLegBDC = getBusinessDayConvention(fixedLegConvention);
-        DayCounter fixedLedDC = getDayCounter(fixedLegDayCounter);
+//         Handle<YieldTermStructure> termStructure(rebuildCurveFromZeroRates(
+//                                                                            iborIndexDate,iborIndexRates));
+//         Rcppparams iborparams(iborIndex);
+//         std::string ibortype = iborparams.getStringValue("type");
+//         std::string iborlength = iborparams.getStringValue("length");
+//         boost::shared_ptr<IborIndex> ibor = getIborIndex(termStructure, ibortype, 
+//                                                          iborlength);
+//         //fix tenor to make sure it is converted by matchparam
+//         Rcppparams swapparams(swapIndexParam);
+//         std::string familyName = swapparams.getStringValue("familyName");
+//         std::double tenor = swapparams.getDoubleValue("tenor");
+//         std::double settlementDays = swapparams.getDoubleValue("settlementDays");
+//         std::string currency = swapparams.getStringValue("currency");
+//         std::string fixedLegTenor = swapparams.getDoubleValue("fixedLegTenor");
+//         std::string fixedLegConvention = swapparams.getDoubleValue("fixedLegConvention");
+//         std::string fixedLegDayCounter = swapparams.getDoubleValue("fixedLegDayCounter");
+//         std::string cal = swapparams.getStringValue("calendar");
+//         Calendar calendar = UnitedStates(UnitedStates::GovernmentBond);
+//         if (cal == "us"){
+//             calendar = UnitedStates(UnitedStates::GovernmentBond);
+//         }
+//         else if (cal == "uk"){
+//             calendar = UnitedKingdom(UnitedKingdom::Exchange);
+//         }
+//         BusinessDayConvention fixedLegBDC = getBusinessDayConvention(fixedLegConvention);
+//         DayCounter fixedLedDC = getDayCounter(fixedLegDayCounter);
 
-        boost::shared_ptr<SwapIndex> swapIndex(new SwapIndex(familiName, 
-                                                             getPeriodFromString(fixedLegTenor),
-                                                             settlemenDays, 
-                                                             currency, 
-                                                             calendar,
-                                                             getPeriodFromString(fixedLegTenor), 
-                                                             fixedLegBDC, 
-                                                             fixedLegDC, 
-                                                             ibor));
+//         boost::shared_ptr<SwapIndex> swapIndex(new SwapIndex(familiName, 
+//                                                              getPeriodFromString(fixedLegTenor),
+//                                                              settlemenDays, 
+//                                                              currency, 
+//                                                              calendar,
+//                                                              getPeriodFromString(fixedLegTenor), 
+//                                                              fixedLegBDC, 
+//                                                              fixedLegDC, 
+//                                                              ibor));
 
-        Rcppparams pricerparams(pricer);
-        std::string pricerType = pricerparams.getStringValue("type");
-        std::double zeroMeanRev = pricerparams.getDoubleValue("zeroMeanRev");
+//         Rcppparams pricerparams(pricer);
+//         std::string pricerType = pricerparams.getStringValue("type");
+//         std::double zeroMeanRev = pricerparams.getDoubleValue("zeroMeanRev");
         
-        Rcppparams swaptionVolParams(swaptionVolSEXP);
-        std::string swaptionCal = swaptionVolParams.getStringValue("calendar");
-        std::double swaptionBDC = swaptionVolParams.getDoubleValue("businessDayConvention");
-        std::double swaptionDC = swaptionVolParams.getDoubleValue("dayCounter");
-        Handle<SwaptionVolatilityStructure> atmVol;
-        atmVol = Handle<SwaptionVolatilityStructure>(
-                                                     boost::shared_ptr<SwaptionVolatilityStructure>
-                                                     new SwaptionVolatilityMatrix(swapCal,
-                                                                                  swaptionBDC,
-                                                                                  atmOptionTenors,
-                                                                                  atmSwapTenors,
-                                                                                  m,
-                                                                                  swaptionDC));
+//         Rcppparams swaptionVolParams(swaptionVolSEXP);
+//         std::string swaptionCal = swaptionVolParams.getStringValue("calendar");
+//         std::double swaptionBDC = swaptionVolParams.getDoubleValue("businessDayConvention");
+//         std::double swaptionDC = swaptionVolParams.getDoubleValue("dayCounter");
+//         Handle<SwaptionVolatilityStructure> atmVol;
+//         atmVol = Handle<SwaptionVolatilityStructure>(
+//                                                      boost::shared_ptr<SwaptionVolatilityStructure>
+//                                                      new SwaptionVolatilityMatrix(swapCal,
+//                                                                                   swaptionBDC,
+//                                                                                   atmOptionTenors,
+//                                                                                   atmSwapTenors,
+//                                                                                   m,
+//                                                                                   swaptionDC));
 
 
-        boost::shared_ptr<CmsCouponPricer> pricer(new NumericHaganPricer(atmVol, yieldCurveModel,
-                                                                         zeroMeanRev));
+//         boost::shared_ptr<CmsCouponPricer> pricer(new NumericHaganPricer(atmVol, yieldCurveModel,
+//                                                                          zeroMeanRev));
         
 
-        Rcppparams rparams(bondparams);        
-        RcppDate mDate = RcppDate(Rcpp::as<int>(rparam["maturityDate"]));
-        RcppDate iDate = RcppDate(Rcpp::as<int>(rparam["issueDate"]));
-        RcppDate pDate = RcppDate(Rcpp::as<int>(rparam["paymentDate"]));
-        QuantLib::Date maturityDate(dateFromR(mDate));
-        QuantLib::Date issueDate(dateFromR(iDate));
-        QuantLib::Date paymentDate(dateFromR(pDate));
-        std::double nomial = rparams.getDoubleValue("nomial");
+//         Rcppparams rparams(bondparams);        
+//         Rcpp::Date mDate = Rcpp::Date(Rcpp::as<int>(rparam["maturityDate"]));
+//         Rcpp::Date iDate = Rcpp::Date(Rcpp::as<int>(rparam["issueDate"]));
+//         Rcpp::Date pDate = Rcpp::Date(Rcpp::as<int>(rparam["paymentDate"]));
+//         QuantLib::Date maturityDate(dateFromR(mDate));
+//         QuantLib::Date issueDate(dateFromR(iDate));
+//         QuantLib::Date paymentDate(dateFromR(pDate));
+//         std::double nomial = rparams.getDoubleValue("nomial");
         
-        CappedFlooredCmsCoupon coupon(paymentDate, nomial,
-                                      issueDate, maturityDate, 
-                                      settlementDays, swapIndex,
-                                      gearings, spreads, 
-                                      caps, floors,
-                                      issueDate, maturityDate,
-                                      dayCounter);
+//         CappedFlooredCmsCoupon coupon(paymentDate, nomial,
+//                                       issueDate, maturityDate, 
+//                                       settlementDays, swapIndex,
+//                                       gearings, spreads, 
+//                                       caps, floors,
+//                                       issueDate, maturityDate,
+//                                       dayCounter);
 
-        pricer->setSwaptionVolatility(atmVol);
-        coupon.setPricer(pricer);
+//         pricer->setSwaptionVolatility(atmVol);
+//         coupon.setPricer(pricer);
         
 
         
-    } catch(std::exception& ex) {
-        exceptionMesg = copyMessageToR(ex.what());
-    } catch(...) {
-        exceptionMesg = copyMessageToR("unknown reason");
-    }
+//     } catch(std::exception& ex) {
+//         exceptionMesg = copyMessageToR(ex.what());
+//     } catch(...) {
+//         exceptionMesg = copyMessageToR("unknown reason");
+//     }
     
-    if(exceptionMesg != NULL)
-        Rf_error(exceptionMesg);
+//     if(exceptionMesg != NULL)
+//         Rf_error(exceptionMesg);
     
-    return rl;
-}
-*/
+//     return rl;
+// }
 
 RcppExport SEXP QL_FittedBondCurve(SEXP curveparams, SEXP lengthVec,
                                    SEXP couponVec,SEXP marketVec,
@@ -1213,7 +1211,7 @@
     
         Rcpp::List curvepam(curveparams);
         std::string method = Rcpp::as<std::string>(curvepam["method"]);
-        RcppDate oDate = RcppDate(Rcpp::as<int>(curvepam["origDate"]));
+        Rcpp::Date oDate = Rcpp::Date(Rcpp::as<int>(curvepam["origDate"]));
         QuantLib::Date origDate(dateFromR(oDate));
         Settings::instance().evaluationDate() = origDate;
 
@@ -1299,13 +1297,13 @@
         int n = curve->maxDate() - curve->referenceDate();
         std::cout << curve->maxDate() << " " << curve->referenceDate() << " " << n << std::endl;
 
-        RcppDateVector dates(n);
+        Rcpp::DateVector dates(n);
         Rcpp::NumericVector zr(n);
         Rcpp::NumericVector di(n);
 
         for (int i = 0; i < n; i++) {
             Date d = current; 
-            dates(i) =  RcppDate(d.month(), d.dayOfMonth(), d.year());
+            dates[i] =  Rcpp::Date(d.month(), d.dayOfMonth(), d.year());
             zr[i] = curve->zeroRate(current, ActualActual(), Continuous);
             di[i] = curve->discount(current);
             current++;

Modified: pkg/RQuantLib/src/calendars.cpp
===================================================================
--- pkg/RQuantLib/src/calendars.cpp	2010-06-21 03:24:55 UTC (rev 263)
+++ pkg/RQuantLib/src/calendars.cpp	2010-06-23 20:27:13 UTC (rev 264)
@@ -93,7 +93,7 @@
         // set fixingDays and settleDate
         RQLContext::instance().fixingDays = Rcpp::as<int>(par["fixingDays"]);
         RQLContext::instance().settleDate = 
-            Date(dateFromR( RcppDate(Rcpp::as<int>(par["settleDate"])) ));
+            Date(dateFromR( Rcpp::Date(Rcpp::as<int>(par["settleDate"])) ));
 
         boost::shared_ptr<Calendar> pcal( getCalendar(Rcpp::as<std::string>(par["calendar"])) );
         RQLContext::instance().calendar = *pcal; // set calendar in global singleton
@@ -112,13 +112,13 @@
     try {
         boost::shared_ptr<Calendar> pcal( getCalendar(Rcpp::as<std::string>(calSexp)) );
 
-        RcppDateVector dates  = RcppDateVector(dateSexp);
+        Rcpp::DateVector dates  = Rcpp::DateVector(dateSexp);
 
         int n = dates.size();
         std::vector<int> bizdays(n);
 
         for (int i=0; i<n; i++) {
-            QuantLib::Date day( dateFromR(dates(i)) );
+            QuantLib::Date day( dateFromR(dates[i]) );
             bizdays[i] = pcal->isBusinessDay(day);
         }
 
@@ -137,12 +137,12 @@
     try {
         boost::shared_ptr<Calendar> pcal( getCalendar(Rcpp::as<std::string>(calSexp)) );
 
-        RcppDateVector dates  = RcppDateVector(dateSexp);
+        Rcpp::DateVector dates  = Rcpp::DateVector(dateSexp);
         int n = dates.size();
         std::vector<int> hdays(n);
 
         for (int i=0; i<n; i++) {
-            QuantLib::Date day( dateFromR(dates(i)) );
+            QuantLib::Date day( dateFromR(dates[i]) );
             hdays[i] = pcal->isHoliday(day);
         }
 
@@ -161,12 +161,12 @@
     try {
         boost::shared_ptr<Calendar> pcal( getCalendar(Rcpp::as<std::string>(calSexp)) );
 
-        RcppDateVector dates  = RcppDateVector(dateSexp);
+        Rcpp::DateVector dates  = Rcpp::DateVector(dateSexp);
         int n = dates.size();
         std::vector<int> weekends(n);
 
         for (int i=0; i<n; i++) {
-            QuantLib::Date day( dateFromR(dates(i)) );
+            QuantLib::Date day( dateFromR(dates[i]) );
             weekends[i] = pcal->isWeekend(day.weekday());
         }
 
@@ -186,12 +186,12 @@
     try {
         boost::shared_ptr<Calendar> pcal( getCalendar(Rcpp::as<std::string>(calSexp)) );
 
-        RcppDateVector dates  = RcppDateVector(dateSexp);
+        Rcpp::DateVector dates  = Rcpp::DateVector(dateSexp);
         int n = dates.size();
         std::vector<int> eom(n);
 
         for (int i=0; i<n; i++) {
-            QuantLib::Date day( dateFromR(dates(i)) );
+            QuantLib::Date day( dateFromR(dates[i]) );
             eom[i] = pcal->isEndOfMonth(day);
         }
 
@@ -211,14 +211,14 @@
     try {
         boost::shared_ptr<Calendar> pcal( getCalendar(Rcpp::as<std::string>(calSexp)) );
 
-        RcppDateVector dates  = RcppDateVector(dateSexp);
+        Rcpp::DateVector dates  = Rcpp::DateVector(dateSexp);
         int n = dates.size();
         std::vector<QuantLib::Date> eom(n);
 
         for (int i=0; i<n; i++) {
-            QuantLib::Date day( dateFromR(dates(i)) );
+            QuantLib::Date day( dateFromR(dates[i]) );
             eom[i] = pcal->endOfMonth(day);
-            dates(i) = RcppDate(eom[i].month(), eom[i].dayOfMonth(), eom[i].year());
+            dates[i] = Rcpp::Date(eom[i].month(), eom[i].dayOfMonth(), eom[i].year());
         }
        
         return Rcpp::wrap(dates);
@@ -237,16 +237,16 @@
     try {
         boost::shared_ptr<Calendar> pcal( getCalendar(Rcpp::as<std::string>(calSexp)) );
         BusinessDayConvention bdc = getBusinessDayConvention( Rcpp::as<double>(bdcSEXP) );
-        RcppDateVector dates  = RcppDateVector(dateSexp);
+        Rcpp::DateVector dates  = Rcpp::DateVector(dateSexp);
         int n = dates.size();
         std::vector<QuantLib::Date> adjusted(n);
 
         for (int i=0; i<n; i++) {
-            QuantLib::Date day( dateFromR(dates(i)) );
+            QuantLib::Date day( dateFromR(dates[i]) );
             adjusted[i] = pcal->adjust(day, bdc);
-            dates(i) =  RcppDate(adjusted[i].month(), 
-                                 adjusted[i].dayOfMonth(), 
-                                 adjusted[i].year());
+            dates[i] =  Rcpp::Date(adjusted[i].month(), 
+                                   adjusted[i].dayOfMonth(), 
+                                   adjusted[i].year());
         }
 
         return Rcpp::wrap(dates);
@@ -270,16 +270,16 @@
         double amount = Rcpp::as<double>(rparam["amount"]);
         double unit = Rcpp::as<double>(rparam["unit"]);
 
-        RcppDateVector dates  = RcppDateVector(dateSexp);
+        Rcpp::DateVector dates  = Rcpp::DateVector(dateSexp);
         int n = dates.size();
         std::vector<QuantLib::Date> advance(n);
 
         for (int i=0; i<n; i++) {
-            QuantLib::Date day( dateFromR(dates(i)) );
+            QuantLib::Date day( dateFromR(dates[i]) );
             advance[i] = pcal->advance(day, amount,getTimeUnit(unit), bdc, (emr == 1)?true:false );
-            dates(i) =  RcppDate(advance[i].month(), 
-                                 advance[i].dayOfMonth(), 
-                                 advance[i].year());
+            dates[i] =  Rcpp::Date(advance[i].month(), 
+                                   advance[i].dayOfMonth(), 
+                                   advance[i].year());
         }
         
         return Rcpp::wrap(dates);
@@ -302,17 +302,17 @@
         double emr = Rcpp::as<double>(rparam["emr"]);
         double period = Rcpp::as<double>(rparam["period"]);
 
-        RcppDateVector dates  = RcppDateVector(dateSexp);
+        Rcpp::DateVector dates  = Rcpp::DateVector(dateSexp);
         int n = dates.size();
         std::vector<QuantLib::Date> advance(n);
 
         for (int i=0; i<n; i++) {
-            QuantLib::Date day( dateFromR(dates(i)) );
+            QuantLib::Date day( dateFromR(dates[i]) );
             advance[i] = pcal->advance(day, Period(getFrequency(period)), 
                                        bdc, (emr == 1)?true:false );
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/rquantlib -r 264


More information about the Rquantlib-commits mailing list