From d3f1144e19e81850761846aac392259580b95d8a Mon Sep 17 00:00:00 2001 From: Eugene Toder Date: Tue, 15 Oct 2024 17:04:58 -0400 Subject: [PATCH 1/2] Expose swap() on DatedOISRateHelper Also, IborIborBasisSwapRateHelper and OvernightIborBasisSwapRateHelper. --- SWIG/ratehelpers.i | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/SWIG/ratehelpers.i b/SWIG/ratehelpers.i index d1c34398a..ccefd85c5 100644 --- a/SWIG/ratehelpers.i +++ b/SWIG/ratehelpers.i @@ -366,6 +366,7 @@ class DatedOISRateHelper : public RateHelper { Natural lockoutDays = 0, bool applyObservationShift = false, const ext::shared_ptr& pricer = {}); + ext::shared_ptr swap(); }; %shared_ptr(FxSwapRateHelper) @@ -382,6 +383,16 @@ class FxSwapRateHelper : public RateHelper { bool isFxBaseCurrencyCollateralCurrency, const Handle& collateralCurve, const Calendar& tradingCalendar = Calendar()); + + Real spot() const; + Period tenor() const; + Natural fixingDays() const; + Calendar calendar() const; + BusinessDayConvention businessDayConvention() const; + bool endOfMonth() const; + bool isFxBaseCurrencyCollateralCurrency() const; + Calendar tradingCalendar() const; + Calendar adjustmentCalendar() const; }; %shared_ptr(OvernightIndexFutureRateHelper) @@ -458,6 +469,7 @@ class IborIborBasisSwapRateHelper : public RateHelper { const ext::shared_ptr& otherIndex, Handle discountHandle, bool bootstrapBaseCurve); + ext::shared_ptr swap(); }; %shared_ptr(OvernightIborBasisSwapRateHelper) @@ -472,6 +484,7 @@ class OvernightIborBasisSwapRateHelper : public RateHelper { const ext::shared_ptr& baseIndex, const ext::shared_ptr& otherIndex, Handle discountHandle = Handle()); + ext::shared_ptr swap(); }; %shared_ptr(ArithmeticOISRateHelper) From 39bff1d2793bd369dd4077fd8847f0778c0dbb09 Mon Sep 17 00:00:00 2001 From: Eugene Toder Date: Tue, 15 Oct 2024 17:28:07 -0400 Subject: [PATCH 2/2] Remove SampledCurve Was deleted from C++ QuantLib. --- SWIG/linearalgebra.i | 13 ------------- SWIG/options.i | 6 ------ SWIG/ql.i | 1 - SWIG/sampledcurve.i | 45 -------------------------------------------- 4 files changed, 65 deletions(-) delete mode 100644 SWIG/sampledcurve.i diff --git a/SWIG/linearalgebra.i b/SWIG/linearalgebra.i index 4ad3d287d..9213b54cd 100644 --- a/SWIG/linearalgebra.i +++ b/SWIG/linearalgebra.i @@ -28,7 +28,6 @@ %{ using QuantLib::Array; using QuantLib::Matrix; -using QuantLib::SampledCurve; %} %define QL_TYPECHECK_ARRAY 4210 %enddef @@ -311,18 +310,6 @@ setMethod("as.matrix", "_p_Matrix", function(x) matrix(data=as.numeric(x$dataVector), nrow=x$rows(), ncol=x$columns())) -setMethod("print", "_p_SampledCurve", -function(x) print(as.data.frame(x)) -) - -setMethod("as.data.frame", "_p_SampledCurve", -function(x,row.names,optional) -data.frame("grid"=as(x$grid(), "numeric"), -"values"=as(x$values(), "numeric"))) - -setMethod("plot", "_p_SampledCurve", -function(x,y) plot(as.data.frame(x))) - %} #endif diff --git a/SWIG/options.i b/SWIG/options.i index 0ff7f100b..c4521ce8b 100644 --- a/SWIG/options.i +++ b/SWIG/options.i @@ -200,12 +200,6 @@ class VanillaOption : public OneAssetOption { Size maxEvaluations = 100, Volatility minVol = 1.0e-4, Volatility maxVol = 4.0); - - %extend{ - SampledCurve priceCurve() { - return self->result("priceCurve"); - } - } }; %template(CalibrationPair) std::pair< ext::shared_ptr, ext::shared_ptr >; diff --git a/SWIG/ql.i b/SWIG/ql.i index 2730c39a9..87ba76e86 100644 --- a/SWIG/ql.i +++ b/SWIG/ql.i @@ -174,7 +174,6 @@ QL_DEPRECATED_DISABLE_WARNING %include randomnumbers.i %include ratehelpers.i %include rounding.i -%include sampledcurve.i %include scheduler.i %include settings.i %include shortratemodels.i diff --git a/SWIG/sampledcurve.i b/SWIG/sampledcurve.i deleted file mode 100644 index d56a6608c..000000000 --- a/SWIG/sampledcurve.i +++ /dev/null @@ -1,45 +0,0 @@ - -/* - Copyright (C) 2006 Joseph Wang - - This file is part of QuantLib, a free-software/open-source library - for financial quantitative analysts and developers - http://quantlib.org/ - - QuantLib is free software: you can redistribute it and/or modify it - under the terms of the QuantLib license. You should have received a - copy of the license along with this program; if not, please email - . The license is also available online at - . - - 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 license for more details. -*/ - -#ifndef quantlib_sampled_curve_i -#define quantlib_sampled_curve_i - -%include linearalgebra.i - -class SampledCurve { - public: - SampledCurve(); - SampledCurve(const Array&); - Array& grid(); - Array& values(); - Real gridValue(Size i); - Real value(Size i); - Size size() const; - bool empty() const; - void setGrid(const Array&); - void setValues(const Array&); - void swap(SampledCurve&); - void setLogGrid(Real min, Real max); - void regridLogGrid(Real min, Real max); - void shiftGrid(Real s); - void scaleGrid(Real s); - void regrid(const Array &); -}; - - -#endif