Permalink
Browse files

Merge pull request #6 from eddelbuettel/feature/new_datetime_vectors

Feature/new datetime vectors
  • Loading branch information...
eddelbuettel committed Nov 5, 2017
2 parents ccd261d + 4e8bc69 commit 5d7e63b5f018fe6b748cbcb22930c82306fac556
Showing with 137 additions and 148 deletions.
  1. +10 −0 ChangeLog
  2. +2 −2 DESCRIPTION
  3. +12 −12 R/RcppExports.R
  4. +1 −0 inst/NEWS.Rd
  5. +23 −23 inst/include/RcppQuantuccia_RcppExports.h
  6. +3 −0 inst/include/RcppQuantuccia_types.h
  7. +68 −47 src/RcppExports.cpp
  8. +18 −19 src/dates.cpp
  9. +0 −45 src/init.c
View
@@ -1,3 +1,13 @@
2017-11-05 Dirk Eddelbuettel <edd@debian.org>
* inst/include/RcppQuantuccia_types.h: Define for new Rcpp date(time)
vector, will be default with Rcpp 0.12.14
* src/dates.cpp: Simplified throughout with new date(time) vectors
* src/RcppExports.cpp: Regenerated
* R/RcppExports.R: Idem
* src/init.c: Remove as registrations generated by Rcpp
2017-08-25 Dirk Eddelbuettel <edd@debian.org>
* inst/include/ql/math/randomnumbers/sobolrsg.hpp: Aligned macro
View
@@ -1,8 +1,8 @@
Package: RcppQuantuccia
Type: Package
Title: R Bindings to the 'Quantuccia' Header-Only Essentials of 'QuantLib'
Version: 0.0.1
Date: 2017-04-18
Version: 0.0.1.2
Date: 2017-11-05
Author: Dirk Eddelbuettel; the authors and contributors of QuantLib
Maintainer: Dirk Eddelbuettel <edd@debian.org>
Description: 'QuantLib' bindings are provided for R using 'Rcpp' and the
View
@@ -14,7 +14,7 @@
#' @examples
#' setCalendar("UnitedStates")
setCalendar <- function(calstr) {
invisible(.Call('RcppQuantuccia_setCalendar', PACKAGE = 'RcppQuantuccia', calstr))
invisible(.Call(`_RcppQuantuccia_setCalendar`, calstr))
}
#' Advance a date to the next business day plus an optional shift
@@ -31,7 +31,7 @@ setCalendar <- function(calstr) {
#' @examples
#' advanceDate(Sys.Date(), 2) # today to the next biz day, plus 2 days
advanceDate <- function(rd, days = 0L) {
.Call('RcppQuantuccia_advanceDate', PACKAGE = 'RcppQuantuccia', rd, days)
.Call(`_RcppQuantuccia_advanceDate`, rd, days)
}
#' Test a vector of dates for business day
@@ -46,7 +46,7 @@ advanceDate <- function(rd, days = 0L) {
#' @examples
#' isBusinessDay(Sys.Date()+0:6)
isBusinessDay <- function(dates) {
.Call('RcppQuantuccia_isBusinessDay', PACKAGE = 'RcppQuantuccia', dates)
.Call(`_RcppQuantuccia_isBusinessDay`, dates)
}
#' Test a vector of dates for holiday
@@ -61,7 +61,7 @@ isBusinessDay <- function(dates) {
#' @examples
#' isHoliday(Sys.Date()+0:6)
isHoliday <- function(dates) {
.Call('RcppQuantuccia_isHoliday', PACKAGE = 'RcppQuantuccia', dates)
.Call(`_RcppQuantuccia_isHoliday`, dates)
}
#' Test a vector of dates for weekends
@@ -76,7 +76,7 @@ isHoliday <- function(dates) {
#' @examples
#' isWeekend(Sys.Date()+0:6)
isWeekend <- function(dates) {
.Call('RcppQuantuccia_isWeekend', PACKAGE = 'RcppQuantuccia', dates)
.Call(`_RcppQuantuccia_isWeekend`, dates)
}
#' Test a vector of dates for end-of-month
@@ -91,7 +91,7 @@ isWeekend <- function(dates) {
#' @examples
#' isEndOfMonth(Sys.Date()+0:6)
isEndOfMonth <- function(dates) {
.Call('RcppQuantuccia_isEndOfMonth', PACKAGE = 'RcppQuantuccia', dates)
.Call(`_RcppQuantuccia_isEndOfMonth`, dates)
}
#' Compute a vector of dates with end-of-month
@@ -106,17 +106,17 @@ isEndOfMonth <- function(dates) {
#' @examples
#' getEndOfMonth(Sys.Date()+0:6)
getEndOfMonth <- function(dates) {
.Call('RcppQuantuccia_getEndOfMonth', PACKAGE = 'RcppQuantuccia', dates)
.Call(`_RcppQuantuccia_getEndOfMonth`, dates)
}
#' @rdname adjust
adjust_cpp <- function(dates, bdc = 0L) {
.Call('RcppQuantuccia_adjust_cpp', PACKAGE = 'RcppQuantuccia', dates, bdc)
.Call(`_RcppQuantuccia_adjust_cpp`, dates, bdc)
}
#' @rdname advanceUnits
advanceUnits_cpp <- function(dates, n, unit, bdc, emr) {
.Call('RcppQuantuccia_advanceUnits_cpp', PACKAGE = 'RcppQuantuccia', dates, n, unit, bdc, emr)
.Call(`_RcppQuantuccia_advanceUnits_cpp`, dates, n, unit, bdc, emr)
}
#' Compute the number of business days between dates
@@ -137,7 +137,7 @@ advanceUnits_cpp <- function(dates, n, unit, bdc, emr) {
#' @examples
#' businessDaysBetween(Sys.Date() + 0:6, Sys.Date() + 3 + 0:6)
businessDaysBetween <- function(from, to, includeFirst = TRUE, includeLast = FALSE) {
.Call('RcppQuantuccia_businessDaysBetween', PACKAGE = 'RcppQuantuccia', from, to, includeFirst, includeLast)
.Call(`_RcppQuantuccia_businessDaysBetween`, from, to, includeFirst, includeLast)
}
#' Compute the number of holidays between two dates
@@ -154,10 +154,10 @@ businessDaysBetween <- function(from, to, includeFirst = TRUE, includeLast = FAL
#' @examples
#' getHolidays(Sys.Date(), Sys.Date() + 30)
getHolidays <- function(from, to, includeWeekends = FALSE) {
.Call('RcppQuantuccia_getHolidays', PACKAGE = 'RcppQuantuccia', from, to, includeWeekends)
.Call(`_RcppQuantuccia_getHolidays`, from, to, includeWeekends)
}
# Register entry points for exported C++ functions
methods::setLoadAction(function(ns) {
.Call('RcppQuantuccia_RcppExport_registerCCallable', PACKAGE = 'RcppQuantuccia')
.Call('_RcppQuantuccia_RcppExport_registerCCallable', PACKAGE = 'RcppQuantuccia')
})
View
@@ -7,6 +7,7 @@
\itemize{
\item Added calendars for Canada, China, Germany, Japan and United Kingdom
\item Added bespoke and joint calendars
\item Using new date(time) vectors
}
}
@@ -17,7 +17,7 @@ namespace RcppQuantuccia {
require("RcppQuantuccia", Rcpp::Named("quietly") = true);
typedef int(*Ptr_validate)(const char*);
static Ptr_validate p_validate = (Ptr_validate)
R_GetCCallable("RcppQuantuccia", "RcppQuantuccia_RcppExport_validate");
R_GetCCallable("RcppQuantuccia", "_RcppQuantuccia_RcppExport_validate");
if (!p_validate(sig)) {
throw Rcpp::function_not_exported(
"C++ function with signature '" + std::string(sig) + "' not found in RcppQuantuccia");
@@ -30,12 +30,12 @@ namespace RcppQuantuccia {
static Ptr_setCalendar p_setCalendar = NULL;
if (p_setCalendar == NULL) {
validateSignature("void(*setCalendar)(std::string)");
p_setCalendar = (Ptr_setCalendar)R_GetCCallable("RcppQuantuccia", "RcppQuantuccia_setCalendar");
p_setCalendar = (Ptr_setCalendar)R_GetCCallable("RcppQuantuccia", "_RcppQuantuccia_setCalendar");
}
RObject rcpp_result_gen;
{
RNGScope RCPP_rngScope_gen;
rcpp_result_gen = p_setCalendar(Rcpp::wrap(calstr));
rcpp_result_gen = p_setCalendar(Shield<SEXP>(Rcpp::wrap(calstr)));
}
if (rcpp_result_gen.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
@@ -48,12 +48,12 @@ namespace RcppQuantuccia {
static Ptr_advanceDate p_advanceDate = NULL;
if (p_advanceDate == NULL) {
validateSignature("Rcpp::Date(*advanceDate)(Rcpp::Date,int)");
p_advanceDate = (Ptr_advanceDate)R_GetCCallable("RcppQuantuccia", "RcppQuantuccia_advanceDate");
p_advanceDate = (Ptr_advanceDate)R_GetCCallable("RcppQuantuccia", "_RcppQuantuccia_advanceDate");
}
RObject rcpp_result_gen;
{
RNGScope RCPP_rngScope_gen;
rcpp_result_gen = p_advanceDate(Rcpp::wrap(rd), Rcpp::wrap(days));
rcpp_result_gen = p_advanceDate(Shield<SEXP>(Rcpp::wrap(rd)), Shield<SEXP>(Rcpp::wrap(days)));
}
if (rcpp_result_gen.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
@@ -67,12 +67,12 @@ namespace RcppQuantuccia {
static Ptr_isBusinessDay p_isBusinessDay = NULL;
if (p_isBusinessDay == NULL) {
validateSignature("Rcpp::LogicalVector(*isBusinessDay)(Rcpp::DateVector)");
p_isBusinessDay = (Ptr_isBusinessDay)R_GetCCallable("RcppQuantuccia", "RcppQuantuccia_isBusinessDay");
p_isBusinessDay = (Ptr_isBusinessDay)R_GetCCallable("RcppQuantuccia", "_RcppQuantuccia_isBusinessDay");
}
RObject rcpp_result_gen;
{
RNGScope RCPP_rngScope_gen;
rcpp_result_gen = p_isBusinessDay(Rcpp::wrap(dates));
rcpp_result_gen = p_isBusinessDay(Shield<SEXP>(Rcpp::wrap(dates)));
}
if (rcpp_result_gen.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
@@ -86,12 +86,12 @@ namespace RcppQuantuccia {
static Ptr_isHoliday p_isHoliday = NULL;
if (p_isHoliday == NULL) {
validateSignature("Rcpp::LogicalVector(*isHoliday)(Rcpp::DateVector)");
p_isHoliday = (Ptr_isHoliday)R_GetCCallable("RcppQuantuccia", "RcppQuantuccia_isHoliday");
p_isHoliday = (Ptr_isHoliday)R_GetCCallable("RcppQuantuccia", "_RcppQuantuccia_isHoliday");
}
RObject rcpp_result_gen;
{
RNGScope RCPP_rngScope_gen;
rcpp_result_gen = p_isHoliday(Rcpp::wrap(dates));
rcpp_result_gen = p_isHoliday(Shield<SEXP>(Rcpp::wrap(dates)));
}
if (rcpp_result_gen.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
@@ -105,12 +105,12 @@ namespace RcppQuantuccia {
static Ptr_isWeekend p_isWeekend = NULL;
if (p_isWeekend == NULL) {
validateSignature("Rcpp::LogicalVector(*isWeekend)(Rcpp::DateVector)");
p_isWeekend = (Ptr_isWeekend)R_GetCCallable("RcppQuantuccia", "RcppQuantuccia_isWeekend");
p_isWeekend = (Ptr_isWeekend)R_GetCCallable("RcppQuantuccia", "_RcppQuantuccia_isWeekend");
}
RObject rcpp_result_gen;
{
RNGScope RCPP_rngScope_gen;
rcpp_result_gen = p_isWeekend(Rcpp::wrap(dates));
rcpp_result_gen = p_isWeekend(Shield<SEXP>(Rcpp::wrap(dates)));
}
if (rcpp_result_gen.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
@@ -124,12 +124,12 @@ namespace RcppQuantuccia {
static Ptr_isEndOfMonth p_isEndOfMonth = NULL;
if (p_isEndOfMonth == NULL) {
validateSignature("Rcpp::LogicalVector(*isEndOfMonth)(Rcpp::DateVector)");
p_isEndOfMonth = (Ptr_isEndOfMonth)R_GetCCallable("RcppQuantuccia", "RcppQuantuccia_isEndOfMonth");
p_isEndOfMonth = (Ptr_isEndOfMonth)R_GetCCallable("RcppQuantuccia", "_RcppQuantuccia_isEndOfMonth");
}
RObject rcpp_result_gen;
{
RNGScope RCPP_rngScope_gen;
rcpp_result_gen = p_isEndOfMonth(Rcpp::wrap(dates));
rcpp_result_gen = p_isEndOfMonth(Shield<SEXP>(Rcpp::wrap(dates)));
}
if (rcpp_result_gen.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
@@ -143,12 +143,12 @@ namespace RcppQuantuccia {
static Ptr_getEndOfMonth p_getEndOfMonth = NULL;
if (p_getEndOfMonth == NULL) {
validateSignature("Rcpp::DateVector(*getEndOfMonth)(Rcpp::DateVector)");
p_getEndOfMonth = (Ptr_getEndOfMonth)R_GetCCallable("RcppQuantuccia", "RcppQuantuccia_getEndOfMonth");
p_getEndOfMonth = (Ptr_getEndOfMonth)R_GetCCallable("RcppQuantuccia", "_RcppQuantuccia_getEndOfMonth");
}
RObject rcpp_result_gen;
{
RNGScope RCPP_rngScope_gen;
rcpp_result_gen = p_getEndOfMonth(Rcpp::wrap(dates));
rcpp_result_gen = p_getEndOfMonth(Shield<SEXP>(Rcpp::wrap(dates)));
}
if (rcpp_result_gen.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
@@ -162,12 +162,12 @@ namespace RcppQuantuccia {
static Ptr_adjust_cpp p_adjust_cpp = NULL;
if (p_adjust_cpp == NULL) {
validateSignature("Rcpp::DateVector(*adjust_cpp)(Rcpp::DateVector,int)");
p_adjust_cpp = (Ptr_adjust_cpp)R_GetCCallable("RcppQuantuccia", "RcppQuantuccia_adjust_cpp");
p_adjust_cpp = (Ptr_adjust_cpp)R_GetCCallable("RcppQuantuccia", "_RcppQuantuccia_adjust_cpp");
}
RObject rcpp_result_gen;
{
RNGScope RCPP_rngScope_gen;
rcpp_result_gen = p_adjust_cpp(Rcpp::wrap(dates), Rcpp::wrap(bdc));
rcpp_result_gen = p_adjust_cpp(Shield<SEXP>(Rcpp::wrap(dates)), Shield<SEXP>(Rcpp::wrap(bdc)));
}
if (rcpp_result_gen.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
@@ -181,12 +181,12 @@ namespace RcppQuantuccia {
static Ptr_advanceUnits_cpp p_advanceUnits_cpp = NULL;
if (p_advanceUnits_cpp == NULL) {
validateSignature("Rcpp::DateVector(*advanceUnits_cpp)(Rcpp::DateVector,int,int,int,bool)");
p_advanceUnits_cpp = (Ptr_advanceUnits_cpp)R_GetCCallable("RcppQuantuccia", "RcppQuantuccia_advanceUnits_cpp");
p_advanceUnits_cpp = (Ptr_advanceUnits_cpp)R_GetCCallable("RcppQuantuccia", "_RcppQuantuccia_advanceUnits_cpp");
}
RObject rcpp_result_gen;
{
RNGScope RCPP_rngScope_gen;
rcpp_result_gen = p_advanceUnits_cpp(Rcpp::wrap(dates), Rcpp::wrap(n), Rcpp::wrap(unit), Rcpp::wrap(bdc), Rcpp::wrap(emr));
rcpp_result_gen = p_advanceUnits_cpp(Shield<SEXP>(Rcpp::wrap(dates)), Shield<SEXP>(Rcpp::wrap(n)), Shield<SEXP>(Rcpp::wrap(unit)), Shield<SEXP>(Rcpp::wrap(bdc)), Shield<SEXP>(Rcpp::wrap(emr)));
}
if (rcpp_result_gen.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
@@ -200,12 +200,12 @@ namespace RcppQuantuccia {
static Ptr_businessDaysBetween p_businessDaysBetween = NULL;
if (p_businessDaysBetween == NULL) {
validateSignature("Rcpp::NumericVector(*businessDaysBetween)(Rcpp::DateVector,Rcpp::DateVector,bool,bool)");
p_businessDaysBetween = (Ptr_businessDaysBetween)R_GetCCallable("RcppQuantuccia", "RcppQuantuccia_businessDaysBetween");
p_businessDaysBetween = (Ptr_businessDaysBetween)R_GetCCallable("RcppQuantuccia", "_RcppQuantuccia_businessDaysBetween");
}
RObject rcpp_result_gen;
{
RNGScope RCPP_rngScope_gen;
rcpp_result_gen = p_businessDaysBetween(Rcpp::wrap(from), Rcpp::wrap(to), Rcpp::wrap(includeFirst), Rcpp::wrap(includeLast));
rcpp_result_gen = p_businessDaysBetween(Shield<SEXP>(Rcpp::wrap(from)), Shield<SEXP>(Rcpp::wrap(to)), Shield<SEXP>(Rcpp::wrap(includeFirst)), Shield<SEXP>(Rcpp::wrap(includeLast)));
}
if (rcpp_result_gen.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
@@ -219,12 +219,12 @@ namespace RcppQuantuccia {
static Ptr_getHolidays p_getHolidays = NULL;
if (p_getHolidays == NULL) {
validateSignature("Rcpp::DateVector(*getHolidays)(Rcpp::Date,Rcpp::Date,bool)");
p_getHolidays = (Ptr_getHolidays)R_GetCCallable("RcppQuantuccia", "RcppQuantuccia_getHolidays");
p_getHolidays = (Ptr_getHolidays)R_GetCCallable("RcppQuantuccia", "_RcppQuantuccia_getHolidays");
}
RObject rcpp_result_gen;
{
RNGScope RCPP_rngScope_gen;
rcpp_result_gen = p_getHolidays(Rcpp::wrap(from), Rcpp::wrap(to), Rcpp::wrap(includeWeekends));
rcpp_result_gen = p_getHolidays(Shield<SEXP>(Rcpp::wrap(from)), Shield<SEXP>(Rcpp::wrap(to)), Shield<SEXP>(Rcpp::wrap(includeWeekends)));
}
if (rcpp_result_gen.inherits("interrupted-error"))
throw Rcpp::internal::InterruptedException();
@@ -7,6 +7,9 @@
//using namespace QuantLib;
// default with Rcpp 0.12.14, supported since Rcpp 0.12.8
#define RCPP_NEW_DATE_DATETIME_VECTORS 1
#include <RcppCommon.h>
namespace Rcpp {
Oops, something went wrong.

0 comments on commit 5d7e63b

Please sign in to comment.