From noreply at r-forge.r-project.org Sun May 26 15:24:26 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Sun, 26 May 2013 15:24:26 +0200 (CEST) Subject: [Rquantlib-commits] r328 - in pkg/RQuantLib: . R inst inst/include src Message-ID: <20130526132426.504EC184C54@r-forge.r-project.org> Author: edd Date: 2013-05-26 15:24:25 +0200 (Sun, 26 May 2013) New Revision: 328 Added: pkg/RQuantLib/R/inline.R pkg/RQuantLib/inst/include/ pkg/RQuantLib/inst/include/rquantlib.h Removed: pkg/RQuantLib/src/rquantlib.h Modified: pkg/RQuantLib/ChangeLog pkg/RQuantLib/DESCRIPTION pkg/RQuantLib/src/Makevars.in pkg/RQuantLib/src/Makevars.win Log: Adding a plugin for use by Rcpp attribute or inline Required move of header file to inst/include and corresponding Makevars changes Header file may need to get trimmed to more properly define the API we need Modified: pkg/RQuantLib/ChangeLog =================================================================== --- pkg/RQuantLib/ChangeLog 2013-02-17 21:10:52 UTC (rev 327) +++ pkg/RQuantLib/ChangeLog 2013-05-26 13:24:25 UTC (rev 328) @@ -1,3 +1,14 @@ +2013-05-26 Dirk Eddelbuettel + + * R/inline.R: Adding a plugin for use by Rcpp attribute or inline + + * inst/include/rquantlib.h: Moved from src/ to expose the RQuantLib + API for use by the plugin (and the header file / API needs to be + properly defined; this file is probably too large) + + * src/Makevars.in: Adjust for header file move + * src/Makevars.win: Idem + 2013-02-17 Dirk Eddelbuettel * DESCRIPTION: Release 0.3.10 @@ -9,7 +20,7 @@ * man/ZeroCouponBond.Rd: Idem * R/arrays.R (plotOptionSurface): Use explicit `rgl::' prefix for all - function from the rgl package to suppress spurious codetools warning + functions from the rgl package to suppress spurious codetools warning * demo/OptionSurfaces.R: Reindented Modified: pkg/RQuantLib/DESCRIPTION =================================================================== --- pkg/RQuantLib/DESCRIPTION 2013-02-17 21:10:52 UTC (rev 327) +++ pkg/RQuantLib/DESCRIPTION 2013-05-26 13:24:25 UTC (rev 328) @@ -1,6 +1,6 @@ Package: RQuantLib Title: R interface to the QuantLib library -Version: 0.3.10 +Version: 0.3.10.1 Date: $Date$ Maintainer: Dirk Eddelbuettel Author: Dirk Eddelbuettel and Khanh Nguyen Added: pkg/RQuantLib/R/inline.R =================================================================== --- pkg/RQuantLib/R/inline.R (rev 0) +++ pkg/RQuantLib/R/inline.R 2013-05-26 13:24:25 UTC (rev 328) @@ -0,0 +1,61 @@ +## RQuantLib -- R interface to the QuantLib libraries +## +## Copyright (C) 2002 - 2013 Dirk Eddelbuettel +## +## $Id$ +## +## 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 Rcpp. If not, see . + +.pkgglobalenv <- new.env(parent=emptyenv()) + +.onLoad <- function(libname, pkgname) { + if (.Platform$OS.type=="windows") { + ## by convention with CRAN, on Windows we expect these two + ## variables to be set, and to be pointing to the respective + ## helper installations + qlroot <- Sys.getenv("QUANTLIB_ROOT") + boostlib <- Sys.getenv("BOOSTLIB") + rarch <- Sys.getenv("R_ARCH") + qlcflags <- sprintf("-I%s -I. -I\"%s\"", qlroot, boostlib) + qllibs <- sprintf("%s -L%s/lib%s -lQuantLib", Rcpp:::LdFlags(), rarch) + } else { + qlcflags <- system( "quantlib-config --cflags", intern = TRUE) + qllibs <- system( "quantlib-config --libs", intern = TRUE) + } + + assign("ql_cflags", qlcflags, envir=.pkgglobalenv) + assign("ql_libs", qllibs, envir=.pkgglobalenv) +} + +LdFlags <- function(print = TRUE) { + if (print) cat(.pkgglobalenv$ql_libs) else .pkgglobalenv$ql_libs +} + +CFlags <- function(print = TRUE) { + if (print) cat(.pkgglobalenv$ql_cflags) else .pkgglobalenv$ql_cflags +} + +inlineCxxPlugin <- function(...) { + plugin <- + Rcpp:::Rcpp.plugin.maker(include.before = "#include ", + libs = sprintf("%s $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)", LdFlags(FALSE)), + package = "RQuantLib", Makevars = NULL, Makevars.win = NULL) + settings <- plugin() + settings$env$PKG_CPPFLAGS <- CFlags(FALSE) + settings +} + + + Copied: pkg/RQuantLib/inst/include/rquantlib.h (from rev 308, pkg/RQuantLib/src/rquantlib.h) =================================================================== --- pkg/RQuantLib/inst/include/rquantlib.h (rev 0) +++ pkg/RQuantLib/inst/include/rquantlib.h 2013-05-26 13:24:25 UTC (rev 328) @@ -0,0 +1,172 @@ +// -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// +// RQuantLib function prototypes and macros +// +// Copyright 2002 - 2013 Dirk Eddelbuettel +// Copyright 2005 - 2006 Dominick Samperi +// +// $Id$ +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// 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 RcppArmadillo. If not, see . + +#ifndef rquantlib_h +#define rquantlib_h + +#include +#include +#include + +//using namespace QuantLib; + +#include + +//#define NULL_RateHelper (boost::shared_ptr)Null >() + +// Prototypes for convenience functions (some macros) +//void insertListElement(SEXP &list, SEXP &names, +// const int pos, const double value, +// const char *label); +//SEXP getListElement(SEXP list, char *str); + +// Used to maintain context while in an R function. +class RQLContext : public QuantLib::Singleton { +public: + RQLContext() { + fixingDays = 2; + calendar = QuantLib::TARGET(); + settleDate = QuantLib::Date::todaysDate()+2; + } + // The tradeDate (evaluation date) is maintained by Settings, + // (which is a singleton structure provided by QuantLib) + // and used to translate between dates and real-valued times. + QuantLib::Date settleDate; + QuantLib::Calendar calendar; + QuantLib::Integer fixingDays; +}; + +// Instrument types used to construct the yield curve. +enum RQLObservableType { RQLDeposit, RQLSwap, RQLFuture, RQLFRA }; + +// Used to identify the specifics of a particular contract. +class RQLObservable { +public: + RQLObservable(RQLObservableType type, + int n1, int n2, + QuantLib::TimeUnit units) + : type_(type), n1_(n1), n2_(n2), units_(units) {} + RQLObservableType getType() { return type_; } + int getN1() { return n1_; } + int getN2() { return n2_; } + QuantLib::TimeUnit getUnits() { return units_; } +private: + RQLObservableType type_; + int n1_, n2_; // n2 used for FRA's + QuantLib::TimeUnit units_; // not used for futures and FRA's +}; + +typedef std::map RQLMap; +typedef std::map::const_iterator RQLMapIterator; + +// Database used to maintain curve construction instrument details. +class ObservableDB : public QuantLib::Singleton { +public: + ObservableDB(); + boost::shared_ptr getRateHelper(std::string& ticker, QuantLib::Rate r); +private: + RQLMap db_; +}; + +boost::shared_ptr +getTermStructure(std::string& interpWhat, std::string& interpHow, + const QuantLib::Date& settleDate, + const std::vector >& curveInput, + QuantLib::DayCounter& dayCounter, QuantLib::Real tolerance); + +boost::shared_ptr +makeFlatCurve(const QuantLib::Date& today, + const boost::shared_ptr& forward, + const QuantLib::DayCounter& dc); + +boost::shared_ptr +flatRate(const QuantLib::Date& today, + const boost::shared_ptr& forward, + const QuantLib::DayCounter& dc); + +boost::shared_ptr +makeFlatVolatility(const QuantLib::Date& today, + const boost::shared_ptr& vol, + QuantLib::DayCounter dc); + +boost::shared_ptr +flatVol(const QuantLib::Date& today, + const boost::shared_ptr& vol, + const QuantLib::DayCounter& dc); + +enum EngineType {Analytic, + JR, CRR, EQP, TGEO, TIAN, LR, JOSHI, + FiniteDifferences, Integral, + PseudoMonteCarlo, QuasiMonteCarlo }; + +boost::shared_ptr +makeOption(const boost::shared_ptr& payoff, + const boost::shared_ptr& exercise, + const boost::shared_ptr& u, + const boost::shared_ptr& q, + const boost::shared_ptr& r, + const boost::shared_ptr& vol, + EngineType engineType = Analytic, + QuantLib::Size binomialSteps=128, + QuantLib::Size samples=100); + +boost::shared_ptr +makeProcess(const boost::shared_ptr& u, + const boost::shared_ptr& q, + const boost::shared_ptr& r, + const boost::shared_ptr& vol); + +// int dateFromR(const RcppDate &d); // using 'classic' API's RcppDate +int dateFromR(const Rcpp::Date &d); // using 'new' API's Rcpp::Date + +//utility functions for parameters of fixed-income instrument function +QuantLib::Frequency getFrequency(const double n); +QuantLib::TimeUnit getTimeUnit(const double n); +QuantLib::Compounding getCompounding(const double n); +QuantLib::BusinessDayConvention getBusinessDayConvention(const double n); +QuantLib::DayCounter getDayCounter(const double n); +QuantLib::DateGeneration::Rule getDateGenerationRule(const double n); +boost::shared_ptr buildTermStructure(SEXP params, + SEXP tsQuotes, + SEXP times); +QuantLib::Schedule getSchedule(SEXP sch); +boost::shared_ptr getIborIndex(SEXP index, const QuantLib::Date today); +std::vector getDoubleVector(SEXP vector); +boost::shared_ptr getFlatCurve(SEXP flatcurve); +boost::shared_ptr rebuildCurveFromZeroRates(SEXP dateSexp, SEXP zeroSexp); +boost::shared_ptr + buildIborIndex(std::string type, + const QuantLib::Handle& iborStrc); +QuantLib::Calendar* getCalendar(SEXP calParameters); +QuantLib::Period periodByTimeUnit(int length, std::string unit); + +// simple option type creator based on string +QuantLib::Option::Type getOptionType(const std::string &t); + +// create a data.frame with dates and amounts +Rcpp::DataFrame getCashFlowDataFrame(const QuantLib::Leg &bondCashFlow); + +// fill QL data structures based on data.frames +QuantLib::DividendSchedule getDividendSchedule(SEXP dividendScheduleFrame); +QuantLib::CallabilitySchedule getCallabilitySchedule(SEXP callabilityScheduleFrame); + +#endif Modified: pkg/RQuantLib/src/Makevars.in =================================================================== --- pkg/RQuantLib/src/Makevars.in 2013-02-17 21:10:52 UTC (rev 327) +++ pkg/RQuantLib/src/Makevars.in 2013-05-26 13:24:25 UTC (rev 328) @@ -1,2 +1,2 @@ -PKG_CXXFLAGS=@CXXFLAGS@ -I. +PKG_CXXFLAGS=@CXXFLAGS@ -I../inst/include -I. PKG_LIBS=@LDFLAGS@ Modified: pkg/RQuantLib/src/Makevars.win =================================================================== --- pkg/RQuantLib/src/Makevars.win 2013-02-17 21:10:52 UTC (rev 327) +++ pkg/RQuantLib/src/Makevars.win 2013-05-26 13:24:25 UTC (rev 328) @@ -2,7 +2,7 @@ # # Copyright 2005 - 2006 Dominick Samperi # Copyright 2005 Uwe Ligges -# Copyright 2008 - 2011 Dirk Eddelbuettel +# Copyright 2008 - 2013 Dirk Eddelbuettel # Copyright 2011 Uwe Ligges, Brian Ripley, and Josh Ulrich ## This assumes that we can call Rscript to ask Rcpp about its locations @@ -11,5 +11,5 @@ ## The environment variable QUANTLIB_ROOT has to point to an existing build of QuantLib ## With R 2.12.0 and later, we also support 32 and 64 bit builds and need to differentiate -PKG_CXXFLAGS=-I$(QUANTLIB_ROOT) -I. -I"$(BOOSTLIB)" +PKG_CXXFLAGS=-I$(QUANTLIB_ROOT) -I../inst/include -I. -I"$(BOOSTLIB)" PKG_LIBS=$(RCPP_LDFLAGS) -L$(QUANTLIB_ROOT)/lib${R_ARCH} -lQuantLib Deleted: pkg/RQuantLib/src/rquantlib.h =================================================================== --- pkg/RQuantLib/src/rquantlib.h 2013-02-17 21:10:52 UTC (rev 327) +++ pkg/RQuantLib/src/rquantlib.h 2013-05-26 13:24:25 UTC (rev 328) @@ -1,173 +0,0 @@ -// -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// -// RQuantLib function prototypes and macros -// -// Copyright 2002 - 2009 Dirk Eddelbuettel -// Copyright 2005 - 2006 Dominick Samperi -// -// $Id$ -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. -// -// 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 - -#ifndef rquantlib_h -#define rquantlib_h - -#include -#include -#include - -//using namespace QuantLib; - -#include - -//#define NULL_RateHelper (boost::shared_ptr)Null >() - -// Prototypes for convenience functions (some macros) -//void insertListElement(SEXP &list, SEXP &names, -// const int pos, const double value, -// const char *label); -//SEXP getListElement(SEXP list, char *str); - -// Used to maintain context while in an R function. -class RQLContext : public QuantLib::Singleton { -public: - RQLContext() { - fixingDays = 2; - calendar = QuantLib::TARGET(); - settleDate = QuantLib::Date::todaysDate()+2; - } - // The tradeDate (evaluation date) is maintained by Settings, - // (which is a singleton structure provided by QuantLib) - // and used to translate between dates and real-valued times. - QuantLib::Date settleDate; - QuantLib::Calendar calendar; - QuantLib::Integer fixingDays; -}; - -// Instrument types used to construct the yield curve. -enum RQLObservableType { RQLDeposit, RQLSwap, RQLFuture, RQLFRA }; - -// Used to identify the specifics of a particular contract. -class RQLObservable { -public: - RQLObservable(RQLObservableType type, - int n1, int n2, - QuantLib::TimeUnit units) - : type_(type), n1_(n1), n2_(n2), units_(units) {} - RQLObservableType getType() { return type_; } - int getN1() { return n1_; } - int getN2() { return n2_; } - QuantLib::TimeUnit getUnits() { return units_; } -private: - RQLObservableType type_; - int n1_, n2_; // n2 used for FRA's - QuantLib::TimeUnit units_; // not used for futures and FRA's -}; - -typedef std::map RQLMap; -typedef std::map::const_iterator RQLMapIterator; - -// Database used to maintain curve construction instrument details. -class ObservableDB : public QuantLib::Singleton { -public: - ObservableDB(); - boost::shared_ptr getRateHelper(std::string& ticker, QuantLib::Rate r); -private: - RQLMap db_; -}; - -boost::shared_ptr -getTermStructure(std::string& interpWhat, std::string& interpHow, - const QuantLib::Date& settleDate, - const std::vector >& curveInput, - QuantLib::DayCounter& dayCounter, QuantLib::Real tolerance); - -boost::shared_ptr -makeFlatCurve(const QuantLib::Date& today, - const boost::shared_ptr& forward, - const QuantLib::DayCounter& dc); - -boost::shared_ptr -flatRate(const QuantLib::Date& today, - const boost::shared_ptr& forward, - const QuantLib::DayCounter& dc); - -boost::shared_ptr -makeFlatVolatility(const QuantLib::Date& today, - const boost::shared_ptr& vol, - QuantLib::DayCounter dc); - -boost::shared_ptr -flatVol(const QuantLib::Date& today, - const boost::shared_ptr& vol, - const QuantLib::DayCounter& dc); - -enum EngineType {Analytic, - JR, CRR, EQP, TGEO, TIAN, LR, JOSHI, - FiniteDifferences, Integral, - PseudoMonteCarlo, QuasiMonteCarlo }; - -boost::shared_ptr -makeOption(const boost::shared_ptr& payoff, - const boost::shared_ptr& exercise, - const boost::shared_ptr& u, - const boost::shared_ptr& q, - const boost::shared_ptr& r, - const boost::shared_ptr& vol, - EngineType engineType = Analytic, - QuantLib::Size binomialSteps=128, - QuantLib::Size samples=100); - -boost::shared_ptr -makeProcess(const boost::shared_ptr& u, - const boost::shared_ptr& q, - const boost::shared_ptr& r, - const boost::shared_ptr& vol); - -// int dateFromR(const RcppDate &d); // using 'classic' API's RcppDate -int dateFromR(const Rcpp::Date &d); // using 'new' API's Rcpp::Date - -//utility functions for parameters of fixed-income instrument function -QuantLib::Frequency getFrequency(const double n); -QuantLib::TimeUnit getTimeUnit(const double n); -QuantLib::Compounding getCompounding(const double n); -QuantLib::BusinessDayConvention getBusinessDayConvention(const double n); -QuantLib::DayCounter getDayCounter(const double n); -QuantLib::DateGeneration::Rule getDateGenerationRule(const double n); -boost::shared_ptr buildTermStructure(SEXP params, - SEXP tsQuotes, - SEXP times); -QuantLib::Schedule getSchedule(SEXP sch); -boost::shared_ptr getIborIndex(SEXP index, const QuantLib::Date today); -std::vector getDoubleVector(SEXP vector); -boost::shared_ptr getFlatCurve(SEXP flatcurve); -boost::shared_ptr rebuildCurveFromZeroRates(SEXP dateSexp, SEXP zeroSexp); -boost::shared_ptr - buildIborIndex(std::string type, - const QuantLib::Handle& iborStrc); -QuantLib::Calendar* getCalendar(SEXP calParameters); -QuantLib::Period periodByTimeUnit(int length, std::string unit); - -// simple option type creator based on string -QuantLib::Option::Type getOptionType(const std::string &t); - -// create a data.frame with dates and amounts -Rcpp::DataFrame getCashFlowDataFrame(const QuantLib::Leg &bondCashFlow); - -// fill QL data structures based on data.frames -QuantLib::DividendSchedule getDividendSchedule(SEXP dividendScheduleFrame); -QuantLib::CallabilitySchedule getCallabilitySchedule(SEXP callabilityScheduleFrame); - -#endif From noreply at r-forge.r-project.org Fri May 31 03:32:18 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 31 May 2013 03:32:18 +0200 (CEST) Subject: [Rquantlib-commits] r329 - in pkg: . QuantLib QuantLib/R QuantLib/demo QuantLib/src Message-ID: <20130531013218.B7291184FAF@r-forge.r-project.org> Author: edd Date: 2013-05-31 03:32:17 +0200 (Fri, 31 May 2013) New Revision: 329 Added: pkg/QuantLib/ pkg/QuantLib/DESCRIPTION pkg/QuantLib/NAMESPACE pkg/QuantLib/R/ pkg/QuantLib/R/QuantLib.R pkg/QuantLib/R/makeRData.R pkg/QuantLib/cleanup pkg/QuantLib/demo/ pkg/QuantLib/demo/00Index pkg/QuantLib/demo/europeanOption.R pkg/QuantLib/demo/fdOption.R pkg/QuantLib/demo/graph.R pkg/QuantLib/demo/scatter.R pkg/QuantLib/demo/wireframe.R pkg/QuantLib/src/ pkg/QuantLib/src/Makevars pkg/QuantLib/src/QuantLib.cpp Log: very initial package based on QuantLib-SWIG bindings for R Added: pkg/QuantLib/DESCRIPTION =================================================================== --- pkg/QuantLib/DESCRIPTION (rev 0) +++ pkg/QuantLib/DESCRIPTION 2013-05-31 01:32:17 UTC (rev 329) @@ -0,0 +1,12 @@ +Package: QuantLib +Title: QuantLib bindings for R +Version: 1.2-1 +Date: $Date$ +Maintainer: Dirk Eddelbuettel +Author: Dirk Eddelbuettel , QuantLib Group +Description: This package provides the SWIG-generated binding from QuantLib to R +Depends: R (>= 2.10.0) +SystemRequirements: QuantLib library (>= 0.9.9) from http://quantlib.org, + Boost library from http://www.boost.org +License: QuantLib License +URL: http://quantlib.org Added: pkg/QuantLib/NAMESPACE =================================================================== --- pkg/QuantLib/NAMESPACE (rev 0) +++ pkg/QuantLib/NAMESPACE 2013-05-31 01:32:17 UTC (rev 329) @@ -0,0 +1,3 @@ + +useDynLib(QuantLib) +exportPattern("^[[:alpha:]]+") Added: pkg/QuantLib/R/QuantLib.R =================================================================== --- pkg/QuantLib/R/QuantLib.R (rev 0) +++ pkg/QuantLib/R/QuantLib.R 2013-05-31 01:32:17 UTC (rev 329) @@ -0,0 +1,70849 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 2.0.4 +# +# Do not make changes to this file unless you know what you are doing--modify +# the SWIG interface file instead. + +## Generated via the command line invocation: +## /usr/local/bin/swig -r -c++ -o QuantLib.cpp ../SWIG/quantlib.i + + +# srun.swg # +# +# This is the basic code that is needed at run time within R to +# provide and define the relevant classes. It is included +# automatically in the generated code by copying the contents of +# srun.swg into the newly created binding code. + + +# This could be provided as a separate run-time library but this +# approach allows the code to to be included directly into the +# generated bindings and so removes the need to have and install an +# additional library. We may however end up with multiple copies of +# this and some confusion at run-time as to which class to use. This +# is an issue when we use NAMESPACES as we may need to export certain +# classes. + +###################################################################### + +if(length(getClassDef("RSWIGStruct")) == 0) + setClass("RSWIGStruct", representation("VIRTUAL")) + + + +if(length(getClassDef("ExternalReference")) == 0) +# Should be virtual but this means it loses its slots currently +#representation("VIRTUAL") + setClass("ExternalReference", representation( ref = "externalptr")) + + + +if(length(getClassDef("NativeRoutinePointer")) == 0) + setClass("NativeRoutinePointer", + representation(parameterTypes = "character", + returnType = "character", + "VIRTUAL"), + contains = "ExternalReference") + +if(length(getClassDef("CRoutinePointer")) == 0) + setClass("CRoutinePointer", contains = "NativeRoutinePointer") + + +if(length(getClassDef("EnumerationValue")) == 0) + setClass("EnumerationValue", contains = "integer") + + +if(!isGeneric("copyToR")) + setGeneric("copyToR", + function(value, obj = new(gsub("Ref$", "", class(value)))) + standardGeneric("copyToR" + )) + +setGeneric("delete", function(obj) standardGeneric("delete")) + + +SWIG_createNewRef = +function(className, ..., append = TRUE) +{ + f = get(paste("new", className, sep = "_"), mode = "function") + + f(...) +} + +if(!isGeneric("copyToC")) + setGeneric("copyToC", + function(value, obj = RSWIG_createNewRef(class(value))) + standardGeneric("copyToC" + )) + + +# +defineEnumeration = +function(name, .values, where = topenv(parent.frame()), suffix = "Value") +{ + # Mirror the class definitions via the E analogous to .__C__ + defName = paste(".__E__", name, sep = "") + assign(defName, .values, envir = where) + + if(nchar(suffix)) + name = paste(name, suffix, sep = "") + + setClass(name, contains = "EnumerationValue", where = where) +} + +enumToInteger <- function(name,type) +{ + if (is.character(name)) { + ans <- as.integer(get(paste(".__E__", type, sep = ""))[name]) + if (is.na(ans)) {warning("enum not found ", name, " ", type)} + ans + } +} + +enumFromInteger = +function(i,type) +{ + itemlist <- get(paste(".__E__", type, sep="")) + names(itemlist)[match(i, itemlist)] +} + +coerceIfNotSubclass = +function(obj, type) +{ + if(!is(obj, type)) {as(obj, type)} else obj +} + + +setClass("SWIGArray", representation(dims = "integer"), contains = "ExternalReference") + +setMethod("length", "SWIGArray", function(x) x at dims[1]) + + +defineEnumeration("SCopyReferences", + .values = c( "FALSE" = 0, "TRUE" = 1, "DEEP" = 2)) + +assert = +function(condition, message = "") +{ + if(!condition) + stop(message) + + TRUE +} + + +if(FALSE) { +print.SWIGFunction = +function(x, ...) + { + } +} + + +####################################################################### + +R_SWIG_getCallbackFunctionStack = +function() +{ + # No PACKAGE argument as we don't know what the DLL is. + .Call("R_SWIG_debug_getCallbackFunctionData") +} + +R_SWIG_addCallbackFunctionStack = +function(fun, userData = NULL) +{ + # No PACKAGE argument as we don't know what the DLL is. + .Call("R_SWIG_R_pushCallbackFunctionData", fun, userData) +} + + +####################################################################### + + +setClass('C++Reference', contains = 'ExternalReference') +setClass('_p_Period', contains = 'C++Reference') +setClass('_p_std__vectorT_Period_std__allocatorT_Period_t_t', contains = 'C++Reference') +setClass('_p_Date', contains = 'C++Reference') +setClass('_p_DateParser', contains = 'C++Reference') +setClass('_p_PeriodParser', contains = 'C++Reference') +setClass('_p_std__vectorT_Date_std__allocatorT_Date_t_t', contains = 'C++Reference') +setClass('_p_IMM', contains = 'ExternalReference') +setClass("IMM", + representation( +), + contains = "RSWIGStruct") + + +# End class IMM + +setClass('_p_std__vectorT_int_std__allocatorT_int_t_t', contains = 'C++Reference') +setClass('_p_std__vectorT_unsigned_int_std__allocatorT_unsigned_int_t_t', contains = 'C++Reference') +setClass('_p_std__vectorT_double_std__allocatorT_double_t_t', contains = 'C++Reference') +setClass('_p_std__vectorT_std__string_std__allocatorT_std__string_t_t', contains = 'C++Reference') +setClass('_p_std__vectorT_bool_std__allocatorT_bool_t_t', contains = 'C++Reference') +setClass('_p_boost__shared_ptrT_Exercise_t', contains = 'C++Reference') +setClass('_p_EuropeanExercisePtr', contains = c('_p_boost__shared_ptrT_Exercise_t')) +setClass('_p_AmericanExercisePtr', contains = c('_p_boost__shared_ptrT_Exercise_t')) +setClass('_p_BermudanExercisePtr', contains = c('_p_boost__shared_ptrT_Exercise_t')) +setClass('_p_boost__shared_ptrT_Observable_t', contains = 'C++Reference') +setClass('_p_Array', contains = 'C++Reference') +setClass('_p_DefaultLexicographicalViewColumn', contains = 'C++Reference') +setClass('_p_DefaultLexicographicalView', contains = 'C++Reference') +setClass('_p_Matrix', contains = 'C++Reference') +setClass('_p_SalvagingAlgorithm', contains = 'ExternalReference') +setClass("SalvagingAlgorithm", + representation( +), + contains = "RSWIGStruct") + + +# End class SalvagingAlgorithm + +setClass('_p_SVD', contains = 'C++Reference') +setClass('_p_boost__shared_ptrT_Quote_t', contains = 'C++Reference') +setClass('_p_HandleT_Quote_t', contains = 'C++Reference') +setClass('_p_RelinkableHandleT_Quote_t', contains = c('_p_HandleT_Quote_t')) +setClass('_p_SimpleQuotePtr', contains = c('_p_boost__shared_ptrT_Quote_t')) +setClass('_p_std__vectorT_boost__shared_ptrT_Quote_t_std__allocatorT_boost__shared_ptrT_Quote_t_t_t', contains = 'C++Reference') +setClass('_p_std__vectorT_std__vectorT_boost__shared_ptrT_Quote_t_std__allocatorT_boost__shared_ptrT_Quote_t_t_t_std__allocatorT_std__vectorT_boost__shared_ptrT_Quote_t_std__allocatorT_boost__shared_ptrT_Quote_t_t_t_t_t', contains = 'C++Reference') +setClass('_p_std__vectorT_HandleT_Quote_t_std__allocatorT_HandleT_Quote_t_t_t', contains = 'C++Reference') +setClass('_p_std__vectorT_std__vectorT_HandleT_Quote_t_std__allocatorT_HandleT_Quote_t_t_t_std__allocatorT_std__vectorT_HandleT_Quote_t_std__allocatorT_HandleT_Quote_t_t_t_t_t', contains = 'C++Reference') +setClass('_p_std__vectorT_RelinkableHandleT_Quote_t_std__allocatorT_RelinkableHandleT_Quote_t_t_t', contains = 'C++Reference') +setClass('_p_std__vectorT_std__vectorT_RelinkableHandleT_Quote_t_std__allocatorT_RelinkableHandleT_Quote_t_t_t_std__allocatorT_std__vectorT_RelinkableHandleT_Quote_t_std__allocatorT_RelinkableHandleT_Quote_t_t_t_t_t', contains = 'C++Reference') +setClass('_p_DayCounter', contains = 'C++Reference') +setClass('_p_QuantLib__Actual360', contains = c('_p_DayCounter')) +setClass('_p_QuantLib__Actual365Fixed', contains = c('_p_DayCounter')) +setClass('_p_QuantLib__Thirty360', contains = c('_p_DayCounter')) +setClass('_p_QuantLib__ActualActual', contains = c('_p_DayCounter')) +setClass('_p_QuantLib__OneDayCounter', contains = c('_p_DayCounter')) +setClass('_p_QuantLib__SimpleDayCounter', contains = c('_p_DayCounter')) +setClass('_p_QuantLib__Business252', contains = c('_p_DayCounter')) +setClass('_p_InterestRate', contains = 'C++Reference') +setClass('_p_Calendar', contains = 'C++Reference') +setClass('_p_QuantLib__Argentina', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Australia', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Brazil', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Canada', contains = c('_p_Calendar')) +setClass('_p_QuantLib__China', contains = c('_p_Calendar')) +setClass('_p_QuantLib__CzechRepublic', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Denmark', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Finland', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Germany', contains = c('_p_Calendar')) +setClass('_p_QuantLib__HongKong', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Hungary', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Iceland', contains = c('_p_Calendar')) +setClass('_p_QuantLib__India', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Indonesia', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Italy', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Japan', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Mexico', contains = c('_p_Calendar')) +setClass('_p_QuantLib__NewZealand', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Norway', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Poland', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Russia', contains = c('_p_Calendar')) +setClass('_p_QuantLib__SaudiArabia', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Singapore', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Slovakia', contains = c('_p_Calendar')) +setClass('_p_QuantLib__SouthAfrica', contains = c('_p_Calendar')) +setClass('_p_QuantLib__SouthKorea', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Sweden', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Switzerland', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Taiwan', contains = c('_p_Calendar')) +setClass('_p_QuantLib__TARGET', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Turkey', contains = c('_p_Calendar')) +setClass('_p_QuantLib__Ukraine', contains = c('_p_Calendar')) +setClass('_p_QuantLib__UnitedKingdom', contains = c('_p_Calendar')) +setClass('_p_QuantLib__UnitedStates', contains = c('_p_Calendar')) +setClass('_p_QuantLib__NullCalendar', contains = c('_p_Calendar')) +setClass('_p_QuantLib__WeekendsOnly', contains = c('_p_Calendar')) +setClass('_p_QuantLib__JointCalendar', contains = c('_p_Calendar')) +setClass('_p_QuantLib__BespokeCalendar', contains = c('_p_Calendar')) +setClass('_p_Rounding', contains = 'C++Reference') +setClass('_p_UpRounding', contains = c('_p_Rounding')) +setClass('_p_DownRounding', contains = c('_p_Rounding')) +setClass('_p_ClosestRounding', contains = c('_p_Rounding')) +setClass('_p_CeilingTruncation', contains = c('_p_Rounding')) +setClass('_p_FloorTruncation', contains = c('_p_Rounding')) +setClass('_p_Currency', contains = 'C++Reference') +setClass('_p_QuantLib__ARSCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__ATSCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__AUDCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__BDTCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__BEFCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__BGLCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__BRLCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__BYRCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__CADCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__CHFCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__CLPCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__CNYCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__COPCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__CYPCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__CZKCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__DEMCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__DKKCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__EEKCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__ESPCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__EURCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__FIMCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__FRFCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__GBPCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__GRDCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__HKDCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__HUFCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__IEPCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__ILSCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__INRCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__IQDCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__IRRCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__ISKCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__ITLCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__JPYCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__KRWCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__KWDCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__LTLCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__LUFCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__LVLCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__MTLCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__MXNCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__NLGCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__NOKCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__NPRCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__NZDCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__PEHCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__PEICurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__PENCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__PKRCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__PLNCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__PTECurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__ROLCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__RONCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__SARCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__SEKCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__SGDCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__SITCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__SKKCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__THBCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__TRLCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__TRYCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__TTDCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__TWDCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__USDCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__VEBCurrency', contains = c('_p_Currency')) +setClass('_p_QuantLib__ZARCurrency', contains = c('_p_Currency')) +setClass('_p_SafeLinearInterpolation', contains = 'C++Reference') +setClass('_p_SafeLogLinearInterpolation', contains = 'C++Reference') +setClass('_p_SafeBackwardFlatInterpolation', contains = 'C++Reference') +setClass('_p_SafeForwardFlatInterpolation', contains = 'C++Reference') +setClass('_p_SafeCubicNaturalSpline', contains = 'C++Reference') +setClass('_p_SafeLogCubicNaturalSpline', contains = 'C++Reference') +setClass('_p_SafeMonotonicCubicNaturalSpline', contains = 'C++Reference') +setClass('_p_SafeMonotonicLogCubicNaturalSpline', contains = 'C++Reference') +setClass('_p_SafeKrugerCubic', contains = 'C++Reference') +setClass('_p_SafeKrugerLogCubic', contains = 'C++Reference') +setClass('_p_SafeFritschButlandCubic', contains = 'C++Reference') +setClass('_p_SafeFritschButlandLogCubic', contains = 'C++Reference') +setClass('_p_SafeParabolic', contains = 'C++Reference') +setClass('_p_SafeLogParabolic', contains = 'C++Reference') +setClass('_p_SafeMonotonicParabolic', contains = 'C++Reference') +setClass('_p_SafeMonotonicLogParabolic', contains = 'C++Reference') +setClass('_p_SafeBilinearInterpolation', contains = 'C++Reference') +setClass('_p_SafeBicubicSpline', contains = 'C++Reference') +setClass('_p_BackwardFlat', contains = 'ExternalReference') +setClass("BackwardFlat", + representation( +), + contains = "RSWIGStruct") + + +# End class BackwardFlat + +setClass('_p_ForwardFlat', contains = 'ExternalReference') +setClass("ForwardFlat", + representation( +), + contains = "RSWIGStruct") + + +# End class ForwardFlat + +setClass('_p_Linear', contains = 'ExternalReference') +setClass("Linear", + representation( +), + contains = "RSWIGStruct") + + +# End class Linear + +setClass('_p_LogLinear', contains = 'ExternalReference') +setClass("LogLinear", + representation( +), + contains = "RSWIGStruct") + + +# End class LogLinear + +setClass('_p_Cubic', contains = 'ExternalReference') +setClass("Cubic", + representation( +), + contains = "RSWIGStruct") + + +# End class Cubic + +setClass('_p_boost__shared_ptrT_YieldTermStructure_t', contains = 'C++Reference') +setClass('_p_HandleT_YieldTermStructure_t', contains = 'C++Reference') +setClass('_p_RelinkableHandleT_YieldTermStructure_t', contains = c('_p_HandleT_YieldTermStructure_t')) +setClass('_p_ImpliedTermStructurePtr', contains = c('_p_boost__shared_ptrT_YieldTermStructure_t')) +setClass('_p_ZeroSpreadedTermStructurePtr', contains = c('_p_boost__shared_ptrT_YieldTermStructure_t')) +setClass('_p_ForwardSpreadedTermStructurePtr', contains = c('_p_boost__shared_ptrT_YieldTermStructure_t')) +setClass('_p_FlatForwardPtr', contains = c('_p_boost__shared_ptrT_YieldTermStructure_t')) +setClass('_p_TimeSeriesT_double_std__mapT_Date_double_t_t', contains = 'C++Reference') +setClass('_p_TimeSeriesT_IntervalPrice_std__mapT_Date_IntervalPrice_t_t', contains = 'C++Reference') +setClass('_p_std__vectorT_IntervalPrice_std__allocatorT_IntervalPrice_t_t', contains = 'C++Reference') +setClass('_p_IntervalPrice', contains = 'C++Reference') +setClass('_p_IndexManager', contains = 'C++Reference') +setClass('_p_boost__shared_ptrT_Index_t', contains = 'C++Reference') +setClass('_p_InterestRateIndexPtr', contains = c('_p_boost__shared_ptrT_Index_t')) +setClass('_p_IborIndexPtr', contains = c('_p_InterestRateIndexPtr')) +setClass('_p_SwapIndexPtr', contains = c('_p_InterestRateIndexPtr')) +setClass('_p_AUDLiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_CADLiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_CdorPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_CHFLiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_DKKLiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_EuriborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_EuriborSWPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor2WPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor3WPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor1MPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor2MPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor3MPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor4MPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor5MPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor6MPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor7MPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor8MPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor9MPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor10MPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor11MPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor1YPtr', contains = c('_p_EuriborPtr')) +setClass('_p_Euribor365Ptr', contains = c('_p_IborIndexPtr')) +setClass('_p_Euribor365_SWPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_2WPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_3WPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_1MPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_2MPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_3MPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_4MPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_5MPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_6MPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_7MPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_8MPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_9MPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_10MPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_11MPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_Euribor365_1YPtr', contains = c('_p_Euribor365Ptr')) +setClass('_p_EURLiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_EURLiborSWPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor2WPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor1MPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor2MPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor3MPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor4MPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor5MPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor6MPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor7MPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor8MPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor9MPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor10MPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor11MPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_EURLibor1YPtr', contains = c('_p_EURLiborPtr')) +setClass('_p_GBPLiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_JibarPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_JPYLiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_NZDLiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_SEKLiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_TiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_TRLiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_USDLiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_ZiborPtr', contains = c('_p_IborIndexPtr')) +setClass('_p_EuriborSwapIsdaFixAPtr', contains = c('_p_SwapIndexPtr')) +setClass('_p_EuriborSwapIsdaFixBPtr', contains = c('_p_SwapIndexPtr')) +setClass('_p_EuriborSwapIfrFixPtr', contains = c('_p_SwapIndexPtr')) +setClass('_p_EurLiborSwapIsdaFixAPtr', contains = c('_p_SwapIndexPtr')) +setClass('_p_EurLiborSwapIsdaFixBPtr', contains = c('_p_SwapIndexPtr')) +setClass('_p_EurLiborSwapIfrFixPtr', contains = c('_p_SwapIndexPtr')) +setClass('_p_Brent', contains = 'C++Reference') +setClass('_p_Bisection', contains = 'C++Reference') +setClass('_p_FalsePosition', contains = 'C++Reference') +setClass('_p_Ridder', contains = 'C++Reference') +setClass('_p_Secant', contains = 'C++Reference') +setClass('_p_Constraint', contains = 'C++Reference') +setClass('_p_BoundaryConstraint', contains = c('_p_Constraint')) +setClass('_p_NoConstraint', contains = c('_p_Constraint')) +setClass('_p_PositiveConstraint', contains = c('_p_Constraint')) +setClass('_p_EndCriteria', contains = 'C++Reference') +setClass('_p_OptimizationMethod', contains = 'C++Reference') +setClass('_p_ConjugateGradient', contains = c('_p_OptimizationMethod')) +setClass('_p_Simplex', contains = c('_p_OptimizationMethod')) +setClass('_p_SteepestDescent', contains = c('_p_OptimizationMethod')) +setClass('_p_BFGS', contains = c('_p_OptimizationMethod')) +setClass('_p_Optimizer', contains = 'C++Reference') +setClass('_p_boost__shared_ptrT_BlackVolTermStructure_t', contains = 'C++Reference') +setClass('_p_HandleT_BlackVolTermStructure_t', contains = 'C++Reference') +setClass('_p_RelinkableHandleT_BlackVolTermStructure_t', contains = c('_p_HandleT_BlackVolTermStructure_t')) +setClass('_p_boost__shared_ptrT_LocalVolTermStructure_t', contains = 'C++Reference') +setClass('_p_HandleT_LocalVolTermStructure_t', contains = 'C++Reference') +setClass('_p_RelinkableHandleT_LocalVolTermStructure_t', contains = c('_p_HandleT_LocalVolTermStructure_t')) +setClass('_p_boost__shared_ptrT_OptionletVolatilityStructure_t', contains = 'C++Reference') +setClass('_p_HandleT_OptionletVolatilityStructure_t', contains = 'C++Reference') +setClass('_p_RelinkableHandleT_OptionletVolatilityStructure_t', contains = c('_p_HandleT_OptionletVolatilityStructure_t')) +setClass('_p_boost__shared_ptrT_SwaptionVolatilityStructure_t', contains = 'C++Reference') +setClass('_p_HandleT_SwaptionVolatilityStructure_t', contains = 'C++Reference') +setClass('_p_RelinkableHandleT_SwaptionVolatilityStructure_t', contains = c('_p_HandleT_SwaptionVolatilityStructure_t')) +setClass('_p_BlackConstantVolPtr', contains = c('_p_boost__shared_ptrT_BlackVolTermStructure_t')) +setClass('_p_BlackVarianceCurvePtr', contains = c('_p_boost__shared_ptrT_BlackVolTermStructure_t')) +setClass('_p_BlackVarianceSurfacePtr', contains = c('_p_boost__shared_ptrT_BlackVolTermStructure_t')) +setClass('_p_LocalConstantVolPtr', contains = c('_p_boost__shared_ptrT_LocalVolTermStructure_t')) +setClass('_p_ConstantOptionletVolatilityPtr', contains = c('_p_boost__shared_ptrT_OptionletVolatilityStructure_t')) +setClass('_p_ConstantSwaptionVolatilityPtr', contains = c('_p_boost__shared_ptrT_SwaptionVolatilityStructure_t')) +setClass('_p_SwaptionVolatilityMatrixPtr', contains = c('_p_boost__shared_ptrT_SwaptionVolatilityStructure_t')) +setClass('_p_SwaptionVolCube1Ptr', contains = c('_p_boost__shared_ptrT_SwaptionVolatilityStructure_t')) +setClass('_p_SwaptionVolCube2Ptr', contains = c('_p_boost__shared_ptrT_SwaptionVolatilityStructure_t')) +setClass('_p_boost__shared_ptrT_StochasticProcess_t', contains = 'C++Reference') +setClass('_p_StochasticProcess1DPtr', contains = c('_p_boost__shared_ptrT_StochasticProcess_t')) +setClass('_p_GeneralizedBlackScholesProcessPtr', contains = c('_p_StochasticProcess1DPtr')) +setClass('_p_BlackScholesProcessPtr', contains = c('_p_GeneralizedBlackScholesProcessPtr')) +setClass('_p_BlackScholesMertonProcessPtr', contains = c('_p_GeneralizedBlackScholesProcessPtr')) +setClass('_p_BlackProcessPtr', contains = c('_p_GeneralizedBlackScholesProcessPtr')) +setClass('_p_GarmanKohlagenProcessPtr', contains = c('_p_GeneralizedBlackScholesProcessPtr')) +setClass('_p_Merton76ProcessPtr', contains = c('_p_StochasticProcess1DPtr')) +setClass('_p_StochasticProcessArrayPtr', contains = c('_p_boost__shared_ptrT_StochasticProcess_t')) +setClass('_p_GeometricBrownianMotionProcessPtr', contains = c('_p_StochasticProcess1DPtr')) +setClass('_p_VarianceGammaProcessPtr', contains = c('_p_StochasticProcess1DPtr')) +setClass('_p_HestonProcessPtr', contains = c('_p_boost__shared_ptrT_StochasticProcess_t')) +setClass('_p_BatesProcessPtr', contains = c('_p_HestonProcessPtr')) +setClass('_p_std__vectorT_boost__shared_ptrT_StochasticProcess_t_std__allocatorT_boost__shared_ptrT_StochasticProcess_t_t_t', contains = 'C++Reference') +setClass('_p_boost__shared_ptrT_PricingEngine_t', contains = 'C++Reference') +setClass('_p_boost__shared_ptrT_Instrument_t', contains = 'C++Reference') +setClass('_p_StockPtr', contains = c('_p_boost__shared_ptrT_Instrument_t')) +setClass('_p_CompositeInstrumentPtr', contains = c('_p_boost__shared_ptrT_Instrument_t')) +setClass('_p_Option', contains = 'C++Reference') +setClass('_p_Barrier', contains = 'ExternalReference') +setClass("Barrier", + representation( +), + contains = "RSWIGStruct") + + +# End class Barrier + +setClass('_p_boost__shared_ptrT_Payoff_t', contains = 'C++Reference') +setClass('_p_VanillaOptionPtr', contains = c('_p_boost__shared_ptrT_Instrument_t')) +setClass('_p_EuropeanOptionPtr', contains = c('_p_VanillaOptionPtr')) +setClass('_p_ForwardVanillaOptionPtr', contains = c('_p_VanillaOptionPtr')) +setClass('_p_QuantoVanillaOptionPtr', contains = c('_p_VanillaOptionPtr')) +setClass('_p_QuantoForwardVanillaOptionPtr', contains = c('_p_QuantoVanillaOptionPtr')) +setClass('_p_MultiAssetOptionPtr', contains = c('_p_boost__shared_ptrT_Instrument_t')) +setClass('_p_AnalyticEuropeanEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_boost__shared_ptrT_CalibratedModel_t', contains = 'C++Reference') +setClass('_p_HestonModelPtr', contains = c('_p_boost__shared_ptrT_CalibratedModel_t')) +setClass('_p_AnalyticHestonEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_BatesModelPtr', contains = c('_p_boost__shared_ptrT_CalibratedModel_t')) +setClass('_p_BatesEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_IntegralEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_FDBermudanEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_FDEuropeanEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_BinomialVanillaEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_MCEuropeanEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_FDAmericanEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_FDShoutEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_BaroneAdesiWhaleyApproximationEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_BjerksundStenslandApproximationEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_AnalyticDigitalAmericanEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_DividendVanillaOptionPtr', contains = c('_p_boost__shared_ptrT_Instrument_t')) +setClass('_p_AnalyticDividendEuropeanEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_FDDividendEuropeanEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_FDDividendAmericanEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_BarrierOptionPtr', contains = c('_p_boost__shared_ptrT_Instrument_t')) +setClass('_p_AnalyticBarrierEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_MCBarrierEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_ForwardEuropeanEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_QuantoEuropeanEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_QuantoForwardEuropeanEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_BlackCalculator', contains = 'C++Reference') +setClass('_p_Average', contains = 'ExternalReference') +setClass("Average", + representation( +), + contains = "RSWIGStruct") + + +# End class Average + +setClass('_p_ContinuousAveragingAsianOptionPtr', contains = c('_p_boost__shared_ptrT_Instrument_t')) +setClass('_p_DiscreteAveragingAsianOptionPtr', contains = c('_p_boost__shared_ptrT_Instrument_t')) +setClass('_p_AnalyticContinuousGeometricAveragePriceAsianEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_AnalyticDiscreteGeometricAveragePriceAsianEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_AnalyticDiscreteGeometricAverageStrikeAsianEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) +setClass('_p_MCDiscreteArithmeticAPEnginePtr', contains = c('_p_boost__shared_ptrT_PricingEngine_t')) [TRUNCATED] To get the complete diff run: svnlook diff /svnroot/rquantlib -r 329 From noreply at r-forge.r-project.org Fri May 31 03:33:56 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 31 May 2013 03:33:56 +0200 (CEST) Subject: [Rquantlib-commits] r330 - in pkg/RQuantLib: . R src Message-ID: <20130531013356.6B01C1845F0@r-forge.r-project.org> Author: edd Date: 2013-05-31 03:33:55 +0200 (Fri, 31 May 2013) New Revision: 330 Added: pkg/RQuantLib/R/mod.R pkg/RQuantLib/src/modules.cpp Modified: pkg/RQuantLib/DESCRIPTION pkg/RQuantLib/NAMESPACE Log: adding initial modules explorations done three days ago Modified: pkg/RQuantLib/DESCRIPTION =================================================================== --- pkg/RQuantLib/DESCRIPTION 2013-05-31 01:32:17 UTC (rev 329) +++ pkg/RQuantLib/DESCRIPTION 2013-05-31 01:33:55 UTC (rev 330) @@ -24,8 +24,9 @@ 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.10.0), Rcpp (>= 0.8.7) +Depends: R (>= 2.10.0), Rcpp (>= 0.8.7), methods Suggests: rgl, zoo, RUnit +Imports: methods, Rcpp LinkingTo: Rcpp SystemRequirements: QuantLib library (>= 0.9.9) from http://quantlib.org, Boost library from http://www.boost.org Modified: pkg/RQuantLib/NAMESPACE =================================================================== --- pkg/RQuantLib/NAMESPACE 2013-05-31 01:32:17 UTC (rev 329) +++ pkg/RQuantLib/NAMESPACE 2013-05-31 01:33:55 UTC (rev 330) @@ -1,4 +1,5 @@ -import("Rcpp") + +import(Rcpp,methods) useDynLib(RQuantLib) exportPattern("*.default") Added: pkg/RQuantLib/R/mod.R =================================================================== --- pkg/RQuantLib/R/mod.R (rev 0) +++ pkg/RQuantLib/R/mod.R 2013-05-31 01:33:55 UTC (rev 330) @@ -0,0 +1,3 @@ + +loadModule("BondsMod", TRUE) +loadModule("BlackMod", TRUE) Added: pkg/RQuantLib/src/modules.cpp =================================================================== --- pkg/RQuantLib/src/modules.cpp (rev 0) +++ pkg/RQuantLib/src/modules.cpp 2013-05-31 01:33:55 UTC (rev 330) @@ -0,0 +1,67 @@ +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- + +// trying something with Rcpp modules + +#include + +using namespace QuantLib; + +Real BlackFormula(std::string type, Real strike, Real fwd, Real stdDev, Real discount, Real displacement) { + if (type=="call") + return blackFormula(Option::Call, strike, fwd, stdDev, discount, displacement); + else if (type=="put") + return blackFormula(Option::Put, strike, fwd, stdDev, discount, displacement); + else { + Rcpp::stop("Unrecognised option type"); + return(-42); // never reached + } +} + +Real BlackFormulaImpliedStdDevApproximation(std::string type, Real strike, Real fwd, Real blackPrice, + Real discount, Real displacement) { + if (type=="call") + return blackFormulaImpliedStdDevApproximation(Option::Call, strike, fwd, blackPrice, discount, displacement); + else if (type=="put") + return blackFormulaImpliedStdDevApproximation(Option::Put, strike, fwd, blackPrice, discount, displacement); + else { + Rcpp::stop("Unrecognised option type"); + return(-42); // never reached + } +} + +RCPP_MODULE(BlackMod) { + + using namespace Rcpp; + + function("BlackFormula", // name of the identifier at the R level + &BlackFormula, // function pointer to helper function defined above + List::create(Named("type") = "character", + Named("strike") = "numeric", // function arguments including default value + Named("fwd") = "numeric", + Named("stddev") = "numeric", + Named("discount") = 1.0, // cf ql/pricingengines/blackformula.hpp + Named("displacement") = 0.0), // cf ql/pricingengines/blackformula.hpp + "Black (1976) formula for an option [note that stdev=vol*sqrt(timeToExp)]"); + + function("BlackFormulaImpliedStdDevApproximation", // name of the identifier at the R level + &BlackFormulaImpliedStdDevApproximation, // function pointer to helper function defined above + List::create(Named("type") = "character", + Named("strike") = "numeric", // function arguments including default value + Named("fwd") = "numeric", + Named("blackPrice") = "numeric", + Named("discount") = 1.0, // cf ql/pricingengines/blackformula.hpp + Named("displacement") = 0.0), // cf ql/pricingengines/blackformula.hpp + "Approximated Black 1976 implied standard deviation, i.e. volatility*sqrt(timeToMaturityBlack"); + + // also see blackFormulaImpliedStdDev() + +} + + + +class Bonds; +RCPP_EXPOSED_CLASS(Bonds) +RCPP_MODULE(BondsMod) { + Rcpp::class_("Bond") + ; +} From noreply at r-forge.r-project.org Fri May 31 03:45:58 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 31 May 2013 03:45:58 +0200 (CEST) Subject: [Rquantlib-commits] r331 - pkg/QuantLib Message-ID: <20130531014558.CDBC3183C01@r-forge.r-project.org> Author: edd Date: 2013-05-31 03:45:58 +0200 (Fri, 31 May 2013) New Revision: 331 Modified: pkg/QuantLib/DESCRIPTION Log: depends on methods package for S4 classes use Modified: pkg/QuantLib/DESCRIPTION =================================================================== --- pkg/QuantLib/DESCRIPTION 2013-05-31 01:33:55 UTC (rev 330) +++ pkg/QuantLib/DESCRIPTION 2013-05-31 01:45:58 UTC (rev 331) @@ -5,7 +5,7 @@ Maintainer: Dirk Eddelbuettel Author: Dirk Eddelbuettel , QuantLib Group Description: This package provides the SWIG-generated binding from QuantLib to R -Depends: R (>= 2.10.0) +Depends: R (>= 2.10.0), methods SystemRequirements: QuantLib library (>= 0.9.9) from http://quantlib.org, Boost library from http://www.boost.org License: QuantLib License