From 00a0ad93ed4c6797a73d8a9a9a18e21578a5f6f4 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Wed, 3 Nov 2021 17:53:24 +0100 Subject: [PATCH 001/292] make floating rate coupons lazy --- ql/cashflows/capflooredcoupon.cpp | 25 ++++++++---- ql/cashflows/capflooredcoupon.hpp | 13 +++++-- ql/cashflows/digitalcoupon.cpp | 38 +++++++++++++------ ql/cashflows/digitalcoupon.hpp | 13 +++++-- ql/cashflows/floatingratecoupon.cpp | 7 +++- ql/cashflows/floatingratecoupon.hpp | 14 +++---- ql/event.hpp | 2 +- .../coupons/strippedcapflooredcoupon.cpp | 21 ++++++---- .../coupons/strippedcapflooredcoupon.hpp | 12 ++++-- ql/instruments/bond.cpp | 15 ++++++-- ql/instruments/bond.hpp | 4 ++ ql/instruments/capfloor.cpp | 5 +-- ql/instruments/floatfloatswaption.cpp | 2 +- ql/instruments/nonstandardswaption.cpp | 2 +- ql/instruments/swap.cpp | 16 ++++++-- ql/instruments/swap.hpp | 4 ++ ql/instruments/swaption.cpp | 8 +++- ql/instruments/swaption.hpp | 4 ++ ql/patterns/lazyobject.hpp | 8 +++- ql/patterns/observable.hpp | 8 +++- ql/termstructures/yield/oisratehelper.cpp | 2 +- ql/termstructures/yield/ratehelpers.cpp | 4 +- 22 files changed, 162 insertions(+), 65 deletions(-) diff --git a/ql/cashflows/capflooredcoupon.cpp b/ql/cashflows/capflooredcoupon.cpp index d24a80b91f7..039d0222545 100644 --- a/ql/cashflows/capflooredcoupon.cpp +++ b/ql/cashflows/capflooredcoupon.cpp @@ -69,7 +69,7 @@ namespace QuantLib { ") less than floor level (" << floor << ")"); } - registerWith(underlying); + registerWith(underlying_); } void CappedFlooredCoupon::setPricer( @@ -78,7 +78,17 @@ namespace QuantLib { underlying_->setPricer(pricer); } - Rate CappedFlooredCoupon::rate() const { + void CappedFlooredCoupon::deepUpdate() { + update(); + underlying_->deepUpdate(); + } + + void CappedFlooredCoupon::alwaysForwardNotifications() { + LazyObject::alwaysForwardNotifications(); + underlying_->alwaysForwardNotifications(); + } + + void CappedFlooredCoupon::performCalculations() const { QL_REQUIRE(underlying_->pricer(), "pricer not set"); Rate swapletRate = underlying_->rate(); Rate floorletRate = 0.; @@ -87,7 +97,12 @@ namespace QuantLib { Rate capletRate = 0.; if(isCapped_) capletRate = underlying_->pricer()->capletRate(effectiveCap()); - return swapletRate + floorletRate - capletRate; + rate_ = swapletRate + floorletRate - capletRate; + } + + Rate CappedFlooredCoupon::rate() const { + calculate(); + return rate_; } Rate CappedFlooredCoupon::convexityAdjustment() const { @@ -124,10 +139,6 @@ namespace QuantLib { return Null(); } - void CappedFlooredCoupon::update() { - notifyObservers(); - } - void CappedFlooredCoupon::accept(AcyclicVisitor& v) { typedef FloatingRateCoupon super; auto* v1 = dynamic_cast*>(&v); diff --git a/ql/cashflows/capflooredcoupon.hpp b/ql/cashflows/capflooredcoupon.hpp index a73770afb5e..abdfef91b3a 100644 --- a/ql/cashflows/capflooredcoupon.hpp +++ b/ql/cashflows/capflooredcoupon.hpp @@ -60,6 +60,15 @@ namespace QuantLib { const ext::shared_ptr& underlying, Rate cap = Null(), Rate floor = Null()); + //! \name Observer interface + //@{ + void deepUpdate() override; + //@} + //! \name LazyObject interface + //@{ + void performCalculations() const override; + void alwaysForwardNotifications() override; + //@} //! \name Coupon interface //@{ Rate rate() const override; @@ -74,10 +83,6 @@ namespace QuantLib { //! effective floor of fixing Rate effectiveFloor() const; //@} - //! \name Observer interface - //@{ - void update() override; - //@} //! \name Visitability //@{ void accept(AcyclicVisitor&) override; diff --git a/ql/cashflows/digitalcoupon.cpp b/ql/cashflows/digitalcoupon.cpp index 206a37ce88f..2c165bae965 100644 --- a/ql/cashflows/digitalcoupon.cpp +++ b/ql/cashflows/digitalcoupon.cpp @@ -172,6 +172,8 @@ namespace QuantLib { } registerWith(underlying); + if (nakedOption_) + underlying_->alwaysForwardNotifications(); } @@ -217,7 +219,17 @@ namespace QuantLib { return putOptionRate; } - Rate DigitalCoupon::rate() const { + void DigitalCoupon::deepUpdate() { + update(); + underlying_->deepUpdate(); + } + + void DigitalCoupon::alwaysForwardNotifications() { + LazyObject::alwaysForwardNotifications(); + underlying_->alwaysForwardNotifications(); + } + + void DigitalCoupon::performCalculations() const { QL_REQUIRE(underlying_->pricer(), "pricer not set"); @@ -229,18 +241,24 @@ namespace QuantLib { if (fixingDate < today || ((fixingDate == today) && enforceTodaysHistoricFixings)) { // must have been fixed - return underlyingRate + callCsi_ * callPayoff() + putCsi_ * putPayoff(); - } - if (fixingDate == today) { + rate_ = underlyingRate + callCsi_ * callPayoff() + putCsi_ * putPayoff(); + } else if (fixingDate == today) { // might have been fixed Rate pastFixing = IndexManager::instance().getHistory((underlying_->index())->name())[fixingDate]; if (pastFixing != Null()) { - return underlyingRate + callCsi_ * callPayoff() + putCsi_ * putPayoff(); - } else - return underlyingRate + callCsi_ * callOptionRate() + putCsi_ * putOptionRate(); + rate_ = underlyingRate + callCsi_ * callPayoff() + putCsi_ * putPayoff(); + } else { + rate_ = underlyingRate + callCsi_ * callOptionRate() + putCsi_ * putOptionRate(); + } + } else { + rate_ = underlyingRate + callCsi_ * callOptionRate() + putCsi_ * putOptionRate(); } - return underlyingRate + callCsi_ * callOptionRate() + putCsi_ * putOptionRate(); + } + + Rate DigitalCoupon::rate() const { + calculate(); + return rate_; } Rate DigitalCoupon::convexityAdjustment() const { @@ -275,10 +293,6 @@ namespace QuantLib { return Null(); } - void DigitalCoupon::update() { - notifyObservers(); - } - void DigitalCoupon::accept(AcyclicVisitor& v) { typedef FloatingRateCoupon super; auto* v1 = dynamic_cast*>(&v); diff --git a/ql/cashflows/digitalcoupon.hpp b/ql/cashflows/digitalcoupon.hpp index 4518fe00baf..24581b89b8b 100644 --- a/ql/cashflows/digitalcoupon.hpp +++ b/ql/cashflows/digitalcoupon.hpp @@ -94,6 +94,15 @@ namespace QuantLib { ext::shared_ptr(), bool nakedOption = false); + //@} + //! \name Obverver interface + //@{ + void deepUpdate() override; + //@} + //! \name LazyObject interface + //@{ + void performCalculations() const override; + void alwaysForwardNotifications() override; //@} //! \name Coupon interface //@{ @@ -122,10 +131,6 @@ namespace QuantLib { */ Rate putOptionRate() const; //@} - //! \name Observer interface - //@{ - void update() override; - //@} //! \name Visitability //@{ void accept(AcyclicVisitor&) override; diff --git a/ql/cashflows/floatingratecoupon.cpp b/ql/cashflows/floatingratecoupon.cpp index 45dd6720bb9..6010201c2c2 100644 --- a/ql/cashflows/floatingratecoupon.cpp +++ b/ql/cashflows/floatingratecoupon.cpp @@ -92,9 +92,14 @@ namespace QuantLib { } Rate FloatingRateCoupon::rate() const { + calculate(); + return rate_; + } + + void FloatingRateCoupon::performCalculations() const { QL_REQUIRE(pricer_, "pricer not set"); pricer_->initialize(*this); - return pricer_->swapletRate(); + rate_ = pricer_->swapletRate(); } Real FloatingRateCoupon::price(const Handle& discountingCurve) const { diff --git a/ql/cashflows/floatingratecoupon.hpp b/ql/cashflows/floatingratecoupon.hpp index 6bb6d191cfa..c05e92aa089 100644 --- a/ql/cashflows/floatingratecoupon.hpp +++ b/ql/cashflows/floatingratecoupon.hpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -41,8 +42,7 @@ namespace QuantLib { class FloatingRateCouponPricer; //! base floating-rate coupon class - class FloatingRateCoupon : public Coupon, - public Observer { + class FloatingRateCoupon : public Coupon, public LazyObject { public: FloatingRateCoupon(const Date& paymentDate, Real nominal, @@ -58,6 +58,10 @@ namespace QuantLib { bool isInArrears = false, const Date& exCouponDate = Date()); + //! \name LazyObject interface + //@{ + void performCalculations() const override; + //@} //! \name CashFlow interface //@{ Real amount() const override { return rate() * accrualPeriod() * nominal(); } @@ -93,11 +97,6 @@ namespace QuantLib { bool isInArrears() const { return isInArrears_; } //@} - //! \name Observer interface - //@{ - void update() override { notifyObservers(); } - //@} - //! \name Visitability //@{ void accept(AcyclicVisitor&) override; @@ -115,6 +114,7 @@ namespace QuantLib { Spread spread_; bool isInArrears_; ext::shared_ptr pricer_; + mutable Real rate_; }; // inline definitions diff --git a/ql/event.hpp b/ql/event.hpp index 65609d6774e..0a5d9060714 100644 --- a/ql/event.hpp +++ b/ql/event.hpp @@ -37,7 +37,7 @@ namespace QuantLib { /*! This class acts as a base class for the actual event implementations. */ - class Event : public Observable { + class Event : public virtual Observable { public: ~Event() override = default; //! \name Event interface diff --git a/ql/experimental/coupons/strippedcapflooredcoupon.cpp b/ql/experimental/coupons/strippedcapflooredcoupon.cpp index 020cc13c44c..de70f4544c3 100644 --- a/ql/experimental/coupons/strippedcapflooredcoupon.cpp +++ b/ql/experimental/coupons/strippedcapflooredcoupon.cpp @@ -34,11 +34,16 @@ namespace QuantLib { underlying->referencePeriodEnd(), underlying->dayCounter(), underlying->isInArrears()), underlying_(underlying) { - registerWith(underlying); + registerWith(underlying_); + underlying_->alwaysForwardNotifications(); } - Rate StrippedCappedFlooredCoupon::rate() const { + void StrippedCappedFlooredCoupon::deepUpdate() { + update(); + underlying_->deepUpdate(); + } + void StrippedCappedFlooredCoupon::performCalculations() const { QL_REQUIRE(underlying_->underlying()->pricer() != nullptr, "pricer not set"); underlying_->underlying()->pricer()->initialize(*underlying_->underlying()); Rate floorletRate = 0.0; @@ -53,9 +58,13 @@ namespace QuantLib { // if the underlying is collared we return the value of the embedded // collar, otherwise the value of a long floor or a long cap respectively - return (underlying_->isFloored() && underlying_->isCapped()) - ? floorletRate - capletRate - : floorletRate + capletRate; + rate_ = (underlying_->isFloored() && underlying_->isCapped()) ? floorletRate - capletRate : + floorletRate + capletRate; + } + + Rate StrippedCappedFlooredCoupon::rate() const { + calculate(); + return rate_; } Rate StrippedCappedFlooredCoupon::convexityAdjustment() const { @@ -76,8 +85,6 @@ namespace QuantLib { return underlying_->effectiveFloor(); } - void StrippedCappedFlooredCoupon::update() { notifyObservers(); } - void StrippedCappedFlooredCoupon::accept(AcyclicVisitor &v) { underlying_->accept(v); auto* v1 = dynamic_cast*>(&v); diff --git a/ql/experimental/coupons/strippedcapflooredcoupon.hpp b/ql/experimental/coupons/strippedcapflooredcoupon.hpp index 1de288f53e3..338879232ae 100644 --- a/ql/experimental/coupons/strippedcapflooredcoupon.hpp +++ b/ql/experimental/coupons/strippedcapflooredcoupon.hpp @@ -34,6 +34,15 @@ namespace QuantLib { explicit StrippedCappedFlooredCoupon(const ext::shared_ptr &underlying); + //! \name Obverver interface + //@{ + void deepUpdate() override; + //@} + + //! \name LazyObject interface + //@{ + void performCalculations() const override; + //@} //! Coupon interface Rate rate() const override; Rate convexityAdjustment() const override; @@ -46,9 +55,6 @@ namespace QuantLib { //! effective floor Rate effectiveFloor() const; - //! Observer interface - void update() override; - //! Visitability void accept(AcyclicVisitor&) override; diff --git a/ql/instruments/bond.cpp b/ql/instruments/bond.cpp index 60f77568068..2ddc6a65bf8 100644 --- a/ql/instruments/bond.cpp +++ b/ql/instruments/bond.cpp @@ -352,11 +352,20 @@ namespace QuantLib { redemptions_.push_back(redemption); } + void Bond::alwaysForwardNotifications() { + for (auto& cashflow : cashflows_) { + if(auto lazy = ext::dynamic_pointer_cast(cashflow)) { + lazy->alwaysForwardNotifications(); + } + } + LazyObject::alwaysForwardNotifications(); + } + void Bond::deepUpdate() { for (auto& cashflow : cashflows_) { - ext::shared_ptr f = ext::dynamic_pointer_cast(cashflow); - if (f != nullptr) - f->update(); + if(auto lazy = ext::dynamic_pointer_cast(cashflow)) { + lazy->deepUpdate(); + } } update(); } diff --git a/ql/instruments/bond.hpp b/ql/instruments/bond.hpp index 8e0b0da6e8f..6c6782543fc 100644 --- a/ql/instruments/bond.hpp +++ b/ql/instruments/bond.hpp @@ -104,6 +104,10 @@ namespace QuantLib { //@{ bool isExpired() const override; //@} + //! \name LazyObject interface + //@{ + void alwaysForwardNotifications() override; + //@} //! \name Observable interface //@{ void deepUpdate() override; diff --git a/ql/instruments/capfloor.cpp b/ql/instruments/capfloor.cpp index c9f549fc910..90d32dffdff 100644 --- a/ql/instruments/capfloor.cpp +++ b/ql/instruments/capfloor.cpp @@ -269,9 +269,8 @@ namespace QuantLib { void CapFloor::deepUpdate() { for (auto& i : floatingLeg_) { - ext::shared_ptr f = ext::dynamic_pointer_cast(i); - if (f != nullptr) - f->update(); + if(auto lazy = ext::dynamic_pointer_cast(i)) + lazy->deepUpdate(); } update(); } diff --git a/ql/instruments/floatfloatswaption.cpp b/ql/instruments/floatfloatswaption.cpp index 13e946e272e..52d7c7dc49c 100644 --- a/ql/instruments/floatfloatswaption.cpp +++ b/ql/instruments/floatfloatswaption.cpp @@ -30,7 +30,7 @@ namespace QuantLib { : Option(ext::shared_ptr(), exercise), swap_(std::move(swap)), settlementType_(delivery), settlementMethod_(settlementMethod) { registerWith(swap_); - registerWithObservables(swap_); + swap_->alwaysForwardNotifications(); } bool FloatFloatSwaption::isExpired() const { diff --git a/ql/instruments/nonstandardswaption.cpp b/ql/instruments/nonstandardswaption.cpp index c4afefbdd63..be083dccc17 100644 --- a/ql/instruments/nonstandardswaption.cpp +++ b/ql/instruments/nonstandardswaption.cpp @@ -41,7 +41,7 @@ namespace QuantLib { : Option(ext::shared_ptr(), exercise), swap_(std::move(swap)), settlementType_(delivery), settlementMethod_(settlementMethod) { registerWith(swap_); - registerWithObservables(swap_); + swap_->alwaysForwardNotifications(); } bool NonstandardSwaption::isExpired() const { diff --git a/ql/instruments/swap.cpp b/ql/instruments/swap.cpp index 0116830ae96..69b66c36676 100644 --- a/ql/instruments/swap.cpp +++ b/ql/instruments/swap.cpp @@ -65,7 +65,6 @@ namespace QuantLib { startDiscounts_(legs, 0.0), endDiscounts_(legs, 0.0), npvDateDiscount_(0.0) {} - bool Swap::isExpired() const { for (const auto& leg : legs_) { Leg::const_iterator i; @@ -161,14 +160,23 @@ namespace QuantLib { void Swap::deepUpdate() { for (auto& leg : legs_) { for (auto& k : leg) { - ext::shared_ptr f = ext::dynamic_pointer_cast(k); - if (f != nullptr) - f->update(); + if (auto lazy = ext::dynamic_pointer_cast(k)) + lazy->deepUpdate(); } } update(); } + void Swap::alwaysForwardNotifications() { + for (auto& leg : legs_) { + for (auto& k : leg) { + if (auto lazy = ext::dynamic_pointer_cast(k)) + lazy->alwaysForwardNotifications(); + } + } + LazyObject::alwaysForwardNotifications(); + } + void Swap::arguments::validate() const { QL_REQUIRE(legs.size() == payer.size(), "number of legs and multipliers differ"); diff --git a/ql/instruments/swap.hpp b/ql/instruments/swap.hpp index 9f8afcd789d..30a1e19ddf8 100644 --- a/ql/instruments/swap.hpp +++ b/ql/instruments/swap.hpp @@ -63,6 +63,10 @@ namespace QuantLib { Swap(const std::vector& legs, const std::vector& payer); //@} + //! \name LazyObject interface + //@{ + void alwaysForwardNotifications() override; + //@} //! \name Observable interface //@{ void deepUpdate() override; diff --git a/ql/instruments/swaption.cpp b/ql/instruments/swaption.cpp index e8b8fbe6586..c1761e69618 100644 --- a/ql/instruments/swaption.cpp +++ b/ql/instruments/swaption.cpp @@ -136,7 +136,13 @@ namespace QuantLib { : Option(ext::shared_ptr(), exercise), swap_(std::move(swap)), settlementType_(delivery), settlementMethod_(settlementMethod) { registerWith(swap_); - registerWithObservables(swap_); + // a swaption engine might not calculate the underlying swap + swap_->alwaysForwardNotifications(); + } + + void Swaption::deepUpdate() { + swap_->deepUpdate(); + update(); } bool Swaption::isExpired() const { diff --git a/ql/instruments/swaption.hpp b/ql/instruments/swaption.hpp index 4c5fd4e42d4..adf9478fca9 100644 --- a/ql/instruments/swaption.hpp +++ b/ql/instruments/swaption.hpp @@ -86,6 +86,10 @@ namespace QuantLib { const ext::shared_ptr& exercise, Settlement::Type delivery = Settlement::Physical, Settlement::Method settlementMethod = Settlement::PhysicalOTC); + //! \name Observer interface + //@{ + void deepUpdate() override; + //@} //! \name Instrument interface //@{ bool isExpired() const override; diff --git a/ql/patterns/lazyobject.hpp b/ql/patterns/lazyobject.hpp index 92c01a772f7..f8b59236137 100644 --- a/ql/patterns/lazyobject.hpp +++ b/ql/patterns/lazyobject.hpp @@ -77,12 +77,18 @@ namespace QuantLib { recalculation, this object would again forward the first notification received. + The method should be overridden in derived classes which + contain nested lazy objects. It should then call the method + on itself and the nested lazy objects to ensure that + notifications from the nested objects are always forwarded + all the way through the observable chain. + \warning Forwarding all notifications will cause a performance hit, and should be used only when discarding notifications cause an incorrect behavior. */ - void alwaysForwardNotifications(); + virtual void alwaysForwardNotifications(); protected: /*! This method performs all needed calculations by calling the performCalculations method. diff --git a/ql/patterns/observable.hpp b/ql/patterns/observable.hpp index 4f671975e53..a1c46bf7b66 100644 --- a/ql/patterns/observable.hpp +++ b/ql/patterns/observable.hpp @@ -115,8 +115,12 @@ namespace QuantLib { /*! register with all observables of a given observer. Note that this does not include registering with the observer - itself. */ - void registerWithObservables(const ext::shared_ptr&); + itself. + + \deprecated consider using LazyObject::alwaysForwardNotifications() instead, + the registration with the next-level observables was just a workaround for that. + */ + QL_DEPRECATED void registerWithObservables(const ext::shared_ptr&); Size unregisterWith(const ext::shared_ptr&); void unregisterWithAll(); diff --git a/ql/termstructures/yield/oisratehelper.cpp b/ql/termstructures/yield/oisratehelper.cpp index 38e0a5dbe68..5aed12fd701 100644 --- a/ql/termstructures/yield/oisratehelper.cpp +++ b/ql/termstructures/yield/oisratehelper.cpp @@ -128,7 +128,7 @@ namespace QuantLib { Real OISRateHelper::impliedQuote() const { QL_REQUIRE(termStructure_ != nullptr, "term structure not set"); // we didn't register as observers - force calculation - swap_->recalculate(); + swap_->deepUpdate(); return swap_->fairRate(); } diff --git a/ql/termstructures/yield/ratehelpers.cpp b/ql/termstructures/yield/ratehelpers.cpp index 7c158a6a9c3..4d7f18a1db0 100644 --- a/ql/termstructures/yield/ratehelpers.cpp +++ b/ql/termstructures/yield/ratehelpers.cpp @@ -883,7 +883,7 @@ namespace QuantLib { Real SwapRateHelper::impliedQuote() const { QL_REQUIRE(termStructure_ != nullptr, "term structure not set"); // we didn't register as observers - force calculation - swap_->recalculate(); + swap_->deepUpdate(); // weak implementation... to be improved static const Spread basisPoint = 1.0e-4; Real floatingLegNPV = swap_->floatingLegNPV(); @@ -986,7 +986,7 @@ namespace QuantLib { Real BMASwapRateHelper::impliedQuote() const { QL_REQUIRE(termStructure_ != nullptr, "term structure not set"); // we didn't register as observers - force calculation - swap_->recalculate(); + swap_->deepUpdate(); return swap_->fairLiborFraction(); } From 5f8f9472cf34f56223b4cb22df363fb9b4a70054 Mon Sep 17 00:00:00 2001 From: Matthias Groncki Date: Mon, 17 Oct 2022 11:55:34 +0200 Subject: [PATCH 002/292] CPICoupon with baseDate add a new CPICoupon constructor which requires a baseDate instead of base CPI fixing value. If baseCPI is provided it will use it, if it baseCPI is NULL the pricer will retriev the index fixing at baseDate from the index. If baseDate and baseCPI are null and we have at least two dates in the schedule, CPILag will imply a regular baseDate = firstCouponStartDate - observationLag If the CPILeg has only one date and one cashflow, a non-null baseDate or baseCPI are still required --- ql/cashflows/cpicoupon.cpp | 116 ++++++++++++++++++++++++++++--- ql/cashflows/cpicoupon.hpp | 44 ++++++++++++ ql/cashflows/cpicouponpricer.cpp | 14 +++- 3 files changed, 163 insertions(+), 11 deletions(-) diff --git a/ql/cashflows/cpicoupon.cpp b/ql/cashflows/cpicoupon.cpp index ee44770fce0..5be9689fe06 100644 --- a/ql/cashflows/cpicoupon.cpp +++ b/ql/cashflows/cpicoupon.cpp @@ -2,6 +2,7 @@ /* Copyright (C) 2009 Chris Kenyon + Copyright (C) 2022 Quaternion Risk Management Ltd This file is part of QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ @@ -42,14 +43,86 @@ namespace QuantLib { const Date& refPeriodStart, const Date& refPeriodEnd, const Date& exCouponDate) - : InflationCoupon(paymentDate, nominal, startDate, endDate, - 0, zeroIndex, observationLag, - dayCounter, refPeriodStart, refPeriodEnd, exCouponDate), + : CPICoupon(baseCPI, + Null(), + paymentDate, + nominal, + startDate, + endDate, + zeroIndex, + observationLag, + observationInterpolation, + dayCounter, + fixedRate, + spread, + refPeriodStart, + refPeriodEnd, + exCouponDate) {} + + CPICoupon::CPICoupon(const Date& baseDate, + const Date& paymentDate, + Real nominal, + const Date& startDate, + const Date& endDate, + const ext::shared_ptr& zeroIndex, + const Period& observationLag, + CPI::InterpolationType observationInterpolation, + const DayCounter& dayCounter, + Real fixedRate, + Spread spread, + const Date& refPeriodStart, + const Date& refPeriodEnd, + const Date& exCouponDate) + : CPICoupon(Null(), + baseDate, + paymentDate, + nominal, + startDate, + endDate, + zeroIndex, + observationLag, + observationInterpolation, + dayCounter, + fixedRate, + spread, + refPeriodStart, + refPeriodEnd, + exCouponDate) {} + + CPICoupon::CPICoupon(Real baseCPI, + const Date& baseDate, + const Date& paymentDate, + Real nominal, + const Date& startDate, + const Date& endDate, + const ext::shared_ptr& zeroIndex, + const Period& observationLag, + CPI::InterpolationType observationInterpolation, + const DayCounter& dayCounter, + Real fixedRate, + Spread spread, + const Date& refPeriodStart, + const Date& refPeriodEnd, + const Date& exCouponDate) + : InflationCoupon(paymentDate, + nominal, + startDate, + endDate, + 0, + zeroIndex, + observationLag, + dayCounter, + refPeriodStart, + refPeriodEnd, + exCouponDate), baseCPI_(baseCPI), fixedRate_(fixedRate), spread_(spread), observationInterpolation_(observationInterpolation) { - QL_REQUIRE(zeroIndex, "no index provided"); - QL_REQUIRE(std::fabs(baseCPI_) > 1e-16, + QL_REQUIRE(index_, "no index provided"); + QL_REQUIRE( + baseCPI_ != Null() || baseDate != Null(), + "baseCPI and baseDate can not be both null, provide a valid baseCPI or baseDate"); + QL_REQUIRE(baseCPI_ == Null() || std::fabs(baseCPI_) > 1e-16, "|baseCPI_| < 1e-16, future divide-by-zero problem"); } @@ -138,8 +211,11 @@ namespace QuantLib { baseFixing_(baseFixing), observationDate_(observationDate), observationLag_(observationLag), interpolation_(interpolation), frequency_(index ? index->frequency() : NoFrequency) { QL_REQUIRE(index, "no index provided"); - QL_REQUIRE(std::fabs(baseFixing_)>1e-16, - "|baseFixing|<1e-16, future divide-by-zero error"); + QL_REQUIRE( + baseFixing_ != Null() || baseDate != Null(), + "baseCPI and baseDate can not be both null, provide a valid baseCPI or baseDate"); + QL_REQUIRE(baseFixing_ == Null() || std::fabs(baseFixing_) > 1e-16, + "|baseCPI_| < 1e-16, future divide-by-zero problem"); } CPICashFlow::CPICashFlow(Real notional, @@ -155,6 +231,7 @@ namespace QuantLib { paymentDate, growthOnly), baseFixing_(baseFixing), interpolation_(interpolation), frequency_(frequency) { + QL_REQUIRE(std::fabs(baseFixing_)>1e-16, "|baseFixing|<1e-16, future divide-by-zero error"); if (interpolation_ != CPI::AsIndex) { @@ -178,6 +255,12 @@ namespace QuantLib { Real CPICashFlow::amount() const { Real I0 = baseFixing(); + + if (I0 == Null()) { + I0 = CPI::laggedFixing(cpiIndex(), baseDate() + observationLag(), observationLag(), + interpolation_); + } + Real I1; if (observationDate_ != Date()) { @@ -216,7 +299,7 @@ namespace QuantLib { observationLag_(observationLag), paymentDayCounter_(Thirty360(Thirty360::BondBasis)), paymentCalendar_(schedule.calendar()), - spreads_(std::vector(1, 0)) {} + spreads_(std::vector(1, 0)), baseDate_(Null()) {} CPILeg& CPILeg::withObservationInterpolation(CPI::InterpolationType interp) { @@ -315,6 +398,11 @@ namespace QuantLib { return *this; } + CPILeg& CPILeg::withBaseDate(const Date& baseDate) { + baseDate_ = baseDate; + return *this; + } + CPILeg::operator Leg() const { @@ -322,9 +410,18 @@ namespace QuantLib { Size n = schedule_.size()-1; Leg leg; leg.reserve(n+1); // +1 for notional, we always have some sort ... + + Date baseDate = baseDate_; + // BaseDate and baseCPI are not given, use the first date as startDate and the baseFixingg + // should be at startDate - observationLag + if (n>0) { QL_REQUIRE(!fixedRates_.empty() || !spreads_.empty(), "no fixedRates or spreads given"); + + if (baseDate_ == Null() && baseCPI_ == Null()) { + baseDate = schedule_.date(0) - observationLag_; + } Date refStart, start, refEnd, end; @@ -359,6 +456,7 @@ namespace QuantLib { if (detail::noOption(caps_, floors_, i)) { // just swaplet leg.push_back(ext::make_shared (baseCPI_, // all have same base for ratio + baseDate, paymentDate, detail::get(notionals_, i, 0.0), start, end, @@ -379,7 +477,7 @@ namespace QuantLib { Date paymentDate = paymentCalendar_.adjust(schedule_.date(n), paymentAdjustment_); leg.push_back(ext::make_shared (detail::get(notionals_, n, 0.0), index_, - Date(), baseCPI_, // no base date provided + baseDate, baseCPI_, schedule_.date(n), observationLag_, observationInterpolation_, paymentDate, subtractInflationNominal_)); diff --git a/ql/cashflows/cpicoupon.hpp b/ql/cashflows/cpicoupon.hpp index f897a3f13bc..d4ddf7550f3 100644 --- a/ql/cashflows/cpicoupon.hpp +++ b/ql/cashflows/cpicoupon.hpp @@ -2,6 +2,7 @@ /* Copyright (C) 2011 Chris Kenyon + Copyright (C) 2022 Quaternion Risk Management Ltd This file is part of QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ @@ -68,6 +69,37 @@ namespace QuantLib { const Date& refPeriodEnd = Date(), const Date& exCouponDate = Date()); + CPICoupon(const Date& baseDate, // user provided, could be arbitrary + const Date& paymentDate, + Real nominal, + const Date& startDate, + const Date& endDate, + const ext::shared_ptr& index, + const Period& observationLag, + CPI::InterpolationType observationInterpolation, + const DayCounter& dayCounter, + Real fixedRate, // aka gearing + Spread spread = 0.0, + const Date& refPeriodStart = Date(), + const Date& refPeriodEnd = Date(), + const Date& exCouponDate = Date()); + + CPICoupon(Real baseCPI, // user provided, could be arbitrary + const Date& baseDate, + const Date& paymentDate, + Real nominal, + const Date& startDate, + const Date& endDate, + const ext::shared_ptr& index, + const Period& observationLag, + CPI::InterpolationType observationInterpolation, + const DayCounter& dayCounter, + Real fixedRate, // aka gearing + Spread spread = 0.0, + const Date& refPeriodStart = Date(), + const Date& refPeriodEnd = Date(), + const Date& exCouponDate = Date()); + /*! \deprecated Use the other constructor instead. Deprecated in version 1.26. */ @@ -108,6 +140,10 @@ namespace QuantLib { i.e. the observationInterpolation. */ Rate baseCPI() const; + + //! base date for the base fixing of the CPI index + Date baseDate() const; + //! how do you observe the index? as-is, flat, linear? CPI::InterpolationType observationInterpolation() const; @@ -136,6 +172,7 @@ namespace QuantLib { Real fixedRate_; Spread spread_; CPI::InterpolationType observationInterpolation_; + Date baseDate_; bool checkPricerImpl(const ext::shared_ptr&) const override; @@ -246,6 +283,8 @@ namespace QuantLib { const Calendar&, BusinessDayConvention, bool endOfMonth = false); + CPILeg& withBaseDate(const Date& baseDate); + operator Leg() const; private: @@ -266,6 +305,7 @@ namespace QuantLib { Calendar exCouponCalendar_; BusinessDayConvention exCouponAdjustment_ = Following; bool exCouponEndOfMonth_ = false; + Date baseDate_ = Null(); }; @@ -291,6 +331,10 @@ namespace QuantLib { return baseCPI_; } + inline Date CPICoupon::baseDate() const { + return baseDate_; + } + inline CPI::InterpolationType CPICoupon::observationInterpolation() const { return observationInterpolation_; } diff --git a/ql/cashflows/cpicouponpricer.cpp b/ql/cashflows/cpicouponpricer.cpp index 3edc90e4ace..a1cddb5e5b1 100644 --- a/ql/cashflows/cpicouponpricer.cpp +++ b/ql/cashflows/cpicouponpricer.cpp @@ -2,6 +2,7 @@ /* Copyright (C) 2009, 2011 Chris Kenyon + Copyright (C) 2022 Quaternion Risk Management Ltd This file is part of QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ @@ -108,10 +109,19 @@ namespace QuantLib { Rate CPICouponPricer::adjustedFixing(Rate fixing) const { + Rate I0 = coupon_->baseCPI(); + + if (I0 == Null()) { + I0 = CPI::laggedFixing(coupon_->cpiIndex(), + coupon_->baseDate() + coupon_->observationLag(), + coupon_->observationLag(), coupon_->observationInterpolation()); + } + + Rate I1 = coupon_->indexFixing(); + if (fixing == Null()) - fixing = coupon_->indexFixing() / coupon_->baseCPI(); + fixing = I1 / I0; - // no further adjustment return fixing; } From 9f58be1bd8d69431624d39c9ae36c10cbca98608 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 17 Oct 2022 11:10:46 +0000 Subject: [PATCH 003/292] Update copyright list in license --- LICENSE.TXT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.TXT b/LICENSE.TXT index 2b1ae2cddbb..2ee51dba7bb 100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT @@ -124,10 +124,10 @@ QuantLib is Copyright (C) 2015, 2016 Andres Hernandez Copyright (C) 2016 Nicholas Bertocchi - Copyright (C) 2016 Quaternion Risk Management Ltd Copyright (C) 2016 Stefano Fondi Copyright (C) 2016, 2017 Fabrice Lecuyer Copyright (C) 2016, 2019, 2020 Eisuke Tani + Copyright (C) 2016, 2022 Quaternion Risk Management Ltd Copyright (C) 2017 BN Algorithms Ltd Copyright (C) 2017 Joseph Jeisman From 0d82b813a8e2e96944f8b06187721f04795d8e6c Mon Sep 17 00:00:00 2001 From: HristoRaykov Date: Tue, 1 Nov 2022 15:57:38 +0200 Subject: [PATCH 004/292] schedule tests added --- test-suite/schedule.cpp | 50 +++++++++++++++++++++++++++++++++++++++++ test-suite/schedule.hpp | 2 ++ 2 files changed, 52 insertions(+) diff --git a/test-suite/schedule.cpp b/test-suite/schedule.cpp index abe333f4e54..7e8b23d757d 100644 --- a/test-suite/schedule.cpp +++ b/test-suite/schedule.cpp @@ -251,6 +251,54 @@ void ScheduleTest::testDoubleFirstDateWithEomAdjustment() { check_dates(s, expected); } +void ScheduleTest::testFirstDateWithEomAdjustment() { + BOOST_TEST_MESSAGE("Testing schedule with first date and EOM adjustments ..."); + + Schedule schedule = MakeSchedule() + .from(Date(10, August, 1996)) + .to(Date(10, August, 1998)) + .withFirstDate(Date(28, February, 1997)) + .withCalendar(UnitedStates(UnitedStates::GovernmentBond)) + .withTenor(6 * Months) + .withConvention(Following) + .withTerminationDateConvention(Following) + .forwards() + .endOfMonth(); + + std::vector expected(5); + expected[0] = Date(12, August, 1996); + expected[1] = Date(28, February, 1997); + expected[2] = Date(29, August, 1997); + expected[3] = Date(27, February, 1998); + expected[4] = Date(10, August, 1998); + + check_dates(schedule, expected); +} + +void ScheduleTest::testNextToLastWithEomAdjustment() { + BOOST_TEST_MESSAGE("Testing schedule with next to last date and EOM adjustments ..."); + + Schedule schedule = MakeSchedule() + .from(Date(10, August, 1996)) + .to(Date(10, August, 1998)) + .withNextToLastDate(Date(28, February, 1998)) + .withCalendar(UnitedStates(UnitedStates::GovernmentBond)) + .withTenor(6 * Months) + .withConvention(Following) + .withTerminationDateConvention(Following) + .backwards() + .endOfMonth(); + + std::vector expected(5); + expected[0] = Date(12, August, 1996); + expected[1] = Date(28, February, 1997); + expected[2] = Date(29, August, 1997); + expected[3] = Date(27, February, 1998); + expected[4] = Date(10, August, 1998); + + check_dates(schedule, expected); +} + namespace CdsTests { Schedule makeCdsSchedule(const Date& from, const Date& to, DateGeneration::Rule rule) { @@ -1088,6 +1136,8 @@ test_suite* ScheduleTest::suite() { &ScheduleTest::testBackwardDatesWithEomAdjustment)); suite->add(QUANTLIB_TEST_CASE( &ScheduleTest::testDoubleFirstDateWithEomAdjustment)); + suite->add(QUANTLIB_TEST_CASE(&ScheduleTest::testFirstDateWithEomAdjustment)); + suite->add(QUANTLIB_TEST_CASE(&ScheduleTest::testNextToLastWithEomAdjustment)); suite->add(QUANTLIB_TEST_CASE(&ScheduleTest::testCDS2015Convention)); suite->add(QUANTLIB_TEST_CASE(&ScheduleTest::testCDS2015ConventionGrid)); suite->add(QUANTLIB_TEST_CASE(&ScheduleTest::testCDSConventionGrid)); diff --git a/test-suite/schedule.hpp b/test-suite/schedule.hpp index 4798b1e767e..a4167f3402f 100644 --- a/test-suite/schedule.hpp +++ b/test-suite/schedule.hpp @@ -34,6 +34,8 @@ class ScheduleTest { static void testForwardDatesWithEomAdjustment(); static void testBackwardDatesWithEomAdjustment(); static void testDoubleFirstDateWithEomAdjustment(); + static void testFirstDateWithEomAdjustment(); + static void testNextToLastWithEomAdjustment(); static void testCDS2015Convention(); static void testCDS2015ConventionGrid(); static void testCDSConventionGrid(); From 7e6b39da6939e8f3849d34884ccc7e6dea276f44 Mon Sep 17 00:00:00 2001 From: HristoRaykov Date: Tue, 1 Nov 2022 16:16:19 +0200 Subject: [PATCH 005/292] EOM adjustment removed for effective and termination date --- ql/time/schedule.cpp | 38 ++++++++++++++++++++++---------------- test-suite/schedule.cpp | 11 ++++++----- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/ql/time/schedule.cpp b/ql/time/schedule.cpp index 91d9c635802..d0fdc14ea8e 100644 --- a/ql/time/schedule.cpp +++ b/ql/time/schedule.cpp @@ -364,27 +364,33 @@ namespace QuantLib { for (Size i=1; i expected(5); + std::vector expected(6); expected[0] = Date(12, August, 1996); - expected[1] = Date(28, February, 1997); - expected[2] = Date(29, August, 1997); - expected[3] = Date(27, February, 1998); - expected[4] = Date(10, August, 1998); + expected[1] = Date(30, August, 1996); + expected[2] = Date(28, February, 1997); + expected[3] = Date(29, August, 1997); + expected[4] = Date(27, February, 1998); + expected[5] = Date(10, August, 1998); check_dates(schedule, expected); } From 1919fd841ac9e7bfd4eef77db099d083b5ec6777 Mon Sep 17 00:00:00 2001 From: HristoRaykov Date: Tue, 1 Nov 2022 17:15:24 +0200 Subject: [PATCH 006/292] schedule tests corrected --- ql/time/schedule.cpp | 18 ------------------ test-suite/schedule.cpp | 33 +++++++++------------------------ 2 files changed, 9 insertions(+), 42 deletions(-) diff --git a/ql/time/schedule.cpp b/ql/time/schedule.cpp index d0fdc14ea8e..6e112a4447e 100644 --- a/ql/time/schedule.cpp +++ b/ql/time/schedule.cpp @@ -373,24 +373,6 @@ namespace QuantLib { dates_.back() = calendar_.adjust(dates_.back(), terminationDateConvention); } - //Date d1 = dates_.front(), d2 = dates_.back(); - //if (terminationDateConvention != Unadjusted) { - // d1 = calendar_.endOfMonth(dates_.front()); - // d2 = calendar_.endOfMonth(dates_.back()); - //} else { - // // the termination date is the first if going backwards, - // // the last otherwise. - // if (*rule_ == DateGeneration::Backward) - // d2 = Date::endOfMonth(dates_.back()); - // else - // d1 = Date::endOfMonth(dates_.front()); - //} - //// if the eom adjustment leads to a single date schedule - //// we do not apply it - //if(d1 != d2) { - // dates_.front() = d1; - // dates_.back() = d2; - //} } else { // first date not adjusted for old CDS schedules if (*rule_ != DateGeneration::OldCDS) diff --git a/test-suite/schedule.cpp b/test-suite/schedule.cpp index 0474d509292..1f55ef5e3a4 100644 --- a/test-suite/schedule.cpp +++ b/test-suite/schedule.cpp @@ -96,28 +96,12 @@ void ScheduleTest::testEndDateWithEomAdjustment() { .endOfMonth(); std::vector expected(7); - // The end date is adjusted, so it should also be moved to the end - // of the month. expected[0] = Date(30,September,2009); expected[1] = Date(31,March,2010); expected[2] = Date(30,September,2010); expected[3] = Date(31,March,2011); expected[4] = Date(30,September,2011); expected[5] = Date(30,March,2012); - expected[6] = Date(29,June,2012); - - check_dates(s, expected); - - // now with unadjusted termination date... - s = MakeSchedule().from(Date(30,September,2009)) - .to(Date(15,June,2012)) - .withCalendar(Japan()) - .withTenor(6*Months) - .withConvention(Following) - .withTerminationDateConvention(Unadjusted) - .forwards() - .endOfMonth(); - // ...which should leave it alone. expected[6] = Date(15,June,2012); check_dates(s, expected); @@ -139,7 +123,7 @@ void ScheduleTest::testDatesPastEndDateWithEomAdjustment() { .endOfMonth(); std::vector expected(3); - expected[0] = Date(31,March,2013); + expected[0] = Date(28,March,2013); expected[1] = Date(31,March,2014); // March 31st 2015, coming from the EOM adjustment of March 28th, // should be discarded as past the end date. @@ -167,7 +151,7 @@ void ScheduleTest::testDatesSameAsEndDateWithEomAdjustment() { .endOfMonth(); std::vector expected(3); - expected[0] = Date(31,March,2013); + expected[0] = Date(28,March,2013); expected[1] = Date(31,March,2014); // March 31st 2015, coming from the EOM adjustment of March 28th, // should be discarded as the same as the end date. @@ -243,10 +227,11 @@ void ScheduleTest::testDoubleFirstDateWithEomAdjustment() { .backwards() .endOfMonth(); - std::vector expected(3); - expected[0] = Date(30,August,1996); - expected[1] = Date(28,February,1997); - expected[2] = Date(29,August,1997); + std::vector expected(4); + expected[0] = Date(22, August, 1996); + expected[1] = Date(30,August,1996); + expected[2] = Date(28,February,1997); + expected[3] = Date(2,September,1997); check_dates(s, expected); } @@ -1107,7 +1092,7 @@ void ScheduleTest::testTruncation() { expected[11] = Date(29, March, 2019); expected[12] = Date(30, September, 2019); expected[13] = Date(31, March, 2020); - expected[14] = Date(30, June, 2020); + expected[14] = Date(15, June, 2020); check_dates(t, expected); BOOST_CHECK(t.isRegular().front() == false); @@ -1118,7 +1103,7 @@ void ScheduleTest::testTruncation() { expected[1] = Date(29, March, 2019); expected[2] = Date(30, September, 2019); expected[3] = Date(31, March, 2020); - expected[4] = Date(30, June, 2020); + expected[4] = Date(15, June, 2020); check_dates(t, expected); BOOST_CHECK(t.isRegular().front() == true); } From 92807d1f3401b895b03ec5718be596c17310063d Mon Sep 17 00:00:00 2001 From: HristoRaykov Date: Wed, 2 Nov 2022 12:26:00 +0200 Subject: [PATCH 007/292] callable bond frequency issue lballabio/QuantLib#928 fixed proposed by @OleBueker --- ql/experimental/callablebonds/callablebond.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/experimental/callablebonds/callablebond.cpp b/ql/experimental/callablebonds/callablebond.cpp index abe24dbeb89..819ef9c87d2 100644 --- a/ql/experimental/callablebonds/callablebond.cpp +++ b/ql/experimental/callablebonds/callablebond.cpp @@ -511,7 +511,7 @@ namespace QuantLib { : CallableBond(settlementDays, schedule.dates().back(), schedule.calendar(), accrualDayCounter, faceAmount, issueDate, putCallSchedule) { - frequency_ = schedule.tenor().frequency(); + frequency_ = schedule.hasTenor() ? schedule.tenor().frequency() : NoFrequency; cashflows_ = FixedRateLeg(schedule) From 1acdc04a5c37396bf117e4b65e75064998e75615 Mon Sep 17 00:00:00 2001 From: Matthias Groncki Date: Thu, 15 Dec 2022 09:51:33 +0700 Subject: [PATCH 008/292] bugfix cpi coupons and cpi cashflow allow optional baseCPI if baseCPI is null, retrieve use the index fixing on baseDate instead --- ql/cashflows/cpicoupon.cpp | 18 +++++++- ql/cashflows/cpicoupon.hpp | 2 + test-suite/inflationcpibond.cpp | 81 ++++++++++++++++++++++++++++++++- test-suite/inflationcpibond.hpp | 1 + 4 files changed, 100 insertions(+), 2 deletions(-) diff --git a/ql/cashflows/cpicoupon.cpp b/ql/cashflows/cpicoupon.cpp index 786ce39c7f3..5ebcf16cbad 100644 --- a/ql/cashflows/cpicoupon.cpp +++ b/ql/cashflows/cpicoupon.cpp @@ -116,7 +116,7 @@ namespace QuantLib { refPeriodEnd, exCouponDate), baseCPI_(baseCPI), fixedRate_(fixedRate), spread_(spread), - observationInterpolation_(observationInterpolation) { + observationInterpolation_(observationInterpolation), baseDate_(baseDate) { QL_REQUIRE(index_, "no index provided"); QL_REQUIRE( @@ -263,6 +263,22 @@ namespace QuantLib { } } + Real CPICashFlow::amount() const { + Rate I0 = baseFixing(); + + // If BaseFixing is null, use the observed index fixing + if (I0 == Null()) { + I0 = IndexedCashFlow::baseFixing(); + } + + Rate I1 = indexFixing(); + + if (growthOnly()) + return notional() * (I1 / I0 - 1.0); + else + return notional() * (I1 / I0); + } + CPILeg::CPILeg(const Schedule& schedule, ext::shared_ptr index, const Real baseCPI, diff --git a/ql/cashflows/cpicoupon.hpp b/ql/cashflows/cpicoupon.hpp index 5ffa9bd5de8..cbf1431793c 100644 --- a/ql/cashflows/cpicoupon.hpp +++ b/ql/cashflows/cpicoupon.hpp @@ -230,6 +230,8 @@ namespace QuantLib { Real indexFixing() const override; + Real amount() const override; + protected: Real baseFixing_; Date observationDate_; diff --git a/test-suite/inflationcpibond.cpp b/test-suite/inflationcpibond.cpp index d5dc7a617fe..a87c19d534b 100644 --- a/test-suite/inflationcpibond.cpp +++ b/test-suite/inflationcpibond.cpp @@ -36,6 +36,7 @@ #include #include #include +#include using namespace QuantLib; using namespace boost::unit_test_framework; @@ -219,11 +220,89 @@ void InflationCPIBondTest::testCleanPrice() { } +void InflationCPIBondTest::testCPILegWithoutBaseCPI() { + IndexManager::instance().clearHistories(); + + using namespace inflation_cpi_bond_test; + + CommonVars common; + + Real notional = 1000000.0; + std::vector fixedRates(1, 0.1); + DayCounter fixedDayCount = Actual365Fixed(); + BusinessDayConvention fixedPaymentConvention = ModifiedFollowing; + Calendar fixedPaymentCalendar = UnitedKingdom(); + ext::shared_ptr fixedIndex = common.ii; + Period contractObservationLag = Period(3, Months); + CPI::InterpolationType observationInterpolation = CPI::Flat; + Natural settlementDays = 3; + bool growthOnly = true; + Real baseCPI = 206.1; + // set the schedules + Date baseDate(1, July, 2007); + Date startDate(2, October, 2007); + Date endDate(2, October, 2052); + Schedule fixedSchedule = MakeSchedule() + .from(startDate) + .to(endDate) + .withTenor(Period(6, Months)) + .withCalendar(UnitedKingdom()) + .withConvention(Unadjusted) + .backwards(); + + Leg legWithBaseDate = CPILeg(fixedSchedule, fixedIndex, Null(), contractObservationLag) + .withSubtractInflationNominal(growthOnly) + .withNotionals(notional) + .withBaseDate(baseDate) + .withFixedRates({0.1}) + .withPaymentDayCounter(fixedDayCount) + .withObservationInterpolation(CPI::Flat) + .withPaymentAdjustment(fixedPaymentConvention); + + Leg legWithBaseCPI = CPILeg(fixedSchedule, fixedIndex, baseCPI, contractObservationLag) + .withSubtractInflationNominal(growthOnly) + .withNotionals(notional) + .withFixedRates({0.1}) + .withPaymentDayCounter(fixedDayCount) + .withObservationInterpolation(CPI::Flat) + .withPaymentAdjustment(fixedPaymentConvention); + + Date settlementDate = fixedPaymentCalendar.advance(common.evaluationDate, settlementDays * Days, + fixedPaymentConvention); + + Real npvWithBaseDate = + CashFlows::npv(legWithBaseDate, **common.yTS, false, settlementDate, settlementDate); + Real accruedsBaseDate = CashFlows::accruedAmount(legWithBaseDate, false, settlementDate); + + Real npvWithBaseCPI = + CashFlows::npv(legWithBaseCPI, **common.yTS, false, settlementDate, settlementDate); + Real accruedsBaseCPI = CashFlows::accruedAmount(legWithBaseCPI, false, settlementDate); + + + Real cleanPriceWithBaseDate = (npvWithBaseDate - accruedsBaseDate) * 100. / notional; + Real cleanPriceWithBaseCPI = (npvWithBaseCPI - accruedsBaseCPI) * 100. / notional; + + Real tolerance = 1.0e-8; + if (std::fabs(cleanPriceWithBaseDate - cleanPriceWithBaseCPI) > tolerance) { + BOOST_FAIL("prices of CPI leg with base date and explicit base CPI fixing are not equal " + << std::fixed << std::setprecision(12) << "\n clean npv of leg with baseDate: " + << cleanPriceWithBaseDate + << "\n clean npv of leg with explicit baseCPI: " << cleanPriceWithBaseCPI); + } + // Compare to expected price + Real storedPrice = 383.01816406; + if (std::fabs(cleanPriceWithBaseDate - storedPrice) > tolerance) { + BOOST_FAIL("failed to reproduce expected CPI-bond clean price" + << std::fixed << std::setprecision(12) << "\n expected: " << storedPrice + << "\n calculated: " << cleanPriceWithBaseDate); + } +} + test_suite* InflationCPIBondTest::suite() { auto* suite = BOOST_TEST_SUITE("CPI bond tests"); suite->add(QUANTLIB_TEST_CASE(&InflationCPIBondTest::testCleanPrice)); - + suite->add(QUANTLIB_TEST_CASE(&InflationCPIBondTest::testCPILegWithoutBaseCPI)); return suite; } diff --git a/test-suite/inflationcpibond.hpp b/test-suite/inflationcpibond.hpp index f08023c7fda..32fe840673f 100644 --- a/test-suite/inflationcpibond.hpp +++ b/test-suite/inflationcpibond.hpp @@ -25,6 +25,7 @@ class InflationCPIBondTest { public: static void testCleanPrice(); + static void testCPILegWithoutBaseCPI(); static boost::unit_test_framework::test_suite* suite(); }; From 6523f36a34cfe00923fdb310ab3a322fcbb15b28 Mon Sep 17 00:00:00 2001 From: Matthias Groncki Date: Thu, 15 Dec 2022 10:18:13 +0700 Subject: [PATCH 009/292] bugfix unused variables --- test-suite/inflationcpibond.cpp | 36 +++++++++++++++++---------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/test-suite/inflationcpibond.cpp b/test-suite/inflationcpibond.cpp index a87c19d534b..88f37a8b9f7 100644 --- a/test-suite/inflationcpibond.cpp +++ b/test-suite/inflationcpibond.cpp @@ -246,26 +246,28 @@ void InflationCPIBondTest::testCPILegWithoutBaseCPI() { .from(startDate) .to(endDate) .withTenor(Period(6, Months)) - .withCalendar(UnitedKingdom()) + .withCalendar(fixedPaymentCalendar) .withConvention(Unadjusted) .backwards(); Leg legWithBaseDate = CPILeg(fixedSchedule, fixedIndex, Null(), contractObservationLag) - .withSubtractInflationNominal(growthOnly) - .withNotionals(notional) - .withBaseDate(baseDate) - .withFixedRates({0.1}) - .withPaymentDayCounter(fixedDayCount) - .withObservationInterpolation(CPI::Flat) - .withPaymentAdjustment(fixedPaymentConvention); + .withSubtractInflationNominal(growthOnly) + .withNotionals(notional) + .withBaseDate(baseDate) + .withFixedRates(fixedRates) + .withPaymentDayCounter(fixedDayCount) + .withObservationInterpolation(observationInterpolation) + .withPaymentAdjustment(fixedPaymentConvention) + .withPaymentCalendar(fixedPaymentCalendar); Leg legWithBaseCPI = CPILeg(fixedSchedule, fixedIndex, baseCPI, contractObservationLag) - .withSubtractInflationNominal(growthOnly) - .withNotionals(notional) - .withFixedRates({0.1}) - .withPaymentDayCounter(fixedDayCount) - .withObservationInterpolation(CPI::Flat) - .withPaymentAdjustment(fixedPaymentConvention); + .withSubtractInflationNominal(growthOnly) + .withNotionals(notional) + .withFixedRates(fixedRates) + .withPaymentDayCounter(fixedDayCount) + .withObservationInterpolation(observationInterpolation) + .withPaymentAdjustment(fixedPaymentConvention) + .withPaymentCalendar(fixedPaymentCalendar); Date settlementDate = fixedPaymentCalendar.advance(common.evaluationDate, settlementDays * Days, fixedPaymentConvention); @@ -281,12 +283,12 @@ void InflationCPIBondTest::testCPILegWithoutBaseCPI() { Real cleanPriceWithBaseDate = (npvWithBaseDate - accruedsBaseDate) * 100. / notional; Real cleanPriceWithBaseCPI = (npvWithBaseCPI - accruedsBaseCPI) * 100. / notional; - + Real tolerance = 1.0e-8; if (std::fabs(cleanPriceWithBaseDate - cleanPriceWithBaseCPI) > tolerance) { BOOST_FAIL("prices of CPI leg with base date and explicit base CPI fixing are not equal " - << std::fixed << std::setprecision(12) << "\n clean npv of leg with baseDate: " - << cleanPriceWithBaseDate + << std::fixed << std::setprecision(12) + << "\n clean npv of leg with baseDate: " << cleanPriceWithBaseDate << "\n clean npv of leg with explicit baseCPI: " << cleanPriceWithBaseCPI); } // Compare to expected price From 17914a4260a9ba03e0987eb91b4b191bf4f312ca Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Sun, 22 Jan 2023 16:34:44 +0100 Subject: [PATCH 010/292] update new basis swap rate helper to use deepUpdate() instead of recalculate --- ql/experimental/termstructures/basisswapratehelpers.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ql/experimental/termstructures/basisswapratehelpers.cpp b/ql/experimental/termstructures/basisswapratehelpers.cpp index 122b1f46103..898454c624a 100644 --- a/ql/experimental/termstructures/basisswapratehelpers.cpp +++ b/ql/experimental/termstructures/basisswapratehelpers.cpp @@ -95,8 +95,6 @@ namespace QuantLib { } void IborIborBasisSwapRateHelper::setTermStructure(YieldTermStructure* t) { - // do not set the relinkable handle as an observer - - // force recalculation when needed---the index is not lazy bool observer = false; ext::shared_ptr temp(t, null_deleter()); @@ -106,7 +104,7 @@ namespace QuantLib { } Real IborIborBasisSwapRateHelper::impliedQuote() const { - swap_->recalculate(); + swap_->deepUpdate(); return - (swap_->NPV() / swap_->legBPS(0)) * 1.0e-4; } @@ -185,7 +183,7 @@ namespace QuantLib { } Real OvernightIborBasisSwapRateHelper::impliedQuote() const { - swap_->recalculate(); + swap_->deepUpdate(); return - (swap_->NPV() / swap_->legBPS(0)) * 1.0e-4; } From 99ba9dbb45d31c5158f7f2ac05b5b3b4140a39d6 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Sun, 22 Jan 2023 18:00:40 +0100 Subject: [PATCH 011/292] forgot to update this one --- ql/termstructures/yield/oisratehelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/termstructures/yield/oisratehelper.cpp b/ql/termstructures/yield/oisratehelper.cpp index 509f7f3def2..611b76ce6af 100644 --- a/ql/termstructures/yield/oisratehelper.cpp +++ b/ql/termstructures/yield/oisratehelper.cpp @@ -200,7 +200,7 @@ namespace QuantLib { Real DatedOISRateHelper::impliedQuote() const { QL_REQUIRE(termStructure_ != nullptr, "term structure not set"); // we didn't register as observers - force calculation - swap_->recalculate(); + swap_->deepUpdate(); return swap_->fairRate(); } From 8bdbaf3e37a7b1caee62675f3fddbd78b067e4c4 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Wed, 25 Jan 2023 16:16:32 +0100 Subject: [PATCH 012/292] always forward notifications from a lazy object when another lazy object registers with it --- ql/cashflows/capflooredcoupon.cpp | 5 ----- ql/cashflows/capflooredcoupon.hpp | 1 - ql/cashflows/digitalcoupon.cpp | 7 ------- ql/cashflows/digitalcoupon.hpp | 1 - ql/experimental/coupons/strippedcapflooredcoupon.cpp | 1 - ql/instruments/bond.cpp | 9 --------- ql/instruments/bond.hpp | 4 ---- ql/instruments/compositeinstrument.cpp | 9 --------- ql/instruments/floatfloatswaption.cpp | 1 - ql/instruments/nonstandardswaption.cpp | 1 - ql/instruments/swap.cpp | 10 ---------- ql/instruments/swap.hpp | 4 ---- ql/instruments/swaption.cpp | 2 -- ql/patterns/lazyobject.hpp | 8 ++++++++ ql/patterns/observable.hpp | 4 ++-- 15 files changed, 10 insertions(+), 57 deletions(-) diff --git a/ql/cashflows/capflooredcoupon.cpp b/ql/cashflows/capflooredcoupon.cpp index 5b97fb3e282..78fa5fcb6bd 100644 --- a/ql/cashflows/capflooredcoupon.cpp +++ b/ql/cashflows/capflooredcoupon.cpp @@ -82,11 +82,6 @@ namespace QuantLib { underlying_->deepUpdate(); } - void CappedFlooredCoupon::alwaysForwardNotifications() { - LazyObject::alwaysForwardNotifications(); - underlying_->alwaysForwardNotifications(); - } - void CappedFlooredCoupon::performCalculations() const { QL_REQUIRE(underlying_->pricer(), "pricer not set"); Rate swapletRate = underlying_->rate(); diff --git a/ql/cashflows/capflooredcoupon.hpp b/ql/cashflows/capflooredcoupon.hpp index 0660af8f64b..1453bf89f5e 100644 --- a/ql/cashflows/capflooredcoupon.hpp +++ b/ql/cashflows/capflooredcoupon.hpp @@ -67,7 +67,6 @@ namespace QuantLib { //! \name LazyObject interface //@{ void performCalculations() const override; - void alwaysForwardNotifications() override; //@} //! \name Coupon interface //@{ diff --git a/ql/cashflows/digitalcoupon.cpp b/ql/cashflows/digitalcoupon.cpp index a576229c1bf..72b8b15c4af 100644 --- a/ql/cashflows/digitalcoupon.cpp +++ b/ql/cashflows/digitalcoupon.cpp @@ -172,8 +172,6 @@ namespace QuantLib { } registerWith(underlying); - if (nakedOption_) - underlying_->alwaysForwardNotifications(); } @@ -224,11 +222,6 @@ namespace QuantLib { underlying_->deepUpdate(); } - void DigitalCoupon::alwaysForwardNotifications() { - LazyObject::alwaysForwardNotifications(); - underlying_->alwaysForwardNotifications(); - } - void DigitalCoupon::performCalculations() const { QL_REQUIRE(underlying_->pricer(), "pricer not set"); diff --git a/ql/cashflows/digitalcoupon.hpp b/ql/cashflows/digitalcoupon.hpp index ec9fbf91f7c..542594156e0 100644 --- a/ql/cashflows/digitalcoupon.hpp +++ b/ql/cashflows/digitalcoupon.hpp @@ -102,7 +102,6 @@ namespace QuantLib { //! \name LazyObject interface //@{ void performCalculations() const override; - void alwaysForwardNotifications() override; //@} //! \name Coupon interface //@{ diff --git a/ql/experimental/coupons/strippedcapflooredcoupon.cpp b/ql/experimental/coupons/strippedcapflooredcoupon.cpp index 62e9c00f863..5f81fc72e9b 100644 --- a/ql/experimental/coupons/strippedcapflooredcoupon.cpp +++ b/ql/experimental/coupons/strippedcapflooredcoupon.cpp @@ -35,7 +35,6 @@ namespace QuantLib { underlying->isInArrears()), underlying_(underlying) { registerWith(underlying_); - underlying_->alwaysForwardNotifications(); } void StrippedCappedFlooredCoupon::deepUpdate() { diff --git a/ql/instruments/bond.cpp b/ql/instruments/bond.cpp index 9def771ed1f..8fd704807d4 100644 --- a/ql/instruments/bond.cpp +++ b/ql/instruments/bond.cpp @@ -353,15 +353,6 @@ namespace QuantLib { redemptions_.push_back(redemption); } - void Bond::alwaysForwardNotifications() { - for (auto& cashflow : cashflows_) { - if(auto lazy = ext::dynamic_pointer_cast(cashflow)) { - lazy->alwaysForwardNotifications(); - } - } - LazyObject::alwaysForwardNotifications(); - } - void Bond::deepUpdate() { for (auto& cashflow : cashflows_) { if(auto lazy = ext::dynamic_pointer_cast(cashflow)) { diff --git a/ql/instruments/bond.hpp b/ql/instruments/bond.hpp index 6c6782543fc..8e0b0da6e8f 100644 --- a/ql/instruments/bond.hpp +++ b/ql/instruments/bond.hpp @@ -104,10 +104,6 @@ namespace QuantLib { //@{ bool isExpired() const override; //@} - //! \name LazyObject interface - //@{ - void alwaysForwardNotifications() override; - //@} //! \name Observable interface //@{ void deepUpdate() override; diff --git a/ql/instruments/compositeinstrument.cpp b/ql/instruments/compositeinstrument.cpp index 0ee7ddc2167..c808801c696 100644 --- a/ql/instruments/compositeinstrument.cpp +++ b/ql/instruments/compositeinstrument.cpp @@ -26,15 +26,6 @@ namespace QuantLib { components_.emplace_back(instrument, multiplier); registerWith(instrument); update(); - // When we ask for the NPV of an expired composite, the - // components are not recalculated and thus wouldn't forward - // later notifications according to the default behavior of - // LazyObject instances. This means that even if the - // evaluation date changes so that the composite is no longer - // expired, the instrument wouldn't be notified and thus it - // wouldn't recalculate. To avoid this, we override the - // default behavior of the components. - instrument->alwaysForwardNotifications(); } void CompositeInstrument::subtract( diff --git a/ql/instruments/floatfloatswaption.cpp b/ql/instruments/floatfloatswaption.cpp index f1fe411d35d..c0fafbfae81 100644 --- a/ql/instruments/floatfloatswaption.cpp +++ b/ql/instruments/floatfloatswaption.cpp @@ -30,7 +30,6 @@ namespace QuantLib { : Option(ext::shared_ptr(), exercise), swap_(std::move(swap)), settlementType_(delivery), settlementMethod_(settlementMethod) { registerWith(swap_); - swap_->alwaysForwardNotifications(); } bool FloatFloatSwaption::isExpired() const { diff --git a/ql/instruments/nonstandardswaption.cpp b/ql/instruments/nonstandardswaption.cpp index 3d3884f6664..a57d7db5270 100644 --- a/ql/instruments/nonstandardswaption.cpp +++ b/ql/instruments/nonstandardswaption.cpp @@ -41,7 +41,6 @@ namespace QuantLib { : Option(ext::shared_ptr(), exercise), swap_(std::move(swap)), settlementType_(delivery), settlementMethod_(settlementMethod) { registerWith(swap_); - swap_->alwaysForwardNotifications(); } bool NonstandardSwaption::isExpired() const { diff --git a/ql/instruments/swap.cpp b/ql/instruments/swap.cpp index 69b66c36676..e9e299f766f 100644 --- a/ql/instruments/swap.cpp +++ b/ql/instruments/swap.cpp @@ -167,16 +167,6 @@ namespace QuantLib { update(); } - void Swap::alwaysForwardNotifications() { - for (auto& leg : legs_) { - for (auto& k : leg) { - if (auto lazy = ext::dynamic_pointer_cast(k)) - lazy->alwaysForwardNotifications(); - } - } - LazyObject::alwaysForwardNotifications(); - } - void Swap::arguments::validate() const { QL_REQUIRE(legs.size() == payer.size(), "number of legs and multipliers differ"); diff --git a/ql/instruments/swap.hpp b/ql/instruments/swap.hpp index 30a1e19ddf8..9f8afcd789d 100644 --- a/ql/instruments/swap.hpp +++ b/ql/instruments/swap.hpp @@ -63,10 +63,6 @@ namespace QuantLib { Swap(const std::vector& legs, const std::vector& payer); //@} - //! \name LazyObject interface - //@{ - void alwaysForwardNotifications() override; - //@} //! \name Observable interface //@{ void deepUpdate() override; diff --git a/ql/instruments/swaption.cpp b/ql/instruments/swaption.cpp index c1761e69618..beeb70c0ed3 100644 --- a/ql/instruments/swaption.cpp +++ b/ql/instruments/swaption.cpp @@ -136,8 +136,6 @@ namespace QuantLib { : Option(ext::shared_ptr(), exercise), swap_(std::move(swap)), settlementType_(delivery), settlementMethod_(settlementMethod) { registerWith(swap_); - // a swaption engine might not calculate the underlying swap - swap_->alwaysForwardNotifications(); } void Swaption::deepUpdate() { diff --git a/ql/patterns/lazyobject.hpp b/ql/patterns/lazyobject.hpp index f8b59236137..24729139f0e 100644 --- a/ql/patterns/lazyobject.hpp +++ b/ql/patterns/lazyobject.hpp @@ -38,6 +38,8 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; + std::pair + registerWith(const ext::shared_ptr&) override; //@} /*! \name Calculations These methods do not modify the structure of the object @@ -178,6 +180,12 @@ namespace QuantLib { } } + inline std::pair + LazyObject::registerWith(const ext::shared_ptr& h) { + if (auto l = boost::dynamic_pointer_cast(h)) + l->alwaysForwardNotifications(); + return Observer::registerWith(h); + } } #endif diff --git a/ql/patterns/observable.hpp b/ql/patterns/observable.hpp index 39ef3c3b384..4c449774d65 100644 --- a/ql/patterns/observable.hpp +++ b/ql/patterns/observable.hpp @@ -119,7 +119,7 @@ namespace QuantLib { virtual ~Observer(); // observer interface - std::pair + virtual std::pair registerWith(const ext::shared_ptr&); /*! register with all observables of a given observer. Note @@ -294,7 +294,7 @@ namespace QuantLib { Observer& operator=(const Observer&); virtual ~Observer(); // observer interface - std::pair + virtual std::pair registerWith(const ext::shared_ptr&); /*! register with all observables of a given observer. Note that this does not include registering with the observer From 01d87f5d27f56e41ad7687dc9a8f2b52460ed751 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Wed, 25 Jan 2023 19:38:17 +0100 Subject: [PATCH 013/292] use ext instead of boost, missing include --- ql/patterns/lazyobject.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ql/patterns/lazyobject.hpp b/ql/patterns/lazyobject.hpp index 24729139f0e..592e0a5efc8 100644 --- a/ql/patterns/lazyobject.hpp +++ b/ql/patterns/lazyobject.hpp @@ -25,6 +25,7 @@ #define quantlib_lazy_object_h #include +#include namespace QuantLib { @@ -182,7 +183,7 @@ namespace QuantLib { inline std::pair LazyObject::registerWith(const ext::shared_ptr& h) { - if (auto l = boost::dynamic_pointer_cast(h)) + if (auto l = ext::dynamic_pointer_cast(h)) l->alwaysForwardNotifications(); return Observer::registerWith(h); } From f88537b3d3021692c5cf6afbb6ae095560aeef6d Mon Sep 17 00:00:00 2001 From: klausspanderen Date: Mon, 30 Jan 2023 22:09:07 +0100 Subject: [PATCH 014/292] moved expm from experimental to main --- QuantLib.vcxproj | 4 ++-- QuantLib.vcxproj.filters | 12 ++++++------ ql/CMakeLists.txt | 4 ++-- ql/experimental/math/Makefile.am | 2 -- ql/math/matrixutilities/Makefile.am | 2 ++ .../math => math/matrixutilities}/expm.cpp | 2 +- .../math => math/matrixutilities}/expm.hpp | 0 test-suite/ode.cpp | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) rename ql/{experimental/math => math/matrixutilities}/expm.cpp (98%) rename ql/{experimental/math => math/matrixutilities}/expm.hpp (100%) diff --git a/QuantLib.vcxproj b/QuantLib.vcxproj index a3421670493..d4bff127f6e 100644 --- a/QuantLib.vcxproj +++ b/QuantLib.vcxproj @@ -735,7 +735,6 @@ - @@ -1055,6 +1054,7 @@ + @@ -2061,7 +2061,6 @@ - @@ -2260,6 +2259,7 @@ + diff --git a/QuantLib.vcxproj.filters b/QuantLib.vcxproj.filters index 8e20992fa3f..6d21d2cf708 100644 --- a/QuantLib.vcxproj.filters +++ b/QuantLib.vcxproj.filters @@ -1191,6 +1191,9 @@ math\matrixutilities + + math\matrixutilities + math\matrixutilities @@ -3672,9 +3675,6 @@ experimental\math - - experimental\math - experimental\math @@ -4867,6 +4867,9 @@ math\matrixutilities + + math\matrixutilities + math\matrixutilities @@ -6595,9 +6598,6 @@ experimental\math - - experimental\math - experimental\math diff --git a/ql/CMakeLists.txt b/ql/CMakeLists.txt index 45a03547bd3..0e9604b5ee6 100644 --- a/ql/CMakeLists.txt +++ b/ql/CMakeLists.txt @@ -178,7 +178,6 @@ set(QL_SOURCES experimental/inflation/yoyoptionlethelpers.cpp experimental/lattices/extendedbinomialtree.cpp experimental/math/convolvedstudentt.cpp - experimental/math/expm.cpp experimental/math/fireflyalgorithm.cpp experimental/math/gaussiancopulapolicy.cpp experimental/math/gaussiannoncentralchisquaredpolynomial.cpp @@ -379,6 +378,7 @@ set(QL_SOURCES math/matrixutilities/basisincompleteordered.cpp math/matrixutilities/bicgstab.cpp math/matrixutilities/choleskydecomposition.cpp + math/matrixutilities/expm.cpp math/matrixutilities/factorreduction.cpp math/matrixutilities/getcovariance.cpp math/matrixutilities/gmres.cpp @@ -1153,7 +1153,6 @@ set(QL_HEADERS experimental/lattices/extendedbinomialtree.hpp experimental/math/claytoncopularng.hpp experimental/math/convolvedstudentt.hpp - experimental/math/expm.hpp experimental/math/farliegumbelmorgensterncopularng.hpp experimental/math/fireflyalgorithm.hpp experimental/math/frankcopularng.hpp @@ -1456,6 +1455,7 @@ set(QL_HEADERS math/matrixutilities/bicgstab.hpp math/matrixutilities/choleskydecomposition.hpp math/matrixutilities/factorreduction.hpp + math/matrixutilities/expm.hpp math/matrixutilities/getcovariance.hpp math/matrixutilities/gmres.hpp math/matrixutilities/pseudosqrt.hpp diff --git a/ql/experimental/math/Makefile.am b/ql/experimental/math/Makefile.am index bb162733967..0c4827c8050 100644 --- a/ql/experimental/math/Makefile.am +++ b/ql/experimental/math/Makefile.am @@ -6,7 +6,6 @@ this_include_HEADERS = \ all.hpp \ claytoncopularng.hpp \ convolvedstudentt.hpp \ - expm.hpp \ farliegumbelmorgensterncopularng.hpp \ fireflyalgorithm.hpp \ frankcopularng.hpp \ @@ -30,7 +29,6 @@ this_include_HEADERS = \ cpp_files = \ convolvedstudentt.cpp \ - expm.cpp \ fireflyalgorithm.cpp \ gaussiancopulapolicy.cpp \ gaussiannoncentralchisquaredpolynomial.cpp \ diff --git a/ql/math/matrixutilities/Makefile.am b/ql/math/matrixutilities/Makefile.am index ea3dc67a25d..6f3a5adbd18 100644 --- a/ql/math/matrixutilities/Makefile.am +++ b/ql/math/matrixutilities/Makefile.am @@ -7,6 +7,7 @@ this_include_HEADERS = \ basisincompleteordered.hpp \ bicgstab.hpp \ choleskydecomposition.hpp \ + expm.hpp \ factorreduction.hpp \ getcovariance.hpp \ gmres.hpp \ @@ -23,6 +24,7 @@ cpp_files = \ bicgstab.cpp \ basisincompleteordered.cpp \ choleskydecomposition.cpp \ + expm.cpp \ factorreduction.cpp \ getcovariance.cpp \ gmres.cpp \ diff --git a/ql/experimental/math/expm.cpp b/ql/math/matrixutilities/expm.cpp similarity index 98% rename from ql/experimental/math/expm.cpp rename to ql/math/matrixutilities/expm.cpp index f79d732761f..c3ae5e5f739 100644 --- a/ql/experimental/math/expm.cpp +++ b/ql/math/matrixutilities/expm.cpp @@ -22,7 +22,7 @@ */ -#include +#include #include #include #include diff --git a/ql/experimental/math/expm.hpp b/ql/math/matrixutilities/expm.hpp similarity index 100% rename from ql/experimental/math/expm.hpp rename to ql/math/matrixutilities/expm.hpp diff --git a/test-suite/ode.cpp b/test-suite/ode.cpp index 2e66c108f26..e01300e53cd 100644 --- a/test-suite/ode.cpp +++ b/test-suite/ode.cpp @@ -20,7 +20,7 @@ #include "ode.hpp" #include "utilities.hpp" -#include +#include #include #include From 94a1a78886d95b99f61730e962872afde32b92ea Mon Sep 17 00:00:00 2001 From: klausspanderen Date: Tue, 31 Jan 2023 21:36:02 +0100 Subject: [PATCH 015/292] Revert "moved expm from experimental to main" This reverts commit f88537b3d3021692c5cf6afbb6ae095560aeef6d. --- QuantLib.vcxproj | 4 ++-- QuantLib.vcxproj.filters | 12 ++++++------ ql/CMakeLists.txt | 4 ++-- ql/experimental/math/Makefile.am | 2 ++ .../matrixutilities => experimental/math}/expm.cpp | 2 +- .../matrixutilities => experimental/math}/expm.hpp | 0 ql/math/matrixutilities/Makefile.am | 2 -- test-suite/ode.cpp | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) rename ql/{math/matrixutilities => experimental/math}/expm.cpp (98%) rename ql/{math/matrixutilities => experimental/math}/expm.hpp (100%) diff --git a/QuantLib.vcxproj b/QuantLib.vcxproj index d4bff127f6e..a3421670493 100644 --- a/QuantLib.vcxproj +++ b/QuantLib.vcxproj @@ -735,6 +735,7 @@ + @@ -1054,7 +1055,6 @@ - @@ -2061,6 +2061,7 @@ + @@ -2259,7 +2260,6 @@ - diff --git a/QuantLib.vcxproj.filters b/QuantLib.vcxproj.filters index 6d21d2cf708..8e20992fa3f 100644 --- a/QuantLib.vcxproj.filters +++ b/QuantLib.vcxproj.filters @@ -1191,9 +1191,6 @@ math\matrixutilities - - math\matrixutilities - math\matrixutilities @@ -3675,6 +3672,9 @@ experimental\math + + experimental\math + experimental\math @@ -4867,9 +4867,6 @@ math\matrixutilities - - math\matrixutilities - math\matrixutilities @@ -6598,6 +6595,9 @@ experimental\math + + experimental\math + experimental\math diff --git a/ql/CMakeLists.txt b/ql/CMakeLists.txt index 0e9604b5ee6..45a03547bd3 100644 --- a/ql/CMakeLists.txt +++ b/ql/CMakeLists.txt @@ -178,6 +178,7 @@ set(QL_SOURCES experimental/inflation/yoyoptionlethelpers.cpp experimental/lattices/extendedbinomialtree.cpp experimental/math/convolvedstudentt.cpp + experimental/math/expm.cpp experimental/math/fireflyalgorithm.cpp experimental/math/gaussiancopulapolicy.cpp experimental/math/gaussiannoncentralchisquaredpolynomial.cpp @@ -378,7 +379,6 @@ set(QL_SOURCES math/matrixutilities/basisincompleteordered.cpp math/matrixutilities/bicgstab.cpp math/matrixutilities/choleskydecomposition.cpp - math/matrixutilities/expm.cpp math/matrixutilities/factorreduction.cpp math/matrixutilities/getcovariance.cpp math/matrixutilities/gmres.cpp @@ -1153,6 +1153,7 @@ set(QL_HEADERS experimental/lattices/extendedbinomialtree.hpp experimental/math/claytoncopularng.hpp experimental/math/convolvedstudentt.hpp + experimental/math/expm.hpp experimental/math/farliegumbelmorgensterncopularng.hpp experimental/math/fireflyalgorithm.hpp experimental/math/frankcopularng.hpp @@ -1455,7 +1456,6 @@ set(QL_HEADERS math/matrixutilities/bicgstab.hpp math/matrixutilities/choleskydecomposition.hpp math/matrixutilities/factorreduction.hpp - math/matrixutilities/expm.hpp math/matrixutilities/getcovariance.hpp math/matrixutilities/gmres.hpp math/matrixutilities/pseudosqrt.hpp diff --git a/ql/experimental/math/Makefile.am b/ql/experimental/math/Makefile.am index 0c4827c8050..bb162733967 100644 --- a/ql/experimental/math/Makefile.am +++ b/ql/experimental/math/Makefile.am @@ -6,6 +6,7 @@ this_include_HEADERS = \ all.hpp \ claytoncopularng.hpp \ convolvedstudentt.hpp \ + expm.hpp \ farliegumbelmorgensterncopularng.hpp \ fireflyalgorithm.hpp \ frankcopularng.hpp \ @@ -29,6 +30,7 @@ this_include_HEADERS = \ cpp_files = \ convolvedstudentt.cpp \ + expm.cpp \ fireflyalgorithm.cpp \ gaussiancopulapolicy.cpp \ gaussiannoncentralchisquaredpolynomial.cpp \ diff --git a/ql/math/matrixutilities/expm.cpp b/ql/experimental/math/expm.cpp similarity index 98% rename from ql/math/matrixutilities/expm.cpp rename to ql/experimental/math/expm.cpp index c3ae5e5f739..f79d732761f 100644 --- a/ql/math/matrixutilities/expm.cpp +++ b/ql/experimental/math/expm.cpp @@ -22,7 +22,7 @@ */ -#include +#include #include #include #include diff --git a/ql/math/matrixutilities/expm.hpp b/ql/experimental/math/expm.hpp similarity index 100% rename from ql/math/matrixutilities/expm.hpp rename to ql/experimental/math/expm.hpp diff --git a/ql/math/matrixutilities/Makefile.am b/ql/math/matrixutilities/Makefile.am index 6f3a5adbd18..ea3dc67a25d 100644 --- a/ql/math/matrixutilities/Makefile.am +++ b/ql/math/matrixutilities/Makefile.am @@ -7,7 +7,6 @@ this_include_HEADERS = \ basisincompleteordered.hpp \ bicgstab.hpp \ choleskydecomposition.hpp \ - expm.hpp \ factorreduction.hpp \ getcovariance.hpp \ gmres.hpp \ @@ -24,7 +23,6 @@ cpp_files = \ bicgstab.cpp \ basisincompleteordered.cpp \ choleskydecomposition.cpp \ - expm.cpp \ factorreduction.cpp \ getcovariance.cpp \ gmres.cpp \ diff --git a/test-suite/ode.cpp b/test-suite/ode.cpp index e01300e53cd..2e66c108f26 100644 --- a/test-suite/ode.cpp +++ b/test-suite/ode.cpp @@ -20,7 +20,7 @@ #include "ode.hpp" #include "utilities.hpp" -#include +#include #include #include From 623a9ae9df697ec85eadd46109b17a512427de92 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Fri, 10 Feb 2023 10:20:03 +0100 Subject: [PATCH 016/292] avoid warning C4250 "inherits via dominance" --- ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp b/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp index 54886808cbc..0e75c4e1332 100644 --- a/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp +++ b/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp @@ -87,6 +87,7 @@ namespace QuantLib { //@{ void update() override; void performCalculations() const override; + using LazyObject::registerWith; //@} //! \name some inspectors //@{ From b4250ad5815f0f61de06cf6dbe0d782879e60166 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Fri, 10 Feb 2023 14:00:22 +0100 Subject: [PATCH 017/292] second attempt to avoid msvc warning c4250 --- .../volatility/capfloor/capfloortermvolsurface.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp b/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp index 0e75c4e1332..47f8be7ca5b 100644 --- a/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp +++ b/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp @@ -87,7 +87,8 @@ namespace QuantLib { //@{ void update() override; void performCalculations() const override; - using LazyObject::registerWith; + std::pair + registerWith(const ext::shared_ptr& o) override; //@} //! \name some inspectors //@{ @@ -165,6 +166,11 @@ namespace QuantLib { inline const std::vector& CapFloorTermVolSurface::strikes() const { return strikes_; } + + inline std::pair + CapFloorTermVolSurface::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif From 6f91089cb53d389c33d8cdeb5c97408ac11c6bd0 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Fri, 10 Feb 2023 18:41:04 +0100 Subject: [PATCH 018/292] fix msvc warning c4250 --- ql/experimental/volatility/abcdatmvolcurve.hpp | 10 ++++++++++ .../volatility/noarbsabrinterpolatedsmilesection.hpp | 9 +++++++++ .../volatility/sviinterpolatedsmilesection.hpp | 10 ++++++++++ ql/models/shortrate/onefactormodels/gsr.hpp | 5 +++++ .../shortrate/onefactormodels/markovfunctional.hpp | 5 +++++ .../volatility/capfloor/capfloortermvolcurve.hpp | 9 +++++++++ .../volatility/capfloor/capfloortermvolsurface.hpp | 3 +++ .../volatility/interpolatedsmilesection.hpp | 6 ++++++ .../volatility/optionlet/strippedoptionletadapter.hpp | 10 ++++++++++ .../volatility/sabrinterpolatedsmilesection.hpp | 9 +++++++++ .../volatility/swaption/swaptionvolcube.hpp | 10 ++++++++++ .../volatility/swaption/swaptionvoldiscrete.hpp | 7 +++++++ .../volatility/swaption/swaptionvolmatrix.hpp | 10 ++++++++++ ql/termstructures/yield/flatforward.hpp | 6 ++++++ 14 files changed, 109 insertions(+) diff --git a/ql/experimental/volatility/abcdatmvolcurve.hpp b/ql/experimental/volatility/abcdatmvolcurve.hpp index ff827df7a24..27dd8738b1b 100644 --- a/ql/experimental/volatility/abcdatmvolcurve.hpp +++ b/ql/experimental/volatility/abcdatmvolcurve.hpp @@ -73,6 +73,11 @@ namespace QuantLib { void update() override; void performCalculations() const override; //@} + //! \name Observer interface + //@{ + std::pair + registerWith(const ext::shared_ptr& o) override; + //@} //! \name some inspectors //@{ const std::vector& optionTenors() const; @@ -195,6 +200,11 @@ namespace QuantLib { inline EndCriteria::Type AbcdAtmVolCurve::endCriteria() const { return interpolation_->endCriteria(); } + + inline std::pair + AbcdAtmVolCurve::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif diff --git a/ql/experimental/volatility/noarbsabrinterpolatedsmilesection.hpp b/ql/experimental/volatility/noarbsabrinterpolatedsmilesection.hpp index c88df824b37..ccef385074f 100644 --- a/ql/experimental/volatility/noarbsabrinterpolatedsmilesection.hpp +++ b/ql/experimental/volatility/noarbsabrinterpolatedsmilesection.hpp @@ -84,6 +84,11 @@ namespace QuantLib { void performCalculations() const override; void update() override; //@} + //! \name Observer interface + //@{ + std::pair + registerWith(const ext::shared_ptr& o) override; + //@} //! \name SmileSection interface //@{ Real minStrike() const override; @@ -190,6 +195,10 @@ namespace QuantLib { return forwardValue_; } + inline std::pair + NoArbSabrInterpolatedSmileSection::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } diff --git a/ql/experimental/volatility/sviinterpolatedsmilesection.hpp b/ql/experimental/volatility/sviinterpolatedsmilesection.hpp index 9974e03f450..7eda7a262eb 100644 --- a/ql/experimental/volatility/sviinterpolatedsmilesection.hpp +++ b/ql/experimental/volatility/sviinterpolatedsmilesection.hpp @@ -87,6 +87,11 @@ class SviInterpolatedSmileSection : public SmileSection, public LazyObject { void performCalculations() const override; void update() override; //@} + //! \name Observer interface + //@{ + std::pair + registerWith(const ext::shared_ptr& o) override; + //@} //! \name SmileSection interface //@{ Real minStrike() const override; @@ -196,6 +201,11 @@ inline Real SviInterpolatedSmileSection::atmLevel() const { calculate(); return forwardValue_; } + +inline std::pair +SviInterpolatedSmileSection::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); +} } #endif diff --git a/ql/models/shortrate/onefactormodels/gsr.hpp b/ql/models/shortrate/onefactormodels/gsr.hpp index c4d7df90709..6490f7f65bf 100644 --- a/ql/models/shortrate/onefactormodels/gsr.hpp +++ b/ql/models/shortrate/onefactormodels/gsr.hpp @@ -59,6 +59,11 @@ class Gsr : public Gaussian1dModel, public CalibratedModel { std::vector > reversions, Real T = 60.0); + std::pair + registerWith(const ext::shared_ptr& o) override { + return LazyObject::registerWith(o); + } + Real numeraireTime() const; void numeraireTime(Real T); diff --git a/ql/models/shortrate/onefactormodels/markovfunctional.hpp b/ql/models/shortrate/onefactormodels/markovfunctional.hpp index 1468af7b857..9ad083130ec 100644 --- a/ql/models/shortrate/onefactormodels/markovfunctional.hpp +++ b/ql/models/shortrate/onefactormodels/markovfunctional.hpp @@ -358,6 +358,11 @@ namespace QuantLib { void update() override { LazyObject::update(); } + std::pair + registerWith(const ext::shared_ptr& o) override { + return LazyObject::registerWith(o); + } + // returns the indices of the af region from the last smile update std::vector > arbitrageIndices() const { calculate(); diff --git a/ql/termstructures/volatility/capfloor/capfloortermvolcurve.hpp b/ql/termstructures/volatility/capfloor/capfloortermvolcurve.hpp index 028db76bdbe..e09ae6873dd 100644 --- a/ql/termstructures/volatility/capfloor/capfloortermvolcurve.hpp +++ b/ql/termstructures/volatility/capfloor/capfloortermvolcurve.hpp @@ -95,6 +95,11 @@ namespace QuantLib { void update() override; void performCalculations() const override; //@} + //! \name Observer interface + //@{ + std::pair + registerWith(const ext::shared_ptr& o) override; + //@} //! \name some inspectors //@{ const std::vector& optionTenors() const; @@ -164,6 +169,10 @@ namespace QuantLib { return optionTimes_; } + inline std::pair + CapFloorTermVolCurve::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif diff --git a/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp b/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp index 47f8be7ca5b..e9a77ab7537 100644 --- a/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp +++ b/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp @@ -87,6 +87,9 @@ namespace QuantLib { //@{ void update() override; void performCalculations() const override; + //@} + //! \name Observer interface + //@{ std::pair registerWith(const ext::shared_ptr& o) override; //@} diff --git a/ql/termstructures/volatility/interpolatedsmilesection.hpp b/ql/termstructures/volatility/interpolatedsmilesection.hpp index 63eb804a8d8..acbf0824215 100644 --- a/ql/termstructures/volatility/interpolatedsmilesection.hpp +++ b/ql/termstructures/volatility/interpolatedsmilesection.hpp @@ -82,6 +82,7 @@ namespace QuantLib { Real maxStrike() const override { return strikes_.back(); } Real atmLevel() const override { return atmLevel_->value(); } void update() override; + std::pair registerWith(const ext::shared_ptr& o); private: Real exerciseTimeSquareRoot_; @@ -221,6 +222,11 @@ namespace QuantLib { } #endif + template + std::pair + InterpolatedSmileSection::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif diff --git a/ql/termstructures/volatility/optionlet/strippedoptionletadapter.hpp b/ql/termstructures/volatility/optionlet/strippedoptionletadapter.hpp index e8b8a96134e..0bb51237b45 100644 --- a/ql/termstructures/volatility/optionlet/strippedoptionletadapter.hpp +++ b/ql/termstructures/volatility/optionlet/strippedoptionletadapter.hpp @@ -60,6 +60,11 @@ namespace QuantLib { //@} //! \name Observer interface //@{ + std::pair + registerWith(const ext::shared_ptr& o) override; + //@} + //! \name Observer interface + //@{ void deepUpdate() override; //@} @@ -93,6 +98,11 @@ namespace QuantLib { return ext::dynamic_pointer_cast< OptionletStripper >( optionletStripper_); } + + inline std::pair + StrippedOptionletAdapter::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif diff --git a/ql/termstructures/volatility/sabrinterpolatedsmilesection.hpp b/ql/termstructures/volatility/sabrinterpolatedsmilesection.hpp index aa38c1a6ded..ef4dde3fc22 100644 --- a/ql/termstructures/volatility/sabrinterpolatedsmilesection.hpp +++ b/ql/termstructures/volatility/sabrinterpolatedsmilesection.hpp @@ -88,6 +88,11 @@ namespace QuantLib { void performCalculations() const override; void update() override; //@} + //! \name Observer interface + //@{ + std::pair + registerWith(const ext::shared_ptr& o) override; + //@} //! \name SmileSection interface //@{ Real minStrike() const override; @@ -196,6 +201,10 @@ namespace QuantLib { return forwardValue_; } + inline std::pair + SabrInterpolatedSmileSection::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } diff --git a/ql/termstructures/volatility/swaption/swaptionvolcube.hpp b/ql/termstructures/volatility/swaption/swaptionvolcube.hpp index a6f5ae58f5c..a3c2e8a778a 100644 --- a/ql/termstructures/volatility/swaption/swaptionvolcube.hpp +++ b/ql/termstructures/volatility/swaption/swaptionvolcube.hpp @@ -64,6 +64,11 @@ namespace QuantLib { //@{ const Period& maxSwapTenor() const override { return atmVol_->maxSwapTenor(); } //@} + //! \name Observer interface + //@{ + std::pair + registerWith(const ext::shared_ptr& o) override; + //@} //! \name Other inspectors //@{ Rate atmStrike(const Date& optionDate, @@ -133,6 +138,11 @@ namespace QuantLib { Time swapLength) const { return atmVol_->shift(optionTime, swapLength); } + + inline std::pair + SwaptionVolatilityCube::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif diff --git a/ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp b/ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp index 454a815118b..76a600f5384 100644 --- a/ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp +++ b/ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp @@ -60,6 +60,8 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; + std::pair + registerWith(const ext::shared_ptr& o) override; //@} //! \name LazyObject interface //@{ @@ -119,6 +121,11 @@ namespace QuantLib { inline Date SwaptionVolatilityDiscrete::optionDateFromTime(Time optionTime) const { return Date(static_cast(optionInterpolator_(optionTime))); } + + inline std::pair + SwaptionVolDiscrete::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif diff --git a/ql/termstructures/volatility/swaption/swaptionvolmatrix.hpp b/ql/termstructures/volatility/swaption/swaptionvolmatrix.hpp index aa349d912b1..299a4e76038 100644 --- a/ql/termstructures/volatility/swaption/swaptionvolmatrix.hpp +++ b/ql/termstructures/volatility/swaption/swaptionvolmatrix.hpp @@ -118,6 +118,11 @@ namespace QuantLib { //@{ void performCalculations() const override; //@} + //! \name Observer interface + //@{ + std::pair + registerWith(const ext::shared_ptr& o) override; + //@} //! \name TermStructure interface //@{ Date maxDate() const override; @@ -205,6 +210,11 @@ namespace QuantLib { Real tmp = interpolationShifts_(swapLength, optionTime, true); return tmp; } + + inline std::pair + SwaptionVolatilityMatrix::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } // namespace QuantLib #endif diff --git a/ql/termstructures/yield/flatforward.hpp b/ql/termstructures/yield/flatforward.hpp index 70c17eb96ec..46ce6476080 100644 --- a/ql/termstructures/yield/flatforward.hpp +++ b/ql/termstructures/yield/flatforward.hpp @@ -74,6 +74,8 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; + std::pair + registerWith(const ext::shared_ptr& o) override; //@} private: //! \name LazyObject interface @@ -109,6 +111,10 @@ namespace QuantLib { compounding_, frequency_); } + inline std::pair + FlatForward::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif From 0ce10bce7f32ebe5122c30a0e117df5afb7dc67e Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Fri, 10 Feb 2023 18:43:31 +0100 Subject: [PATCH 019/292] fixes --- ql/termstructures/volatility/interpolatedsmilesection.hpp | 7 ++++--- .../volatility/swaption/swaptionvoldiscrete.hpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ql/termstructures/volatility/interpolatedsmilesection.hpp b/ql/termstructures/volatility/interpolatedsmilesection.hpp index acbf0824215..388a08a46b7 100644 --- a/ql/termstructures/volatility/interpolatedsmilesection.hpp +++ b/ql/termstructures/volatility/interpolatedsmilesection.hpp @@ -82,7 +82,8 @@ namespace QuantLib { Real maxStrike() const override { return strikes_.back(); } Real atmLevel() const override { return atmLevel_->value(); } void update() override; - std::pair registerWith(const ext::shared_ptr& o); + std::pair + registerWith(const ext::shared_ptr& o) override; private: Real exerciseTimeSquareRoot_; @@ -220,13 +221,13 @@ namespace QuantLib { LazyObject::update(); SmileSection::update(); } - #endif template std::pair - InterpolatedSmileSection::registerWith(const ext::shared_ptr& o) { + InterpolatedSmileSection::registerWith(const ext::shared_ptr& o) { return LazyObject::registerWith(o); } + #endif } #endif diff --git a/ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp b/ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp index 76a600f5384..fc7fca8c9ce 100644 --- a/ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp +++ b/ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp @@ -123,7 +123,7 @@ namespace QuantLib { } inline std::pair - SwaptionVolDiscrete::registerWith(const ext::shared_ptr& o) { + SwaptionVolatilityDiscrete::registerWith(const ext::shared_ptr& o) { return LazyObject::registerWith(o); } } From 31bd92d6be307462701ef81288cb30b011058a2a Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Sat, 11 Feb 2023 10:23:43 +0100 Subject: [PATCH 020/292] fix warning c4250 --- ql/termstructures/yield/fittedbonddiscountcurve.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ql/termstructures/yield/fittedbonddiscountcurve.hpp b/ql/termstructures/yield/fittedbonddiscountcurve.hpp index eb06165819e..6dfc5461e16 100644 --- a/ql/termstructures/yield/fittedbonddiscountcurve.hpp +++ b/ql/termstructures/yield/fittedbonddiscountcurve.hpp @@ -120,6 +120,8 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; + std::pair + registerWith(const ext::shared_ptr& o) override; //@} private: @@ -337,6 +339,11 @@ namespace QuantLib { return discountFunction(x, t); } } + + inline std::pair + FittedBondDiscountCurve::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif From 8ff6d49d345e8e67ad9989460a543c52719195c7 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Sat, 11 Feb 2023 12:03:15 +0100 Subject: [PATCH 021/292] avoid warning c4250 --- ql/termstructures/defaulttermstructure.hpp | 6 ++++++ ql/termstructures/inflation/piecewisezeroinflationcurve.hpp | 6 ++++++ ql/termstructures/yield/piecewiseyieldcurve.hpp | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/ql/termstructures/defaulttermstructure.hpp b/ql/termstructures/defaulttermstructure.hpp index 93ec81ea33f..b2b86687460 100644 --- a/ql/termstructures/defaulttermstructure.hpp +++ b/ql/termstructures/defaulttermstructure.hpp @@ -142,6 +142,8 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; + std::pair + registerWith(const ext::shared_ptr& o) override; //@} protected: /*! \name Calculations @@ -246,6 +248,10 @@ namespace QuantLib { setJumps(); } + inline void + DefaultProbabilityTermStructure::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif diff --git a/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp b/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp index 069a4508832..ed22da19432 100644 --- a/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp +++ b/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp @@ -87,6 +87,8 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; + std::pair + registerWith(const ext::shared_ptr& o) override; //@} private: // methods @@ -151,6 +153,10 @@ namespace QuantLib { LazyObject::update(); } + template class B, class T> + void PiecewiseZeroInflationCurve::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif diff --git a/ql/termstructures/yield/piecewiseyieldcurve.hpp b/ql/termstructures/yield/piecewiseyieldcurve.hpp index d622a98d899..28542065473 100644 --- a/ql/termstructures/yield/piecewiseyieldcurve.hpp +++ b/ql/termstructures/yield/piecewiseyieldcurve.hpp @@ -168,6 +168,8 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; + std::pair + registerWith(const ext::shared_ptr& o) override; //@} private: //! \name LazyObject interface @@ -252,6 +254,10 @@ namespace QuantLib { bootstrap_.calculate(); } + template class B> + inline void PiecewiseYieldCurve::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif From 686062ecf411274a8b488060f02a5d1f81ce5cf9 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Sat, 11 Feb 2023 18:19:18 +0100 Subject: [PATCH 022/292] more fixes --- ql/termstructures/credit/piecewisedefaultcurve.hpp | 9 ++++++++- ql/termstructures/defaulttermstructure.hpp | 4 ++-- .../inflation/piecewisezeroinflationcurve.hpp | 3 ++- ql/termstructures/yield/piecewiseyieldcurve.hpp | 3 ++- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ql/termstructures/credit/piecewisedefaultcurve.hpp b/ql/termstructures/credit/piecewisedefaultcurve.hpp index 7adaf961d74..01e6e4aab33 100644 --- a/ql/termstructures/credit/piecewisedefaultcurve.hpp +++ b/ql/termstructures/credit/piecewisedefaultcurve.hpp @@ -185,7 +185,8 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; - //@} + std::pair + registerWith(const ext::shared_ptr& o) override; private: //! \name LazyObject interface //@{ @@ -282,6 +283,12 @@ namespace QuantLib { bootstrap_.calculate(); } + template class B> + inline std::pair + PiecewiseDefaultCurve::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } + } #endif diff --git a/ql/termstructures/defaulttermstructure.hpp b/ql/termstructures/defaulttermstructure.hpp index b2b86687460..41d9f812a9c 100644 --- a/ql/termstructures/defaulttermstructure.hpp +++ b/ql/termstructures/defaulttermstructure.hpp @@ -248,9 +248,9 @@ namespace QuantLib { setJumps(); } - inline void + inline std::pair DefaultProbabilityTermStructure::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); + return TermStructure::registerWith(o); } } diff --git a/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp b/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp index ed22da19432..68efac143b4 100644 --- a/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp +++ b/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp @@ -154,7 +154,8 @@ namespace QuantLib { } template class B, class T> - void PiecewiseZeroInflationCurve::registerWith(const ext::shared_ptr& o) { + std::pair + PiecewiseZeroInflationCurve::registerWith(const ext::shared_ptr& o) { return LazyObject::registerWith(o); } } diff --git a/ql/termstructures/yield/piecewiseyieldcurve.hpp b/ql/termstructures/yield/piecewiseyieldcurve.hpp index 28542065473..aaa3de26b37 100644 --- a/ql/termstructures/yield/piecewiseyieldcurve.hpp +++ b/ql/termstructures/yield/piecewiseyieldcurve.hpp @@ -255,7 +255,8 @@ namespace QuantLib { } template class B> - inline void PiecewiseYieldCurve::registerWith(const ext::shared_ptr& o) { + inline std::pair + PiecewiseYieldCurve::registerWith(const ext::shared_ptr& o) { return LazyObject::registerWith(o); } } From ecf19c87302e6207a85c81debfa6ef7f2ba25566 Mon Sep 17 00:00:00 2001 From: jakeheke75 Date: Sun, 12 Feb 2023 01:03:23 +0100 Subject: [PATCH 023/292] forwardrateagreement ctor enhancements fixes #154 --- ql/instruments/forwardrateagreement.cpp | 88 +++++++++++++++++++++++-- ql/instruments/forwardrateagreement.hpp | 46 +++++++++++++ 2 files changed, 128 insertions(+), 6 deletions(-) diff --git a/ql/instruments/forwardrateagreement.cpp b/ql/instruments/forwardrateagreement.cpp index 51bbfc7024c..2db49b17624 100644 --- a/ql/instruments/forwardrateagreement.cpp +++ b/ql/instruments/forwardrateagreement.cpp @@ -61,8 +61,72 @@ namespace QuantLib { : ForwardRateAgreement(valueDate, index->maturityDate(valueDate), type, strikeForwardRate, notionalAmount, index, std::move(discountCurve), true) {} + ForwardRateAgreement::ForwardRateAgreement(Position::Type type, + const Date& valueDate, + Rate strikeForwardRate, + Real notionalAmount, + const ext::shared_ptr& index, + Handle discountCurve, + bool useIndexedCoupon) + : fraType_(type), valueDate_(valueDate), notionalAmount_(notionalAmount), + index_(index), discountCurve_(std::move(discountCurve)), + useIndexedCoupon_(useIndexedCoupon), + dayCounter_(index->dayCounter()), calendar_(index->fixingCalendar()), + businessDayConvention_(index->businessDayConvention()), + maturityDate_(index->maturityDate(valueDate)) { + + QL_REQUIRE(notionalAmount > 0.0, "notionalAmount must be positive"); + + registerWith(Settings::instance().evaluationDate()); + registerWith(discountCurve_); + registerWith(index_); + + maturityDate_ = calendar_.adjust(maturityDate_, businessDayConvention_); + QL_REQUIRE(valueDate_ < maturityDate_, "valueDate must be earlier than maturityDate"); + strikeForwardRate_ = InterestRate(strikeForwardRate, + index->dayCounter(), + Simple, Once); + } + + ForwardRateAgreement::ForwardRateAgreement(const Date& valueDate, + const Date& maturityDate, + Position::Type type, + Rate strikeForwardRate, + Rate referenceRate, + Real notionalAmount, + const DayCounter dayCounter, + const Calendar fixingCalendar, + const BusinessDayConvention businessDayConvention, + Handle discountCurve) + : valueDate_(valueDate), maturityDate_(maturityDate), + fraType_(type), notionalAmount_(notionalAmount), + dayCounter_(dayCounter), calendar_(fixingCalendar), + businessDayConvention_(businessDayConvention), + discountCurve_(std::move(discountCurve)), + useIndexedCoupon_(false) { + + QL_REQUIRE(notionalAmount > 0.0, "notionalAmount must be positive"); + + registerWith(Settings::instance().evaluationDate()); + registerWith(discountCurve_); + + maturityDate_ = calendar_.adjust(maturityDate_, businessDayConvention_); + QL_REQUIRE(valueDate_ < maturityDate_, "valueDate must be earlier than maturityDate"); + strikeForwardRate_ = InterestRate(strikeForwardRate, + dayCounter, + Simple, Once); + referenceRate_ = InterestRate(referenceRate, + dayCounter, + Simple, Once); + valueDateTime_ = dayCounter_.yearFraction(Settings::instance().evaluationDate(), valueDate_); + maturityDateTime_ = dayCounter_.yearFraction(Settings::instance().evaluationDate(), maturityDate_); + } + Date ForwardRateAgreement::fixingDate() const { - return index_->fixingDate(valueDate_); + if (index_) + return index_->fixingDate(valueDate_); + else // if FRA is constructed without the index it returns the valueDate + return valueDate_; } bool ForwardRateAgreement::isExpired() const { @@ -88,17 +152,21 @@ namespace QuantLib { void ForwardRateAgreement::performCalculations() const { calculateAmount(); - Handle discount = - discountCurve_.empty() ? index_->forwardingTermStructure() : discountCurve_; + if (!discountCurve_.empty() || index_) { + + Handle discount = + discountCurve_.empty() ? index_->forwardingTermStructure() : discountCurve_; - NPV_ = amount_ * discount->discount(valueDate_); + NPV_ = amount_ * discount->discount(valueDate_); + } else + NPV_ = amount_ * referenceRate_.discountFactor(valueDateTime_); } void ForwardRateAgreement::calculateForwardRate() const { - if (useIndexedCoupon_) + if (useIndexedCoupon_ && index_) forwardRate_ = InterestRate(index_->fixing(fixingDate()), index_->dayCounter(), Simple, Once); - else + else if (!useIndexedCoupon_ && index_) // par coupon approximation forwardRate_ = InterestRate((index_->forwardingTermStructure()->discount(valueDate_) / @@ -106,6 +174,14 @@ namespace QuantLib { 1.0) / index_->dayCounter().yearFraction(valueDate_, maturityDate_), index_->dayCounter(), Simple, Once); + else + forwardRate_ = + InterestRate((referenceRate_.discountFactor(valueDateTime_) / + referenceRate_.discountFactor(maturityDateTime_) - + 1.0) / + dayCounter_.yearFraction(valueDate_, maturityDate_), + dayCounter_, Simple, Once); + } void ForwardRateAgreement::calculateAmount() const { diff --git a/ql/instruments/forwardrateagreement.hpp b/ql/instruments/forwardrateagreement.hpp index 6b86b1ae04c..47970ce3c97 100644 --- a/ql/instruments/forwardrateagreement.hpp +++ b/ql/instruments/forwardrateagreement.hpp @@ -65,6 +65,10 @@ namespace QuantLib { */ class ForwardRateAgreement: public Instrument { public: + /*! \deprecated use the new constructors + deprecated in version 1.30 + */ + QL_DEPRECATED ForwardRateAgreement( const Date& valueDate, const Date& maturityDate, @@ -74,6 +78,11 @@ namespace QuantLib { const ext::shared_ptr& index, Handle discountCurve = Handle(), bool useIndexedCoupon = true); + + /*! \deprecated use the new constructors + deprecated in version 1.30 + */ + QL_DEPRECATED ForwardRateAgreement( const Date& valueDate, Position::Type type, @@ -82,6 +91,35 @@ namespace QuantLib { const ext::shared_ptr& index, Handle discountCurve = Handle()); + /*! \brief constructor taking the index + \details constructor taking the index, the FRA maturityDate is calculated from the index + in this way we are avoiding conflicting information in the definition of the FRA + */ + ForwardRateAgreement( + Position::Type type, + const Date& valueDate, + Rate strikeForwardRate, + Real notionalAmount, + const ext::shared_ptr& index, + Handle discountCurve = Handle(), + bool useIndexedCoupon = true); + + /*! \brief constructor not taking the index + \details constructor not taking the index, all the FRA components must be provided + the FRA evaluationDate must be specified in Settings::instance().evaluationDate() + */ + ForwardRateAgreement( + const Date& valueDate, + const Date& maturityDate, + Position::Type type, + Rate strikeForwardRate, + Rate referenceRate, + Real notionalAmount, + const DayCounter dayCounter, + const Calendar fixingCalendar, + const BusinessDayConvention businessDayConvention, + Handle discountCurve = Handle()); + //! \name Calculations //@{ //! A FRA expires/settles on the value date @@ -95,6 +133,7 @@ namespace QuantLib { //! term structure relevant to the contract (e.g. repo curve) Handle discountCurve() const; + //! if the FRA is constructed without the index it returns the valueDate Date fixingDate() const; //! Returns the relevant forward rate associated with the FRA term @@ -123,6 +162,13 @@ namespace QuantLib { Date maturityDate_; Handle discountCurve_; + //! needed for FRA calculations without index + Time valueDateTime_; + Time maturityDateTime_; + //! the interest rate the FRA contract rate will be compared + // against in order to determine the settlement amount + InterestRate referenceRate_; + private: void calculateForwardRate() const; void calculateAmount() const; From 64a72ead06acc925e3f448881f63a78a2a9fb808 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Sun, 12 Feb 2023 15:12:17 +0100 Subject: [PATCH 024/292] avoid c4250 --- .../inflation/piecewiseyoyoptionletvolatility.hpp | 7 +++++++ ql/termstructures/inflation/piecewiseyoyinflationcurve.hpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/ql/experimental/inflation/piecewiseyoyoptionletvolatility.hpp b/ql/experimental/inflation/piecewiseyoyoptionletvolatility.hpp index a104994439e..752d634ca1c 100644 --- a/ql/experimental/inflation/piecewiseyoyoptionletvolatility.hpp +++ b/ql/experimental/inflation/piecewiseyoyoptionletvolatility.hpp @@ -162,6 +162,8 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; + std::pair + registerWith(const ext::shared_ptr& o) override; //@} private: // methods @@ -230,6 +232,11 @@ namespace QuantLib { LazyObject::update(); } + template class B, class T> + std::pair PiecewiseYoYOptionletVolatilityCurve::registerWith( + const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif diff --git a/ql/termstructures/inflation/piecewiseyoyinflationcurve.hpp b/ql/termstructures/inflation/piecewiseyoyinflationcurve.hpp index 6a14f168100..6e4678dfdb2 100644 --- a/ql/termstructures/inflation/piecewiseyoyinflationcurve.hpp +++ b/ql/termstructures/inflation/piecewiseyoyinflationcurve.hpp @@ -88,6 +88,8 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; + std::pair + registerWith(const ext::shared_ptr& o) override; //@} private: // methods @@ -152,6 +154,11 @@ namespace QuantLib { LazyObject::update(); } + template class B, class T> + std::pair + PiecewiseYoYInflationCurve::registerWith(const ext::shared_ptr& o) { + return LazyObject::registerWith(o); + } } #endif From 87ee176a4d58ee89ba65ddd072d459f5a57d79a2 Mon Sep 17 00:00:00 2001 From: jakeheke75 Date: Sun, 19 Feb 2023 14:13:10 +0100 Subject: [PATCH 025/292] 1) Fixed intializer list 2) New ctor with Handle --- ql/instruments/forwardrateagreement.cpp | 84 ++++++++----------------- ql/instruments/forwardrateagreement.hpp | 44 ++++--------- 2 files changed, 37 insertions(+), 91 deletions(-) diff --git a/ql/instruments/forwardrateagreement.cpp b/ql/instruments/forwardrateagreement.cpp index 2db49b17624..28cc1bc986b 100644 --- a/ql/instruments/forwardrateagreement.cpp +++ b/ql/instruments/forwardrateagreement.cpp @@ -45,6 +45,7 @@ namespace QuantLib { registerWith(discountCurve_); QL_REQUIRE(notionalAmount > 0.0, "notionalAmount must be positive"); + QL_REQUIRE(valueDate_ < maturityDate_, "valueDate must be earlier than maturityDate"); strikeForwardRate_ = InterestRate(strikeForwardRate, index->dayCounter(), @@ -57,53 +58,24 @@ namespace QuantLib { Rate strikeForwardRate, Real notionalAmount, const ext::shared_ptr& index, - Handle discountCurve) - : ForwardRateAgreement(valueDate, index->maturityDate(valueDate), type, strikeForwardRate, - notionalAmount, index, std::move(discountCurve), true) {} - - ForwardRateAgreement::ForwardRateAgreement(Position::Type type, - const Date& valueDate, - Rate strikeForwardRate, - Real notionalAmount, - const ext::shared_ptr& index, Handle discountCurve, bool useIndexedCoupon) - : fraType_(type), valueDate_(valueDate), notionalAmount_(notionalAmount), - index_(index), discountCurve_(std::move(discountCurve)), - useIndexedCoupon_(useIndexedCoupon), - dayCounter_(index->dayCounter()), calendar_(index->fixingCalendar()), - businessDayConvention_(index->businessDayConvention()), - maturityDate_(index->maturityDate(valueDate)) { - - QL_REQUIRE(notionalAmount > 0.0, "notionalAmount must be positive"); - - registerWith(Settings::instance().evaluationDate()); - registerWith(discountCurve_); - registerWith(index_); - - maturityDate_ = calendar_.adjust(maturityDate_, businessDayConvention_); - QL_REQUIRE(valueDate_ < maturityDate_, "valueDate must be earlier than maturityDate"); - strikeForwardRate_ = InterestRate(strikeForwardRate, - index->dayCounter(), - Simple, Once); - } + : ForwardRateAgreement(valueDate, index->maturityDate(valueDate), type, strikeForwardRate, + notionalAmount, index, std::move(discountCurve), useIndexedCoupon) {} ForwardRateAgreement::ForwardRateAgreement(const Date& valueDate, const Date& maturityDate, Position::Type type, Rate strikeForwardRate, - Rate referenceRate, Real notionalAmount, - const DayCounter dayCounter, - const Calendar fixingCalendar, - const BusinessDayConvention businessDayConvention, - Handle discountCurve) - : valueDate_(valueDate), maturityDate_(maturityDate), - fraType_(type), notionalAmount_(notionalAmount), - dayCounter_(dayCounter), calendar_(fixingCalendar), - businessDayConvention_(businessDayConvention), - discountCurve_(std::move(discountCurve)), - useIndexedCoupon_(false) { + Handle discountCurve, + const Real fixingDays, + const BusinessDayConvention businessDayConvention) + : fraType_(type), notionalAmount_(notionalAmount), + useIndexedCoupon_(false), dayCounter_(discountCurve->dayCounter()), + calendar_(discountCurve->calendar()), businessDayConvention_(businessDayConvention), + valueDate_(valueDate), maturityDate_(maturityDate), + discountCurve_(std::move(discountCurve)), fixingDays_(fixingDays) { QL_REQUIRE(notionalAmount > 0.0, "notionalAmount must be positive"); @@ -113,20 +85,18 @@ namespace QuantLib { maturityDate_ = calendar_.adjust(maturityDate_, businessDayConvention_); QL_REQUIRE(valueDate_ < maturityDate_, "valueDate must be earlier than maturityDate"); strikeForwardRate_ = InterestRate(strikeForwardRate, - dayCounter, + discountCurve_->dayCounter(), Simple, Once); - referenceRate_ = InterestRate(referenceRate, - dayCounter, - Simple, Once); - valueDateTime_ = dayCounter_.yearFraction(Settings::instance().evaluationDate(), valueDate_); - maturityDateTime_ = dayCounter_.yearFraction(Settings::instance().evaluationDate(), maturityDate_); } Date ForwardRateAgreement::fixingDate() const { if (index_) return index_->fixingDate(valueDate_); - else // if FRA is constructed without the index it returns the valueDate - return valueDate_; + else { + Date fixingDate_ = calendar_.advance(valueDate_, + -static_cast(fixingDays_), Days, businessDayConvention_); + return fixingDate_; + } } bool ForwardRateAgreement::isExpired() const { @@ -152,14 +122,10 @@ namespace QuantLib { void ForwardRateAgreement::performCalculations() const { calculateAmount(); - if (!discountCurve_.empty() || index_) { - - Handle discount = - discountCurve_.empty() ? index_->forwardingTermStructure() : discountCurve_; + Handle discount = + discountCurve_.empty() ? index_->forwardingTermStructure() : discountCurve_; - NPV_ = amount_ * discount->discount(valueDate_); - } else - NPV_ = amount_ * referenceRate_.discountFactor(valueDateTime_); + NPV_ = amount_ * discount->discount(valueDate_); } void ForwardRateAgreement::calculateForwardRate() const { @@ -174,13 +140,13 @@ namespace QuantLib { 1.0) / index_->dayCounter().yearFraction(valueDate_, maturityDate_), index_->dayCounter(), Simple, Once); - else + else // calculating forward rate using the term structure forwardRate_ = - InterestRate((referenceRate_.discountFactor(valueDateTime_) / - referenceRate_.discountFactor(maturityDateTime_) - + InterestRate((discountCurve_->discount(valueDate_) / + discountCurve_->discount(maturityDate_) - 1.0) / - dayCounter_.yearFraction(valueDate_, maturityDate_), - dayCounter_, Simple, Once); + discountCurve_->dayCounter().yearFraction(valueDate_, maturityDate_), + discountCurve_->dayCounter(), Simple, Once); } diff --git a/ql/instruments/forwardrateagreement.hpp b/ql/instruments/forwardrateagreement.hpp index 47970ce3c97..bd7acf68d6a 100644 --- a/ql/instruments/forwardrateagreement.hpp +++ b/ql/instruments/forwardrateagreement.hpp @@ -66,6 +66,8 @@ namespace QuantLib { class ForwardRateAgreement: public Instrument { public: /*! \deprecated use the new constructors + the one without the maturityDate + or the one without the index deprecated in version 1.30 */ QL_DEPRECATED @@ -77,48 +79,32 @@ namespace QuantLib { Real notionalAmount, const ext::shared_ptr& index, Handle discountCurve = Handle(), - bool useIndexedCoupon = true); - - /*! \deprecated use the new constructors - deprecated in version 1.30 - */ - QL_DEPRECATED + bool useIndexedCoupon = true); ForwardRateAgreement( const Date& valueDate, Position::Type type, Rate strikeForwardRate, Real notionalAmount, const ext::shared_ptr& index, - Handle discountCurve = Handle()); - - /*! \brief constructor taking the index - \details constructor taking the index, the FRA maturityDate is calculated from the index - in this way we are avoiding conflicting information in the definition of the FRA - */ - ForwardRateAgreement( - Position::Type type, - const Date& valueDate, - Rate strikeForwardRate, - Real notionalAmount, - const ext::shared_ptr& index, Handle discountCurve = Handle(), bool useIndexedCoupon = true); /*! \brief constructor not taking the index - \details constructor not taking the index, all the FRA components must be provided + \details constructor not taking the index, Handle must be provided + with calendar, dayCounter, Compounding and Frequency the FRA evaluationDate must be specified in Settings::instance().evaluationDate() + the number of fixingDays must be specified for the fixingDate calculation + as well as the businessDayConvention */ ForwardRateAgreement( const Date& valueDate, const Date& maturityDate, Position::Type type, Rate strikeForwardRate, - Rate referenceRate, Real notionalAmount, - const DayCounter dayCounter, - const Calendar fixingCalendar, - const BusinessDayConvention businessDayConvention, - Handle discountCurve = Handle()); + Handle discountCurve, + const Real fixingDays, + const BusinessDayConvention businessDayConvention); //! \name Calculations //@{ @@ -133,7 +119,6 @@ namespace QuantLib { //! term structure relevant to the contract (e.g. repo curve) Handle discountCurve() const; - //! if the FRA is constructed without the index it returns the valueDate Date fixingDate() const; //! Returns the relevant forward rate associated with the FRA term @@ -161,13 +146,8 @@ namespace QuantLib { //! maturityDate of the underlying index; not the date the FRA is settled. Date maturityDate_; Handle discountCurve_; - - //! needed for FRA calculations without index - Time valueDateTime_; - Time maturityDateTime_; - //! the interest rate the FRA contract rate will be compared - // against in order to determine the settlement amount - InterestRate referenceRate_; + //! the number of fixingDays for fixingDate calculation without the index + Natural fixingDays_; private: void calculateForwardRate() const; From afef8765edabc095b07854c880c3e4e9660c64b6 Mon Sep 17 00:00:00 2001 From: jakeheke75 Date: Wed, 22 Feb 2023 21:37:14 +0100 Subject: [PATCH 026/292] ForwardRateAgreement constructor fix Fixed the deprecated constructor Removed the deprecated constructor from the test suite --- ql/instruments/forwardrateagreement.cpp | 21 +++++++++++++++++++-- ql/instruments/forwardrateagreement.hpp | 5 +++-- test-suite/forwardrateagreement.cpp | 1 - test-suite/piecewiseyieldcurve.cpp | 17 ++++------------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/ql/instruments/forwardrateagreement.cpp b/ql/instruments/forwardrateagreement.cpp index 28cc1bc986b..d8897638b4a 100644 --- a/ql/instruments/forwardrateagreement.cpp +++ b/ql/instruments/forwardrateagreement.cpp @@ -60,8 +60,25 @@ namespace QuantLib { const ext::shared_ptr& index, Handle discountCurve, bool useIndexedCoupon) - : ForwardRateAgreement(valueDate, index->maturityDate(valueDate), type, strikeForwardRate, - notionalAmount, index, std::move(discountCurve), useIndexedCoupon) {} + : fraType_(type), notionalAmount_(notionalAmount), index_(index), + useIndexedCoupon_(useIndexedCoupon), dayCounter_(index->dayCounter()), + calendar_(index->fixingCalendar()), businessDayConvention_(index->businessDayConvention()), + valueDate_(valueDate), maturityDate_(index->maturityDate(valueDate)), + discountCurve_(std::move(discountCurve)) { + + maturityDate_ = calendar_.adjust(maturityDate_, businessDayConvention_); + + registerWith(Settings::instance().evaluationDate()); + registerWith(discountCurve_); + + QL_REQUIRE(notionalAmount > 0.0, "notionalAmount must be positive"); + QL_REQUIRE(valueDate_ < maturityDate_, "valueDate must be earlier than maturityDate"); + + strikeForwardRate_ = InterestRate(strikeForwardRate, + index->dayCounter(), + Simple, Once); + registerWith(index_); + } ForwardRateAgreement::ForwardRateAgreement(const Date& valueDate, const Date& maturityDate, diff --git a/ql/instruments/forwardrateagreement.hpp b/ql/instruments/forwardrateagreement.hpp index bd7acf68d6a..1f1909bfaf2 100644 --- a/ql/instruments/forwardrateagreement.hpp +++ b/ql/instruments/forwardrateagreement.hpp @@ -66,8 +66,9 @@ namespace QuantLib { class ForwardRateAgreement: public Instrument { public: /*! \deprecated use the new constructors - the one without the maturityDate - or the one without the index + the second one without the maturityDate + or the third one without the index and + with the term structure handle deprecated in version 1.30 */ QL_DEPRECATED diff --git a/test-suite/forwardrateagreement.cpp b/test-suite/forwardrateagreement.cpp index a93763af0c0..7c9ddc6f608 100644 --- a/test-suite/forwardrateagreement.cpp +++ b/test-suite/forwardrateagreement.cpp @@ -77,7 +77,6 @@ void ForwardRateAgreementTest::testConstructionWithoutACurve() { // set up the instrument to price ForwardRateAgreement fra(settlementDate + Period(12, Months), - settlementDate + Period(15, Months), Position::Long, 0, 1, diff --git a/test-suite/piecewiseyieldcurve.cpp b/test-suite/piecewiseyieldcurve.cpp index 6be88eca41e..a49d2d3b458 100644 --- a/test-suite/piecewiseyieldcurve.cpp +++ b/test-suite/piecewiseyieldcurve.cpp @@ -456,11 +456,8 @@ namespace piecewise_yield_curve_test { euribor3m->businessDayConvention(), euribor3m->endOfMonth()); BOOST_REQUIRE(fraData[i].units == Months); - Date end = vars.calendar.advance(vars.settlement, 3 + fraData[i].n, Months, - euribor3m->businessDayConvention(), - euribor3m->endOfMonth()); - ForwardRateAgreement fra(start, end, Position::Long, + ForwardRateAgreement fra(start, Position::Long, fraData[i].rate/100, 100.0, euribor3m, curveHandle, useIndexedFra); @@ -489,11 +486,8 @@ namespace piecewise_yield_curve_test { if (euribor3m->fixingDate(immStart) < Settings::instance().evaluationDate()) immStart = IMM::nextDate(immStart, false); - Date end = vars.calendar.advance(immStart, 3, Months, - euribor3m->businessDayConvention(), - euribor3m->endOfMonth()); - - ForwardRateAgreement immFut(immStart, end, Position::Long, + + ForwardRateAgreement immFut(immStart, Position::Long, immFutData[i].rate / 100, 100.0, euribor3m, curveHandle); Rate expectedRate = immFutData[i].rate / 100, @@ -523,11 +517,8 @@ namespace piecewise_yield_curve_test { asxStart = ASX::nextDate(asxStart, false); if (euribor3m->fixingCalendar().isHoliday(asxStart)) continue; - Date end = vars.calendar.advance(asxStart, 3, Months, - euribor3m->businessDayConvention(), - euribor3m->endOfMonth()); - ForwardRateAgreement asxFut(asxStart, end, Position::Long, + ForwardRateAgreement asxFut(asxStart, Position::Long, asxFutData[i].rate / 100, 100.0, euribor3m, curveHandle); Rate expectedRate = asxFutData[i].rate / 100, From 812d8ca9d593a220022bd0eaa728f5bf3f84cb73 Mon Sep 17 00:00:00 2001 From: jakeheke75 Date: Thu, 23 Feb 2023 00:26:57 +0100 Subject: [PATCH 027/292] Fixes the AppVeyor build failed --- ql/instruments/forwardrateagreement.cpp | 4 ++-- ql/instruments/forwardrateagreement.hpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ql/instruments/forwardrateagreement.cpp b/ql/instruments/forwardrateagreement.cpp index d8897638b4a..eccbb9f75fb 100644 --- a/ql/instruments/forwardrateagreement.cpp +++ b/ql/instruments/forwardrateagreement.cpp @@ -86,8 +86,8 @@ namespace QuantLib { Rate strikeForwardRate, Real notionalAmount, Handle discountCurve, - const Real fixingDays, - const BusinessDayConvention businessDayConvention) + Natural fixingDays, + BusinessDayConvention businessDayConvention) : fraType_(type), notionalAmount_(notionalAmount), useIndexedCoupon_(false), dayCounter_(discountCurve->dayCounter()), calendar_(discountCurve->calendar()), businessDayConvention_(businessDayConvention), diff --git a/ql/instruments/forwardrateagreement.hpp b/ql/instruments/forwardrateagreement.hpp index 1f1909bfaf2..73b59c47ae7 100644 --- a/ql/instruments/forwardrateagreement.hpp +++ b/ql/instruments/forwardrateagreement.hpp @@ -104,8 +104,8 @@ namespace QuantLib { Rate strikeForwardRate, Real notionalAmount, Handle discountCurve, - const Real fixingDays, - const BusinessDayConvention businessDayConvention); + Natural fixingDays, + BusinessDayConvention businessDayConvention); //! \name Calculations //@{ From 537ea232ec383bcba469ad9898fb05ce3cb44bde Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Tue, 7 Mar 2023 15:08:33 +0100 Subject: [PATCH 028/292] Revert "avoid warning C4250 "inherits via dominance"" This reverts commit 623a9ae9df697ec85eadd46109b17a512427de92. --- .../volatility/capfloor/capfloortermvolsurface.hpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp b/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp index e9a77ab7537..74ecfc33e36 100644 --- a/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp +++ b/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp @@ -88,11 +88,6 @@ namespace QuantLib { void update() override; void performCalculations() const override; //@} - //! \name Observer interface - //@{ - std::pair - registerWith(const ext::shared_ptr& o) override; - //@} //! \name some inspectors //@{ const std::vector& optionTenors() const; From 464800bf0d26b7e4cac27eb876310cec3094f643 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Tue, 7 Mar 2023 15:08:45 +0100 Subject: [PATCH 029/292] Revert "avoid c4250" This reverts commit 64a72ead06acc925e3f448881f63a78a2a9fb808. --- .../inflation/piecewiseyoyoptionletvolatility.hpp | 7 ------- ql/termstructures/inflation/piecewiseyoyinflationcurve.hpp | 7 ------- 2 files changed, 14 deletions(-) diff --git a/ql/experimental/inflation/piecewiseyoyoptionletvolatility.hpp b/ql/experimental/inflation/piecewiseyoyoptionletvolatility.hpp index 752d634ca1c..a104994439e 100644 --- a/ql/experimental/inflation/piecewiseyoyoptionletvolatility.hpp +++ b/ql/experimental/inflation/piecewiseyoyoptionletvolatility.hpp @@ -162,8 +162,6 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; - std::pair - registerWith(const ext::shared_ptr& o) override; //@} private: // methods @@ -232,11 +230,6 @@ namespace QuantLib { LazyObject::update(); } - template class B, class T> - std::pair PiecewiseYoYOptionletVolatilityCurve::registerWith( - const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif diff --git a/ql/termstructures/inflation/piecewiseyoyinflationcurve.hpp b/ql/termstructures/inflation/piecewiseyoyinflationcurve.hpp index 6e4678dfdb2..6a14f168100 100644 --- a/ql/termstructures/inflation/piecewiseyoyinflationcurve.hpp +++ b/ql/termstructures/inflation/piecewiseyoyinflationcurve.hpp @@ -88,8 +88,6 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; - std::pair - registerWith(const ext::shared_ptr& o) override; //@} private: // methods @@ -154,11 +152,6 @@ namespace QuantLib { LazyObject::update(); } - template class B, class T> - std::pair - PiecewiseYoYInflationCurve::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif From e9da2d5e8fd49895d6eca7b573e771fa6e561c18 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Tue, 7 Mar 2023 15:08:54 +0100 Subject: [PATCH 030/292] Revert "more fixes" This reverts commit 686062ecf411274a8b488060f02a5d1f81ce5cf9. --- ql/termstructures/credit/piecewisedefaultcurve.hpp | 9 +-------- ql/termstructures/defaulttermstructure.hpp | 4 ++-- .../inflation/piecewisezeroinflationcurve.hpp | 3 +-- ql/termstructures/yield/piecewiseyieldcurve.hpp | 3 +-- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/ql/termstructures/credit/piecewisedefaultcurve.hpp b/ql/termstructures/credit/piecewisedefaultcurve.hpp index 01e6e4aab33..7adaf961d74 100644 --- a/ql/termstructures/credit/piecewisedefaultcurve.hpp +++ b/ql/termstructures/credit/piecewisedefaultcurve.hpp @@ -185,8 +185,7 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; - std::pair - registerWith(const ext::shared_ptr& o) override; + //@} private: //! \name LazyObject interface //@{ @@ -283,12 +282,6 @@ namespace QuantLib { bootstrap_.calculate(); } - template class B> - inline std::pair - PiecewiseDefaultCurve::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } - } #endif diff --git a/ql/termstructures/defaulttermstructure.hpp b/ql/termstructures/defaulttermstructure.hpp index 41d9f812a9c..b2b86687460 100644 --- a/ql/termstructures/defaulttermstructure.hpp +++ b/ql/termstructures/defaulttermstructure.hpp @@ -248,9 +248,9 @@ namespace QuantLib { setJumps(); } - inline std::pair + inline void DefaultProbabilityTermStructure::registerWith(const ext::shared_ptr& o) { - return TermStructure::registerWith(o); + return LazyObject::registerWith(o); } } diff --git a/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp b/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp index 68efac143b4..ed22da19432 100644 --- a/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp +++ b/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp @@ -154,8 +154,7 @@ namespace QuantLib { } template class B, class T> - std::pair - PiecewiseZeroInflationCurve::registerWith(const ext::shared_ptr& o) { + void PiecewiseZeroInflationCurve::registerWith(const ext::shared_ptr& o) { return LazyObject::registerWith(o); } } diff --git a/ql/termstructures/yield/piecewiseyieldcurve.hpp b/ql/termstructures/yield/piecewiseyieldcurve.hpp index aaa3de26b37..28542065473 100644 --- a/ql/termstructures/yield/piecewiseyieldcurve.hpp +++ b/ql/termstructures/yield/piecewiseyieldcurve.hpp @@ -255,8 +255,7 @@ namespace QuantLib { } template class B> - inline std::pair - PiecewiseYieldCurve::registerWith(const ext::shared_ptr& o) { + inline void PiecewiseYieldCurve::registerWith(const ext::shared_ptr& o) { return LazyObject::registerWith(o); } } From 19386b9ea5bd802a3a5d5383878505a51430a404 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Tue, 7 Mar 2023 15:08:56 +0100 Subject: [PATCH 031/292] Revert "avoid warning c4250" This reverts commit 8ff6d49d345e8e67ad9989460a543c52719195c7. --- ql/termstructures/defaulttermstructure.hpp | 6 ------ ql/termstructures/inflation/piecewisezeroinflationcurve.hpp | 6 ------ ql/termstructures/yield/piecewiseyieldcurve.hpp | 6 ------ 3 files changed, 18 deletions(-) diff --git a/ql/termstructures/defaulttermstructure.hpp b/ql/termstructures/defaulttermstructure.hpp index b2b86687460..93ec81ea33f 100644 --- a/ql/termstructures/defaulttermstructure.hpp +++ b/ql/termstructures/defaulttermstructure.hpp @@ -142,8 +142,6 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; - std::pair - registerWith(const ext::shared_ptr& o) override; //@} protected: /*! \name Calculations @@ -248,10 +246,6 @@ namespace QuantLib { setJumps(); } - inline void - DefaultProbabilityTermStructure::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif diff --git a/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp b/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp index ed22da19432..069a4508832 100644 --- a/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp +++ b/ql/termstructures/inflation/piecewisezeroinflationcurve.hpp @@ -87,8 +87,6 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; - std::pair - registerWith(const ext::shared_ptr& o) override; //@} private: // methods @@ -153,10 +151,6 @@ namespace QuantLib { LazyObject::update(); } - template class B, class T> - void PiecewiseZeroInflationCurve::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif diff --git a/ql/termstructures/yield/piecewiseyieldcurve.hpp b/ql/termstructures/yield/piecewiseyieldcurve.hpp index 28542065473..d622a98d899 100644 --- a/ql/termstructures/yield/piecewiseyieldcurve.hpp +++ b/ql/termstructures/yield/piecewiseyieldcurve.hpp @@ -168,8 +168,6 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; - std::pair - registerWith(const ext::shared_ptr& o) override; //@} private: //! \name LazyObject interface @@ -254,10 +252,6 @@ namespace QuantLib { bootstrap_.calculate(); } - template class B> - inline void PiecewiseYieldCurve::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif From 70ec6d5ee84926f3a65c4ed31f8b421d47c85cc1 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Tue, 7 Mar 2023 15:08:58 +0100 Subject: [PATCH 032/292] Revert "fix warning c4250" This reverts commit 31bd92d6be307462701ef81288cb30b011058a2a. --- ql/termstructures/yield/fittedbonddiscountcurve.hpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/ql/termstructures/yield/fittedbonddiscountcurve.hpp b/ql/termstructures/yield/fittedbonddiscountcurve.hpp index 6dfc5461e16..eb06165819e 100644 --- a/ql/termstructures/yield/fittedbonddiscountcurve.hpp +++ b/ql/termstructures/yield/fittedbonddiscountcurve.hpp @@ -120,8 +120,6 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; - std::pair - registerWith(const ext::shared_ptr& o) override; //@} private: @@ -339,11 +337,6 @@ namespace QuantLib { return discountFunction(x, t); } } - - inline std::pair - FittedBondDiscountCurve::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif From 3ec0dd43dc1a795524f3ac6736e11b20940c48ea Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Tue, 7 Mar 2023 15:10:05 +0100 Subject: [PATCH 033/292] Revert "fix msvc warning c4250" This reverts commit 6f91089cb53d389c33d8cdeb5c97408ac11c6bd0. --- ql/experimental/volatility/abcdatmvolcurve.hpp | 10 ---------- .../volatility/noarbsabrinterpolatedsmilesection.hpp | 9 --------- .../volatility/sviinterpolatedsmilesection.hpp | 10 ---------- ql/models/shortrate/onefactormodels/gsr.hpp | 5 ----- .../shortrate/onefactormodels/markovfunctional.hpp | 5 ----- .../volatility/capfloor/capfloortermvolcurve.hpp | 9 --------- .../volatility/interpolatedsmilesection.hpp | 8 -------- .../volatility/optionlet/strippedoptionletadapter.hpp | 10 ---------- .../volatility/sabrinterpolatedsmilesection.hpp | 9 --------- .../volatility/swaption/swaptionvolcube.hpp | 10 ---------- .../volatility/swaption/swaptionvoldiscrete.hpp | 7 ------- .../volatility/swaption/swaptionvolmatrix.hpp | 10 ---------- ql/termstructures/yield/flatforward.hpp | 6 ------ 13 files changed, 108 deletions(-) diff --git a/ql/experimental/volatility/abcdatmvolcurve.hpp b/ql/experimental/volatility/abcdatmvolcurve.hpp index 27dd8738b1b..ff827df7a24 100644 --- a/ql/experimental/volatility/abcdatmvolcurve.hpp +++ b/ql/experimental/volatility/abcdatmvolcurve.hpp @@ -73,11 +73,6 @@ namespace QuantLib { void update() override; void performCalculations() const override; //@} - //! \name Observer interface - //@{ - std::pair - registerWith(const ext::shared_ptr& o) override; - //@} //! \name some inspectors //@{ const std::vector& optionTenors() const; @@ -200,11 +195,6 @@ namespace QuantLib { inline EndCriteria::Type AbcdAtmVolCurve::endCriteria() const { return interpolation_->endCriteria(); } - - inline std::pair - AbcdAtmVolCurve::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif diff --git a/ql/experimental/volatility/noarbsabrinterpolatedsmilesection.hpp b/ql/experimental/volatility/noarbsabrinterpolatedsmilesection.hpp index ccef385074f..c88df824b37 100644 --- a/ql/experimental/volatility/noarbsabrinterpolatedsmilesection.hpp +++ b/ql/experimental/volatility/noarbsabrinterpolatedsmilesection.hpp @@ -84,11 +84,6 @@ namespace QuantLib { void performCalculations() const override; void update() override; //@} - //! \name Observer interface - //@{ - std::pair - registerWith(const ext::shared_ptr& o) override; - //@} //! \name SmileSection interface //@{ Real minStrike() const override; @@ -195,10 +190,6 @@ namespace QuantLib { return forwardValue_; } - inline std::pair - NoArbSabrInterpolatedSmileSection::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } diff --git a/ql/experimental/volatility/sviinterpolatedsmilesection.hpp b/ql/experimental/volatility/sviinterpolatedsmilesection.hpp index 7eda7a262eb..9974e03f450 100644 --- a/ql/experimental/volatility/sviinterpolatedsmilesection.hpp +++ b/ql/experimental/volatility/sviinterpolatedsmilesection.hpp @@ -87,11 +87,6 @@ class SviInterpolatedSmileSection : public SmileSection, public LazyObject { void performCalculations() const override; void update() override; //@} - //! \name Observer interface - //@{ - std::pair - registerWith(const ext::shared_ptr& o) override; - //@} //! \name SmileSection interface //@{ Real minStrike() const override; @@ -201,11 +196,6 @@ inline Real SviInterpolatedSmileSection::atmLevel() const { calculate(); return forwardValue_; } - -inline std::pair -SviInterpolatedSmileSection::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); -} } #endif diff --git a/ql/models/shortrate/onefactormodels/gsr.hpp b/ql/models/shortrate/onefactormodels/gsr.hpp index 6490f7f65bf..c4d7df90709 100644 --- a/ql/models/shortrate/onefactormodels/gsr.hpp +++ b/ql/models/shortrate/onefactormodels/gsr.hpp @@ -59,11 +59,6 @@ class Gsr : public Gaussian1dModel, public CalibratedModel { std::vector > reversions, Real T = 60.0); - std::pair - registerWith(const ext::shared_ptr& o) override { - return LazyObject::registerWith(o); - } - Real numeraireTime() const; void numeraireTime(Real T); diff --git a/ql/models/shortrate/onefactormodels/markovfunctional.hpp b/ql/models/shortrate/onefactormodels/markovfunctional.hpp index 9ad083130ec..1468af7b857 100644 --- a/ql/models/shortrate/onefactormodels/markovfunctional.hpp +++ b/ql/models/shortrate/onefactormodels/markovfunctional.hpp @@ -358,11 +358,6 @@ namespace QuantLib { void update() override { LazyObject::update(); } - std::pair - registerWith(const ext::shared_ptr& o) override { - return LazyObject::registerWith(o); - } - // returns the indices of the af region from the last smile update std::vector > arbitrageIndices() const { calculate(); diff --git a/ql/termstructures/volatility/capfloor/capfloortermvolcurve.hpp b/ql/termstructures/volatility/capfloor/capfloortermvolcurve.hpp index e09ae6873dd..028db76bdbe 100644 --- a/ql/termstructures/volatility/capfloor/capfloortermvolcurve.hpp +++ b/ql/termstructures/volatility/capfloor/capfloortermvolcurve.hpp @@ -95,11 +95,6 @@ namespace QuantLib { void update() override; void performCalculations() const override; //@} - //! \name Observer interface - //@{ - std::pair - registerWith(const ext::shared_ptr& o) override; - //@} //! \name some inspectors //@{ const std::vector& optionTenors() const; @@ -169,10 +164,6 @@ namespace QuantLib { return optionTimes_; } - inline std::pair - CapFloorTermVolCurve::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif diff --git a/ql/termstructures/volatility/interpolatedsmilesection.hpp b/ql/termstructures/volatility/interpolatedsmilesection.hpp index 388a08a46b7..4a619520af4 100644 --- a/ql/termstructures/volatility/interpolatedsmilesection.hpp +++ b/ql/termstructures/volatility/interpolatedsmilesection.hpp @@ -82,8 +82,6 @@ namespace QuantLib { Real maxStrike() const override { return strikes_.back(); } Real atmLevel() const override { return atmLevel_->value(); } void update() override; - std::pair - registerWith(const ext::shared_ptr& o) override; private: Real exerciseTimeSquareRoot_; @@ -222,12 +220,6 @@ namespace QuantLib { SmileSection::update(); } - template - std::pair - InterpolatedSmileSection::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } - #endif } #endif diff --git a/ql/termstructures/volatility/optionlet/strippedoptionletadapter.hpp b/ql/termstructures/volatility/optionlet/strippedoptionletadapter.hpp index 0bb51237b45..e8b8a96134e 100644 --- a/ql/termstructures/volatility/optionlet/strippedoptionletadapter.hpp +++ b/ql/termstructures/volatility/optionlet/strippedoptionletadapter.hpp @@ -60,11 +60,6 @@ namespace QuantLib { //@} //! \name Observer interface //@{ - std::pair - registerWith(const ext::shared_ptr& o) override; - //@} - //! \name Observer interface - //@{ void deepUpdate() override; //@} @@ -98,11 +93,6 @@ namespace QuantLib { return ext::dynamic_pointer_cast< OptionletStripper >( optionletStripper_); } - - inline std::pair - StrippedOptionletAdapter::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif diff --git a/ql/termstructures/volatility/sabrinterpolatedsmilesection.hpp b/ql/termstructures/volatility/sabrinterpolatedsmilesection.hpp index ef4dde3fc22..aa38c1a6ded 100644 --- a/ql/termstructures/volatility/sabrinterpolatedsmilesection.hpp +++ b/ql/termstructures/volatility/sabrinterpolatedsmilesection.hpp @@ -88,11 +88,6 @@ namespace QuantLib { void performCalculations() const override; void update() override; //@} - //! \name Observer interface - //@{ - std::pair - registerWith(const ext::shared_ptr& o) override; - //@} //! \name SmileSection interface //@{ Real minStrike() const override; @@ -201,10 +196,6 @@ namespace QuantLib { return forwardValue_; } - inline std::pair - SabrInterpolatedSmileSection::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } diff --git a/ql/termstructures/volatility/swaption/swaptionvolcube.hpp b/ql/termstructures/volatility/swaption/swaptionvolcube.hpp index a3c2e8a778a..a6f5ae58f5c 100644 --- a/ql/termstructures/volatility/swaption/swaptionvolcube.hpp +++ b/ql/termstructures/volatility/swaption/swaptionvolcube.hpp @@ -64,11 +64,6 @@ namespace QuantLib { //@{ const Period& maxSwapTenor() const override { return atmVol_->maxSwapTenor(); } //@} - //! \name Observer interface - //@{ - std::pair - registerWith(const ext::shared_ptr& o) override; - //@} //! \name Other inspectors //@{ Rate atmStrike(const Date& optionDate, @@ -138,11 +133,6 @@ namespace QuantLib { Time swapLength) const { return atmVol_->shift(optionTime, swapLength); } - - inline std::pair - SwaptionVolatilityCube::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif diff --git a/ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp b/ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp index fc7fca8c9ce..454a815118b 100644 --- a/ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp +++ b/ql/termstructures/volatility/swaption/swaptionvoldiscrete.hpp @@ -60,8 +60,6 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; - std::pair - registerWith(const ext::shared_ptr& o) override; //@} //! \name LazyObject interface //@{ @@ -121,11 +119,6 @@ namespace QuantLib { inline Date SwaptionVolatilityDiscrete::optionDateFromTime(Time optionTime) const { return Date(static_cast(optionInterpolator_(optionTime))); } - - inline std::pair - SwaptionVolatilityDiscrete::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif diff --git a/ql/termstructures/volatility/swaption/swaptionvolmatrix.hpp b/ql/termstructures/volatility/swaption/swaptionvolmatrix.hpp index 299a4e76038..aa349d912b1 100644 --- a/ql/termstructures/volatility/swaption/swaptionvolmatrix.hpp +++ b/ql/termstructures/volatility/swaption/swaptionvolmatrix.hpp @@ -118,11 +118,6 @@ namespace QuantLib { //@{ void performCalculations() const override; //@} - //! \name Observer interface - //@{ - std::pair - registerWith(const ext::shared_ptr& o) override; - //@} //! \name TermStructure interface //@{ Date maxDate() const override; @@ -210,11 +205,6 @@ namespace QuantLib { Real tmp = interpolationShifts_(swapLength, optionTime, true); return tmp; } - - inline std::pair - SwaptionVolatilityMatrix::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } // namespace QuantLib #endif diff --git a/ql/termstructures/yield/flatforward.hpp b/ql/termstructures/yield/flatforward.hpp index 46ce6476080..70c17eb96ec 100644 --- a/ql/termstructures/yield/flatforward.hpp +++ b/ql/termstructures/yield/flatforward.hpp @@ -74,8 +74,6 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; - std::pair - registerWith(const ext::shared_ptr& o) override; //@} private: //! \name LazyObject interface @@ -111,10 +109,6 @@ namespace QuantLib { compounding_, frequency_); } - inline std::pair - FlatForward::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif From f6e4715bca5b7ace570c0f3778fb95c68e4e0c6d Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Tue, 7 Mar 2023 15:20:24 +0100 Subject: [PATCH 034/292] Revert "second attempt to avoid msvc warning c4250" This reverts commit b4250ad5815f0f61de06cf6dbe0d782879e60166. --- ql/patterns/lazyobject.hpp | 46 +++++++++++--------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/ql/patterns/lazyobject.hpp b/ql/patterns/lazyobject.hpp index 592e0a5efc8..f4dc1208e69 100644 --- a/ql/patterns/lazyobject.hpp +++ b/ql/patterns/lazyobject.hpp @@ -39,8 +39,6 @@ namespace QuantLib { //! \name Observer interface //@{ void update() override; - std::pair - registerWith(const ext::shared_ptr&) override; //@} /*! \name Calculations These methods do not modify the structure of the object @@ -70,28 +68,17 @@ namespace QuantLib { method, thus re-enabling recalculations. */ void unfreeze(); - /*! This method causes the object to forward all - notifications, even when not calculated. The default - behavior is to forward the first notification received, - and discard the others until recalculated; the rationale - is that observers were already notified, and don't need - further notification until they recalculate, at which - point this object would be recalculated too. After - recalculation, this object would again forward the first - notification received. - - The method should be overridden in derived classes which - contain nested lazy objects. It should then call the method - on itself and the nested lazy objects to ensure that - notifications from the nested objects are always forwarded - all the way through the observable chain. - - \warning Forwarding all notifications will cause a - performance hit, and should be used only when - discarding notifications cause an incorrect - behavior. + /*! This method causes the object to forward the first notification received, + and discard the others until recalculated; the rationale is that observers + were already notified, and don't need further notifications until they + recalculate, at which point this object would be recalculated too. + After recalculation, this object would again forward the first notification + received. + + The behaviour is not always correct though and should only be enabled in + appropriate configurations. */ - virtual void alwaysForwardNotifications(); + virtual void forwardFirstNotificationOnly(); protected: /*! This method performs all needed calculations by calling the performCalculations method. @@ -115,7 +102,7 @@ namespace QuantLib { */ virtual void performCalculations() const = 0; //@} - mutable bool calculated_ = false, frozen_ = false, alwaysForward_ = false; + mutable bool calculated_ = false, frozen_ = false, alwaysForward_ = true; }; @@ -164,8 +151,8 @@ namespace QuantLib { } } - inline void LazyObject::alwaysForwardNotifications() { - alwaysForward_ = true; + inline void LazyObject::forwardFirstNotificationOnly() { + alwaysForward_ = false; } inline void LazyObject::calculate() const { @@ -180,13 +167,6 @@ namespace QuantLib { } } } - - inline std::pair - LazyObject::registerWith(const ext::shared_ptr& h) { - if (auto l = ext::dynamic_pointer_cast(h)) - l->alwaysForwardNotifications(); - return Observer::registerWith(h); - } } #endif From 4dd582e6ca2e29d99c28ba4556a2dd4c16222c17 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Tue, 7 Mar 2023 15:22:24 +0100 Subject: [PATCH 035/292] remove registerWith overwrite --- .../volatility/capfloor/capfloortermvolsurface.hpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp b/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp index 74ecfc33e36..54886808cbc 100644 --- a/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp +++ b/ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp @@ -164,11 +164,6 @@ namespace QuantLib { inline const std::vector& CapFloorTermVolSurface::strikes() const { return strikes_; } - - inline std::pair - CapFloorTermVolSurface::registerWith(const ext::shared_ptr& o) { - return LazyObject::registerWith(o); - } } #endif From 8f6b5f1333ea2b8873c0305eb70e567e4d5ef547 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Tue, 7 Mar 2023 15:29:31 +0100 Subject: [PATCH 036/292] fix unit test --- test-suite/lazyobject.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test-suite/lazyobject.cpp b/test-suite/lazyobject.cpp index c0c9167cf4b..680ee9b1f82 100644 --- a/test-suite/lazyobject.cpp +++ b/test-suite/lazyobject.cpp @@ -58,13 +58,11 @@ void LazyObjectTest::testDiscardingNotifications() { void LazyObjectTest::testForwardingNotifications() { BOOST_TEST_MESSAGE( - "Testing that lazy objects forward all notifications when told..."); + "Testing that lazy objects forward all notifications by default..."); ext::shared_ptr q(new SimpleQuote(0.0)); ext::shared_ptr s(new Stock(Handle(q))); - s->alwaysForwardNotifications(); - Flag f; f.registerWith(s); From d2cadf74c0b58e3b47061189fb3a7dfbab06f83f Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Tue, 7 Mar 2023 15:34:47 +0100 Subject: [PATCH 037/292] fix --- ql/termstructures/volatility/interpolatedsmilesection.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ql/termstructures/volatility/interpolatedsmilesection.hpp b/ql/termstructures/volatility/interpolatedsmilesection.hpp index 4a619520af4..63eb804a8d8 100644 --- a/ql/termstructures/volatility/interpolatedsmilesection.hpp +++ b/ql/termstructures/volatility/interpolatedsmilesection.hpp @@ -219,6 +219,7 @@ namespace QuantLib { LazyObject::update(); SmileSection::update(); } + #endif } From 2fab9eda4494441f5c4c9e9058e5b66b1874cd17 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Tue, 7 Mar 2023 16:25:53 +0100 Subject: [PATCH 038/292] address Luigi's comments --- ql/patterns/lazyobject.hpp | 11 ++++++++++- ql/patterns/observable.hpp | 11 +++++++---- test-suite/lazyobject.cpp | 8 +++++--- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ql/patterns/lazyobject.hpp b/ql/patterns/lazyobject.hpp index f4dc1208e69..2f6fd0ebd39 100644 --- a/ql/patterns/lazyobject.hpp +++ b/ql/patterns/lazyobject.hpp @@ -78,7 +78,12 @@ namespace QuantLib { The behaviour is not always correct though and should only be enabled in appropriate configurations. */ - virtual void forwardFirstNotificationOnly(); + void forwardFirstNotificationOnly(); + + /*! Restore the default behaviour after a call to forwardFirstNotificationOnly(), + see above. */ + void alwaysForwardNotifications(); + protected: /*! This method performs all needed calculations by calling the performCalculations method. @@ -155,6 +160,10 @@ namespace QuantLib { alwaysForward_ = false; } + inline void LazyObject::alwaysForwardNotifications() { + alwaysForward_ = true; + } + inline void LazyObject::calculate() const { if (!calculated_ && !frozen_) { calculated_ = true; // prevent infinite recursion in diff --git a/ql/patterns/observable.hpp b/ql/patterns/observable.hpp index 4c449774d65..1523307c533 100644 --- a/ql/patterns/observable.hpp +++ b/ql/patterns/observable.hpp @@ -119,15 +119,18 @@ namespace QuantLib { virtual ~Observer(); // observer interface - virtual std::pair + std::pair registerWith(const ext::shared_ptr&); /*! register with all observables of a given observer. Note that this does not include registering with the observer itself. - \deprecated consider using LazyObject::alwaysForwardNotifications() instead, - the registration with the next-level observables was just a workaround for that. + \deprecated This method was introduced to work around incorrect behaviour + caused by limiting notifications from LazyObject instances to the first + notification. The default behaviour of LazyObject was changed to forward + all notifications so that a call to this method should no longer be + necessary. */ QL_DEPRECATED void registerWithObservables(const ext::shared_ptr&); Size unregisterWith(const ext::shared_ptr&); @@ -294,7 +297,7 @@ namespace QuantLib { Observer& operator=(const Observer&); virtual ~Observer(); // observer interface - virtual std::pair + std::pair registerWith(const ext::shared_ptr&); /*! register with all observables of a given observer. Note that this does not include registering with the observer diff --git a/test-suite/lazyobject.cpp b/test-suite/lazyobject.cpp index 680ee9b1f82..10846a49cde 100644 --- a/test-suite/lazyobject.cpp +++ b/test-suite/lazyobject.cpp @@ -29,14 +29,16 @@ using ext::shared_ptr; void LazyObjectTest::testDiscardingNotifications() { BOOST_TEST_MESSAGE( - "Testing that lazy objects discard notifications after the first..."); + "Testing that lazy objects discard notifications after the first (if requested)..."); ext::shared_ptr q(new SimpleQuote(0.0)); ext::shared_ptr s(new Stock(Handle(q))); Flag f; f.registerWith(s); - + + s->forwardFirstNotificationOnly(); + s->NPV(); q->setValue(1.0); if (!f.isUp()) @@ -58,7 +60,7 @@ void LazyObjectTest::testDiscardingNotifications() { void LazyObjectTest::testForwardingNotifications() { BOOST_TEST_MESSAGE( - "Testing that lazy objects forward all notifications by default..."); + "Testing that lazy objects forward all notifications (default behaviour)..."); ext::shared_ptr q(new SimpleQuote(0.0)); ext::shared_ptr s(new Stock(Handle(q))); From a1d34ac730e96cc3b4a395eccd6b7f3515604f3c Mon Sep 17 00:00:00 2001 From: Marcin Rybacki Date: Tue, 7 Mar 2023 18:18:56 +0100 Subject: [PATCH 039/292] Added equity quanto cash flow. --- QuantLib.vcxproj | 2 + QuantLib.vcxproj.filters | 6 ++ ql/cashflows/equityquantocashflow.cpp | 100 +++++++++++++++++++++ ql/cashflows/equityquantocashflow.hpp | 107 +++++++++++++++++++++++ ql/instruments/equitytotalreturnswap.cpp | 39 ++++----- ql/instruments/equitytotalreturnswap.hpp | 3 + 6 files changed, 234 insertions(+), 23 deletions(-) create mode 100644 ql/cashflows/equityquantocashflow.cpp create mode 100644 ql/cashflows/equityquantocashflow.hpp diff --git a/QuantLib.vcxproj b/QuantLib.vcxproj index 625f9bfe67e..2dbf980019b 100644 --- a/QuantLib.vcxproj +++ b/QuantLib.vcxproj @@ -517,6 +517,7 @@ + @@ -1911,6 +1912,7 @@ + diff --git a/QuantLib.vcxproj.filters b/QuantLib.vcxproj.filters index 1db10bb7997..ca4695a4d28 100644 --- a/QuantLib.vcxproj.filters +++ b/QuantLib.vcxproj.filters @@ -4439,6 +4439,9 @@ instruments + + cashflows + @@ -7168,5 +7171,8 @@ instruments + + cashflows + \ No newline at end of file diff --git a/ql/cashflows/equityquantocashflow.cpp b/ql/cashflows/equityquantocashflow.cpp new file mode 100644 index 00000000000..ea7066d61a0 --- /dev/null +++ b/ql/cashflows/equityquantocashflow.cpp @@ -0,0 +1,100 @@ +/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + Copyright (C) 2023 Marcin Rybacki + + 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. +*/ + +#include +#include +#include +#include + +namespace QuantLib { + + EquityQuantoCashFlow::EquityQuantoCashFlow(Real notional, + ext::shared_ptr equityIndex, + const Date& startDate, + const Date& endDate, + const Date& paymentDate) + : notional_(notional), equityIndex_(std::move(equityIndex)), startDate_(startDate), + endDate_(endDate), paymentDate_(paymentDate) { + registerWith(equityIndex_); + registerWith(Settings::instance().evaluationDate()); + } + + void EquityQuantoCashFlow::setPricer(const ext::shared_ptr& pricer) { + if (pricer_ != nullptr) + unregisterWith(pricer_); + pricer_ = pricer; + if (pricer_ != nullptr) + registerWith(pricer_); + update(); + } + + Real EquityQuantoCashFlow::amount() const { + QL_REQUIRE(pricer_, "pricer not set"); + pricer_->initialize(*this); + return pricer_->quantoAmount(); + } + + EquityQuantoCashFlowPricer::EquityQuantoCashFlowPricer( + Handle quantoCurrencyTermStructure, + Handle equityVolatility, + Handle fxVolatility, + Handle correlation) + : quantoCurrencyTermStructure_(std::move(quantoCurrencyTermStructure)), + equityVolatility_(std::move(equityVolatility)), fxVolatility_(std::move(fxVolatility)), + correlation_(std::move(correlation)){ + registerWith(quantoCurrencyTermStructure_); + registerWith(equityVolatility_); + registerWith(fxVolatility_); + registerWith(correlation_); + } + + void EquityQuantoCashFlowPricer::initialize(const EquityQuantoCashFlow& cashFlow) { + cashFlow_ = dynamic_cast(&cashFlow); + QL_REQUIRE(cashFlow_, "Equity quanto cash flow needed."); + QL_REQUIRE( + !quantoCurrencyTermStructure_.empty() && !equityVolatility_.empty() && + !fxVolatility_.empty(), + "Quanto currency, equity and FX volatility term structure handles cannot be empty."); + QL_REQUIRE(quantoCurrencyTermStructure_->referenceDate() == + equityVolatility_->referenceDate() && + equityVolatility_->referenceDate() == fxVolatility_->referenceDate(), + "Quanto currency term structure, equity and FX volatility need to have the same " + "reference date."); + } + + Real EquityQuantoCashFlowPricer::quantoAmount() const { + const ext::shared_ptr& originalIndex = cashFlow_->equityIndex(); + auto endDate = cashFlow_->endDate(); + auto strike = originalIndex->fixing(endDate); + + Handle quantoTermStructure(ext::make_shared( + originalIndex->equityDividendCurve(), quantoCurrencyTermStructure_, + originalIndex->equityInterestRateCurve(), equityVolatility_, strike, fxVolatility_, 1.0, + correlation_->value())); + + ext::shared_ptr quantoIndex = originalIndex->clone( + quantoCurrencyTermStructure_, quantoTermStructure, originalIndex->spot()); + + auto quantoCashFlow = ext::make_shared(cashFlow_->notional(), quantoIndex, + cashFlow_->startDate(), endDate, + cashFlow_->paymentDate(), true); + + return quantoCashFlow->amount(); + } +} \ No newline at end of file diff --git a/ql/cashflows/equityquantocashflow.hpp b/ql/cashflows/equityquantocashflow.hpp new file mode 100644 index 00000000000..9abda448466 --- /dev/null +++ b/ql/cashflows/equityquantocashflow.hpp @@ -0,0 +1,107 @@ +/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + Copyright (C) 2023 Marcin Rybacki + + 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. +*/ + +/*! \file equityquantocashflow.hpp + \brief equity quanto cash flow +*/ + +#ifndef quantlib_equity_quanto_cash_flow_hpp +#define quantlib_equity_quanto_cash_flow_hpp + +#include +#include +#include +#include + +namespace QuantLib { + + class EquityIndex; + class EquityQuantoCashFlowPricer; + + class EquityQuantoCashFlow : public CashFlow, public Observer { + public: + EquityQuantoCashFlow(Real notional, + ext::shared_ptr equityIndex, + const Date& startDate, + const Date& endDate, + const Date& paymentDate); + //! \name Inspectors + //@{ + Real notional() const { return notional_; } + const ext::shared_ptr& equityIndex() const { return equityIndex_; } + Date startDate() const { return startDate_; } + Date endDate() const { return endDate_; } + Date paymentDate() const { return paymentDate_; } + //@} + //! \name CashFlow interface + //@{ + Real amount() const override; + //@} + //! \name Observer interface + //@{ + void update() override { notifyObservers(); } + //@} + //! \name Visitability + //@{ + void accept(AcyclicVisitor&) override; + //@} + void setPricer(const ext::shared_ptr&); + const ext::shared_ptr& pricer() const { return pricer_; }; + + private: + Real notional_; + ext::shared_ptr equityIndex_; + Date startDate_, endDate_, paymentDate_; + ext::shared_ptr pricer_; + }; + + inline void EquityQuantoCashFlow::accept(AcyclicVisitor& v) { + auto* v1 = dynamic_cast*>(&v); + if (v1 != nullptr) + v1->visit(*this); + else + CashFlow::accept(v); + } + + class EquityQuantoCashFlowPricer : public virtual Observer, public virtual Observable { + public: + EquityQuantoCashFlowPricer(Handle quantoCurrencyTermStructure, + Handle equityVolatility, + Handle fxVolatility, + Handle correlation); + //! \name Interface + //@{ + virtual Real quantoAmount() const; + virtual void initialize(const EquityQuantoCashFlow&); + //@} + + //! \name Observer interface + //@{ + void update() override { notifyObservers(); } + //@} + private: + Handle quantoCurrencyTermStructure_, quantoTermStructure; + Handle equityVolatility_, fxVolatility_; + Handle correlation_; + + const EquityQuantoCashFlow* cashFlow_; + }; +} + +#endif \ No newline at end of file diff --git a/ql/instruments/equitytotalreturnswap.cpp b/ql/instruments/equitytotalreturnswap.cpp index 094653f0203..6ed948b274e 100644 --- a/ql/instruments/equitytotalreturnswap.cpp +++ b/ql/instruments/equitytotalreturnswap.cpp @@ -26,27 +26,6 @@ Copyright (C) 2023 Marcin Rybacki namespace QuantLib { namespace { - ext::shared_ptr - createEquityCashFlow(const Schedule& schedule, - const ext::shared_ptr& equityIndex, - Real nominal, - const Calendar& paymentCalendar, - BusinessDayConvention paymentConvention, - Natural paymentDelay) { - Date startDate = schedule.startDate(); - Date endDate = schedule.endDate(); - - Calendar cal = paymentCalendar; - if (cal.empty()) { - QL_REQUIRE(!schedule.calendar().empty(), "Calendar in schedule cannot be empty"); - cal = schedule.calendar(); - } - Date paymentDate = - cal.advance(endDate, paymentDelay, Days, paymentConvention, schedule.endOfMonth()); - return ext::make_shared(nominal, equityIndex, startDate, endDate, - paymentDate, true); - } - template Leg createInterestLeg(const Schedule& schedule, const ext::shared_ptr& interestRateIndex, @@ -68,6 +47,21 @@ namespace QuantLib { } } + ext::shared_ptr EquityTotalReturnSwap::createEquityCashFlow() const { + Date startDate = schedule_.startDate(); + Date endDate = schedule_.endDate(); + + Calendar cal = paymentCalendar_; + if (cal.empty()) { + QL_REQUIRE(!schedule_.calendar().empty(), "Calendar in schedule cannot be empty"); + cal = schedule_.calendar(); + } + Date paymentDate = + cal.advance(endDate, paymentDelay_, Days, paymentConvention_, schedule_.endOfMonth()); + return ext::make_shared(nominal_, equityIndex_, startDate, endDate, + paymentDate, true); + } + EquityTotalReturnSwap::EquityTotalReturnSwap(ext::shared_ptr equityIndex, const ext::shared_ptr& interestRateIndex, Type type, @@ -87,8 +81,7 @@ namespace QuantLib { QL_REQUIRE(!(nominal_ < 0.0), "Nominal cannot be negative"); - legs_[0].push_back(createEquityCashFlow(schedule_, equityIndex_, nominal_, paymentCalendar_, - paymentConvention_, paymentDelay_)); + legs_[0].push_back(createEquityCashFlow()); for (Leg::const_iterator i = legs_[0].begin(); i < legs_[0].end(); ++i) registerWith(*i); diff --git a/ql/instruments/equitytotalreturnswap.hpp b/ql/instruments/equitytotalreturnswap.hpp index 315569863ba..9f9106c08e9 100644 --- a/ql/instruments/equitytotalreturnswap.hpp +++ b/ql/instruments/equitytotalreturnswap.hpp @@ -102,6 +102,9 @@ namespace QuantLib { Real fairMargin() const; //@} + protected: + virtual ext::shared_ptr createEquityCashFlow() const; + private: EquityTotalReturnSwap(ext::shared_ptr equityIndex, const ext::shared_ptr& interestRateIndex, From 61d2ee807403fb8eb02aaa7e1a99051d8d869e92 Mon Sep 17 00:00:00 2001 From: Marcin Rybacki Date: Tue, 7 Mar 2023 22:29:52 +0100 Subject: [PATCH 040/292] Setting up equity quanto cash flow and the pricer. --- ql/cashflows/equityquantocashflow.cpp | 20 ++++++++++++++------ ql/cashflows/equityquantocashflow.hpp | 2 ++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ql/cashflows/equityquantocashflow.cpp b/ql/cashflows/equityquantocashflow.cpp index ea7066d61a0..5f002b48599 100644 --- a/ql/cashflows/equityquantocashflow.cpp +++ b/ql/cashflows/equityquantocashflow.cpp @@ -24,6 +24,15 @@ namespace QuantLib { + void setCouponPricer(const Leg& leg, const ext::shared_ptr& p) { + for (const auto& i : leg) { + ext::shared_ptr c = + ext::dynamic_pointer_cast(i); + if (c != nullptr) + c->setPricer(p); + } + } + EquityQuantoCashFlow::EquityQuantoCashFlow(Real notional, ext::shared_ptr equityIndex, const Date& startDate, @@ -45,7 +54,7 @@ namespace QuantLib { } Real EquityQuantoCashFlow::amount() const { - QL_REQUIRE(pricer_, "pricer not set"); + QL_REQUIRE(pricer_, "Equity quanto cash flow pricer not set."); pricer_->initialize(*this); return pricer_->quantoAmount(); } @@ -90,11 +99,10 @@ namespace QuantLib { ext::shared_ptr quantoIndex = originalIndex->clone( quantoCurrencyTermStructure_, quantoTermStructure, originalIndex->spot()); - - auto quantoCashFlow = ext::make_shared(cashFlow_->notional(), quantoIndex, - cashFlow_->startDate(), endDate, - cashFlow_->paymentDate(), true); - return quantoCashFlow->amount(); + Real I0 = quantoIndex->fixing(cashFlow_->startDate()); + Real I1 = quantoIndex->fixing(endDate); + + return cashFlow_->notional() * (I1 / I0 - 1.0); } } \ No newline at end of file diff --git a/ql/cashflows/equityquantocashflow.hpp b/ql/cashflows/equityquantocashflow.hpp index 9abda448466..18a0bc9d25c 100644 --- a/ql/cashflows/equityquantocashflow.hpp +++ b/ql/cashflows/equityquantocashflow.hpp @@ -79,6 +79,8 @@ namespace QuantLib { CashFlow::accept(v); } + void setCouponPricer(const Leg& leg, const ext::shared_ptr&); + class EquityQuantoCashFlowPricer : public virtual Observer, public virtual Observable { public: EquityQuantoCashFlowPricer(Handle quantoCurrencyTermStructure, From 79d29b6403a28cec4c6714dd0b65be6193766a61 Mon Sep 17 00:00:00 2001 From: Marcin Rybacki Date: Wed, 8 Mar 2023 13:52:56 +0100 Subject: [PATCH 041/292] Introduced inheritance from IndexedCashFlow. --- ql/cashflows/equityquantocashflow.cpp | 31 ++++++++++++------------- ql/cashflows/equityquantocashflow.hpp | 33 ++++++++++----------------- 2 files changed, 27 insertions(+), 37 deletions(-) diff --git a/ql/cashflows/equityquantocashflow.cpp b/ql/cashflows/equityquantocashflow.cpp index 5f002b48599..cee0a674e5f 100644 --- a/ql/cashflows/equityquantocashflow.cpp +++ b/ql/cashflows/equityquantocashflow.cpp @@ -34,15 +34,12 @@ namespace QuantLib { } EquityQuantoCashFlow::EquityQuantoCashFlow(Real notional, - ext::shared_ptr equityIndex, - const Date& startDate, - const Date& endDate, - const Date& paymentDate) - : notional_(notional), equityIndex_(std::move(equityIndex)), startDate_(startDate), - endDate_(endDate), paymentDate_(paymentDate) { - registerWith(equityIndex_); - registerWith(Settings::instance().evaluationDate()); - } + ext::shared_ptr index, + const Date& baseDate, + const Date& fixingDate, + const Date& paymentDate, + bool growthOnly) + : IndexedCashFlow(notional, std::move(index), baseDate, fixingDate, paymentDate, growthOnly) {} void EquityQuantoCashFlow::setPricer(const ext::shared_ptr& pricer) { if (pricer_ != nullptr) @@ -56,7 +53,7 @@ namespace QuantLib { Real EquityQuantoCashFlow::amount() const { QL_REQUIRE(pricer_, "Equity quanto cash flow pricer not set."); pricer_->initialize(*this); - return pricer_->quantoAmount(); + return notional() * pricer_->quantoPrice(); } EquityQuantoCashFlowPricer::EquityQuantoCashFlowPricer( @@ -87,10 +84,10 @@ namespace QuantLib { "reference date."); } - Real EquityQuantoCashFlowPricer::quantoAmount() const { + Real EquityQuantoCashFlowPricer::quantoPrice() const { const ext::shared_ptr& originalIndex = cashFlow_->equityIndex(); - auto endDate = cashFlow_->endDate(); - auto strike = originalIndex->fixing(endDate); + Date fixingDate = cashFlow_->fixingDate(); + Real strike = originalIndex->fixing(fixingDate); Handle quantoTermStructure(ext::make_shared( originalIndex->equityDividendCurve(), quantoCurrencyTermStructure_, @@ -100,9 +97,11 @@ namespace QuantLib { ext::shared_ptr quantoIndex = originalIndex->clone( quantoCurrencyTermStructure_, quantoTermStructure, originalIndex->spot()); - Real I0 = quantoIndex->fixing(cashFlow_->startDate()); - Real I1 = quantoIndex->fixing(endDate); + Real I0 = quantoIndex->fixing(cashFlow_->baseDate()); + Real I1 = quantoIndex->fixing(fixingDate); - return cashFlow_->notional() * (I1 / I0 - 1.0); + if (cashFlow_->growthOnly()) + return I1 / I0 - 1.0; + return I1 / I0; } } \ No newline at end of file diff --git a/ql/cashflows/equityquantocashflow.hpp b/ql/cashflows/equityquantocashflow.hpp index 18a0bc9d25c..d8fa0d4e36b 100644 --- a/ql/cashflows/equityquantocashflow.hpp +++ b/ql/cashflows/equityquantocashflow.hpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include namespace QuantLib { @@ -34,29 +34,22 @@ namespace QuantLib { class EquityIndex; class EquityQuantoCashFlowPricer; - class EquityQuantoCashFlow : public CashFlow, public Observer { + class EquityQuantoCashFlow : public IndexedCashFlow { public: EquityQuantoCashFlow(Real notional, - ext::shared_ptr equityIndex, - const Date& startDate, - const Date& endDate, - const Date& paymentDate); - //! \name Inspectors - //@{ - Real notional() const { return notional_; } + ext::shared_ptr index, + const Date& baseDate, + const Date& fixingDate, + const Date& paymentDate, + bool growthOnly = true); + //! \name EquityQuantoCashFlow interface + //@{ const ext::shared_ptr& equityIndex() const { return equityIndex_; } - Date startDate() const { return startDate_; } - Date endDate() const { return endDate_; } - Date paymentDate() const { return paymentDate_; } - //@} + //@} //! \name CashFlow interface //@{ Real amount() const override; //@} - //! \name Observer interface - //@{ - void update() override { notifyObservers(); } - //@} //! \name Visitability //@{ void accept(AcyclicVisitor&) override; @@ -65,9 +58,7 @@ namespace QuantLib { const ext::shared_ptr& pricer() const { return pricer_; }; private: - Real notional_; ext::shared_ptr equityIndex_; - Date startDate_, endDate_, paymentDate_; ext::shared_ptr pricer_; }; @@ -76,7 +67,7 @@ namespace QuantLib { if (v1 != nullptr) v1->visit(*this); else - CashFlow::accept(v); + IndexedCashFlow::accept(v); } void setCouponPricer(const Leg& leg, const ext::shared_ptr&); @@ -89,7 +80,7 @@ namespace QuantLib { Handle correlation); //! \name Interface //@{ - virtual Real quantoAmount() const; + virtual Real quantoPrice() const; virtual void initialize(const EquityQuantoCashFlow&); //@} From 9e089821190ce56779723949560f023202c2b2a7 Mon Sep 17 00:00:00 2001 From: Marcin Rybacki Date: Wed, 8 Mar 2023 15:24:12 +0100 Subject: [PATCH 042/292] Added unit test files for equity quanto cash flow. --- test-suite/equityquantocashflow.cpp | 159 +++++++++++++++++++++++++++ test-suite/equityquantocashflow.hpp | 32 ++++++ test-suite/quantlibtestsuite.cpp | 2 + test-suite/testsuite.vcxproj | 2 + test-suite/testsuite.vcxproj.filters | 6 + 5 files changed, 201 insertions(+) create mode 100644 test-suite/equityquantocashflow.cpp create mode 100644 test-suite/equityquantocashflow.hpp diff --git a/test-suite/equityquantocashflow.cpp b/test-suite/equityquantocashflow.cpp new file mode 100644 index 00000000000..811318df573 --- /dev/null +++ b/test-suite/equityquantocashflow.cpp @@ -0,0 +1,159 @@ +/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + Copyright (C) 2023 Marcin Rybacki + + 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. +*/ + +#include "equityquantocashflow.hpp" +#include "utilities.hpp" +#include +#include +#include +#include + +using namespace QuantLib; +using namespace boost::unit_test_framework; + +namespace equityquantocashflow_test { + + // Used to check that the exception message contains the expected message string, expMsg. + struct ExpErrorPred { + + explicit ExpErrorPred(std::string msg) : expMsg(std::move(msg)) {} + + bool operator()(const Error& ex) const { + std::string errMsg(ex.what()); + if (errMsg.find(expMsg) == std::string::npos) { + BOOST_TEST_MESSAGE("Error expected to contain: '" << expMsg << "'."); + BOOST_TEST_MESSAGE("Actual error is: '" << errMsg << "'."); + return false; + } else { + return true; + } + } + + std::string expMsg; + }; + + struct CommonVars { + + Date today; + Calendar calendar; + DayCounter dayCount; + + Real notional; + + ext::shared_ptr equityIndex; + + RelinkableHandle localCcyInterestHandle; + RelinkableHandle dividendHandle; + RelinkableHandle quantoCcyInterestHandle; + + RelinkableHandle equityVolHandle; + RelinkableHandle fxVolHandle; + + RelinkableHandle spotHandle; + RelinkableHandle correlationHandle; + + // cleanup + SavedSettings backup; + // utilities + + CommonVars() { + calendar = TARGET(); + dayCount = Actual365Fixed(); + notional = 1.0e7; + + today = calendar.adjust(Date(27, January, 2023)); + Settings::instance().evaluationDate() = today; + + equityIndex = ext::make_shared("eqIndex", calendar, localCcyInterestHandle, + dividendHandle, spotHandle); + IndexManager::instance().clearHistory(equityIndex->name()); + equityIndex->addFixing(Date(5, January, 2023), 9010.0); + equityIndex->addFixing(today, 8690.0); + + localCcyInterestHandle.linkTo(flatRate(0.0375, dayCount)); + dividendHandle.linkTo(flatRate(0.005, dayCount)); + quantoCcyInterestHandle.linkTo(flatRate(0.001, dayCount)); + + equityVolHandle.linkTo(flatVol(0.4, dayCount)); + fxVolHandle.linkTo(flatVol(0.2, dayCount)); + + spotHandle.linkTo(ext::make_shared(8700.0)); + correlationHandle.linkTo(ext::make_shared(0.4)); + } + + ext::shared_ptr createEquityQuantoCashFlow(const Date& start, + const Date& end) { + return ext::make_shared(notional, equityIndex, start, end, end); + } + + ext::shared_ptr createEquityQuantoPricer() { + return ext::make_shared( + quantoCcyInterestHandle, equityVolHandle, fxVolHandle, correlationHandle); + } + }; +} + +void EquityQuantoCashFlowTest::test() { + BOOST_TEST_MESSAGE("Testing quanto correction..."); + + using namespace equityquantocashflow_test; + + const Real tolerance = 1.0e-6; + + CommonVars vars; + + Date startDate(5, January, 2023); + Date endDate(5, April, 2023); + + auto cf = vars.createEquityQuantoCashFlow(startDate, endDate); + auto pricer = vars.createEquityQuantoPricer(); + cf->setPricer(pricer); + + Real strike = vars.equityIndex->fixing(endDate); + Real indexStart = vars.equityIndex->fixing(startDate); + + Real time = vars.localCcyInterestHandle->timeFromReference(endDate); + Real rf = vars.localCcyInterestHandle->zeroRate(time, Continuous); + Real eqVol = vars.equityVolHandle->blackVol(endDate, strike); + Real fxVol = vars.fxVolHandle->blackVol(endDate, 1.0); + Real rho = vars.correlationHandle->value(); + Real spot = vars.spotHandle->value(); + + Real quantoForward = spot * std::exp((rf - rho * eqVol * fxVol) * time); + Real expectedAmount = (quantoForward / indexStart - 1.0) * vars.notional; + + Real actualAmount = cf->amount(); + + if ((std::fabs(actualAmount - expectedAmount) > tolerance)) + BOOST_ERROR("could not replicate equity quanto correction\n" + << " actual amount: " << actualAmount << "\n" + << " expected amount: " << expectedAmount << "\n" + << " local rate: " << rf << "\n" + << " equity volatility: " << eqVol << "\n" + << " FX volatility: " << fxVol << "\n" + << " correlation: " << rho << "\n" + << " spot: " << spot << "\n"); +} + +test_suite* EquityQuantoCashFlowTest::suite() { + auto* suite = BOOST_TEST_SUITE("Equity quanto cash flow tests"); + + suite->add(QUANTLIB_TEST_CASE(&EquityQuantoCashFlowTest::test)); + + return suite; +} \ No newline at end of file diff --git a/test-suite/equityquantocashflow.hpp b/test-suite/equityquantocashflow.hpp new file mode 100644 index 00000000000..35c5d9e7aaa --- /dev/null +++ b/test-suite/equityquantocashflow.hpp @@ -0,0 +1,32 @@ +/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + Copyright (C) 2023 Marcin Rybacki + + 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_test_equityquantocashflow_hpp +#define quantlib_test_equityquantocashflow_hpp + +#include + +class EquityQuantoCashFlowTest { + public: + static void test(); + + static boost::unit_test_framework::test_suite* suite(); +}; + +#endif \ No newline at end of file diff --git a/test-suite/quantlibtestsuite.cpp b/test-suite/quantlibtestsuite.cpp index 6201c7fd594..a83128de307 100644 --- a/test-suite/quantlibtestsuite.cpp +++ b/test-suite/quantlibtestsuite.cpp @@ -93,6 +93,7 @@ #include "europeanoption.hpp" #include "everestoption.hpp" #include "equityindex.hpp" +#include "equityquantocashflow.hpp" #include "equitytotalreturnswap.hpp" #include "exchangerate.hpp" #include "extendedtrees.hpp" @@ -389,6 +390,7 @@ test_suite* init_unit_test_suite(int, char* []) { test->add(DistributionTest::suite(speed)); test->add(DividendOptionTest::suite()); test->add(EquityIndexTest::suite()); + test->add(EquityQuantoCashFlowTest::suite()); test->add(EquityTotalReturnSwapTest::suite()); test->add(EuropeanOptionTest::suite()); test->add(ExchangeRateTest::suite()); diff --git a/test-suite/testsuite.vcxproj b/test-suite/testsuite.vcxproj index fad1d32af30..f510a5a9302 100644 --- a/test-suite/testsuite.vcxproj +++ b/test-suite/testsuite.vcxproj @@ -688,6 +688,7 @@ + @@ -857,6 +858,7 @@ + diff --git a/test-suite/testsuite.vcxproj.filters b/test-suite/testsuite.vcxproj.filters index 38425d8d059..31649bdfe49 100644 --- a/test-suite/testsuite.vcxproj.filters +++ b/test-suite/testsuite.vcxproj.filters @@ -510,6 +510,9 @@ Source Files + + Source Files + @@ -1019,5 +1022,8 @@ Header Files + + Header Files + \ No newline at end of file From 00ffe231e23b15d4d0d084f858c9f25046ab127f Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Wed, 8 Mar 2023 19:58:51 +0100 Subject: [PATCH 043/292] add function to enable single notification recursively --- ql/patterns/lazyobject.hpp | 12 ++++++++++++ ql/patterns/observable.hpp | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/ql/patterns/lazyobject.hpp b/ql/patterns/lazyobject.hpp index 2f6fd0ebd39..d359ec1b47e 100644 --- a/ql/patterns/lazyobject.hpp +++ b/ql/patterns/lazyobject.hpp @@ -176,6 +176,18 @@ namespace QuantLib { } } } + + /*! Calls fowardFirstNotificationOnly on o and all observables of o that are a lazy object, + recursively. This reduces the number of notifications sent from the lazy objects, but might + result in missing recalculations of objects observing one of the lazy object directly or + indireclty. */ + inline void enableSingleNotificationFromLazyObjects(ext::shared_ptr& o) { + if (auto l = ext::dynamic_pointer_cast(o)) + l->forwardFirstNotificationOnly(); + for (auto& o : o->observables()) + if (auto l = ext::dynamic_pointer_cast(o)) + enableSingleNotificationFromLazyObjects(l); + } } #endif diff --git a/ql/patterns/observable.hpp b/ql/patterns/observable.hpp index 1523307c533..320d012e1fb 100644 --- a/ql/patterns/observable.hpp +++ b/ql/patterns/observable.hpp @@ -149,6 +149,11 @@ namespace QuantLib { should be implemented in derived classes whenever applicable */ virtual void deepUpdate(); + /*! returns the set of observables */ + const boost::unordered_set>& observables() const { + return observables_; + } + private: QL_DEPRECATED_DISABLE_WARNING set_type observables_; From 4d6a70a6f5368724e1b93df08e55c787919a847b Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Wed, 8 Mar 2023 19:59:28 +0100 Subject: [PATCH 044/292] fix unit test case --- test-suite/piecewiseyieldcurve.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test-suite/piecewiseyieldcurve.cpp b/test-suite/piecewiseyieldcurve.cpp index 6be88eca41e..80431cef229 100644 --- a/test-suite/piecewiseyieldcurve.cpp +++ b/test-suite/piecewiseyieldcurve.cpp @@ -824,6 +824,10 @@ void PiecewiseYieldCurveTest::testObservability() { vars.calendar, vars.instruments, Actual360())); + + auto o = ext::static_pointer_cast(vars.termStructure); + enableSingleNotificationFromLazyObjects(o); + Flag f; f.registerWith(vars.termStructure); From be329691d02738a90c0cd2af3689a934590c3d51 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Thu, 9 Mar 2023 07:54:36 +0100 Subject: [PATCH 045/292] fixes --- ql/patterns/lazyobject.hpp | 6 +++--- test-suite/piecewiseyieldcurve.cpp | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ql/patterns/lazyobject.hpp b/ql/patterns/lazyobject.hpp index d359ec1b47e..223191485a3 100644 --- a/ql/patterns/lazyobject.hpp +++ b/ql/patterns/lazyobject.hpp @@ -181,11 +181,11 @@ namespace QuantLib { recursively. This reduces the number of notifications sent from the lazy objects, but might result in missing recalculations of objects observing one of the lazy object directly or indireclty. */ - inline void enableSingleNotificationFromLazyObjects(ext::shared_ptr& o) { + inline void enableSingleNotificationFromLazyObjects(ext::shared_ptr o) { if (auto l = ext::dynamic_pointer_cast(o)) l->forwardFirstNotificationOnly(); - for (auto& o : o->observables()) - if (auto l = ext::dynamic_pointer_cast(o)) + for (auto& p : o->observables()) + if (auto l = ext::dynamic_pointer_cast(p)) enableSingleNotificationFromLazyObjects(l); } } diff --git a/test-suite/piecewiseyieldcurve.cpp b/test-suite/piecewiseyieldcurve.cpp index 80431cef229..49ff451aad7 100644 --- a/test-suite/piecewiseyieldcurve.cpp +++ b/test-suite/piecewiseyieldcurve.cpp @@ -825,8 +825,7 @@ void PiecewiseYieldCurveTest::testObservability() { vars.instruments, Actual360())); - auto o = ext::static_pointer_cast(vars.termStructure); - enableSingleNotificationFromLazyObjects(o); + enableSingleNotificationFromLazyObjects(vars.termStructure); Flag f; f.registerWith(vars.termStructure); From f1abb78a22b6a850f7105a59c1a8b71aacc5c8e7 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Thu, 9 Mar 2023 08:22:02 +0100 Subject: [PATCH 046/292] expose observables for enabled thread safe observer pattern --- ql/patterns/observable.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ql/patterns/observable.hpp b/ql/patterns/observable.hpp index 320d012e1fb..515ce340d99 100644 --- a/ql/patterns/observable.hpp +++ b/ql/patterns/observable.hpp @@ -324,6 +324,11 @@ namespace QuantLib { should be implemented in derived classes whenever applicable */ virtual void deepUpdate(); + /*! returns the set of observables */ + const boost::unordered_set>& observables() const { + return observables_; + } + private: class Proxy { From 47b0558a80e38a16f42119a4bcdcd4bf3d8767f6 Mon Sep 17 00:00:00 2001 From: Marcin Rybacki Date: Thu, 9 Mar 2023 11:12:21 +0100 Subject: [PATCH 047/292] Introduced general equity cash flow. --- QuantLib.vcxproj | 4 +- QuantLib.vcxproj.filters | 4 +- ...yquantocashflow.cpp => equitycashflow.cpp} | 63 ++++++++-------- ...yquantocashflow.hpp => equitycashflow.hpp} | 71 ++++++++++--------- ql/instruments/equitytotalreturnswap.cpp | 5 +- ...yquantocashflow.cpp => equitycashflow.cpp} | 23 +++--- ...yquantocashflow.hpp => equitycashflow.hpp} | 6 +- test-suite/quantlibtestsuite.cpp | 4 +- test-suite/testsuite.vcxproj | 4 +- test-suite/testsuite.vcxproj.filters | 4 +- 10 files changed, 100 insertions(+), 88 deletions(-) rename ql/cashflows/{equityquantocashflow.cpp => equitycashflow.cpp} (61%) rename ql/cashflows/{equityquantocashflow.hpp => equitycashflow.hpp} (60%) rename test-suite/{equityquantocashflow.cpp => equitycashflow.cpp} (88%) rename test-suite/{equityquantocashflow.hpp => equitycashflow.hpp} (88%) diff --git a/QuantLib.vcxproj b/QuantLib.vcxproj index 2dbf980019b..693142932bb 100644 --- a/QuantLib.vcxproj +++ b/QuantLib.vcxproj @@ -517,7 +517,7 @@ - + @@ -1912,7 +1912,7 @@ - + diff --git a/QuantLib.vcxproj.filters b/QuantLib.vcxproj.filters index ca4695a4d28..13127a8c1fc 100644 --- a/QuantLib.vcxproj.filters +++ b/QuantLib.vcxproj.filters @@ -4439,7 +4439,7 @@ instruments - + cashflows @@ -7171,7 +7171,7 @@ instruments - + cashflows diff --git a/ql/cashflows/equityquantocashflow.cpp b/ql/cashflows/equitycashflow.cpp similarity index 61% rename from ql/cashflows/equityquantocashflow.cpp rename to ql/cashflows/equitycashflow.cpp index cee0a674e5f..6d4cf2ca3bc 100644 --- a/ql/cashflows/equityquantocashflow.cpp +++ b/ql/cashflows/equitycashflow.cpp @@ -17,31 +17,31 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -#include +#include #include #include #include namespace QuantLib { - void setCouponPricer(const Leg& leg, const ext::shared_ptr& p) { + void setCouponPricer(const Leg& leg, const ext::shared_ptr& p) { for (const auto& i : leg) { - ext::shared_ptr c = - ext::dynamic_pointer_cast(i); + ext::shared_ptr c = + ext::dynamic_pointer_cast(i); if (c != nullptr) c->setPricer(p); } } - EquityQuantoCashFlow::EquityQuantoCashFlow(Real notional, - ext::shared_ptr index, - const Date& baseDate, - const Date& fixingDate, - const Date& paymentDate, - bool growthOnly) + EquityCashFlow::EquityCashFlow(Real notional, + ext::shared_ptr index, + const Date& baseDate, + const Date& fixingDate, + const Date& paymentDate, + bool growthOnly) : IndexedCashFlow(notional, std::move(index), baseDate, fixingDate, paymentDate, growthOnly) {} - void EquityQuantoCashFlow::setPricer(const ext::shared_ptr& pricer) { + void EquityCashFlow::setPricer(const ext::shared_ptr& pricer) { if (pricer_ != nullptr) unregisterWith(pricer_); pricer_ = pricer; @@ -50,10 +50,11 @@ namespace QuantLib { update(); } - Real EquityQuantoCashFlow::amount() const { - QL_REQUIRE(pricer_, "Equity quanto cash flow pricer not set."); + Real EquityCashFlow::amount() const { + if (!pricer_) + return IndexedCashFlow::amount(); pricer_->initialize(*this); - return notional() * pricer_->quantoPrice(); + return notional() * pricer_->price(); } EquityQuantoCashFlowPricer::EquityQuantoCashFlowPricer( @@ -70,9 +71,16 @@ namespace QuantLib { registerWith(correlation_); } - void EquityQuantoCashFlowPricer::initialize(const EquityQuantoCashFlow& cashFlow) { - cashFlow_ = dynamic_cast(&cashFlow); - QL_REQUIRE(cashFlow_, "Equity quanto cash flow needed."); + void EquityQuantoCashFlowPricer::initialize(const EquityCashFlow& cashFlow) { + index_ = ext::dynamic_pointer_cast(cashFlow.index()); + if (!index_) { + QL_FAIL("Equity index required."); + } + baseDate_ = cashFlow.baseDate(); + fixingDate_ = cashFlow.fixingDate(); + QL_REQUIRE(fixingDate_ >= baseDate_, "Fixing date cannot fall before base date."); + growthOnlyPayoff_ = cashFlow.growthOnly(); + QL_REQUIRE( !quantoCurrencyTermStructure_.empty() && !equityVolatility_.empty() && !fxVolatility_.empty(), @@ -84,23 +92,20 @@ namespace QuantLib { "reference date."); } - Real EquityQuantoCashFlowPricer::quantoPrice() const { - const ext::shared_ptr& originalIndex = cashFlow_->equityIndex(); - Date fixingDate = cashFlow_->fixingDate(); - Real strike = originalIndex->fixing(fixingDate); + Real EquityQuantoCashFlowPricer::price() const { + Real strike = index_->fixing(fixingDate_); Handle quantoTermStructure(ext::make_shared( - originalIndex->equityDividendCurve(), quantoCurrencyTermStructure_, - originalIndex->equityInterestRateCurve(), equityVolatility_, strike, fxVolatility_, 1.0, + index_->equityDividendCurve(), quantoCurrencyTermStructure_, + index_->equityInterestRateCurve(), equityVolatility_, strike, fxVolatility_, 1.0, correlation_->value())); - - ext::shared_ptr quantoIndex = originalIndex->clone( - quantoCurrencyTermStructure_, quantoTermStructure, originalIndex->spot()); + ext::shared_ptr quantoIndex = + index_->clone(quantoCurrencyTermStructure_, quantoTermStructure, index_->spot()); - Real I0 = quantoIndex->fixing(cashFlow_->baseDate()); - Real I1 = quantoIndex->fixing(fixingDate); + Real I0 = quantoIndex->fixing(baseDate_); + Real I1 = quantoIndex->fixing(fixingDate_); - if (cashFlow_->growthOnly()) + if (growthOnlyPayoff_) return I1 / I0 - 1.0; return I1 / I0; } diff --git a/ql/cashflows/equityquantocashflow.hpp b/ql/cashflows/equitycashflow.hpp similarity index 60% rename from ql/cashflows/equityquantocashflow.hpp rename to ql/cashflows/equitycashflow.hpp index d8fa0d4e36b..4ae554f458c 100644 --- a/ql/cashflows/equityquantocashflow.hpp +++ b/ql/cashflows/equitycashflow.hpp @@ -17,12 +17,12 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -/*! \file equityquantocashflow.hpp - \brief equity quanto cash flow +/*! \file equitycashflow.hpp + \brief equity cash flow */ -#ifndef quantlib_equity_quanto_cash_flow_hpp -#define quantlib_equity_quanto_cash_flow_hpp +#ifndef quantlib_equity_cash_flow_hpp +#define quantlib_equity_cash_flow_hpp #include #include @@ -32,20 +32,16 @@ namespace QuantLib { class EquityIndex; - class EquityQuantoCashFlowPricer; + class EquityCashFlowPricer; - class EquityQuantoCashFlow : public IndexedCashFlow { + class EquityCashFlow : public IndexedCashFlow { public: - EquityQuantoCashFlow(Real notional, - ext::shared_ptr index, - const Date& baseDate, - const Date& fixingDate, - const Date& paymentDate, - bool growthOnly = true); - //! \name EquityQuantoCashFlow interface - //@{ - const ext::shared_ptr& equityIndex() const { return equityIndex_; } - //@} + EquityCashFlow(Real notional, + ext::shared_ptr index, + const Date& baseDate, + const Date& fixingDate, + const Date& paymentDate, + bool growthOnly = true); //! \name CashFlow interface //@{ Real amount() const override; @@ -54,46 +50,57 @@ namespace QuantLib { //@{ void accept(AcyclicVisitor&) override; //@} - void setPricer(const ext::shared_ptr&); - const ext::shared_ptr& pricer() const { return pricer_; }; + void setPricer(const ext::shared_ptr&); + const ext::shared_ptr& pricer() const { return pricer_; }; private: - ext::shared_ptr equityIndex_; - ext::shared_ptr pricer_; + ext::shared_ptr pricer_; }; - inline void EquityQuantoCashFlow::accept(AcyclicVisitor& v) { - auto* v1 = dynamic_cast*>(&v); + inline void EquityCashFlow::accept(AcyclicVisitor& v) { + auto* v1 = dynamic_cast*>(&v); if (v1 != nullptr) v1->visit(*this); else IndexedCashFlow::accept(v); } - void setCouponPricer(const Leg& leg, const ext::shared_ptr&); + void setCouponPricer(const Leg& leg, const ext::shared_ptr&); - class EquityQuantoCashFlowPricer : public virtual Observer, public virtual Observable { + class EquityCashFlowPricer : public virtual Observer, public virtual Observable { public: - EquityQuantoCashFlowPricer(Handle quantoCurrencyTermStructure, - Handle equityVolatility, - Handle fxVolatility, - Handle correlation); + EquityCashFlowPricer() = default; //! \name Interface //@{ - virtual Real quantoPrice() const; - virtual void initialize(const EquityQuantoCashFlow&); + virtual Real price() const = 0; + virtual void initialize(const EquityCashFlow&) = 0; //@} //! \name Observer interface //@{ void update() override { notifyObservers(); } //@} + protected: + ext::shared_ptr index_; + Date baseDate_, fixingDate_; + bool growthOnlyPayoff_; + }; + + class EquityQuantoCashFlowPricer : public EquityCashFlowPricer { + public: + EquityQuantoCashFlowPricer(Handle quantoCurrencyTermStructure, + Handle equityVolatility, + Handle fxVolatility, + Handle correlation); + //! \name Interface + //@{ + Real price() const override; + void initialize(const EquityCashFlow&) override; + //@} private: Handle quantoCurrencyTermStructure_, quantoTermStructure; Handle equityVolatility_, fxVolatility_; Handle correlation_; - - const EquityQuantoCashFlow* cashFlow_; }; } diff --git a/ql/instruments/equitytotalreturnswap.cpp b/ql/instruments/equitytotalreturnswap.cpp index 6ed948b274e..dc4cee6bd39 100644 --- a/ql/instruments/equitytotalreturnswap.cpp +++ b/ql/instruments/equitytotalreturnswap.cpp @@ -21,7 +21,7 @@ Copyright (C) 2023 Marcin Rybacki #include #include #include -#include +#include namespace QuantLib { @@ -58,8 +58,7 @@ namespace QuantLib { } Date paymentDate = cal.advance(endDate, paymentDelay_, Days, paymentConvention_, schedule_.endOfMonth()); - return ext::make_shared(nominal_, equityIndex_, startDate, endDate, - paymentDate, true); + return ext::make_shared(nominal_, equityIndex_, startDate, endDate, paymentDate); } EquityTotalReturnSwap::EquityTotalReturnSwap(ext::shared_ptr equityIndex, diff --git a/test-suite/equityquantocashflow.cpp b/test-suite/equitycashflow.cpp similarity index 88% rename from test-suite/equityquantocashflow.cpp rename to test-suite/equitycashflow.cpp index 811318df573..3ebcb0d464b 100644 --- a/test-suite/equityquantocashflow.cpp +++ b/test-suite/equitycashflow.cpp @@ -16,9 +16,9 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -#include "equityquantocashflow.hpp" +#include "equitycashflow.hpp" #include "utilities.hpp" -#include +#include #include #include #include @@ -26,7 +26,7 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -namespace equityquantocashflow_test { +namespace equitycashflow_test { // Used to check that the exception message contains the expected message string, expMsg. struct ExpErrorPred { @@ -96,22 +96,22 @@ namespace equityquantocashflow_test { correlationHandle.linkTo(ext::make_shared(0.4)); } - ext::shared_ptr createEquityQuantoCashFlow(const Date& start, + ext::shared_ptr createEquityQuantoCashFlow(const Date& start, const Date& end) { - return ext::make_shared(notional, equityIndex, start, end, end); + return ext::make_shared(notional, equityIndex, start, end, end); } - ext::shared_ptr createEquityQuantoPricer() { + ext::shared_ptr createEquityQuantoPricer() { return ext::make_shared( quantoCcyInterestHandle, equityVolHandle, fxVolHandle, correlationHandle); } }; } -void EquityQuantoCashFlowTest::test() { +void EquityCashFlowTest::test() { BOOST_TEST_MESSAGE("Testing quanto correction..."); - using namespace equityquantocashflow_test; + using namespace equitycashflow_test; const Real tolerance = 1.0e-6; @@ -129,12 +129,13 @@ void EquityQuantoCashFlowTest::test() { Real time = vars.localCcyInterestHandle->timeFromReference(endDate); Real rf = vars.localCcyInterestHandle->zeroRate(time, Continuous); + Real q = vars.dividendHandle->zeroRate(time, Continuous); Real eqVol = vars.equityVolHandle->blackVol(endDate, strike); Real fxVol = vars.fxVolHandle->blackVol(endDate, 1.0); Real rho = vars.correlationHandle->value(); Real spot = vars.spotHandle->value(); - Real quantoForward = spot * std::exp((rf - rho * eqVol * fxVol) * time); + Real quantoForward = spot * std::exp((rf - q - rho * eqVol * fxVol) * time); Real expectedAmount = (quantoForward / indexStart - 1.0) * vars.notional; Real actualAmount = cf->amount(); @@ -150,10 +151,10 @@ void EquityQuantoCashFlowTest::test() { << " spot: " << spot << "\n"); } -test_suite* EquityQuantoCashFlowTest::suite() { +test_suite* EquityCashFlowTest::suite() { auto* suite = BOOST_TEST_SUITE("Equity quanto cash flow tests"); - suite->add(QUANTLIB_TEST_CASE(&EquityQuantoCashFlowTest::test)); + suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::test)); return suite; } \ No newline at end of file diff --git a/test-suite/equityquantocashflow.hpp b/test-suite/equitycashflow.hpp similarity index 88% rename from test-suite/equityquantocashflow.hpp rename to test-suite/equitycashflow.hpp index 35c5d9e7aaa..771f737184f 100644 --- a/test-suite/equityquantocashflow.hpp +++ b/test-suite/equitycashflow.hpp @@ -17,12 +17,12 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -#ifndef quantlib_test_equityquantocashflow_hpp -#define quantlib_test_equityquantocashflow_hpp +#ifndef quantlib_test_equitycashflow_hpp +#define quantlib_test_equitycashflow_hpp #include -class EquityQuantoCashFlowTest { +class EquityCashFlowTest { public: static void test(); diff --git a/test-suite/quantlibtestsuite.cpp b/test-suite/quantlibtestsuite.cpp index a83128de307..619638f6bc7 100644 --- a/test-suite/quantlibtestsuite.cpp +++ b/test-suite/quantlibtestsuite.cpp @@ -93,7 +93,7 @@ #include "europeanoption.hpp" #include "everestoption.hpp" #include "equityindex.hpp" -#include "equityquantocashflow.hpp" +#include "equitycashflow.hpp" #include "equitytotalreturnswap.hpp" #include "exchangerate.hpp" #include "extendedtrees.hpp" @@ -390,7 +390,7 @@ test_suite* init_unit_test_suite(int, char* []) { test->add(DistributionTest::suite(speed)); test->add(DividendOptionTest::suite()); test->add(EquityIndexTest::suite()); - test->add(EquityQuantoCashFlowTest::suite()); + test->add(EquityCashFlowTest::suite()); test->add(EquityTotalReturnSwapTest::suite()); test->add(EuropeanOptionTest::suite()); test->add(ExchangeRateTest::suite()); diff --git a/test-suite/testsuite.vcxproj b/test-suite/testsuite.vcxproj index f510a5a9302..ac0657b3444 100644 --- a/test-suite/testsuite.vcxproj +++ b/test-suite/testsuite.vcxproj @@ -688,7 +688,7 @@ - + @@ -858,7 +858,7 @@ - + diff --git a/test-suite/testsuite.vcxproj.filters b/test-suite/testsuite.vcxproj.filters index 31649bdfe49..322335b83e2 100644 --- a/test-suite/testsuite.vcxproj.filters +++ b/test-suite/testsuite.vcxproj.filters @@ -510,7 +510,7 @@ Source Files - + Source Files @@ -1022,7 +1022,7 @@ Header Files - + Header Files From 12b2efd8c74ce22d590f4a587e9952b036e5abce Mon Sep 17 00:00:00 2001 From: Marcin Rybacki Date: Thu, 9 Mar 2023 18:07:16 +0100 Subject: [PATCH 048/292] Adjusted equity leg creation approach in the TRS. --- ql/instruments/equitytotalreturnswap.cpp | 38 ++++++++++++++---------- ql/instruments/equitytotalreturnswap.hpp | 1 - test-suite/equitycashflow.cpp | 4 +-- test-suite/equitycashflow.hpp | 2 +- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/ql/instruments/equitytotalreturnswap.cpp b/ql/instruments/equitytotalreturnswap.cpp index dc4cee6bd39..6d337d552fb 100644 --- a/ql/instruments/equitytotalreturnswap.cpp +++ b/ql/instruments/equitytotalreturnswap.cpp @@ -26,6 +26,27 @@ Copyright (C) 2023 Marcin Rybacki namespace QuantLib { namespace { + ext::shared_ptr + createEquityCashFlow(const Schedule& schedule, + const ext::shared_ptr& equityIndex, + Real nominal, + const Calendar& paymentCalendar, + BusinessDayConvention paymentConvention, + Natural paymentDelay) { + Date startDate = schedule.startDate(); + Date endDate = schedule.endDate(); + + Calendar cal = paymentCalendar; + if (cal.empty()) { + QL_REQUIRE(!schedule.calendar().empty(), "Calendar in schedule cannot be empty"); + cal = schedule.calendar(); + } + Date paymentDate = + cal.advance(endDate, paymentDelay, Days, paymentConvention, schedule.endOfMonth()); + return ext::make_shared(nominal, equityIndex, startDate, endDate, + paymentDate); + } + template Leg createInterestLeg(const Schedule& schedule, const ext::shared_ptr& interestRateIndex, @@ -47,20 +68,6 @@ namespace QuantLib { } } - ext::shared_ptr EquityTotalReturnSwap::createEquityCashFlow() const { - Date startDate = schedule_.startDate(); - Date endDate = schedule_.endDate(); - - Calendar cal = paymentCalendar_; - if (cal.empty()) { - QL_REQUIRE(!schedule_.calendar().empty(), "Calendar in schedule cannot be empty"); - cal = schedule_.calendar(); - } - Date paymentDate = - cal.advance(endDate, paymentDelay_, Days, paymentConvention_, schedule_.endOfMonth()); - return ext::make_shared(nominal_, equityIndex_, startDate, endDate, paymentDate); - } - EquityTotalReturnSwap::EquityTotalReturnSwap(ext::shared_ptr equityIndex, const ext::shared_ptr& interestRateIndex, Type type, @@ -80,7 +87,8 @@ namespace QuantLib { QL_REQUIRE(!(nominal_ < 0.0), "Nominal cannot be negative"); - legs_[0].push_back(createEquityCashFlow()); + legs_[0].push_back(createEquityCashFlow(schedule_, equityIndex_, nominal_, paymentCalendar_, + paymentConvention_, paymentDelay_)); for (Leg::const_iterator i = legs_[0].begin(); i < legs_[0].end(); ++i) registerWith(*i); diff --git a/ql/instruments/equitytotalreturnswap.hpp b/ql/instruments/equitytotalreturnswap.hpp index 9f9106c08e9..d578af59d45 100644 --- a/ql/instruments/equitytotalreturnswap.hpp +++ b/ql/instruments/equitytotalreturnswap.hpp @@ -103,7 +103,6 @@ namespace QuantLib { //@} protected: - virtual ext::shared_ptr createEquityCashFlow() const; private: EquityTotalReturnSwap(ext::shared_ptr equityIndex, diff --git a/test-suite/equitycashflow.cpp b/test-suite/equitycashflow.cpp index 3ebcb0d464b..6609612d9db 100644 --- a/test-suite/equitycashflow.cpp +++ b/test-suite/equitycashflow.cpp @@ -108,7 +108,7 @@ namespace equitycashflow_test { }; } -void EquityCashFlowTest::test() { +void EquityCashFlowTest::testQuantoCorrection() { BOOST_TEST_MESSAGE("Testing quanto correction..."); using namespace equitycashflow_test; @@ -154,7 +154,7 @@ void EquityCashFlowTest::test() { test_suite* EquityCashFlowTest::suite() { auto* suite = BOOST_TEST_SUITE("Equity quanto cash flow tests"); - suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::test)); + suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testQuantoCorrection)); return suite; } \ No newline at end of file diff --git a/test-suite/equitycashflow.hpp b/test-suite/equitycashflow.hpp index 771f737184f..533f553a55b 100644 --- a/test-suite/equitycashflow.hpp +++ b/test-suite/equitycashflow.hpp @@ -24,7 +24,7 @@ class EquityCashFlowTest { public: - static void test(); + static void testQuantoCorrection(); static boost::unit_test_framework::test_suite* suite(); }; From 325327550fda7dcc7eef5e772a8e271d18c54b25 Mon Sep 17 00:00:00 2001 From: Marcin Rybacki Date: Thu, 9 Mar 2023 18:08:22 +0100 Subject: [PATCH 049/292] Removed protected section from the TRS. --- ql/instruments/equitytotalreturnswap.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/ql/instruments/equitytotalreturnswap.hpp b/ql/instruments/equitytotalreturnswap.hpp index d578af59d45..315569863ba 100644 --- a/ql/instruments/equitytotalreturnswap.hpp +++ b/ql/instruments/equitytotalreturnswap.hpp @@ -102,8 +102,6 @@ namespace QuantLib { Real fairMargin() const; //@} - protected: - private: EquityTotalReturnSwap(ext::shared_ptr equityIndex, const ext::shared_ptr& interestRateIndex, From b60b649e7db908611c136d580ff5cf135d3bafbd Mon Sep 17 00:00:00 2001 From: Marcin Rybacki Date: Fri, 10 Mar 2023 12:03:59 +0100 Subject: [PATCH 050/292] Added more unit tests for equity cash flow and quanto pricer. --- ql/cashflows/equitycashflow.cpp | 23 +++- test-suite/equitycashflow.cpp | 187 +++++++++++++++++++++++++++----- test-suite/equitycashflow.hpp | 4 + 3 files changed, 187 insertions(+), 27 deletions(-) diff --git a/ql/cashflows/equitycashflow.cpp b/ql/cashflows/equitycashflow.cpp index 6d4cf2ca3bc..ab62c3097c1 100644 --- a/ql/cashflows/equitycashflow.cpp +++ b/ql/cashflows/equitycashflow.cpp @@ -21,9 +21,26 @@ #include #include #include +#include +#include +#include +#include namespace QuantLib { + namespace { + Handle + configureDividendHandle(const Handle& dividendHandle) { + if (dividendHandle.empty()) { + ext::shared_ptr flatTs(ext::make_shared( + 0, NullCalendar(), Handle(ext::make_shared(0.0)), + Actual365Fixed())); + return Handle(flatTs); + } + return dividendHandle; + } + } + void setCouponPricer(const Leg& leg, const ext::shared_ptr& p) { for (const auto& i : leg) { ext::shared_ptr c = @@ -94,9 +111,11 @@ namespace QuantLib { Real EquityQuantoCashFlowPricer::price() const { Real strike = index_->fixing(fixingDate_); - + Handle dividendHandle = + configureDividendHandle(index_->equityDividendCurve()); + Handle quantoTermStructure(ext::make_shared( - index_->equityDividendCurve(), quantoCurrencyTermStructure_, + dividendHandle, quantoCurrencyTermStructure_, index_->equityInterestRateCurve(), equityVolatility_, strike, fxVolatility_, 1.0, correlation_->value())); ext::shared_ptr quantoIndex = diff --git a/test-suite/equitycashflow.cpp b/test-suite/equitycashflow.cpp index 6609612d9db..51d0a84b3d8 100644 --- a/test-suite/equitycashflow.cpp +++ b/test-suite/equitycashflow.cpp @@ -96,20 +96,88 @@ namespace equitycashflow_test { correlationHandle.linkTo(ext::make_shared(0.4)); } - ext::shared_ptr createEquityQuantoCashFlow(const Date& start, - const Date& end) { - return ext::make_shared(notional, equityIndex, start, end, end); + ext::shared_ptr createEquityQuantoCashFlow( + const ext::shared_ptr& index, const Date& start, const Date& end) { + return ext::make_shared(notional, index, start, end, end); } ext::shared_ptr createEquityQuantoPricer() { return ext::make_shared( quantoCcyInterestHandle, equityVolHandle, fxVolHandle, correlationHandle); } + + ext::shared_ptr createEquityQuantoPricerWithMissingHandles() { + Handle vol; + return ext::make_shared(quantoCcyInterestHandle, vol, vol, + correlationHandle); + } }; + + void bumpMarketData(CommonVars& vars) { + + vars.localCcyInterestHandle.linkTo(flatRate(0.04, vars.dayCount)); + vars.dividendHandle.linkTo(flatRate(0.01, vars.dayCount)); + vars.quantoCcyInterestHandle.linkTo(flatRate(0.03, vars.dayCount)); + + vars.equityVolHandle.linkTo(flatVol(0.45, vars.dayCount)); + vars.fxVolHandle.linkTo(flatVol(0.25, vars.dayCount)); + + vars.spotHandle.linkTo(ext::make_shared(8710.0)); + } + + void checkQuantoCorrection(const Date& start, + const Date& end, + bool includeDividend, + bool bumpData = false) { + const Real tolerance = 1.0e-6; + + CommonVars vars; + + ext::shared_ptr equityIndex = + includeDividend ? + vars.equityIndex : + vars.equityIndex->clone(vars.localCcyInterestHandle, Handle(), + vars.spotHandle); + + auto cf = vars.createEquityQuantoCashFlow(equityIndex, start, end); + auto pricer = vars.createEquityQuantoPricer(); + cf->setPricer(pricer); + + if (bumpData) + bumpMarketData(vars); + + Real strike = vars.equityIndex->fixing(end); + Real indexStart = vars.equityIndex->fixing(start); + + Real time = vars.localCcyInterestHandle->timeFromReference(end); + Real rf = vars.localCcyInterestHandle->zeroRate(time, Continuous); + Real q = includeDividend ? vars.dividendHandle->zeroRate(time, Continuous) : 0.0; + Real eqVol = vars.equityVolHandle->blackVol(end, strike); + Real fxVol = vars.fxVolHandle->blackVol(end, 1.0); + Real rho = vars.correlationHandle->value(); + Real spot = vars.spotHandle->value(); + + Real quantoForward = spot * std::exp((rf - q - rho * eqVol * fxVol) * time); + Real expectedAmount = (quantoForward / indexStart - 1.0) * vars.notional; + + Real actualAmount = cf->amount(); + + if ((std::fabs(actualAmount - expectedAmount) > tolerance)) + BOOST_ERROR("could not replicate equity quanto correction\n" + << " actual amount: " << actualAmount << "\n" + << " expected amount: " << expectedAmount << "\n" + << " index start: " << indexStart << "\n" + << " index end: " << quantoForward << "\n" + << " local rate: " << rf << "\n" + << " equity volatility: " << eqVol << "\n" + << " FX volatility: " << fxVol << "\n" + << " correlation: " << rho << "\n" + << " spot: " << spot << "\n"); + } } -void EquityCashFlowTest::testQuantoCorrection() { - BOOST_TEST_MESSAGE("Testing quanto correction..."); +void EquityCashFlowTest::testSimpleEquityCashFlow() { + BOOST_TEST_MESSAGE("Testing simple equity cash flow..."); using namespace equitycashflow_test; @@ -120,41 +188,110 @@ void EquityCashFlowTest::testQuantoCorrection() { Date startDate(5, January, 2023); Date endDate(5, April, 2023); - auto cf = vars.createEquityQuantoCashFlow(startDate, endDate); - auto pricer = vars.createEquityQuantoPricer(); - cf->setPricer(pricer); + auto cf = vars.createEquityQuantoCashFlow(vars.equityIndex, startDate, endDate); - Real strike = vars.equityIndex->fixing(endDate); Real indexStart = vars.equityIndex->fixing(startDate); + Real indexEnd = vars.equityIndex->fixing(endDate); - Real time = vars.localCcyInterestHandle->timeFromReference(endDate); - Real rf = vars.localCcyInterestHandle->zeroRate(time, Continuous); - Real q = vars.dividendHandle->zeroRate(time, Continuous); - Real eqVol = vars.equityVolHandle->blackVol(endDate, strike); - Real fxVol = vars.fxVolHandle->blackVol(endDate, 1.0); - Real rho = vars.correlationHandle->value(); - Real spot = vars.spotHandle->value(); - - Real quantoForward = spot * std::exp((rf - q - rho * eqVol * fxVol) * time); - Real expectedAmount = (quantoForward / indexStart - 1.0) * vars.notional; + Real expectedAmount = (indexEnd / indexStart - 1.0) * vars.notional; Real actualAmount = cf->amount(); if ((std::fabs(actualAmount - expectedAmount) > tolerance)) - BOOST_ERROR("could not replicate equity quanto correction\n" + BOOST_ERROR("could not replicate simple equity quanto cash flow\n" << " actual amount: " << actualAmount << "\n" << " expected amount: " << expectedAmount << "\n" - << " local rate: " << rf << "\n" - << " equity volatility: " << eqVol << "\n" - << " FX volatility: " << fxVol << "\n" - << " correlation: " << rho << "\n" - << " spot: " << spot << "\n"); + << " index start: " << indexStart << "\n" + << " index end: " << indexEnd << "\n"); +} + +void EquityCashFlowTest::testQuantoCorrection() { + BOOST_TEST_MESSAGE("Testing quanto correction..."); + + using namespace equitycashflow_test; + + Date startDate(5, January, 2023); + Date endDate(5, April, 2023); + + checkQuantoCorrection(startDate, endDate, true); + checkQuantoCorrection(startDate, endDate, false); + + // Checks whether observers are being notified + // about changes in market data handles. + checkQuantoCorrection(startDate, endDate, false, true); +} + +void EquityCashFlowTest::testErrorWhenBaseDateAfterFixingDate() { + BOOST_TEST_MESSAGE("Testing error when base date after fixing date..."); + + using namespace equitycashflow_test; + + CommonVars vars; + + Date endDate(5, January, 2023); + Date startDate(5, April, 2023); + + auto cf = vars.createEquityQuantoCashFlow(vars.equityIndex, startDate, endDate); + auto pricer = vars.createEquityQuantoPricer(); + cf->setPricer(pricer); + + BOOST_CHECK_EXCEPTION( + cf->amount(), Error, + equitycashflow_test::ExpErrorPred("Fixing date cannot fall before base date.")); +} + +void EquityCashFlowTest::testErrorWhenHandleInPricerIsEmpty() { + BOOST_TEST_MESSAGE("Testing error when market data handle in pricer is empty..."); + + using namespace equitycashflow_test; + + CommonVars vars; + + Date startDate(5, January, 2023); + Date endDate(5, April, 2023); + + auto cf = vars.createEquityQuantoCashFlow(vars.equityIndex, startDate, endDate); + auto pricer = vars.createEquityQuantoPricerWithMissingHandles(); + cf->setPricer(pricer); + + BOOST_CHECK_EXCEPTION( + cf->amount(), Error, + equitycashflow_test::ExpErrorPred( + "Quanto currency, equity and FX volatility term structure handles cannot be empty.")); +} + +void EquityCashFlowTest::testErrorWhenInconsistentMarketDataReferenceDate() { + BOOST_TEST_MESSAGE("Testing error when market data reference dates are inconsistent..."); + + using namespace equitycashflow_test; + + CommonVars vars; + + Date startDate(5, January, 2023); + Date endDate(5, April, 2023); + + auto cf = vars.createEquityQuantoCashFlow(vars.equityIndex, startDate, endDate); + auto pricer = vars.createEquityQuantoPricer(); + cf->setPricer(pricer); + + vars.quantoCcyInterestHandle.linkTo(flatRate(Date(26, January, 2023), 0.02, vars.dayCount)); + + BOOST_CHECK_EXCEPTION( + cf->amount(), Error, + equitycashflow_test::ExpErrorPred( + "Quanto currency term structure, equity and FX volatility need to have the same " + "reference date.")); } test_suite* EquityCashFlowTest::suite() { auto* suite = BOOST_TEST_SUITE("Equity quanto cash flow tests"); + suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testSimpleEquityCashFlow)); suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testQuantoCorrection)); + suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testErrorWhenBaseDateAfterFixingDate)); + suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testErrorWhenHandleInPricerIsEmpty)); + suite->add( + QUANTLIB_TEST_CASE(&EquityCashFlowTest::testErrorWhenInconsistentMarketDataReferenceDate)); return suite; } \ No newline at end of file diff --git a/test-suite/equitycashflow.hpp b/test-suite/equitycashflow.hpp index 533f553a55b..13e336f845e 100644 --- a/test-suite/equitycashflow.hpp +++ b/test-suite/equitycashflow.hpp @@ -24,7 +24,11 @@ class EquityCashFlowTest { public: + static void testSimpleEquityCashFlow(); static void testQuantoCorrection(); + static void testErrorWhenBaseDateAfterFixingDate(); + static void testErrorWhenHandleInPricerIsEmpty(); + static void testErrorWhenInconsistentMarketDataReferenceDate(); static boost::unit_test_framework::test_suite* suite(); }; From 23bb2710d97214266a78eb080dc723985507edf5 Mon Sep 17 00:00:00 2001 From: Marcin Rybacki Date: Fri, 10 Mar 2023 12:11:46 +0100 Subject: [PATCH 051/292] Updated CMake- and Makefiles. --- ql/CMakeLists.txt | 2 ++ ql/cashflows/Makefile.am | 2 ++ ql/cashflows/all.hpp | 1 + test-suite/CMakeLists.txt | 2 ++ test-suite/Makefile.am | 2 ++ 5 files changed, 9 insertions(+) diff --git a/ql/CMakeLists.txt b/ql/CMakeLists.txt index 74c5657f159..d411586fec7 100644 --- a/ql/CMakeLists.txt +++ b/ql/CMakeLists.txt @@ -16,6 +16,7 @@ set(QL_SOURCES cashflows/digitaliborcoupon.cpp cashflows/dividend.cpp cashflows/duration.cpp + cashflows/equitycashflow.cpp cashflows/fixedratecoupon.cpp cashflows/floatingratecoupon.cpp cashflows/iborcoupon.cpp @@ -944,6 +945,7 @@ set(QL_HEADERS cashflows/digitaliborcoupon.hpp cashflows/dividend.hpp cashflows/duration.hpp + cashflows/equitycashflow.hpp cashflows/fixedratecoupon.hpp cashflows/floatingratecoupon.hpp cashflows/iborcoupon.hpp diff --git a/ql/cashflows/Makefile.am b/ql/cashflows/Makefile.am index 94bf8118374..5320f812c93 100644 --- a/ql/cashflows/Makefile.am +++ b/ql/cashflows/Makefile.am @@ -20,6 +20,7 @@ this_include_HEADERS = \ digitaliborcoupon.hpp \ dividend.hpp \ duration.hpp \ + equitycashflow.hpp \ fixedratecoupon.hpp \ floatingratecoupon.hpp \ iborcoupon.hpp \ @@ -54,6 +55,7 @@ cpp_files = \ digitaliborcoupon.cpp \ dividend.cpp \ duration.cpp \ + equitycashflow.cpp \ fixedratecoupon.cpp \ floatingratecoupon.cpp \ iborcoupon.cpp \ diff --git a/ql/cashflows/all.hpp b/ql/cashflows/all.hpp index 1dfce31205f..59ee0ab2e11 100644 --- a/ql/cashflows/all.hpp +++ b/ql/cashflows/all.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/test-suite/CMakeLists.txt b/test-suite/CMakeLists.txt index dce35ddcc37..960295013c5 100644 --- a/test-suite/CMakeLists.txt +++ b/test-suite/CMakeLists.txt @@ -50,6 +50,7 @@ set(QL_TEST_SOURCES dividendoption.cpp doublebarrieroption.cpp doublebinaryoption.cpp + equitycashflow.cpp equityindex.cpp equitytotalreturnswap.cpp europeanoption.cpp @@ -221,6 +222,7 @@ set(QL_TEST_HEADERS doublebarrieroption.hpp doublebinaryoption.hpp equityindex.hpp + equitycashflow.hpp equitytotalreturnswap.hpp europeanoption.hpp everestoption.hpp diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am index 05e45059e8f..8a4ee189145 100644 --- a/test-suite/Makefile.am +++ b/test-suite/Makefile.am @@ -53,6 +53,7 @@ QL_TEST_SRCS = \ doublebarrieroption.cpp \ doublebinaryoption.cpp \ equityindex.cpp \ + equitycashflow.cpp \ equitytotalreturnswap.cpp \ europeanoption.cpp \ everestoption.cpp \ @@ -222,6 +223,7 @@ QL_TEST_HDRS = \ doublebarrieroption.hpp \ doublebinaryoption.hpp \ equityindex.hpp \ + equitycashflow.hpp \ equitytotalreturnswap.hpp \ europeanoption.hpp \ everestoption.hpp \ From 2e48157bef16b7135f1d06b15b7a51768db1a9ba Mon Sep 17 00:00:00 2001 From: Marcin Rybacki Date: Sat, 11 Mar 2023 20:19:18 +0100 Subject: [PATCH 052/292] Adjusted checks when initiating quanto cash flow pricer. --- ql/cashflows/equitycashflow.cpp | 12 ++- test-suite/equitycashflow.cpp | 165 +++++++++++++++++++------------- test-suite/equitycashflow.hpp | 5 +- 3 files changed, 111 insertions(+), 71 deletions(-) diff --git a/ql/cashflows/equitycashflow.cpp b/ql/cashflows/equitycashflow.cpp index ab62c3097c1..dcad33a1834 100644 --- a/ql/cashflows/equitycashflow.cpp +++ b/ql/cashflows/equitycashflow.cpp @@ -98,10 +98,14 @@ namespace QuantLib { QL_REQUIRE(fixingDate_ >= baseDate_, "Fixing date cannot fall before base date."); growthOnlyPayoff_ = cashFlow.growthOnly(); - QL_REQUIRE( - !quantoCurrencyTermStructure_.empty() && !equityVolatility_.empty() && - !fxVolatility_.empty(), - "Quanto currency, equity and FX volatility term structure handles cannot be empty."); + QL_REQUIRE(!quantoCurrencyTermStructure_.empty(), + "Quanto currency term structure handle cannot be empty."); + QL_REQUIRE(!equityVolatility_.empty(), + "Equity volatility term structure handle cannot be empty."); + QL_REQUIRE(!fxVolatility_.empty(), + "FX volatility term structure handle cannot be empty."); + QL_REQUIRE(!correlation_.empty(), "Correlation handle cannot be empty."); + QL_REQUIRE(quantoCurrencyTermStructure_->referenceDate() == equityVolatility_->referenceDate() && equityVolatility_->referenceDate() == fxVolatility_->referenceDate(), diff --git a/test-suite/equitycashflow.cpp b/test-suite/equitycashflow.cpp index 51d0a84b3d8..db70292de6f 100644 --- a/test-suite/equitycashflow.cpp +++ b/test-suite/equitycashflow.cpp @@ -96,20 +96,32 @@ namespace equitycashflow_test { correlationHandle.linkTo(ext::make_shared(0.4)); } - ext::shared_ptr createEquityQuantoCashFlow( - const ext::shared_ptr& index, const Date& start, const Date& end) { - return ext::make_shared(notional, index, start, end, end); + ext::shared_ptr + createEquityQuantoCashFlow(const ext::shared_ptr& index, + const Date& start, + const Date& end, + bool useQuantoPricer = true) { + + auto cf = ext::make_shared(notional, index, start, end, end); + if (useQuantoPricer) { + auto pricer = ext::make_shared( + quantoCcyInterestHandle, equityVolHandle, fxVolHandle, correlationHandle); + cf->setPricer(pricer); + } + return cf; } - ext::shared_ptr createEquityQuantoPricer() { - return ext::make_shared( - quantoCcyInterestHandle, equityVolHandle, fxVolHandle, correlationHandle); + ext::shared_ptr + createEquityQuantoCashFlow(const ext::shared_ptr& index, + bool useQuantoPricer = true) { + Date start(5, January, 2023); + Date end(5, April, 2023); + + return createEquityQuantoCashFlow(index, start, end, useQuantoPricer); } - ext::shared_ptr createEquityQuantoPricerWithMissingHandles() { - Handle vol; - return ext::make_shared(quantoCcyInterestHandle, vol, vol, - correlationHandle); + ext::shared_ptr createEquityQuantoCashFlow(bool useQuantoPricer = true) { + return createEquityQuantoCashFlow(equityIndex, useQuantoPricer); } }; @@ -125,10 +137,7 @@ namespace equitycashflow_test { vars.spotHandle.linkTo(ext::make_shared(8710.0)); } - void checkQuantoCorrection(const Date& start, - const Date& end, - bool includeDividend, - bool bumpData = false) { + void checkQuantoCorrection(bool includeDividend, bool bumpData = false) { const Real tolerance = 1.0e-6; CommonVars vars; @@ -139,21 +148,19 @@ namespace equitycashflow_test { vars.equityIndex->clone(vars.localCcyInterestHandle, Handle(), vars.spotHandle); - auto cf = vars.createEquityQuantoCashFlow(equityIndex, start, end); - auto pricer = vars.createEquityQuantoPricer(); - cf->setPricer(pricer); + auto cf = vars.createEquityQuantoCashFlow(equityIndex); if (bumpData) bumpMarketData(vars); - Real strike = vars.equityIndex->fixing(end); - Real indexStart = vars.equityIndex->fixing(start); + Real strike = vars.equityIndex->fixing(cf->fixingDate()); + Real indexStart = vars.equityIndex->fixing(cf->baseDate()); - Real time = vars.localCcyInterestHandle->timeFromReference(end); + Real time = vars.localCcyInterestHandle->timeFromReference(cf->fixingDate()); Real rf = vars.localCcyInterestHandle->zeroRate(time, Continuous); Real q = includeDividend ? vars.dividendHandle->zeroRate(time, Continuous) : 0.0; - Real eqVol = vars.equityVolHandle->blackVol(end, strike); - Real fxVol = vars.fxVolHandle->blackVol(end, 1.0); + Real eqVol = vars.equityVolHandle->blackVol(cf->fixingDate(), strike); + Real fxVol = vars.fxVolHandle->blackVol(cf->fixingDate(), 1.0); Real rho = vars.correlationHandle->value(); Real spot = vars.spotHandle->value(); @@ -174,6 +181,10 @@ namespace equitycashflow_test { << " correlation: " << rho << "\n" << " spot: " << spot << "\n"); } + + void checkRaisedError(const ext::shared_ptr& cf, const std::string& message) { + BOOST_CHECK_EXCEPTION(cf->amount(), Error, equitycashflow_test::ExpErrorPred(message)); + } } void EquityCashFlowTest::testSimpleEquityCashFlow() { @@ -185,13 +196,10 @@ void EquityCashFlowTest::testSimpleEquityCashFlow() { CommonVars vars; - Date startDate(5, January, 2023); - Date endDate(5, April, 2023); + auto cf = vars.createEquityQuantoCashFlow(false); - auto cf = vars.createEquityQuantoCashFlow(vars.equityIndex, startDate, endDate); - - Real indexStart = vars.equityIndex->fixing(startDate); - Real indexEnd = vars.equityIndex->fixing(endDate); + Real indexStart = vars.equityIndex->fixing(cf->baseDate()); + Real indexEnd = vars.equityIndex->fixing(cf->fixingDate()); Real expectedAmount = (indexEnd / indexStart - 1.0) * vars.notional; @@ -210,15 +218,12 @@ void EquityCashFlowTest::testQuantoCorrection() { using namespace equitycashflow_test; - Date startDate(5, January, 2023); - Date endDate(5, April, 2023); - - checkQuantoCorrection(startDate, endDate, true); - checkQuantoCorrection(startDate, endDate, false); + checkQuantoCorrection(true); + checkQuantoCorrection(false); // Checks whether observers are being notified // about changes in market data handles. - checkQuantoCorrection(startDate, endDate, false, true); + checkQuantoCorrection(false, true); } void EquityCashFlowTest::testErrorWhenBaseDateAfterFixingDate() { @@ -228,36 +233,68 @@ void EquityCashFlowTest::testErrorWhenBaseDateAfterFixingDate() { CommonVars vars; - Date endDate(5, January, 2023); - Date startDate(5, April, 2023); + Date end(5, January, 2023); + Date start(5, April, 2023); + + auto cf = vars.createEquityQuantoCashFlow(vars.equityIndex, start, end); + + checkRaisedError(cf, "Fixing date cannot fall before base date."); +} + +void EquityCashFlowTest::testErrorWhenQuantoCurveHandleIsEmpty() { + BOOST_TEST_MESSAGE("Testing error when quanto currency curve handle is empty..."); + + using namespace equitycashflow_test; + + CommonVars vars; + + auto cf = vars.createEquityQuantoCashFlow(); - auto cf = vars.createEquityQuantoCashFlow(vars.equityIndex, startDate, endDate); - auto pricer = vars.createEquityQuantoPricer(); - cf->setPricer(pricer); + ext::shared_ptr yts; + vars.quantoCcyInterestHandle.linkTo(yts); + checkRaisedError(cf, "Quanto currency term structure handle cannot be empty."); +} + +void EquityCashFlowTest::testErrorWhenEquityVolHandleIsEmpty() { + BOOST_TEST_MESSAGE("Testing error when equity vol handle is empty..."); + + using namespace equitycashflow_test; - BOOST_CHECK_EXCEPTION( - cf->amount(), Error, - equitycashflow_test::ExpErrorPred("Fixing date cannot fall before base date.")); + CommonVars vars; + + auto cf = vars.createEquityQuantoCashFlow(); + + ext::shared_ptr vol; + vars.equityVolHandle.linkTo(vol); + checkRaisedError(cf, "Equity volatility term structure handle cannot be empty."); } -void EquityCashFlowTest::testErrorWhenHandleInPricerIsEmpty() { - BOOST_TEST_MESSAGE("Testing error when market data handle in pricer is empty..."); +void EquityCashFlowTest::testErrorWhenFXVolHandleIsEmpty() { + BOOST_TEST_MESSAGE("Testing error when FX vol handle is empty..."); using namespace equitycashflow_test; CommonVars vars; - Date startDate(5, January, 2023); - Date endDate(5, April, 2023); + auto cf = vars.createEquityQuantoCashFlow(); - auto cf = vars.createEquityQuantoCashFlow(vars.equityIndex, startDate, endDate); - auto pricer = vars.createEquityQuantoPricerWithMissingHandles(); - cf->setPricer(pricer); + ext::shared_ptr vol; + vars.fxVolHandle.linkTo(vol); + checkRaisedError(cf, "FX volatility term structure handle cannot be empty."); +} - BOOST_CHECK_EXCEPTION( - cf->amount(), Error, - equitycashflow_test::ExpErrorPred( - "Quanto currency, equity and FX volatility term structure handles cannot be empty.")); +void EquityCashFlowTest::testErrorWhenCorrelationHandleIsEmpty() { + BOOST_TEST_MESSAGE("Testing error when correlation handle is empty..."); + + using namespace equitycashflow_test; + + CommonVars vars; + + auto cf = vars.createEquityQuantoCashFlow(); + + ext::shared_ptr correlation; + vars.correlationHandle.linkTo(correlation); + checkRaisedError(cf, "Correlation handle cannot be empty."); } void EquityCashFlowTest::testErrorWhenInconsistentMarketDataReferenceDate() { @@ -267,29 +304,25 @@ void EquityCashFlowTest::testErrorWhenInconsistentMarketDataReferenceDate() { CommonVars vars; - Date startDate(5, January, 2023); - Date endDate(5, April, 2023); - - auto cf = vars.createEquityQuantoCashFlow(vars.equityIndex, startDate, endDate); - auto pricer = vars.createEquityQuantoPricer(); - cf->setPricer(pricer); + auto cf = vars.createEquityQuantoCashFlow(); vars.quantoCcyInterestHandle.linkTo(flatRate(Date(26, January, 2023), 0.02, vars.dayCount)); - BOOST_CHECK_EXCEPTION( - cf->amount(), Error, - equitycashflow_test::ExpErrorPred( - "Quanto currency term structure, equity and FX volatility need to have the same " - "reference date.")); + checkRaisedError( + cf, "Quanto currency term structure, equity and FX volatility need to have the same " + "reference date."); } test_suite* EquityCashFlowTest::suite() { - auto* suite = BOOST_TEST_SUITE("Equity quanto cash flow tests"); + auto* suite = BOOST_TEST_SUITE("Equity cash flow tests"); suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testSimpleEquityCashFlow)); suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testQuantoCorrection)); suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testErrorWhenBaseDateAfterFixingDate)); - suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testErrorWhenHandleInPricerIsEmpty)); + suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testErrorWhenQuantoCurveHandleIsEmpty)); + suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testErrorWhenEquityVolHandleIsEmpty)); + suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testErrorWhenFXVolHandleIsEmpty)); + suite->add(QUANTLIB_TEST_CASE(&EquityCashFlowTest::testErrorWhenCorrelationHandleIsEmpty)); suite->add( QUANTLIB_TEST_CASE(&EquityCashFlowTest::testErrorWhenInconsistentMarketDataReferenceDate)); diff --git a/test-suite/equitycashflow.hpp b/test-suite/equitycashflow.hpp index 13e336f845e..4b950f4daa6 100644 --- a/test-suite/equitycashflow.hpp +++ b/test-suite/equitycashflow.hpp @@ -27,7 +27,10 @@ class EquityCashFlowTest { static void testSimpleEquityCashFlow(); static void testQuantoCorrection(); static void testErrorWhenBaseDateAfterFixingDate(); - static void testErrorWhenHandleInPricerIsEmpty(); + static void testErrorWhenQuantoCurveHandleIsEmpty(); + static void testErrorWhenEquityVolHandleIsEmpty(); + static void testErrorWhenFXVolHandleIsEmpty(); + static void testErrorWhenCorrelationHandleIsEmpty(); static void testErrorWhenInconsistentMarketDataReferenceDate(); static boost::unit_test_framework::test_suite* suite(); From c89d4bb4225343c72d2b32ef924046d17ac581f4 Mon Sep 17 00:00:00 2001 From: RalfKonrad Date: Sat, 11 Mar 2023 20:45:58 +0100 Subject: [PATCH 053/292] Define QL_ENABLE_DEFAULT_WARNING_LEVEL and QL_COMPILE_WARNING_AS_ERROR in CMakeLists.txt and use them in the cmake workflow. --- .github/workflows/cmake.yml | 20 ++++++++++---------- CMakeLists.txt | 29 +++++++++++++++++++++++++++++ cmake/Platform.cmake | 1 + 3 files changed, 40 insertions(+), 10 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 1d65d2356bb..b54a4a3a382 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -21,8 +21,8 @@ jobs: run: | mkdir build cd build - cmake .. -GNinja -DBOOST_ROOT=/usr -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - cmake --build . + cmake .. -GNinja -DBOOST_ROOT=/usr -DCMAKE_BUILD_TYPE=Release -DQL_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -L + cmake --build . --verbose - name: Test run: | cd build @@ -45,8 +45,8 @@ jobs: cmake-linux-ci-opts- - name: Compile run: | - cmake --preset linux-ci-build-with-nonstandard-options - cmake --build --preset linux-ci-build-with-nonstandard-options + cmake --preset linux-ci-build-with-nonstandard-options -DQL_COMPILE_WARNING_AS_ERROR=ON -L + cmake --build --preset linux-ci-build-with-nonstandard-options --verbose - name: Test run: | cd build @@ -78,7 +78,7 @@ jobs: mkdir build cd build call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Vc\Auxiliary\Build\vcvarsall.bat" amd64 -vcvars_ver=14.3 || exit 1 - cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DQL_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -L cmake --build . --verbose dir ql\*.lib - name: Test @@ -112,7 +112,7 @@ jobs: mkdir build cd build call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Vc\Auxiliary\Build\vcvarsall.bat" amd64 -vcvars_ver=14.3 || exit 1 - cmake .. -GNinja -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER_LAUNCHER=sccache + cmake .. -GNinja -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL -DCMAKE_BUILD_TYPE=Release -DQL_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -L cmake --build . --verbose dir ql\*.lib - name: Test @@ -144,8 +144,8 @@ jobs: shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Vc\Auxiliary\Build\vcvarsall.bat" amd64 -vcvars_ver=14.3 || exit 1 - cmake --preset windows-ci-build-with-nonstandard-options - cmake --build --preset windows-ci-build-with-nonstandard-options + cmake --preset windows-ci-build-with-nonstandard-options -DQL_COMPILE_WARNING_AS_ERROR=ON -L + cmake --build --preset windows-ci-build-with-nonstandard-options --verbose - name: Test run: | cd build @@ -171,8 +171,8 @@ jobs: run: | mkdir build cd build - cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -GNinja - cmake --build . + cmake .. -DCMAKE_BUILD_TYPE=Release -DQL_COMPILE_WARNING_AS_ERROR=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -GNinja -L + cmake --build . --verbose - name: Test run: | cd build diff --git a/CMakeLists.txt b/CMakeLists.txt index 878c4d6b39b..c8a555bfb76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,8 @@ option(QL_ENABLE_PARALLEL_UNIT_TEST_RUNNER "Enable the parallel unit test runner option(QL_ENABLE_SESSIONS "Singletons return different instances for different sessions" OFF) option(QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN "Enable the thread-safe observer pattern" OFF) option(QL_ENABLE_TRACING "Tracing messages should be allowed" OFF) +option(QL_ENABLE_DEFAULT_WARNING_LEVEL "Enable the default warning level to pass the ci pipeline" ON) +option(QL_COMPILE_WARNING_AS_ERROR "Specify whether to treat warnings on compile as errors." OFF) option(QL_ERROR_FUNCTIONS "Error messages should include current function information" OFF) option(QL_ERROR_LINES "Error messages should include file and line information" OFF) option(QL_EXTRA_SAFETY_CHECKS "Extra safety checks should be performed" OFF) @@ -115,6 +117,33 @@ if (NOT DEFINED CMAKE_CXX_EXTENSIONS) set(CMAKE_CXX_EXTENSIONS FALSE) endif() +# Set the default warning level we use to pass the GitHub workflows +if (QL_ENABLE_DEFAULT_WARNING_LEVEL) + if (MSVC) + # warning level 3 + add_compile_options(-W3) + else() + # lots of warnings + add_compile_options(-Wall -Wno-unknown-pragmas) + endif() +endif() + +# Treat warnings on compile as errors +if (QL_COMPILE_WARNING_AS_ERROR) + # all compiler warnings as errors + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") + # since v3.24 cmake can set all compiler warnings as errors itself + set(CMAKE_COMPILE_WARNING_AS_ERROR ON) + else() + # or set them manually + if (MSVC) + add_compile_options(-WX) + else() + add_compile_options(-Werror) + endif() + endif() +endif() + if (NOT DEFINED QL_BOOST_VERSION) # Boost 1.75.0 or greater required for compiling with C++20 if (CMAKE_CXX_STANDARD GREATER_EQUAL 20) diff --git a/cmake/Platform.cmake b/cmake/Platform.cmake index 9c21865d98d..ca20b234f35 100644 --- a/cmake/Platform.cmake +++ b/cmake/Platform.cmake @@ -16,6 +16,7 @@ if (MSVC) endif() add_compile_definitions(NOMINMAX) + add_compile_definitions(_CRT_SECURE_NO_WARNINGS) # /wd4267 # Suppress warnings: assignment of 64-bit value to 32-bit QuantLib::Integer (x64) From e7bc1c4ee5d0410dbbccd4f8e10512d6593c688e Mon Sep 17 00:00:00 2001 From: RalfKonrad Date: Sun, 12 Mar 2023 18:44:04 +0100 Subject: [PATCH 054/292] Added add_compile_definitions(_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING) to prevent deprecation warnings from boost::ublas --- cmake/Platform.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmake/Platform.cmake b/cmake/Platform.cmake index ca20b234f35..2d6a5887fbb 100644 --- a/cmake/Platform.cmake +++ b/cmake/Platform.cmake @@ -16,6 +16,8 @@ if (MSVC) endif() add_compile_definitions(NOMINMAX) + + # caused by ql\time\date.cpp: warning C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. add_compile_definitions(_CRT_SECURE_NO_WARNINGS) # /wd4267 @@ -28,4 +30,11 @@ if (MSVC) # Suppress warnings: "Prefer enum class over enum" (Enum.3) add_compile_options(/wd4267 /wd4819 /wd26812) + + # prevent warnings when using /std:c++17 and above + if(CMAKE_CXX_STANDARD GREATER 14) + # E.g. caused by #include + # In c++17 std::iterator is deprecated. As of boost 1.81 boost::ublas has not provided a fix for this. + add_compile_definitions(_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING) + endif() endif() From 81302912e6b5984d9b0107c1240a911c97351c6e Mon Sep 17 00:00:00 2001 From: RalfKonrad Date: Sun, 12 Mar 2023 18:59:17 +0100 Subject: [PATCH 055/292] Adding a bit of documentation --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8a555bfb76..32dcefe9c71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,6 +121,7 @@ endif() if (QL_ENABLE_DEFAULT_WARNING_LEVEL) if (MSVC) # warning level 3 + # There are also specific warnings disabled for MSCV in cmake/Platform.cmake. add_compile_options(-W3) else() # lots of warnings From 34183e99ee9fea97ffb045f450128800f926796e Mon Sep 17 00:00:00 2001 From: Marcin Rybacki Date: Mon, 13 Mar 2023 09:15:18 +0100 Subject: [PATCH 056/292] Fixed build. --- ql/instruments/equitytotalreturnswap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/instruments/equitytotalreturnswap.cpp b/ql/instruments/equitytotalreturnswap.cpp index 9e1c4882f3b..9b50f65af13 100644 --- a/ql/instruments/equitytotalreturnswap.cpp +++ b/ql/instruments/equitytotalreturnswap.cpp @@ -18,9 +18,9 @@ Copyright (C) 2023 Marcin Rybacki */ #include -#include #include #include +#include #include #include From 5889314e6dcf686d5f9cd30447ebd220e8be8d59 Mon Sep 17 00:00:00 2001 From: Marcin Rybacki Date: Mon, 13 Mar 2023 09:16:06 +0100 Subject: [PATCH 057/292] Keep alphabetic order of imports. --- ql/instruments/equitytotalreturnswap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/instruments/equitytotalreturnswap.cpp b/ql/instruments/equitytotalreturnswap.cpp index 9b50f65af13..c217d858e85 100644 --- a/ql/instruments/equitytotalreturnswap.cpp +++ b/ql/instruments/equitytotalreturnswap.cpp @@ -17,10 +17,10 @@ Copyright (C) 2023 Marcin Rybacki FOR A PARTICULAR PURPOSE. See the license for more details. */ +#include #include #include #include -#include #include #include From b441c82831d4ee3a72513199a432bcb18124bf71 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Sat, 18 Mar 2023 12:53:29 +0100 Subject: [PATCH 058/292] remove utility to enable first notification on subgraph, remove observables inspector, update test case --- ql/patterns/lazyobject.hpp | 12 ------------ ql/patterns/observable.hpp | 10 ---------- test-suite/piecewiseyieldcurve.cpp | 2 +- 3 files changed, 1 insertion(+), 23 deletions(-) diff --git a/ql/patterns/lazyobject.hpp b/ql/patterns/lazyobject.hpp index 223191485a3..2f6fd0ebd39 100644 --- a/ql/patterns/lazyobject.hpp +++ b/ql/patterns/lazyobject.hpp @@ -176,18 +176,6 @@ namespace QuantLib { } } } - - /*! Calls fowardFirstNotificationOnly on o and all observables of o that are a lazy object, - recursively. This reduces the number of notifications sent from the lazy objects, but might - result in missing recalculations of objects observing one of the lazy object directly or - indireclty. */ - inline void enableSingleNotificationFromLazyObjects(ext::shared_ptr o) { - if (auto l = ext::dynamic_pointer_cast(o)) - l->forwardFirstNotificationOnly(); - for (auto& p : o->observables()) - if (auto l = ext::dynamic_pointer_cast(p)) - enableSingleNotificationFromLazyObjects(l); - } } #endif diff --git a/ql/patterns/observable.hpp b/ql/patterns/observable.hpp index 515ce340d99..1523307c533 100644 --- a/ql/patterns/observable.hpp +++ b/ql/patterns/observable.hpp @@ -149,11 +149,6 @@ namespace QuantLib { should be implemented in derived classes whenever applicable */ virtual void deepUpdate(); - /*! returns the set of observables */ - const boost::unordered_set>& observables() const { - return observables_; - } - private: QL_DEPRECATED_DISABLE_WARNING set_type observables_; @@ -324,11 +319,6 @@ namespace QuantLib { should be implemented in derived classes whenever applicable */ virtual void deepUpdate(); - /*! returns the set of observables */ - const boost::unordered_set>& observables() const { - return observables_; - } - private: class Proxy { diff --git a/test-suite/piecewiseyieldcurve.cpp b/test-suite/piecewiseyieldcurve.cpp index 49ff451aad7..6626003634b 100644 --- a/test-suite/piecewiseyieldcurve.cpp +++ b/test-suite/piecewiseyieldcurve.cpp @@ -825,7 +825,7 @@ void PiecewiseYieldCurveTest::testObservability() { vars.instruments, Actual360())); - enableSingleNotificationFromLazyObjects(vars.termStructure); + vars.termStrucure.forwardFirstNotificaionOnly(); Flag f; f.registerWith(vars.termStructure); From 3c7e6eba0c199a0a33d13972428d8e7e3eda1ab2 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Sat, 18 Mar 2023 13:04:55 +0100 Subject: [PATCH 059/292] fix --- test-suite/piecewiseyieldcurve.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-suite/piecewiseyieldcurve.cpp b/test-suite/piecewiseyieldcurve.cpp index 6626003634b..8faaae2b134 100644 --- a/test-suite/piecewiseyieldcurve.cpp +++ b/test-suite/piecewiseyieldcurve.cpp @@ -825,7 +825,7 @@ void PiecewiseYieldCurveTest::testObservability() { vars.instruments, Actual360())); - vars.termStrucure.forwardFirstNotificaionOnly(); + boost::dynamic_pointer_cast(vars.termStructure)->forwardFirstNotificationOnly(); Flag f; f.registerWith(vars.termStructure); From 05a278be334f055c7ad17651195fe6c9a1176dac Mon Sep 17 00:00:00 2001 From: Jonathan Sweemer Date: Thu, 16 Mar 2023 21:46:37 +0900 Subject: [PATCH 060/292] Add support for std::any and std::optional --- CMakeLists.txt | 47 +++++++++++------ QuantLib.vcxproj | 2 + QuantLib.vcxproj.filters | 2 + configure.ac | 31 +++++++++++ ql/CMakeLists.txt | 2 + ql/Makefile.am | 2 + ql/any.hpp | 51 +++++++++++++++++++ ql/cashflow.cpp | 4 +- ql/cashflow.hpp | 3 +- ql/cashflows/couponpricer.cpp | 3 +- ql/cashflows/couponpricer.hpp | 5 +- ql/cashflows/iborcoupon.cpp | 3 +- ql/cashflows/iborcoupon.hpp | 5 +- ql/config.hpp.cfg | 2 + ql/event.cpp | 3 +- ql/event.hpp | 4 +- .../catbonds/montecarlocatbondengine.cpp | 3 +- .../catbonds/montecarlocatbondengine.hpp | 5 +- ql/experimental/commodities/commodity.hpp | 3 +- .../commodities/energycommodity.cpp | 8 +-- .../coupons/lognormalcmsspreadpricer.cpp | 6 +-- .../coupons/lognormalcmsspreadpricer.hpp | 3 +- ql/experimental/credit/syntheticcdo.cpp | 5 +- ql/experimental/credit/syntheticcdo.hpp | 3 +- ql/experimental/swaptions/irregularswap.hpp | 1 - .../swaptions/irregularswaption.cpp | 3 +- ql/instrument.hpp | 14 ++--- ql/instruments/callabilityschedule.hpp | 4 +- ql/instruments/capfloor.cpp | 3 +- ql/instruments/creditdefaultswap.cpp | 9 ++-- ql/instruments/creditdefaultswap.hpp | 7 +-- ql/instruments/floatfloatswap.cpp | 13 ++--- ql/instruments/floatfloatswap.hpp | 14 ++--- ql/instruments/makecds.hpp | 6 +-- ql/instruments/makeswaption.cpp | 3 +- ql/instruments/makeswaption.hpp | 5 +- ql/instruments/makevanillaswap.cpp | 7 +-- ql/instruments/makevanillaswap.hpp | 4 +- ql/instruments/nonstandardswap.cpp | 5 +- ql/instruments/nonstandardswap.hpp | 6 +-- ql/instruments/swaption.cpp | 3 +- ql/instruments/vanillaswap.cpp | 5 +- ql/instruments/vanillaswap.hpp | 6 +-- ql/optional.hpp | 51 +++++++++++++++++++ .../bond/discountingbondengine.cpp | 3 +- .../bond/discountingbondengine.hpp | 5 +- .../capfloor/analyticcapfloorengine.cpp | 3 +- .../credit/integralcdsengine.cpp | 3 +- .../credit/integralcdsengine.hpp | 5 +- ql/pricingengines/credit/isdacdsengine.cpp | 3 +- ql/pricingengines/credit/isdacdsengine.hpp | 5 +- .../credit/midpointcdsengine.cpp | 3 +- .../credit/midpointcdsengine.hpp | 5 +- .../mclongstaffschwartzengine.hpp | 10 ++-- .../swap/discountingswapengine.cpp | 3 +- .../swap/discountingswapengine.hpp | 5 +- .../vanilla/bjerksundstenslandengine.cpp | 4 +- .../vanilla/mcamericanengine.hpp | 9 ++-- ql/settings.hpp | 14 ++--- ql/termstructures/yield/oisratehelper.cpp | 2 +- ql/termstructures/yield/oisratehelper.hpp | 5 +- ql/termstructures/yield/ratehelpers.cpp | 9 ++-- ql/termstructures/yield/ratehelpers.hpp | 17 +++---- ql/time/schedule.cpp | 11 ++-- ql/time/schedule.hpp | 32 ++++++------ ql/userconfig.hpp | 10 ++++ test-suite/americanoption.cpp | 5 +- test-suite/cashflows.cpp | 10 ++-- test-suite/creditdefaultswap.cpp | 7 +-- test-suite/defaultprobabilitycurves.cpp | 2 +- test-suite/period.cpp | 2 +- test-suite/quantlibtestsuite.cpp | 11 ++-- 72 files changed, 392 insertions(+), 185 deletions(-) create mode 100644 ql/any.hpp create mode 100644 ql/optional.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 878c4d6b39b..b84afec52d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,20 +58,49 @@ option(QL_INSTALL_TEST_SUITE "Install test suite" ON) option(QL_TAGGED_LAYOUT "Library names use layout tags" ${MSVC}) option(QL_USE_CLANG_TIDY "Use clang-tidy when building" OFF) option(QL_USE_INDEXED_COUPON "Use indexed coupons instead of par coupons" OFF) +option(QL_USE_STD_ANY "Use std::any instead of boost::any" OFF) option(QL_USE_STD_CLASSES "Enable all QL_USE_STD_ options" OFF) -option(QL_USE_STD_SHARED_PTR "Use standard smart pointers instead of Boost ones" OFF) option(QL_USE_STD_FUNCTION "Use std::function and std::bind instead of Boost ones" OFF) +option(QL_USE_STD_OPTIONAL "Use std::optional instead of boost::optional" OFF) +option(QL_USE_STD_SHARED_PTR "Use standard smart pointers instead of Boost ones" OFF) option(QL_USE_STD_TUPLE "Use std::tuple instead of boost::tuple" OFF) set(QL_EXTERNAL_SUBDIRECTORIES "" CACHE STRING "Optional list of external source directories to be added to the build (semicolon-separated)") set(QL_EXTRA_LINK_LIBRARIES "" CACHE STRING "Optional extra link libraries to add to QuantLib") +# Require C++14 or higher +if (NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +elseif(CMAKE_CXX_STANDARD LESS 14) + message(FATAL_ERROR "Please specify CMAKE_CXX_STANDARD of 14 or higher") +endif() +if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) + set(CMAKE_CXX_STANDARD_REQUIRED ON) +endif() +# Avoid use of compiler language extensions, i.e. -std=c++14 not -std=gnu++14 +if (NOT DEFINED CMAKE_CXX_EXTENSIONS) + set(CMAKE_CXX_EXTENSIONS FALSE) +endif() + # Convenience option to activate all STD options if (QL_USE_STD_CLASSES) - set(QL_USE_STD_SHARED_PTR ON) + if (CMAKE_CXX_STANDARD GREATER_EQUAL 17) + set(QL_USE_STD_ANY ON) + set(QL_USE_STD_OPTIONAL ON) + endif() set(QL_USE_STD_FUNCTION ON) + set(QL_USE_STD_SHARED_PTR ON) set(QL_USE_STD_TUPLE ON) endif() +if (CMAKE_CXX_STANDARD LESS 17) + if (QL_USE_STD_ANY) + message(FATAL_ERROR "QL_USE_STD_ANY requires at least C++17") + endif() + if (QL_USE_STD_OPTIONAL) + message(FATAL_ERROR "QL_USE_STD_OPTIONAL requires at least C++17") + endif() +endif () + if (QL_USE_CLANG_TIDY) if (NOT DEFINED QL_CLANG_TIDY) set(QL_CLANG_TIDY clang-tidy) @@ -101,20 +130,6 @@ if (NOT DEFINED Boost_USE_STATIC_RUNTIME) set(Boost_USE_STATIC_RUNTIME ${MSVC}) endif() -# Require C++14 or higher -if (NOT DEFINED CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) -elseif(CMAKE_CXX_STANDARD LESS 14) - message(FATAL_ERROR "Please specify CMAKE_CXX_STANDARD of 14 or higher") -endif() -if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED) - set(CMAKE_CXX_STANDARD_REQUIRED ON) -endif() -# Avoid use of compiler language extensions, i.e. -std=c++14 not -std=gnu++14 -if (NOT DEFINED CMAKE_CXX_EXTENSIONS) - set(CMAKE_CXX_EXTENSIONS FALSE) -endif() - if (NOT DEFINED QL_BOOST_VERSION) # Boost 1.75.0 or greater required for compiling with C++20 if (CMAKE_CXX_STANDARD GREATER_EQUAL 20) diff --git a/QuantLib.vcxproj b/QuantLib.vcxproj index 625f9bfe67e..b4e0043094f 100644 --- a/QuantLib.vcxproj +++ b/QuantLib.vcxproj @@ -1849,6 +1849,7 @@ + @@ -1874,6 +1875,7 @@ + diff --git a/QuantLib.vcxproj.filters b/QuantLib.vcxproj.filters index 1db10bb7997..ca1ed84225d 100644 --- a/QuantLib.vcxproj.filters +++ b/QuantLib.vcxproj.filters @@ -3738,6 +3738,7 @@ pricingengines\barrier + @@ -3764,6 +3765,7 @@ + diff --git a/configure.ac b/configure.ac index dc0abe9e4e9..5c34f71c84b 100644 --- a/configure.ac +++ b/configure.ac @@ -331,6 +331,37 @@ if test "$ql_use_intraday" = "yes" ; then fi AC_MSG_RESULT([$ql_use_intraday]) +AC_MSG_CHECKING([whether to enable std::any instead of boost::any]) +AC_ARG_ENABLE([std-any], + AS_HELP_STRING([--enable-std-any], + [If enabled, std::any and related classes and + functions will be used instead of boost::any. + If disabled (the default) the Boost facilities + are used.]), + [ql_use_std_any=$enableval], + [ql_use_std_any=no]) +if test "$ql_use_std_any" = "yes" ; then + AC_DEFINE([QL_USE_STD_ANY],[1], + [Define this if you want to use std::any.]) +fi +AC_MSG_RESULT([$ql_use_std_any]) + +AC_MSG_CHECKING([whether to enable std::optional instead of boost::optional]) +AC_ARG_ENABLE([std-optional], + AS_HELP_STRING([--enable-std-optional], + [If enabled, std::optional and related + classes and functions will be used instead + of boost::optional. + If disabled (the default) the Boost facilities + are used.]), + [ql_use_std_optional=$enableval], + [ql_use_std_optional=no]) +if test "$ql_use_std_optional" = "yes" ; then + AC_DEFINE([QL_USE_STD_OPTIONAL],[1], + [Define this if you want to use std::optional.]) +fi +AC_MSG_RESULT([$ql_use_std_optional]) + AC_MSG_CHECKING([whether to enable standard smart pointers]) AC_ARG_ENABLE([std-pointers], AS_HELP_STRING([--enable-std-pointers], diff --git a/ql/CMakeLists.txt b/ql/CMakeLists.txt index 74c5657f159..0399181da73 100644 --- a/ql/CMakeLists.txt +++ b/ql/CMakeLists.txt @@ -925,6 +925,7 @@ set(QL_SOURCES ) set(QL_HEADERS + any.hpp auto_link.hpp auto_ptr.hpp cashflow.hpp @@ -1828,6 +1829,7 @@ set(QL_HEADERS money.hpp numericalmethod.hpp option.hpp + optional.hpp patterns/composite.hpp patterns/curiouslyrecurring.hpp patterns/lazyobject.hpp diff --git a/ql/Makefile.am b/ql/Makefile.am index 9cf55bb3212..5597fb23617 100644 --- a/ql/Makefile.am +++ b/ql/Makefile.am @@ -21,6 +21,7 @@ AM_CPPFLAGS = -I${top_builddir} -I${top_srcdir} this_includedir=${includedir}/${subdir} this_include_HEADERS = \ + any.hpp \ auto_link.hpp \ auto_ptr.hpp \ cashflow.hpp \ @@ -43,6 +44,7 @@ this_include_HEADERS = \ money.hpp \ numericalmethod.hpp \ option.hpp \ + optional.hpp \ payoff.hpp \ position.hpp \ prices.hpp \ diff --git a/ql/any.hpp b/ql/any.hpp new file mode 100644 index 00000000000..d9248dffb1f --- /dev/null +++ b/ql/any.hpp @@ -0,0 +1,51 @@ +/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + Copyright (C) 2023 Jonathan Sweemer + + 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. +*/ + +/*! \file any.hpp + \brief Maps any to either the boost or std implementation +*/ + +#ifndef quantlib_any_hpp +#define quantlib_any_hpp + +#include + +#if defined(QL_USE_STD_ANY) +#include +#else +#include +#endif + +namespace QuantLib { + + namespace ext { + + #if defined(QL_USE_STD_ANY) + using std::any; // NOLINT(misc-unused-using-decls) + using std::any_cast; // NOLINT(misc-unused-using-decls) + #else + using boost::any; // NOLINT(misc-unused-using-decls) + using boost::any_cast; // NOLINT(misc-unused-using-decls) + #endif + + } + +} + +#endif diff --git a/ql/cashflow.cpp b/ql/cashflow.cpp index 0100bb4fc00..b6ecca631d9 100644 --- a/ql/cashflow.cpp +++ b/ql/cashflow.cpp @@ -25,7 +25,7 @@ namespace QuantLib { bool CashFlow::hasOccurred(const Date& refDate, - boost::optional includeRefDate) const { + ext::optional includeRefDate) const { // easy and quick handling of most cases if (refDate != Date()) { @@ -40,7 +40,7 @@ namespace QuantLib { refDate == Settings::instance().evaluationDate()) { // today's date; we override the bool with the one // specified in the settings (if any) - boost::optional includeToday = + ext::optional includeToday = Settings::instance().includeTodaysCashFlows(); if (includeToday) // NOLINT(readability-implicit-bool-conversion) includeRefDate = *includeToday; diff --git a/ql/cashflow.hpp b/ql/cashflow.hpp index 29c26173e70..2aa45a9d549 100644 --- a/ql/cashflow.hpp +++ b/ql/cashflow.hpp @@ -27,6 +27,7 @@ #include #include +#include #include namespace QuantLib { @@ -47,7 +48,7 @@ namespace QuantLib { Settings::includeTodaysCashflows in account */ bool hasOccurred(const Date& refDate = Date(), - boost::optional includeRefDate = boost::none) const override; + ext::optional includeRefDate = ext::nullopt()) const override; //@} //! \name CashFlow interface //@{ diff --git a/ql/cashflows/couponpricer.cpp b/ql/cashflows/couponpricer.cpp index 61b02d637e7..beaf87b66b3 100644 --- a/ql/cashflows/couponpricer.cpp +++ b/ql/cashflows/couponpricer.cpp @@ -31,6 +31,7 @@ #include /* internal */ #include #include +#include #include namespace QuantLib { @@ -41,7 +42,7 @@ namespace QuantLib { IborCouponPricer::IborCouponPricer( Handle v, - boost::optional useIndexedCoupon) + ext::optional useIndexedCoupon) : capletVol_(std::move(v)), useIndexedCoupon_(useIndexedCoupon ? *useIndexedCoupon : diff --git a/ql/cashflows/couponpricer.hpp b/ql/cashflows/couponpricer.hpp index 2c03f00b5ab..54284d0d012 100644 --- a/ql/cashflows/couponpricer.hpp +++ b/ql/cashflows/couponpricer.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -66,7 +67,7 @@ namespace QuantLib { public: explicit IborCouponPricer( Handle v = Handle(), - boost::optional useIndexedCoupon = boost::none); + ext::optional useIndexedCoupon = ext::nullopt()); bool useIndexedCoupon() const { return useIndexedCoupon_; } @@ -114,7 +115,7 @@ namespace QuantLib { const Handle& v = Handle(), const TimingAdjustment timingAdjustment = Black76, Handle correlation = Handle(ext::shared_ptr(new SimpleQuote(1.0))), - const boost::optional useIndexedCoupon = boost::none) + const ext::optional useIndexedCoupon = ext::nullopt()) : IborCouponPricer(v, useIndexedCoupon), timingAdjustment_(timingAdjustment), correlation_(std::move(correlation)) { { // this additional scope seems required to avoid a misleading-indentation warning diff --git a/ql/cashflows/iborcoupon.cpp b/ql/cashflows/iborcoupon.cpp index bd986b05dd7..bab3d3f5298 100644 --- a/ql/cashflows/iborcoupon.cpp +++ b/ql/cashflows/iborcoupon.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include namespace QuantLib { @@ -255,7 +256,7 @@ namespace QuantLib { return *this; } - IborLeg& IborLeg::withIndexedCoupons(boost::optional b) { + IborLeg& IborLeg::withIndexedCoupons(ext::optional b) { useIndexedCoupons_ = b; return *this; } diff --git a/ql/cashflows/iborcoupon.hpp b/ql/cashflows/iborcoupon.hpp index 88478d2be0e..1f85f195dd9 100644 --- a/ql/cashflows/iborcoupon.hpp +++ b/ql/cashflows/iborcoupon.hpp @@ -33,6 +33,7 @@ #include #include #include +#include namespace QuantLib { @@ -154,7 +155,7 @@ namespace QuantLib { const Calendar&, BusinessDayConvention, bool endOfMonth = false); - IborLeg& withIndexedCoupons(boost::optional b = true); + IborLeg& withIndexedCoupons(ext::optional b = true); IborLeg& withAtParCoupons(bool b = true); operator Leg() const; @@ -175,7 +176,7 @@ namespace QuantLib { Calendar exCouponCalendar_; BusinessDayConvention exCouponAdjustment_ = Unadjusted; bool exCouponEndOfMonth_ = false; - boost::optional useIndexedCoupons_; + ext::optional useIndexedCoupons_; }; } diff --git a/ql/config.hpp.cfg b/ql/config.hpp.cfg index c8a848b7f05..775f6b83a01 100644 --- a/ql/config.hpp.cfg +++ b/ql/config.hpp.cfg @@ -36,6 +36,8 @@ #cmakedefine QL_EXTRA_SAFETY_CHECKS #cmakedefine QL_HIGH_RESOLUTION_DATE #cmakedefine QL_USE_INDEXED_COUPON +#cmakedefine QL_USE_STD_ANY +#cmakedefine QL_USE_STD_OPTIONAL #cmakedefine QL_USE_STD_SHARED_PTR #cmakedefine QL_USE_STD_FUNCTION #cmakedefine QL_USE_STD_TUPLE diff --git a/ql/event.cpp b/ql/event.cpp index a5edf97fa2c..bc764b4df86 100644 --- a/ql/event.cpp +++ b/ql/event.cpp @@ -20,12 +20,13 @@ #include #include +#include #include namespace QuantLib { bool Event::hasOccurred(const Date& d, // refDate - boost::optional includeRefDate) const { + ext::optional includeRefDate) const { Date refDate = d != Date() ? d : Settings::instance().evaluationDate(); bool includeRefDateEvent = includeRefDate ? // NOLINT(readability-implicit-bool-conversion) diff --git a/ql/event.hpp b/ql/event.hpp index 65609d6774e..a03fdac7dee 100644 --- a/ql/event.hpp +++ b/ql/event.hpp @@ -27,7 +27,7 @@ #include #include -#include +#include namespace QuantLib { @@ -52,7 +52,7 @@ namespace QuantLib { */ virtual bool hasOccurred( const Date& refDate = Date(), - boost::optional includeRefDate = boost::none) const; + ext::optional includeRefDate = ext::nullopt()) const; //@} //! \name Visitability diff --git a/ql/experimental/catbonds/montecarlocatbondengine.cpp b/ql/experimental/catbonds/montecarlocatbondengine.cpp index fdc8bd4dd5b..601eabc4582 100644 --- a/ql/experimental/catbonds/montecarlocatbondengine.cpp +++ b/ql/experimental/catbonds/montecarlocatbondengine.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -27,7 +28,7 @@ namespace QuantLib { MonteCarloCatBondEngine::MonteCarloCatBondEngine( ext::shared_ptr catRisk, Handle discountCurve, - const boost::optional& includeSettlementDateFlows) + const ext::optional& includeSettlementDateFlows) : catRisk_(std::move(catRisk)), discountCurve_(std::move(discountCurve)), includeSettlementDateFlows_(includeSettlementDateFlows) { registerWith(discountCurve_); diff --git a/ql/experimental/catbonds/montecarlocatbondengine.hpp b/ql/experimental/catbonds/montecarlocatbondengine.hpp index d5ad54d0c88..883d7f28503 100644 --- a/ql/experimental/catbonds/montecarlocatbondengine.hpp +++ b/ql/experimental/catbonds/montecarlocatbondengine.hpp @@ -24,6 +24,7 @@ #ifndef quantlib_montecarlo_catbond_engine_hpp #define quantlib_montecarlo_catbond_engine_hpp +#include #include namespace QuantLib { @@ -35,7 +36,7 @@ namespace QuantLib { explicit MonteCarloCatBondEngine( ext::shared_ptr catRisk, Handle discountCurve = Handle(), - const boost::optional& includeSettlementDateFlows = boost::none); + const ext::optional& includeSettlementDateFlows = ext::nullopt()); void calculate() const override; Handle discountCurve() const { return discountCurve_; } protected: @@ -56,7 +57,7 @@ namespace QuantLib { private: ext::shared_ptr catRisk_; Handle discountCurve_; - boost::optional includeSettlementDateFlows_; + ext::optional includeSettlementDateFlows_; }; } diff --git a/ql/experimental/commodities/commodity.hpp b/ql/experimental/commodities/commodity.hpp index 56cf6a514b4..92dddb9d4b9 100644 --- a/ql/experimental/commodities/commodity.hpp +++ b/ql/experimental/commodities/commodity.hpp @@ -24,6 +24,7 @@ #ifndef quantlib_commodity_hpp #define quantlib_commodity_hpp +#include #include #include #include @@ -32,7 +33,7 @@ namespace QuantLib { - typedef std::map SecondaryCosts; + typedef std::map SecondaryCosts; typedef std::map SecondaryCostAmounts; std::ostream& operator<<(std::ostream& out, diff --git a/ql/experimental/commodities/energycommodity.cpp b/ql/experimental/commodities/energycommodity.cpp index 2205ee1c8ad..4ade5b1361d 100644 --- a/ql/experimental/commodities/energycommodity.cpp +++ b/ql/experimental/commodities/energycommodity.cpp @@ -144,16 +144,16 @@ namespace QuantLib { try { for (SecondaryCosts::const_iterator i = secondaryCosts_->begin(); i != secondaryCosts_->end(); ++i) { - if (boost::any_cast(&i->second) != nullptr) { + if (ext::any_cast(&i->second) != nullptr) { Real value = calculateUnitCost( commodityType, - boost::any_cast(i->second), + ext::any_cast(i->second), evaluationDate) * totalQuantityValue; secondaryCostAmounts_[i->first] = Money(baseCurrency, value); - } else if (boost::any_cast(&i->second) != nullptr) { - const Money& amount = boost::any_cast(i->second); + } else if (ext::any_cast(&i->second) != nullptr) { + const Money& amount = ext::any_cast(i->second); Real fxConversionFactor = calculateFxConversionFactor(amount.currency(), baseCurrency, diff --git a/ql/experimental/coupons/lognormalcmsspreadpricer.cpp b/ql/experimental/coupons/lognormalcmsspreadpricer.cpp index 33dcf92a62a..769b0f16967 100644 --- a/ql/experimental/coupons/lognormalcmsspreadpricer.cpp +++ b/ql/experimental/coupons/lognormalcmsspreadpricer.cpp @@ -25,9 +25,9 @@ #include #include #include +#include #include - using std::sqrt; namespace QuantLib { @@ -47,7 +47,7 @@ namespace QuantLib { const Handle& correlation, Handle couponDiscountCurve, const Size integrationPoints, - const boost::optional& volatilityType, + const ext::optional& volatilityType, const Real shift1, const Real shift2) : CmsSpreadCouponPricer(correlation), cmsPricer_(cmsPricer), @@ -66,7 +66,7 @@ namespace QuantLib { cnd_ = ext::make_shared(0.0, 1.0); - if(volatilityType == boost::none) { + if (!volatilityType) { QL_REQUIRE(shift1 == Null() && shift2 == Null(), "if volatility type is inherited, no shifts should be " "specified"); diff --git a/ql/experimental/coupons/lognormalcmsspreadpricer.hpp b/ql/experimental/coupons/lognormalcmsspreadpricer.hpp index 2ab0af81bdd..ce67e51913f 100644 --- a/ql/experimental/coupons/lognormalcmsspreadpricer.hpp +++ b/ql/experimental/coupons/lognormalcmsspreadpricer.hpp @@ -31,6 +31,7 @@ #include #include #include +#include namespace QuantLib { @@ -64,7 +65,7 @@ namespace QuantLib { const Handle& correlation, Handle couponDiscountCurve = Handle(), Size IntegrationPoints = 16, - const boost::optional& volatilityType = boost::none, + const ext::optional& volatilityType = ext::nullopt(), Real shift1 = Null(), Real shift2 = Null()); diff --git a/ql/experimental/credit/syntheticcdo.cpp b/ql/experimental/credit/syntheticcdo.cpp index 0c50579f873..8d0cdeaadcb 100644 --- a/ql/experimental/credit/syntheticcdo.cpp +++ b/ql/experimental/credit/syntheticcdo.cpp @@ -27,6 +27,7 @@ #include #include #include +#include using namespace std; @@ -39,9 +40,9 @@ namespace QuantLib { Rate runningRate, const DayCounter& dayCounter, BusinessDayConvention paymentConvention, - boost::optional notional) + ext::optional notional) : basket_(basket), side_(side), upfrontRate_(upfrontRate), runningRate_(runningRate), - leverageFactor_(notional ? notional.get() / basket->trancheNotional() : Real(1.)), // NOLINT(readability-implicit-bool-conversion) + leverageFactor_(notional ? *notional / basket->trancheNotional() : Real(1.)), // NOLINT(readability-implicit-bool-conversion) dayCounter_(dayCounter), paymentConvention_(paymentConvention) { QL_REQUIRE(!basket->names().empty(), "basket is empty"); // Basket inception must lie before contract protection start. diff --git a/ql/experimental/credit/syntheticcdo.hpp b/ql/experimental/credit/syntheticcdo.hpp index 378785645ba..effa0a7cf4e 100644 --- a/ql/experimental/credit/syntheticcdo.hpp +++ b/ql/experimental/credit/syntheticcdo.hpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -123,7 +124,7 @@ namespace QuantLib { Rate runningRate, const DayCounter& dayCounter, BusinessDayConvention paymentConvention, - boost::optional notional = boost::none); + ext::optional notional = ext::nullopt()); const ext::shared_ptr& basket() const { return basket_; } diff --git a/ql/experimental/swaptions/irregularswap.hpp b/ql/experimental/swaptions/irregularswap.hpp index c378a7692d6..5257d6f44ad 100644 --- a/ql/experimental/swaptions/irregularswap.hpp +++ b/ql/experimental/swaptions/irregularswap.hpp @@ -32,7 +32,6 @@ #include #include #include -#include namespace QuantLib { diff --git a/ql/experimental/swaptions/irregularswaption.cpp b/ql/experimental/swaptions/irregularswaption.cpp index d3127db5038..601018d164c 100644 --- a/ql/experimental/swaptions/irregularswaption.cpp +++ b/ql/experimental/swaptions/irregularswaption.cpp @@ -21,6 +21,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ +#include #include #include #include @@ -79,7 +80,7 @@ namespace QuantLib { auto vega_ = results_->additionalResults.find("vega"); QL_REQUIRE(vega_ != results_->additionalResults.end(), "vega not provided"); - return boost::any_cast(vega_->second); + return ext::any_cast(vega_->second); } } diff --git a/ql/instrument.hpp b/ql/instrument.hpp index 34112e683bd..394d079c4a8 100644 --- a/ql/instrument.hpp +++ b/ql/instrument.hpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include @@ -58,7 +58,7 @@ namespace QuantLib { //! returns any additional result returned by the pricing engine. template T result(const std::string& tag) const; //! returns all additional result returned by the pricing engine. - const std::map& additionalResults() const; + const std::map& additionalResults() const; //! returns whether the instrument might have value greater than zero. virtual bool isExpired() const = 0; @@ -105,7 +105,7 @@ namespace QuantLib { //@{ mutable Real NPV_, errorEstimate_; mutable Date valuationDate_; - mutable std::map additionalResults_; + mutable std::map additionalResults_; //@} ext::shared_ptr engine_; }; @@ -120,7 +120,7 @@ namespace QuantLib { Real value; Real errorEstimate; Date valuationDate; - std::map additionalResults; + std::map additionalResults; }; @@ -204,14 +204,14 @@ namespace QuantLib { template inline T Instrument::result(const std::string& tag) const { calculate(); - std::map::const_iterator value = + std::map::const_iterator value = additionalResults_.find(tag); QL_REQUIRE(value != additionalResults_.end(), tag << " not provided"); - return boost::any_cast(value->second); + return ext::any_cast(value->second); } - inline const std::map& + inline const std::map& Instrument::additionalResults() const { calculate(); return additionalResults_; diff --git a/ql/instruments/callabilityschedule.hpp b/ql/instruments/callabilityschedule.hpp index a6344f85582..c0b7e39ec50 100644 --- a/ql/instruments/callabilityschedule.hpp +++ b/ql/instruments/callabilityschedule.hpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include namespace QuantLib { @@ -57,7 +57,7 @@ namespace QuantLib { void accept(AcyclicVisitor&) override; //@} private: - boost::optional price_; + ext::optional price_; Type type_; Date date_; }; diff --git a/ql/instruments/capfloor.cpp b/ql/instruments/capfloor.cpp index c9f549fc910..1c228b6b82a 100644 --- a/ql/instruments/capfloor.cpp +++ b/ql/instruments/capfloor.cpp @@ -21,6 +21,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ +#include #include #include #include @@ -102,7 +103,7 @@ namespace QuantLib { auto vega_ = results_->additionalResults.find("vega"); QL_REQUIRE(vega_ != results_->additionalResults.end(), "vega not provided"); - return boost::any_cast(vega_->second); + return ext::any_cast(vega_->second); } } diff --git a/ql/instruments/creditdefaultswap.cpp b/ql/instruments/creditdefaultswap.cpp index 043dc649448..4c872d303cd 100644 --- a/ql/instruments/creditdefaultswap.cpp +++ b/ql/instruments/creditdefaultswap.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include namespace QuantLib { @@ -49,7 +50,7 @@ namespace QuantLib { const bool rebatesAccrual, const Date& tradeDate, Natural cashSettlementDays) - : side_(side), notional_(notional), upfront_(boost::none), runningSpread_(spread), + : side_(side), notional_(notional), upfront_(ext::nullopt()), runningSpread_(spread), settlesAccrual_(settlesAccrual), paysAtDefaultTime_(paysAtDefaultTime), claim_(std::move(claim)), protectionStart_(protectionStart == Null() ? schedule[0] : protectionStart), @@ -186,7 +187,7 @@ namespace QuantLib { return runningSpread_; } - boost::optional CreditDefaultSwap::upfront() const { + ext::optional CreditDefaultSwap::upfront() const { return upfront_; } @@ -360,7 +361,7 @@ namespace QuantLib { case ISDA: engine = ext::make_shared( probability, recoveryRate, discountCurve, - boost::none, + ext::nullopt(), IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); @@ -401,7 +402,7 @@ namespace QuantLib { case ISDA: engine = ext::make_shared( probability, conventionalRecovery, discountCurve, - boost::none, + ext::nullopt(), IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); diff --git a/ql/instruments/creditdefaultswap.hpp b/ql/instruments/creditdefaultswap.hpp index 4b7fa52cbaa..6180e3dcb46 100644 --- a/ql/instruments/creditdefaultswap.hpp +++ b/ql/instruments/creditdefaultswap.hpp @@ -31,6 +31,7 @@ #include #include #include +#include namespace QuantLib { @@ -175,7 +176,7 @@ namespace QuantLib { Protection::Side side() const; Real notional() const; Rate runningSpread() const; - boost::optional upfront() const; + ext::optional upfront() const; bool settlesAccrual() const; bool paysAtDefaultTime() const; const Leg& coupons() const; @@ -281,7 +282,7 @@ namespace QuantLib { // data members Protection::Side side_; Real notional_; - boost::optional upfront_; + ext::optional upfront_; Rate runningSpread_; bool settlesAccrual_, paysAtDefaultTime_; ext::shared_ptr claim_; @@ -313,7 +314,7 @@ namespace QuantLib { arguments(); Protection::Side side; Real notional; - boost::optional upfront; + ext::optional upfront; Rate spread; Leg leg; // if not initialized by constructors means theres no flows. diff --git a/ql/instruments/floatfloatswap.cpp b/ql/instruments/floatfloatswap.cpp index f8ec673588d..1df6a850143 100644 --- a/ql/instruments/floatfloatswap.cpp +++ b/ql/instruments/floatfloatswap.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include namespace QuantLib { @@ -52,8 +53,8 @@ namespace QuantLib { const Real spread2, const Real cappedRate2, const Real flooredRate2, - const boost::optional& paymentConvention1, - const boost::optional& paymentConvention2) + const ext::optional& paymentConvention1, + const ext::optional& paymentConvention2) : Swap(2), type_(type), nominal1_(std::vector(schedule1.size() - 1, nominal1)), nominal2_(std::vector(schedule2.size() - 1, nominal2)), schedule1_(schedule1), schedule2_(schedule2), index1_(std::move(index1)), index2_(std::move(index2)), @@ -91,8 +92,8 @@ namespace QuantLib { std::vector spread2, std::vector cappedRate2, std::vector flooredRate2, - const boost::optional& paymentConvention1, - const boost::optional& paymentConvention2) + const ext::optional& paymentConvention1, + const ext::optional& paymentConvention2) : Swap(2), type_(type), nominal1_(std::move(nominal1)), nominal2_(std::move(nominal2)), schedule1_(std::move(schedule1)), schedule2_(std::move(schedule2)), index1_(std::move(index1)), index2_(std::move(index2)), gearing1_(std::move(gearing1)), @@ -107,8 +108,8 @@ namespace QuantLib { } void FloatFloatSwap::init( - boost::optional paymentConvention1, - boost::optional paymentConvention2) { + ext::optional paymentConvention1, + ext::optional paymentConvention2) { QL_REQUIRE(nominal1_.size() == schedule1_.size() - 1, "nominal1 size (" << nominal1_.size() diff --git a/ql/instruments/floatfloatswap.hpp b/ql/instruments/floatfloatswap.hpp index 4914c609689..8172490f540 100644 --- a/ql/instruments/floatfloatswap.hpp +++ b/ql/instruments/floatfloatswap.hpp @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -65,8 +65,8 @@ namespace QuantLib { Real spread2 = 0.0, Real cappedRate2 = Null(), Real flooredRate2 = Null(), - const boost::optional& paymentConvention1 = boost::none, - const boost::optional& paymentConvention2 = boost::none); + const ext::optional& paymentConvention1 = ext::nullopt(), + const ext::optional& paymentConvention2 = ext::nullopt()); FloatFloatSwap( Swap::Type type, @@ -88,8 +88,8 @@ namespace QuantLib { std::vector spread2 = std::vector(), std::vector cappedRate2 = std::vector(), std::vector flooredRate2 = std::vector(), - const boost::optional& paymentConvention1 = boost::none, - const boost::optional& paymentConvention2 = boost::none); + const ext::optional& paymentConvention1 = ext::nullopt(), + const ext::optional& paymentConvention2 = ext::nullopt()); //! \name Inspectors //@{ @@ -132,8 +132,8 @@ namespace QuantLib { void fetchResults(const PricingEngine::results*) const override; private: - void init(boost::optional paymentConvention1, - boost::optional paymentConvention2); + void init(ext::optional paymentConvention1, + ext::optional paymentConvention2); void setupExpired() const override; Swap::Type type_; std::vector nominal1_, nominal2_; diff --git a/ql/instruments/makecds.hpp b/ql/instruments/makecds.hpp index ee4e2b6e3cb..9e3a98f2e75 100644 --- a/ql/instruments/makecds.hpp +++ b/ql/instruments/makecds.hpp @@ -26,7 +26,7 @@ #define quantlib_makecds_hpp #include -#include +#include namespace QuantLib { @@ -58,8 +58,8 @@ namespace QuantLib { private: Protection::Side side_; Real nominal_; - boost::optional tenor_; - boost::optional termDate_; + ext::optional tenor_; + ext::optional termDate_; Period couponTenor_; Real couponRate_; Real upfrontRate_; diff --git a/ql/instruments/makeswaption.cpp b/ql/instruments/makeswaption.cpp index 45fbf1a06df..bbbe3736267 100644 --- a/ql/instruments/makeswaption.cpp +++ b/ql/instruments/makeswaption.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -145,7 +146,7 @@ namespace QuantLib { return *this; } - MakeSwaption& MakeSwaption::withIndexedCoupons(const boost::optional& b) { + MakeSwaption& MakeSwaption::withIndexedCoupons(const ext::optional& b) { useIndexedCoupons_ = b; return *this; } diff --git a/ql/instruments/makeswaption.hpp b/ql/instruments/makeswaption.hpp index 4fa1ec26ae5..08802daf7df 100644 --- a/ql/instruments/makeswaption.hpp +++ b/ql/instruments/makeswaption.hpp @@ -27,6 +27,7 @@ #include #include +#include namespace QuantLib { @@ -60,7 +61,7 @@ namespace QuantLib { MakeSwaption& withOptionConvention(BusinessDayConvention bdc); MakeSwaption& withExerciseDate(const Date&); MakeSwaption& withUnderlyingType(Swap::Type type); - MakeSwaption& withIndexedCoupons(const boost::optional& b = true); + MakeSwaption& withIndexedCoupons(const ext::optional& b = true); MakeSwaption& withAtParCoupons(bool b = true); MakeSwaption& withPricingEngine( @@ -80,7 +81,7 @@ namespace QuantLib { Rate strike_; Swap::Type underlyingType_; Real nominal_; - boost::optional useIndexedCoupons_; + ext::optional useIndexedCoupons_; ext::shared_ptr engine_; }; diff --git a/ql/instruments/makevanillaswap.cpp b/ql/instruments/makevanillaswap.cpp index 6efd9eedcf8..98d89bac0c0 100644 --- a/ql/instruments/makevanillaswap.cpp +++ b/ql/instruments/makevanillaswap.cpp @@ -33,6 +33,7 @@ #include #include #include +#include namespace QuantLib { @@ -152,7 +153,7 @@ namespace QuantLib { VanillaSwap temp(type_, 100.00, fixedSchedule, 0.0, // fixed rate fixedDayCount, floatSchedule, iborIndex_, floatSpread_, floatDayCount_, - boost::none, useIndexedCoupons_); + ext::nullopt(), useIndexedCoupons_); if (engine_ == nullptr) { Handle disc = iborIndex_->forwardingTermStructure(); @@ -171,7 +172,7 @@ namespace QuantLib { ext::shared_ptr swap(new VanillaSwap( type_, nominal_, fixedSchedule, usedFixedRate, fixedDayCount, floatSchedule, iborIndex_, - floatSpread_, floatDayCount_, boost::none, useIndexedCoupons_)); + floatSpread_, floatDayCount_, ext::nullopt(), useIndexedCoupons_)); if (engine_ == nullptr) { Handle disc = @@ -346,7 +347,7 @@ namespace QuantLib { return *this; } - MakeVanillaSwap& MakeVanillaSwap::withIndexedCoupons(const boost::optional& b) { + MakeVanillaSwap& MakeVanillaSwap::withIndexedCoupons(const ext::optional& b) { useIndexedCoupons_ = b; return *this; } diff --git a/ql/instruments/makevanillaswap.hpp b/ql/instruments/makevanillaswap.hpp index c1466cd3588..dfa04bd4108 100644 --- a/ql/instruments/makevanillaswap.hpp +++ b/ql/instruments/makevanillaswap.hpp @@ -82,7 +82,7 @@ namespace QuantLib { const Handle& discountCurve); MakeVanillaSwap& withPricingEngine( const ext::shared_ptr& engine); - MakeVanillaSwap& withIndexedCoupons(const boost::optional& b = true); + MakeVanillaSwap& withIndexedCoupons(const ext::optional& b = true); MakeVanillaSwap& withAtParCoupons(bool b = true); private: Period swapTenor_; @@ -107,7 +107,7 @@ namespace QuantLib { Date floatFirstDate_, floatNextToLastDate_; Spread floatSpread_ = 0.0; DayCounter fixedDayCount_, floatDayCount_; - boost::optional useIndexedCoupons_; + ext::optional useIndexedCoupons_; ext::shared_ptr engine_; }; diff --git a/ql/instruments/nonstandardswap.cpp b/ql/instruments/nonstandardswap.cpp index efd9db61b43..bf7f7cfd237 100644 --- a/ql/instruments/nonstandardswap.cpp +++ b/ql/instruments/nonstandardswap.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include namespace QuantLib { @@ -67,7 +68,7 @@ namespace QuantLib { DayCounter floatingDayCount, const bool intermediateCapitalExchange, const bool finalCapitalExchange, - boost::optional paymentConvention) + ext::optional paymentConvention) : Swap(2), type_(type), fixedNominal_(std::move(fixedNominal)), floatingNominal_(floatingNominal), fixedSchedule_(std::move(fixedSchedule)), fixedRate_(std::move(fixedRate)), fixedDayCount_(std::move(fixedDayCount)), @@ -98,7 +99,7 @@ namespace QuantLib { DayCounter floatingDayCount, const bool intermediateCapitalExchange, const bool finalCapitalExchange, - boost::optional paymentConvention) + ext::optional paymentConvention) : Swap(2), type_(type), fixedNominal_(std::move(fixedNominal)), floatingNominal_(std::move(floatingNominal)), fixedSchedule_(std::move(fixedSchedule)), fixedRate_(std::move(fixedRate)), fixedDayCount_(std::move(fixedDayCount)), diff --git a/ql/instruments/nonstandardswap.hpp b/ql/instruments/nonstandardswap.hpp index 4146b073c52..499012dc1d2 100644 --- a/ql/instruments/nonstandardswap.hpp +++ b/ql/instruments/nonstandardswap.hpp @@ -28,7 +28,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -56,7 +56,7 @@ namespace QuantLib { DayCounter floatingDayCount, bool intermediateCapitalExchange = false, bool finalCapitalExchange = false, - boost::optional paymentConvention = boost::none); + ext::optional paymentConvention = ext::nullopt()); NonstandardSwap(Swap::Type type, std::vector fixedNominal, std::vector floatingNominal, @@ -70,7 +70,7 @@ namespace QuantLib { DayCounter floatingDayCount, bool intermediateCapitalExchange = false, bool finalCapitalExchange = false, - boost::optional paymentConvention = boost::none); + ext::optional paymentConvention = ext::nullopt()); //! \name Inspectors //@{ Swap::Type type() const; diff --git a/ql/instruments/swaption.cpp b/ql/instruments/swaption.cpp index e8b8fbe6586..581963873b4 100644 --- a/ql/instruments/swaption.cpp +++ b/ql/instruments/swaption.cpp @@ -22,6 +22,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ +#include #include #include #include @@ -98,7 +99,7 @@ namespace QuantLib { auto vega_ = results_->additionalResults.find("vega"); QL_REQUIRE(vega_ != results_->additionalResults.end(), "vega not provided"); - return boost::any_cast(vega_->second); + return ext::any_cast(vega_->second); } } diff --git a/ql/instruments/vanillaswap.cpp b/ql/instruments/vanillaswap.cpp index e7bcbc4fd11..ff1489b8224 100644 --- a/ql/instruments/vanillaswap.cpp +++ b/ql/instruments/vanillaswap.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include namespace QuantLib { @@ -40,8 +41,8 @@ namespace QuantLib { ext::shared_ptr iborIndex, Spread spread, DayCounter floatingDayCount, - boost::optional paymentConvention, - boost::optional useIndexedCoupons) + ext::optional paymentConvention, + ext::optional useIndexedCoupons) : Swap(2), type_(type), nominal_(nominal), fixedSchedule_(std::move(fixedSchedule)), fixedRate_(fixedRate), fixedDayCount_(std::move(fixedDayCount)), floatingSchedule_(std::move(floatSchedule)), iborIndex_(std::move(iborIndex)), diff --git a/ql/instruments/vanillaswap.hpp b/ql/instruments/vanillaswap.hpp index 60fdf947aeb..f240a6e2de8 100644 --- a/ql/instruments/vanillaswap.hpp +++ b/ql/instruments/vanillaswap.hpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -76,8 +76,8 @@ namespace QuantLib { ext::shared_ptr iborIndex, Spread spread, DayCounter floatingDayCount, - boost::optional paymentConvention = boost::none, - boost::optional useIndexedCoupons = boost::none); + ext::optional paymentConvention = ext::nullopt(), + ext::optional useIndexedCoupons = ext::nullopt()); //! \name Inspectors //@{ Type type() const; diff --git a/ql/optional.hpp b/ql/optional.hpp new file mode 100644 index 00000000000..2d6edd4aa1b --- /dev/null +++ b/ql/optional.hpp @@ -0,0 +1,51 @@ +/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + Copyright (C) 2023 Jonathan Sweemer + + 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. +*/ + +/*! \file optional.hpp + \brief Maps optional to either the boost or std implementation +*/ + +#ifndef quantlib_optional_hpp +#define quantlib_optional_hpp + +#include + +#if defined(QL_USE_STD_OPTIONAL) +#include +#else +#include +#endif + +namespace QuantLib { + + namespace ext { + + #if defined(QL_USE_STD_OPTIONAL) + using std::optional; // NOLINT(misc-unused-using-decls) + constexpr const std::nullopt_t& nullopt() { return std::nullopt; } + #else + using boost::optional; // NOLINT(misc-unused-using-decls) + constexpr const boost::none_t& nullopt() { return boost::none; } + #endif + + } + +} + +#endif diff --git a/ql/pricingengines/bond/discountingbondengine.cpp b/ql/pricingengines/bond/discountingbondengine.cpp index 20a97b8e633..699f73a3923 100644 --- a/ql/pricingengines/bond/discountingbondengine.cpp +++ b/ql/pricingengines/bond/discountingbondengine.cpp @@ -20,13 +20,14 @@ #include #include +#include #include namespace QuantLib { DiscountingBondEngine::DiscountingBondEngine( Handle discountCurve, - const boost::optional& includeSettlementDateFlows) + const ext::optional& includeSettlementDateFlows) : discountCurve_(std::move(discountCurve)), includeSettlementDateFlows_(includeSettlementDateFlows) { registerWith(discountCurve_); diff --git a/ql/pricingengines/bond/discountingbondengine.hpp b/ql/pricingengines/bond/discountingbondengine.hpp index eb41c28dfae..f518b20dff6 100644 --- a/ql/pricingengines/bond/discountingbondengine.hpp +++ b/ql/pricingengines/bond/discountingbondengine.hpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace QuantLib { @@ -35,14 +36,14 @@ namespace QuantLib { public: DiscountingBondEngine( Handle discountCurve = Handle(), - const boost::optional& includeSettlementDateFlows = boost::none); + const ext::optional& includeSettlementDateFlows = ext::nullopt()); void calculate() const override; Handle discountCurve() const { return discountCurve_; } private: Handle discountCurve_; - boost::optional includeSettlementDateFlows_; + ext::optional includeSettlementDateFlows_; }; } diff --git a/ql/pricingengines/capfloor/analyticcapfloorengine.cpp b/ql/pricingengines/capfloor/analyticcapfloorengine.cpp index 1cc6ff8a608..eb6125d788d 100644 --- a/ql/pricingengines/capfloor/analyticcapfloorengine.cpp +++ b/ql/pricingengines/capfloor/analyticcapfloorengine.cpp @@ -18,6 +18,7 @@ */ #include +#include #include namespace QuantLib { @@ -53,7 +54,7 @@ namespace QuantLib { bool includeRefDatePayments = Settings::instance().includeReferenceDateEvents(); if (referenceDate == Settings::instance().evaluationDate()) { - boost::optional includeTodaysPayments = + ext::optional includeTodaysPayments = Settings::instance().includeTodaysCashFlows(); if (includeTodaysPayments) // NOLINT(readability-implicit-bool-conversion) includeRefDatePayments = *includeTodaysPayments; diff --git a/ql/pricingengines/credit/integralcdsengine.cpp b/ql/pricingengines/credit/integralcdsengine.cpp index a7ae1194ec1..b22d5b06cc3 100644 --- a/ql/pricingengines/credit/integralcdsengine.cpp +++ b/ql/pricingengines/credit/integralcdsengine.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include namespace QuantLib { @@ -31,7 +32,7 @@ namespace QuantLib { Handle probability, Real recoveryRate, Handle discountCurve, - const boost::optional& includeSettlementDateFlows) + const ext::optional& includeSettlementDateFlows) : integrationStep_(step), probability_(std::move(probability)), recoveryRate_(recoveryRate), discountCurve_(std::move(discountCurve)), includeSettlementDateFlows_(includeSettlementDateFlows) { diff --git a/ql/pricingengines/credit/integralcdsengine.hpp b/ql/pricingengines/credit/integralcdsengine.hpp index efb23c02cb5..dba086e3eac 100644 --- a/ql/pricingengines/credit/integralcdsengine.hpp +++ b/ql/pricingengines/credit/integralcdsengine.hpp @@ -26,6 +26,7 @@ #define quantlib_integral_cds_engine_hpp #include +#include namespace QuantLib { @@ -35,7 +36,7 @@ namespace QuantLib { Handle, Real recoveryRate, Handle discountCurve, - const boost::optional& includeSettlementDateFlows = boost::none); + const ext::optional& includeSettlementDateFlows = ext::nullopt()); void calculate() const override; private: @@ -43,7 +44,7 @@ namespace QuantLib { Handle probability_; Real recoveryRate_; Handle discountCurve_; - boost::optional includeSettlementDateFlows_; + ext::optional includeSettlementDateFlows_; }; } diff --git a/ql/pricingengines/credit/isdacdsengine.cpp b/ql/pricingengines/credit/isdacdsengine.cpp index f325ce46977..d03fe65f8ed 100644 --- a/ql/pricingengines/credit/isdacdsengine.cpp +++ b/ql/pricingengines/credit/isdacdsengine.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include namespace QuantLib { @@ -35,7 +36,7 @@ namespace QuantLib { IsdaCdsEngine::IsdaCdsEngine(Handle probability, Real recoveryRate, Handle discountCurve, - const boost::optional& includeSettlementDateFlows, + const ext::optional& includeSettlementDateFlows, const NumericalFix numericalFix, const AccrualBias accrualBias, const ForwardsInCouponPeriod forwardsInCouponPeriod) diff --git a/ql/pricingengines/credit/isdacdsengine.hpp b/ql/pricingengines/credit/isdacdsengine.hpp index 83a292ee2d0..55ee86aacf4 100644 --- a/ql/pricingengines/credit/isdacdsengine.hpp +++ b/ql/pricingengines/credit/isdacdsengine.hpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace QuantLib { @@ -97,7 +98,7 @@ namespace QuantLib { IsdaCdsEngine(Handle probability, Real recoveryRate, Handle discountCurve, - const boost::optional& includeSettlementDateFlows = boost::none, + const ext::optional& includeSettlementDateFlows = ext::nullopt(), NumericalFix numericalFix = Taylor, AccrualBias accrualBias = HalfDayBias, ForwardsInCouponPeriod forwardsInCouponPeriod = Piecewise); @@ -111,7 +112,7 @@ namespace QuantLib { Handle probability_; const Real recoveryRate_; Handle discountCurve_; - const boost::optional includeSettlementDateFlows_; + const ext::optional includeSettlementDateFlows_; const NumericalFix numericalFix_; const AccrualBias accrualBias_; const ForwardsInCouponPeriod forwardsInCouponPeriod_; diff --git a/ql/pricingengines/credit/midpointcdsengine.cpp b/ql/pricingengines/credit/midpointcdsengine.cpp index 486f485634f..aef1c710ac6 100644 --- a/ql/pricingengines/credit/midpointcdsengine.cpp +++ b/ql/pricingengines/credit/midpointcdsengine.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include namespace QuantLib { @@ -30,7 +31,7 @@ namespace QuantLib { MidPointCdsEngine::MidPointCdsEngine(Handle probability, Real recoveryRate, Handle discountCurve, - const boost::optional& includeSettlementDateFlows) + const ext::optional& includeSettlementDateFlows) : probability_(std::move(probability)), recoveryRate_(recoveryRate), discountCurve_(std::move(discountCurve)), includeSettlementDateFlows_(includeSettlementDateFlows) { diff --git a/ql/pricingengines/credit/midpointcdsengine.hpp b/ql/pricingengines/credit/midpointcdsengine.hpp index 6a5ad0999f3..172b78531d8 100644 --- a/ql/pricingengines/credit/midpointcdsengine.hpp +++ b/ql/pricingengines/credit/midpointcdsengine.hpp @@ -27,6 +27,7 @@ #define quantlib_mid_point_cds_engine_hpp #include +#include namespace QuantLib { @@ -35,14 +36,14 @@ namespace QuantLib { MidPointCdsEngine(Handle, Real recoveryRate, Handle discountCurve, - const boost::optional& includeSettlementDateFlows = boost::none); + const ext::optional& includeSettlementDateFlows = ext::nullopt()); void calculate() const override; private: Handle probability_; Real recoveryRate_; Handle discountCurve_; - boost::optional includeSettlementDateFlows_; + ext::optional includeSettlementDateFlows_; }; } diff --git a/ql/pricingengines/mclongstaffschwartzengine.hpp b/ql/pricingengines/mclongstaffschwartzengine.hpp index 7fce93aec02..9483fb43236 100644 --- a/ql/pricingengines/mclongstaffschwartzengine.hpp +++ b/ql/pricingengines/mclongstaffschwartzengine.hpp @@ -30,7 +30,7 @@ #include #include #include - +#include namespace QuantLib { @@ -80,8 +80,8 @@ namespace QuantLib { Size maxSamples, BigNatural seed, Size nCalibrationSamples = Null(), - boost::optional brownianBridgeCalibration = boost::none, - boost::optional antitheticVariateCalibration = boost::none, + ext::optional brownianBridgeCalibration = ext::nullopt(), + ext::optional antitheticVariateCalibration = ext::nullopt(), BigNatural seedCalibration = Null()); void calculate() const override; @@ -131,8 +131,8 @@ namespace QuantLib { Size maxSamples, BigNatural seed, Size nCalibrationSamples, - boost::optional brownianBridgeCalibration, - boost::optional antitheticVariateCalibration, + ext::optional brownianBridgeCalibration, + ext::optional antitheticVariateCalibration, BigNatural seedCalibration) : McSimulation(antitheticVariate, controlVariate), process_(std::move(process)), timeSteps_(timeSteps), timeStepsPerYear_(timeStepsPerYear), brownianBridge_(brownianBridge), diff --git a/ql/pricingengines/swap/discountingswapengine.cpp b/ql/pricingengines/swap/discountingswapengine.cpp index a4d46ee7f5b..206b479935e 100644 --- a/ql/pricingengines/swap/discountingswapengine.cpp +++ b/ql/pricingengines/swap/discountingswapengine.cpp @@ -21,13 +21,14 @@ #include #include #include +#include #include namespace QuantLib { DiscountingSwapEngine::DiscountingSwapEngine( Handle discountCurve, - const boost::optional& includeSettlementDateFlows, + const ext::optional& includeSettlementDateFlows, Date settlementDate, Date npvDate) : discountCurve_(std::move(discountCurve)), diff --git a/ql/pricingengines/swap/discountingswapengine.hpp b/ql/pricingengines/swap/discountingswapengine.hpp index 97270931596..7a5a0c16a9e 100644 --- a/ql/pricingengines/swap/discountingswapengine.hpp +++ b/ql/pricingengines/swap/discountingswapengine.hpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace QuantLib { @@ -35,7 +36,7 @@ namespace QuantLib { public: DiscountingSwapEngine( Handle discountCurve = Handle(), - const boost::optional& includeSettlementDateFlows = boost::none, + const ext::optional& includeSettlementDateFlows = ext::nullopt(), Date settlementDate = Date(), Date npvDate = Date()); void calculate() const override; @@ -44,7 +45,7 @@ namespace QuantLib { } private: Handle discountCurve_; - boost::optional includeSettlementDateFlows_; + ext::optional includeSettlementDateFlows_; Date settlementDate_, npvDate_; }; diff --git a/ql/pricingengines/vanilla/bjerksundstenslandengine.cpp b/ql/pricingengines/vanilla/bjerksundstenslandengine.cpp index d0a24d31ec7..6412e65b4e8 100644 --- a/ql/pricingengines/vanilla/bjerksundstenslandengine.cpp +++ b/ql/pricingengines/vanilla/bjerksundstenslandengine.cpp @@ -19,6 +19,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ +#include #include #include #include @@ -28,7 +29,6 @@ #include #include - namespace QuantLib { namespace { @@ -488,7 +488,7 @@ namespace QuantLib { Real tmp = results_.gamma; results_.gamma = - boost::any_cast(results_.additionalResults["strikeGamma"]); + ext::any_cast(results_.additionalResults["strikeGamma"]); results_.additionalResults["strikeGamma"] = tmp; std::swap(results_.rho, results_.dividendRho); diff --git a/ql/pricingengines/vanilla/mcamericanengine.hpp b/ql/pricingengines/vanilla/mcamericanengine.hpp index 04cbf92771f..41b8f6cd2f4 100644 --- a/ql/pricingengines/vanilla/mcamericanengine.hpp +++ b/ql/pricingengines/vanilla/mcamericanengine.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -64,7 +65,7 @@ namespace QuantLib { Size polynomialOrder, LsmBasisSystem::PolynomialType polynomialType, Size nCalibrationSamples = Null(), - const boost::optional& antitheticVariateCalibration = boost::none, + const ext::optional& antitheticVariateCalibration = ext::nullopt(), BigNatural seedCalibration = Null()); void calculate() const override; @@ -139,7 +140,7 @@ namespace QuantLib { BigNatural seed_ = 0; Size polynomialOrder_ = 2; LsmBasisSystem::PolynomialType polynomialType_ = LsmBasisSystem::Monomial; - boost::optional antitheticCalibration_; + ext::optional antitheticCalibration_; BigNatural seedCalibration_; }; @@ -157,7 +158,7 @@ namespace QuantLib { Size polynomialOrder, LsmBasisSystem::PolynomialType polynomialType, Size nCalibrationSamples, - const boost::optional& antitheticVariateCalibration, + const ext::optional& antitheticVariateCalibration, BigNatural seedCalibration) : MCLongstaffSchwartzEngine( process, @@ -274,7 +275,7 @@ namespace QuantLib { ext::shared_ptr process) : process_(std::move(process)), steps_(Null()), stepsPerYear_(Null()), samples_(Null()), maxSamples_(Null()), tolerance_(Null()), - antitheticCalibration_(boost::none), seedCalibration_(Null()) {} + antitheticCalibration_(ext::nullopt()), seedCalibration_(Null()) {} template inline MakeMCAmericanEngine & diff --git a/ql/settings.hpp b/ql/settings.hpp index 18b21b63801..67686d6063f 100644 --- a/ql/settings.hpp +++ b/ql/settings.hpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -102,8 +102,8 @@ namespace QuantLib { behavior chosen for includeReferenceDate. It cannot be overridden locally when calling the CashFlow::hasOccurred method. */ - boost::optional& includeTodaysCashFlows(); - boost::optional includeTodaysCashFlows() const; + ext::optional& includeTodaysCashFlows(); + ext::optional includeTodaysCashFlows() const; bool& enforcesTodaysHistoricFixings(); bool enforcesTodaysHistoricFixings() const; @@ -111,7 +111,7 @@ namespace QuantLib { private: DateProxy evaluationDate_; bool includeReferenceDateEvents_ = false; - boost::optional includeTodaysCashFlows_; + ext::optional includeTodaysCashFlows_; bool enforcesTodaysHistoricFixings_ = false; }; @@ -124,7 +124,7 @@ namespace QuantLib { private: Date evaluationDate_; bool includeReferenceDateEvents_; - boost::optional includeTodaysCashFlows_; + ext::optional includeTodaysCashFlows_; bool enforcesTodaysHistoricFixings_; }; @@ -160,11 +160,11 @@ namespace QuantLib { return includeReferenceDateEvents_; } - inline boost::optional& Settings::includeTodaysCashFlows() { + inline ext::optional& Settings::includeTodaysCashFlows() { return includeTodaysCashFlows_; } - inline boost::optional Settings::includeTodaysCashFlows() const { + inline ext::optional Settings::includeTodaysCashFlows() const { return includeTodaysCashFlows_; } diff --git a/ql/termstructures/yield/oisratehelper.cpp b/ql/termstructures/yield/oisratehelper.cpp index 16203312f25..675a0bcad6c 100644 --- a/ql/termstructures/yield/oisratehelper.cpp +++ b/ql/termstructures/yield/oisratehelper.cpp @@ -41,7 +41,7 @@ namespace QuantLib { Pillar::Choice pillar, Date customPillarDate, RateAveraging::Type averagingMethod, - boost::optional endOfMonth) + ext::optional endOfMonth) : RelativeDateRateHelper(fixedRate), pillarChoice_(pillar), settlementDays_(settlementDays), tenor_(tenor), overnightIndex_(std::move(overnightIndex)), discountHandle_(std::move(discount)), telescopicValueDates_(telescopicValueDates), diff --git a/ql/termstructures/yield/oisratehelper.hpp b/ql/termstructures/yield/oisratehelper.hpp index 2f0b92ef804..c372cb97494 100644 --- a/ql/termstructures/yield/oisratehelper.hpp +++ b/ql/termstructures/yield/oisratehelper.hpp @@ -27,6 +27,7 @@ #include #include +#include namespace QuantLib { @@ -49,7 +50,7 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), RateAveraging::Type averagingMethod = RateAveraging::Compound, - boost::optional endOfMonth = boost::none); + ext::optional endOfMonth = ext::nullopt()); //! \name RateHelper interface //@{ Real impliedQuote() const override; @@ -85,7 +86,7 @@ namespace QuantLib { Period forwardStart_; Spread overnightSpread_; RateAveraging::Type averagingMethod_; - boost::optional endOfMonth_; + ext::optional endOfMonth_; }; //! Rate helper for bootstrapping over Overnight Indexed Swap rates diff --git a/ql/termstructures/yield/ratehelpers.cpp b/ql/termstructures/yield/ratehelpers.cpp index cfbc4b8338d..95210b406e5 100644 --- a/ql/termstructures/yield/ratehelpers.cpp +++ b/ql/termstructures/yield/ratehelpers.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include namespace QuantLib { @@ -685,7 +686,7 @@ namespace QuantLib { Pillar::Choice pillarChoice, Date customPillarDate, bool endOfMonth, - const boost::optional& useIndexedCoupons) + const ext::optional& useIndexedCoupons) : RelativeDateRateHelper(rate), settlementDays_(Null()), tenor_(swapIndex->tenor()), pillarChoice_(pillarChoice), calendar_(swapIndex->fixingCalendar()), fixedConvention_(swapIndex->fixedLegConvention()), @@ -721,7 +722,7 @@ namespace QuantLib { Pillar::Choice pillarChoice, Date customPillarDate, bool endOfMonth, - const boost::optional& useIndexedCoupons) + const ext::optional& useIndexedCoupons) : RelativeDateRateHelper(rate), settlementDays_(settlementDays), tenor_(tenor), pillarChoice_(pillarChoice), calendar_(std::move(calendar)), fixedConvention_(fixedConvention), fixedFrequency_(fixedFrequency), @@ -752,7 +753,7 @@ namespace QuantLib { Pillar::Choice pillarChoice, Date customPillarDate, bool endOfMonth, - const boost::optional& useIndexedCoupons) + const ext::optional& useIndexedCoupons) : RelativeDateRateHelper(rate), settlementDays_(Null()), tenor_(swapIndex->tenor()), pillarChoice_(pillarChoice), calendar_(swapIndex->fixingCalendar()), fixedConvention_(swapIndex->fixedLegConvention()), @@ -789,7 +790,7 @@ namespace QuantLib { Pillar::Choice pillarChoice, Date customPillarDate, bool endOfMonth, - const boost::optional& useIndexedCoupons) + const ext::optional& useIndexedCoupons) : RelativeDateRateHelper(rate), settlementDays_(settlementDays), tenor_(tenor), pillarChoice_(pillarChoice), calendar_(std::move(calendar)), fixedConvention_(fixedConvention), fixedFrequency_(fixedFrequency), diff --git a/ql/termstructures/yield/ratehelpers.hpp b/ql/termstructures/yield/ratehelpers.hpp index 1eea43e4137..570797668ab 100644 --- a/ql/termstructures/yield/ratehelpers.hpp +++ b/ql/termstructures/yield/ratehelpers.hpp @@ -37,8 +37,7 @@ #include #include #include - -#include +#include namespace QuantLib { @@ -245,8 +244,8 @@ namespace QuantLib { private: void initializeDates() override; Date fixingDate_; - boost::optional periodToStart_; - boost::optional immOffsetStart_, immOffsetEnd_; + ext::optional periodToStart_; + ext::optional immOffsetStart_, immOffsetEnd_; Pillar::Choice pillarChoice_; ext::shared_ptr iborIndex_; RelinkableHandle termStructureHandle_; @@ -268,7 +267,7 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), bool endOfMonth = false, - const boost::optional& useIndexedCoupons = boost::none); + const ext::optional& useIndexedCoupons = ext::nullopt()); SwapRateHelper(const Handle& rate, const Period& tenor, Calendar calendar, @@ -286,7 +285,7 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), bool endOfMonth = false, - const boost::optional& useIndexedCoupons = boost::none); + const ext::optional& useIndexedCoupons = ext::nullopt()); SwapRateHelper(Rate rate, const ext::shared_ptr& swapIndex, Handle spread = {}, @@ -296,7 +295,7 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), bool endOfMonth = false, - const boost::optional& useIndexedCoupons = boost::none); + const ext::optional& useIndexedCoupons = ext::nullopt()); SwapRateHelper(Rate rate, const Period& tenor, Calendar calendar, @@ -314,7 +313,7 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), bool endOfMonth = false, - const boost::optional& useIndexedCoupons = boost::none); + const ext::optional& useIndexedCoupons = ext::nullopt()); //! \name RateHelper interface //@{ Real impliedQuote() const override; @@ -347,7 +346,7 @@ namespace QuantLib { Period fwdStart_; Handle discountHandle_; RelinkableHandle discountRelinkableHandle_; - boost::optional useIndexedCoupons_; + ext::optional useIndexedCoupons_; }; diff --git a/ql/time/schedule.cpp b/ql/time/schedule.cpp index 91d9c635802..31405a05006 100644 --- a/ql/time/schedule.cpp +++ b/ql/time/schedule.cpp @@ -19,6 +19,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ +#include #include #include #include @@ -56,16 +57,16 @@ namespace QuantLib { Schedule::Schedule(const std::vector& dates, Calendar calendar, BusinessDayConvention convention, - const boost::optional& terminationDateConvention, - const boost::optional& tenor, - const boost::optional& rule, - const boost::optional& endOfMonth, + const ext::optional& terminationDateConvention, + const ext::optional& tenor, + const ext::optional& rule, + const ext::optional& endOfMonth, std::vector isRegular) : tenor_(tenor), calendar_(std::move(calendar)), convention_(convention), terminationDateConvention_(terminationDateConvention), rule_(rule), dates_(dates), isRegular_(std::move(isRegular)) { - if (tenor != boost::none && !allowsEndOfMonth(*tenor)) + if (tenor && !allowsEndOfMonth(*tenor)) endOfMonth_ = false; else endOfMonth_ = endOfMonth; diff --git a/ql/time/schedule.hpp b/ql/time/schedule.hpp index ea2c6edf92f..95b790c65d0 100644 --- a/ql/time/schedule.hpp +++ b/ql/time/schedule.hpp @@ -31,7 +31,7 @@ #include #include #include -#include +#include namespace QuantLib { @@ -47,10 +47,10 @@ namespace QuantLib { const std::vector&, Calendar calendar = NullCalendar(), BusinessDayConvention convention = Unadjusted, - const boost::optional& terminationDateConvention = boost::none, - const boost::optional& tenor = boost::none, - const boost::optional& rule = boost::none, - const boost::optional& endOfMonth = boost::none, + const ext::optional& terminationDateConvention = ext::nullopt(), + const ext::optional& tenor = ext::nullopt(), + const ext::optional& rule = ext::nullopt(), + const ext::optional& endOfMonth = ext::nullopt(), std::vector isRegular = std::vector(0)); /*! rule based constructor */ Schedule(Date effectiveDate, @@ -107,12 +107,12 @@ namespace QuantLib { Schedule until(const Date& truncationDate) const; //@} private: - boost::optional tenor_; + ext::optional tenor_; Calendar calendar_; BusinessDayConvention convention_; - boost::optional terminationDateConvention_; - boost::optional rule_; - boost::optional endOfMonth_; + ext::optional terminationDateConvention_; + ext::optional rule_; + ext::optional endOfMonth_; Date firstDate_, nextToLastDate_; std::vector dates_; std::vector isRegular_; @@ -142,9 +142,9 @@ namespace QuantLib { private: Calendar calendar_; Date effectiveDate_, terminationDate_; - boost::optional tenor_; - boost::optional convention_; - boost::optional terminationDateConvention_; + ext::optional tenor_; + ext::optional convention_; + ext::optional terminationDateConvention_; DateGeneration::Rule rule_ = DateGeneration::Backward; bool endOfMonth_ = false; Date firstDate_, nextToLastDate_; @@ -184,7 +184,7 @@ namespace QuantLib { inline const Date &Schedule::endDate() const { return dates_.back(); } inline bool Schedule::hasTenor() const { - return tenor_ != boost::none; + return static_cast(tenor_); } inline const Period& Schedule::tenor() const { @@ -199,7 +199,7 @@ namespace QuantLib { inline bool Schedule::hasTerminationDateBusinessDayConvention() const { - return terminationDateConvention_ != boost::none; + return static_cast(terminationDateConvention_); } inline BusinessDayConvention @@ -210,7 +210,7 @@ namespace QuantLib { } inline bool Schedule::hasRule() const { - return rule_ != boost::none; + return static_cast(rule_); } inline DateGeneration::Rule Schedule::rule() const { @@ -219,7 +219,7 @@ namespace QuantLib { } inline bool Schedule::hasEndOfMonth() const { - return endOfMonth_ != boost::none; + return static_cast(endOfMonth_); } inline bool Schedule::endOfMonth() const { diff --git a/ql/userconfig.hpp b/ql/userconfig.hpp index 7add622ca61..70e79e3e2f0 100644 --- a/ql/userconfig.hpp +++ b/ql/userconfig.hpp @@ -83,6 +83,16 @@ //# define QL_HIGH_RESOLUTION_DATE #endif +/* Define this to use std::any instead of boost::any. */ +#ifndef QL_USE_STD_ANY +//# define QL_USE_STD_ANY +#endif + +/* Define this to use std::optional instead of boost::optional. */ +#ifndef QL_USE_STD_OPTIONAL +//# define QL_USE_STD_OPTIONAL +#endif + /* Define this to use standard smart pointers instead of Boost ones. Note that std::shared_ptr does not check access and can cause segmentation faults. */ diff --git a/test-suite/americanoption.cpp b/test-suite/americanoption.cpp index af8e1186982..a6ca179ad47 100644 --- a/test-suite/americanoption.cpp +++ b/test-suite/americanoption.cpp @@ -21,6 +21,7 @@ #include "americanoption.hpp" #include "utilities.hpp" +#include #include #include #include @@ -2084,7 +2085,7 @@ void AmericanOptionTest::testBjerksundStenslandAmericanGreeks() { const Real rho = option.rho(); const Real vega = option.vega(); const Real theta = option.theta(); - const std::string exerciseType = boost::any_cast( + const std::string exerciseType = ext::any_cast( option.additionalResults().find("exerciseType")->second); OneAssetOption::results numericalResults; @@ -2243,7 +2244,7 @@ void AmericanOptionTest::testSingleBjerksundStenslandGreeks() { const Real vega = option.vega(); const Real theta = option.theta(); const Real thetaPerDay = option.thetaPerDay(); - const std::string exerciseType = boost::any_cast( + const std::string exerciseType = ext::any_cast( option.additionalResults().find("exerciseType")->second); const Real expectedNpv = 17.9251834488399169; diff --git a/test-suite/cashflows.cpp b/test-suite/cashflows.cpp index a7d0afc7832..f81b3fff737 100644 --- a/test-suite/cashflows.cpp +++ b/test-suite/cashflows.cpp @@ -34,12 +34,12 @@ #include #include #include +#include #include #include using namespace QuantLib; using namespace boost::unit_test_framework; -using boost::none; void CashFlowsTest::testSettings() { @@ -68,7 +68,7 @@ void CashFlowsTest::testSettings() { // today's date Settings::instance().includeReferenceDateEvents() = false; - Settings::instance().includeTodaysCashFlows() = none; + Settings::instance().includeTodaysCashFlows() = ext::nullopt(); CHECK_INCLUSION(0, 0, false); CHECK_INCLUSION(0, 1, false); @@ -101,7 +101,7 @@ void CashFlowsTest::testSettings() { // today's date Settings::instance().includeReferenceDateEvents() = true; - Settings::instance().includeTodaysCashFlows() = none; + Settings::instance().includeTodaysCashFlows() = ext::nullopt(); CHECK_INCLUSION(0, 0, true); CHECK_INCLUSION(0, 1, false); @@ -163,7 +163,7 @@ void CashFlowsTest::testSettings() { } while (false); // no override - Settings::instance().includeTodaysCashFlows() = none; + Settings::instance().includeTodaysCashFlows() = ext::nullopt(); CHECK_NPV(false, 2.0); CHECK_NPV(true, 3.0); @@ -409,7 +409,7 @@ void CashFlowsTest::testPartialScheduleLegConstruction() { .backwards(); // same schedule, date based, with metadata Schedule schedule2(schedule.dates(), NullCalendar(), Unadjusted, Unadjusted, - 6 * Months, boost::none, schedule.endOfMonth(), + 6 * Months, ext::nullopt(), schedule.endOfMonth(), schedule.isRegular()); // same schedule, date based, without metadata Schedule schedule3(schedule.dates()); diff --git a/test-suite/creditdefaultswap.cpp b/test-suite/creditdefaultswap.cpp index d97d59c229b..558aa76008c 100644 --- a/test-suite/creditdefaultswap.cpp +++ b/test-suite/creditdefaultswap.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -692,7 +693,7 @@ void CreditDefaultSwapTest::testIsdaEngine() { ext::make_shared(0, WeekendsOnly(), h, Actual365Fixed())); ext::shared_ptr engine = ext::make_shared( - probabilityCurve, recovery, discountCurve, boost::none, IsdaCdsEngine::Taylor, + probabilityCurve, recovery, discountCurve, ext::nullopt(), IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); ext::shared_ptr conventionalTrade = @@ -839,7 +840,7 @@ void CreditDefaultSwapTest::testIsdaCalculatorReconcileSingleQuote () ext::make_shared(0, WeekendsOnly(), h, Actual365Fixed())); ext::shared_ptr engine = ext::make_shared( - probabilityCurve, recovery, discountCurve, boost::none, IsdaCdsEngine::Taylor, + probabilityCurve, recovery, discountCurve, ext::nullopt(), IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); ext::shared_ptr conventionalTrade = @@ -953,7 +954,7 @@ void CreditDefaultSwapTest::testIsdaCalculatorReconcileSingleWithIssueDateInTheP ext::make_shared(0, WeekendsOnly(), h, Actual365Fixed())); ext::shared_ptr engine = ext::make_shared( - probabilityCurve, recovery, discountCurve, boost::none, IsdaCdsEngine::Taylor, + probabilityCurve, recovery, discountCurve, ext::nullopt(), IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); ext::shared_ptr conventionalTrade = diff --git a/test-suite/defaultprobabilitycurves.cpp b/test-suite/defaultprobabilitycurves.cpp index 445c2efa4d4..26ba6ce60c5 100644 --- a/test-suite/defaultprobabilitycurves.cpp +++ b/test-suite/defaultprobabilitycurves.cpp @@ -402,7 +402,7 @@ void DefaultProbabilityCurveTest::testUpfrontBootstrap() { testBootstrapFromUpfront(); // also ensure that we didn't override the flag permanently - boost::optional flag = Settings::instance().includeTodaysCashFlows(); + ext::optional flag = Settings::instance().includeTodaysCashFlows(); if (flag != false) BOOST_ERROR("Cash-flow settings improperly modified"); } diff --git a/test-suite/period.cpp b/test-suite/period.cpp index 39361f63fa6..c9f4eeace95 100644 --- a/test-suite/period.cpp +++ b/test-suite/period.cpp @@ -158,7 +158,7 @@ void PeriodTest::testNormalization() { for (Period p2 : test_values) { auto n2 = p2.normalized(); - boost::optional comparison; + ext::optional comparison; try { comparison = (p1 == p2); } catch (Error&) { diff --git a/test-suite/quantlibtestsuite.cpp b/test-suite/quantlibtestsuite.cpp index 6201c7fd594..eb27ccfe4bd 100644 --- a/test-suite/quantlibtestsuite.cpp +++ b/test-suite/quantlibtestsuite.cpp @@ -246,7 +246,7 @@ namespace { */ // QuantLib::Settings::instance().includeReferenceDateCashFlows() = true; - // QuantLib::Settings::instance().includeTodaysCashFlows() = boost::none; + // QuantLib::Settings::instance().includeTodaysCashFlows() = ext::nullopt(); QuantLib::Settings::instance().evaluationDate() = evaluationDate; } @@ -330,10 +330,11 @@ test_suite* init_unit_test_suite(int, char* []) { << (settings.includeReferenceDateEvents() ? "reference date events are included,\n" : "reference date events are excluded,\n") - << (settings.includeTodaysCashFlows() == boost::none ? - "" : (*settings.includeTodaysCashFlows() ? - "today's cashflows are included,\n" - : "today's cashflows are excluded,\n")) + << (settings.includeTodaysCashFlows() + ? (*settings.includeTodaysCashFlows() + ? "today's cashflows are included,\n" + : "today's cashflows are excluded,\n") + : "") << (settings.enforcesTodaysHistoricFixings() ? "today's historic fixings are enforced." : "today's historic fixings are not enforced.") From 1ca515fd766afec155e4c97a4c24e2574d2c9f50 Mon Sep 17 00:00:00 2001 From: Peter Caspers Date: Sat, 18 Mar 2023 18:02:05 +0100 Subject: [PATCH 061/292] Update test-suite/piecewiseyieldcurve.cpp Co-authored-by: Luigi Ballabio --- test-suite/piecewiseyieldcurve.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-suite/piecewiseyieldcurve.cpp b/test-suite/piecewiseyieldcurve.cpp index 8faaae2b134..6086d971cf4 100644 --- a/test-suite/piecewiseyieldcurve.cpp +++ b/test-suite/piecewiseyieldcurve.cpp @@ -825,7 +825,7 @@ void PiecewiseYieldCurveTest::testObservability() { vars.instruments, Actual360())); - boost::dynamic_pointer_cast(vars.termStructure)->forwardFirstNotificationOnly(); + ext::dynamic_pointer_cast(vars.termStructure)->forwardFirstNotificationOnly(); Flag f; f.registerWith(vars.termStructure); From 49bbdf1edeeacf21b33b674a986aee3efea4e443 Mon Sep 17 00:00:00 2001 From: Jonathan Sweemer Date: Sun, 12 Mar 2023 05:36:07 +0000 Subject: [PATCH 062/292] Remove copy on key compare --- ql/indexes/indexmanager.cpp | 28 ++++++++++++---------------- ql/indexes/indexmanager.hpp | 13 +++++++++++-- test-suite/indexes.cpp | 18 +++++++++++++++++- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/ql/indexes/indexmanager.cpp b/ql/indexes/indexmanager.cpp index b9ee3b34973..19f4c4f77de 100644 --- a/ql/indexes/indexmanager.cpp +++ b/ql/indexes/indexmanager.cpp @@ -18,43 +18,39 @@ */ #include -#include - -using boost::algorithm::to_upper_copy; -using std::string; namespace QuantLib { - bool IndexManager::hasHistory(const string& name) const { - return data_.find(to_upper_copy(name)) != data_.end(); + bool IndexManager::hasHistory(const std::string& name) const { + return data_.find(name) != data_.end(); } - const TimeSeries& IndexManager::getHistory(const string& name) const { - return data_[to_upper_copy(name)].value(); + const TimeSeries& IndexManager::getHistory(const std::string& name) const { + return data_[name].value(); } - void IndexManager::setHistory(const string& name, TimeSeries history) { - data_[to_upper_copy(name)] = std::move(history); + void IndexManager::setHistory(const std::string& name, TimeSeries history) { + data_[name] = std::move(history); } - ext::shared_ptr IndexManager::notifier(const string& name) const { - return data_[to_upper_copy(name)]; + ext::shared_ptr IndexManager::notifier(const std::string& name) const { + return data_[name]; } - std::vector IndexManager::histories() const { - std::vector temp; + std::vector IndexManager::histories() const { + std::vector temp; temp.reserve(data_.size()); for (const auto& i : data_) temp.push_back(i.first); return temp; } - void IndexManager::clearHistory(const string& name) { data_.erase(to_upper_copy(name)); } + void IndexManager::clearHistory(const std::string& name) { data_.erase(name); } void IndexManager::clearHistories() { data_.clear(); } bool IndexManager::hasHistoricalFixing(const std::string& name, const Date& fixingDate) const { - auto const& indexIter = data_.find(to_upper_copy(name)); + auto const& indexIter = data_.find(name); return (indexIter != data_.end()) && ((*indexIter).second.value()[fixingDate] != Null()); } diff --git a/ql/indexes/indexmanager.hpp b/ql/indexes/indexmanager.hpp index d08ad0f87d6..0115aabfe93 100644 --- a/ql/indexes/indexmanager.hpp +++ b/ql/indexes/indexmanager.hpp @@ -27,7 +27,8 @@ #include #include #include - +#include +#include namespace QuantLib { @@ -58,7 +59,15 @@ namespace QuantLib { bool hasHistoricalFixing(const std::string& name, const Date& fixingDate) const; private: - mutable std::map>> data_; + struct CaseInsensitiveCompare { + bool operator()(const std::string& s1, const std::string& s2) const { + return std::lexicographical_compare(s1.begin(), s1.end(), s2.begin(), s2.end(), [](const auto& c1, const auto& c2) { + return std::toupper(static_cast(c1)) < std::toupper(static_cast(c2)); + }); + } + }; + + mutable std::map>, CaseInsensitiveCompare> data_; }; } diff --git a/test-suite/indexes.cpp b/test-suite/indexes.cpp index a976c0f8dda..500a69e217e 100644 --- a/test-suite/indexes.cpp +++ b/test-suite/indexes.cpp @@ -22,6 +22,7 @@ #include #include #include +#include using namespace QuantLib; using namespace boost::unit_test_framework; @@ -92,25 +93,40 @@ void IndexTest::testFixingHasHistoricalFixing() { name = euribor3M->name(); testCase(name, fixingNotFound, euribor3M->hasHistoricalFixing(today)); testCase(name, fixingNotFound, IndexManager::instance().hasHistoricalFixing(name, today)); + name = boost::to_upper_copy(euribor3M->name()); + testCase(name, fixingNotFound, IndexManager::instance().hasHistoricalFixing(name, today)); + name = boost::to_lower_copy(euribor3M->name()); + testCase(name, fixingNotFound, IndexManager::instance().hasHistoricalFixing(name, today)); name = euribor6M->name(); testCase(name, fixingFound, euribor6M->hasHistoricalFixing(today)); testCase(name, fixingFound, euribor6M_a->hasHistoricalFixing(today)); testCase(name, fixingFound, IndexManager::instance().hasHistoricalFixing(name, today)); + name = boost::to_upper_copy(euribor6M->name()); + testCase(name, fixingFound, IndexManager::instance().hasHistoricalFixing(name, today)); + name = boost::to_lower_copy(euribor6M->name()); + testCase(name, fixingFound, IndexManager::instance().hasHistoricalFixing(name, today)); IndexManager::instance().clearHistories(); name = euribor3M->name(); testCase(name, fixingNotFound, euribor3M->hasHistoricalFixing(today)); testCase(name, fixingNotFound, IndexManager::instance().hasHistoricalFixing(name, today)); + name = boost::to_upper_copy(euribor3M->name()); + testCase(name, fixingNotFound, IndexManager::instance().hasHistoricalFixing(name, today)); + name = boost::to_lower_copy(euribor3M->name()); + testCase(name, fixingNotFound, IndexManager::instance().hasHistoricalFixing(name, today)); name = euribor6M->name(); testCase(name, fixingNotFound, euribor6M->hasHistoricalFixing(today)); testCase(name, fixingNotFound, euribor6M_a->hasHistoricalFixing(today)); testCase(name, fixingNotFound, IndexManager::instance().hasHistoricalFixing(name, today)); + name = boost::to_upper_copy(euribor6M->name()); + testCase(name, fixingNotFound, IndexManager::instance().hasHistoricalFixing(name, today)); + name = boost::to_lower_copy(euribor6M->name()); + testCase(name, fixingNotFound, IndexManager::instance().hasHistoricalFixing(name, today)); } - test_suite* IndexTest::suite() { auto* suite = BOOST_TEST_SUITE("index tests"); suite->add(QUANTLIB_TEST_CASE(&IndexTest::testFixingObservability)); From c347a1ebb934e07f236d0de81c830da851c1d82d Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Mon, 20 Mar 2023 11:12:52 +0100 Subject: [PATCH 063/292] Don't include obsolete headers --- ql/experimental/volatility/Makefile.am | 2 +- ql/experimental/volatility/all.hpp | 1 - ql/termstructures/volatility/swaption/Makefile.am | 2 +- ql/termstructures/volatility/swaption/all.hpp | 2 -- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/ql/experimental/volatility/Makefile.am b/ql/experimental/volatility/Makefile.am index c956434ee6a..024a027985d 100644 --- a/ql/experimental/volatility/Makefile.am +++ b/ql/experimental/volatility/Makefile.am @@ -72,7 +72,7 @@ all.hpp: Makefile.am echo "/* This file is automatically generated; do not edit. */" > ${srcdir}/$@ echo "/* Add the files to be included into Makefile.am instead. */" >> ${srcdir}/$@ echo >> ${srcdir}/$@ - for i in $(filter-out all.hpp, $(this_include_HEADERS)); do \ + for i in $(filter-out all.hpp swaptionvolcube1a.hpp, $(this_include_HEADERS)); do \ echo "#include <${subdir}/$$i>" >> ${srcdir}/$@; \ done echo >> ${srcdir}/$@ diff --git a/ql/experimental/volatility/all.hpp b/ql/experimental/volatility/all.hpp index 776e9403cd1..cd8f49a3fdb 100644 --- a/ql/experimental/volatility/all.hpp +++ b/ql/experimental/volatility/all.hpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/ql/termstructures/volatility/swaption/Makefile.am b/ql/termstructures/volatility/swaption/Makefile.am index da83e9219cc..fa446c93abc 100644 --- a/ql/termstructures/volatility/swaption/Makefile.am +++ b/ql/termstructures/volatility/swaption/Makefile.am @@ -56,7 +56,7 @@ all.hpp: Makefile.am echo "/* This file is automatically generated; do not edit. */" > ${srcdir}/$@ echo "/* Add the files to be included into Makefile.am instead. */" >> ${srcdir}/$@ echo >> ${srcdir}/$@ - for i in $(filter-out all.hpp, $(this_include_HEADERS)); do \ + for i in $(filter-out all.hpp swaptionvolcube1.hpp swaptionvolcube2.hpp, $(this_include_HEADERS)); do \ echo "#include <${subdir}/$$i>" >> ${srcdir}/$@; \ done echo >> ${srcdir}/$@ diff --git a/ql/termstructures/volatility/swaption/all.hpp b/ql/termstructures/volatility/swaption/all.hpp index 7f477f9b4d9..789be07421f 100644 --- a/ql/termstructures/volatility/swaption/all.hpp +++ b/ql/termstructures/volatility/swaption/all.hpp @@ -9,8 +9,6 @@ #include #include #include -#include -#include #include #include #include From 7220d2c3333fb68f194367c5b21a451e7f84200b Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Mon, 20 Mar 2023 11:25:14 +0100 Subject: [PATCH 064/292] Avoid deprecation warnings in VC++22 when including quantlib.hpp --- ql/termstructures/yield/drifttermstructure.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ql/termstructures/yield/drifttermstructure.hpp b/ql/termstructures/yield/drifttermstructure.hpp index 6a12fbeb052..b297c9c3797 100644 --- a/ql/termstructures/yield/drifttermstructure.hpp +++ b/ql/termstructures/yield/drifttermstructure.hpp @@ -61,6 +61,8 @@ namespace QuantLib { // inline definitions + QL_DEPRECATED_DISABLE_WARNING + inline DriftTermStructure::DriftTermStructure(const Handle& riskFreeTS, Handle dividendTS, Handle blackVolTS) @@ -105,6 +107,9 @@ namespace QuantLib { - 0.5 * blackVolTS_->blackVol(t, underlyingLevel_, true) * blackVolTS_->blackVol(t, underlyingLevel_, true); } + + QL_DEPRECATED_ENABLE_WARNING + } From 90a6026a3b79844dfa4c89a314218b6e7ebbb7db Mon Sep 17 00:00:00 2001 From: Anastasiia Shumyk Date: Tue, 21 Mar 2023 19:35:30 +0200 Subject: [PATCH 065/292] Make GOV bond USA 2023 Good Friday working day --- ql/time/calendars/unitedstates.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ql/time/calendars/unitedstates.cpp b/ql/time/calendars/unitedstates.cpp index b7e27a2f6c1..1bced512169 100644 --- a/ql/time/calendars/unitedstates.cpp +++ b/ql/time/calendars/unitedstates.cpp @@ -73,7 +73,7 @@ namespace QuantLib { return (d >= 22 && d <= 28) && w == Monday && m == October; } } - + bool isVeteransDayNoSaturday(Day d, Month m, Year y, Weekday w) { if (y <= 1970 || y >= 1978) { // November 11th, adjusted, but no Saturday to Friday @@ -90,7 +90,7 @@ namespace QuantLib { && m == June && y >= 2022; } } - + UnitedStates::UnitedStates(UnitedStates::Market market) { // all calendar instances on the same market share the same // implementation instance @@ -282,8 +282,8 @@ namespace QuantLib { && y >= 1983) // Washington's birthday (third Monday in February) || isWashingtonBirthday(d, m, y, w) - // Good Friday (2015 was half day due to NFP report) - || (dd == em-3 && y != 2015) + // Good Friday (2015, 2021, 2023 are half day due to NFP/SIFMA) + || (dd == em-3 && y != 2015 && y != 2021 && y != 2023) // Memorial Day (last Monday in May) || isMemorialDay(d, m, y, w) // Juneteenth (Monday if Sunday or Friday if Saturday) @@ -303,7 +303,7 @@ namespace QuantLib { || ((d == 25 || (d == 26 && w == Monday) || (d == 24 && w == Friday)) && m == December)) return false; - + // Special closings if (// President Bush's Funeral (y == 2018 && m == December && d == 5) @@ -312,7 +312,7 @@ namespace QuantLib { // President Reagan's funeral || (y == 2004 && m == June && d == 11) ) return false; - + return true; } @@ -338,8 +338,8 @@ namespace QuantLib { return false; // NOLINT(readability-simplify-boolean-expr) return true; } - - + + bool UnitedStates::FederalReserveImpl::isBusinessDay(const Date& date) const { // see https://www.frbservices.org/holidayschedules/ for details Weekday w = date.weekday(); From 055cf6b5c30123b0dc006c9b83a2692db47b3165 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Wed, 22 Mar 2023 15:20:08 +0100 Subject: [PATCH 066/292] ext::nullopt as variable --- QuantLib.vcxproj | 3 +- QuantLib.vcxproj.filters | 3 +- ql/CMakeLists.txt | 1 + ql/Makefile.am | 1 + ql/cashflow.hpp | 2 +- ql/cashflows/couponpricer.hpp | 4 +-- ql/event.hpp | 2 +- .../catbonds/montecarlocatbondengine.hpp | 2 +- .../coupons/lognormalcmsspreadpricer.hpp | 2 +- ql/experimental/credit/syntheticcdo.hpp | 2 +- ql/instruments/creditdefaultswap.cpp | 6 ++-- ql/instruments/floatfloatswap.hpp | 8 ++--- ql/instruments/makevanillaswap.cpp | 4 +-- ql/instruments/nonstandardswap.hpp | 4 +-- ql/instruments/vanillaswap.hpp | 4 +-- ql/optional.cpp | 33 +++++++++++++++++++ ql/optional.hpp | 6 ++-- .../bond/discountingbondengine.hpp | 2 +- .../credit/integralcdsengine.hpp | 2 +- ql/pricingengines/credit/isdacdsengine.hpp | 2 +- .../credit/midpointcdsengine.hpp | 2 +- .../mclongstaffschwartzengine.hpp | 4 +-- .../swap/discountingswapengine.hpp | 2 +- .../vanilla/mcamericanengine.hpp | 4 +-- ql/termstructures/yield/oisratehelper.hpp | 2 +- ql/termstructures/yield/ratehelpers.hpp | 8 ++--- ql/time/schedule.hpp | 8 ++--- test-suite/cashflows.cpp | 8 ++--- test-suite/creditdefaultswap.cpp | 6 ++-- test-suite/quantlibtestsuite.cpp | 2 +- 30 files changed, 89 insertions(+), 50 deletions(-) create mode 100644 ql/optional.cpp diff --git a/QuantLib.vcxproj b/QuantLib.vcxproj index b4e0043094f..9e0c7a88d0d 100644 --- a/QuantLib.vcxproj +++ b/QuantLib.vcxproj @@ -2812,6 +2812,7 @@ + @@ -2825,4 +2826,4 @@ - \ No newline at end of file + diff --git a/QuantLib.vcxproj.filters b/QuantLib.vcxproj.filters index ca1ed84225d..479dd22a054 100644 --- a/QuantLib.vcxproj.filters +++ b/QuantLib.vcxproj.filters @@ -6632,6 +6632,7 @@ + @@ -7171,4 +7172,4 @@ instruments - \ No newline at end of file + diff --git a/ql/CMakeLists.txt b/ql/CMakeLists.txt index 0399181da73..4caa6b0544c 100644 --- a/ql/CMakeLists.txt +++ b/ql/CMakeLists.txt @@ -644,6 +644,7 @@ set(QL_SOURCES models/volatility/constantestimator.cpp models/volatility/garch.cpp money.cpp + optional.cpp patterns/observable.cpp position.cpp prices.cpp diff --git a/ql/Makefile.am b/ql/Makefile.am index 5597fb23617..83a8fe7caa4 100644 --- a/ql/Makefile.am +++ b/ql/Makefile.am @@ -75,6 +75,7 @@ cpp_files = \ index.cpp \ interestrate.cpp \ money.cpp \ + optional.cpp \ position.cpp \ prices.cpp \ rebatedexercise.cpp \ diff --git a/ql/cashflow.hpp b/ql/cashflow.hpp index 2aa45a9d549..5de9a88d19c 100644 --- a/ql/cashflow.hpp +++ b/ql/cashflow.hpp @@ -48,7 +48,7 @@ namespace QuantLib { Settings::includeTodaysCashflows in account */ bool hasOccurred(const Date& refDate = Date(), - ext::optional includeRefDate = ext::nullopt()) const override; + ext::optional includeRefDate = ext::nullopt) const override; //@} //! \name CashFlow interface //@{ diff --git a/ql/cashflows/couponpricer.hpp b/ql/cashflows/couponpricer.hpp index 54284d0d012..8236e5c2410 100644 --- a/ql/cashflows/couponpricer.hpp +++ b/ql/cashflows/couponpricer.hpp @@ -67,7 +67,7 @@ namespace QuantLib { public: explicit IborCouponPricer( Handle v = Handle(), - ext::optional useIndexedCoupon = ext::nullopt()); + ext::optional useIndexedCoupon = ext::nullopt); bool useIndexedCoupon() const { return useIndexedCoupon_; } @@ -115,7 +115,7 @@ namespace QuantLib { const Handle& v = Handle(), const TimingAdjustment timingAdjustment = Black76, Handle correlation = Handle(ext::shared_ptr(new SimpleQuote(1.0))), - const ext::optional useIndexedCoupon = ext::nullopt()) + const ext::optional useIndexedCoupon = ext::nullopt) : IborCouponPricer(v, useIndexedCoupon), timingAdjustment_(timingAdjustment), correlation_(std::move(correlation)) { { // this additional scope seems required to avoid a misleading-indentation warning diff --git a/ql/event.hpp b/ql/event.hpp index a03fdac7dee..7efdbe85058 100644 --- a/ql/event.hpp +++ b/ql/event.hpp @@ -52,7 +52,7 @@ namespace QuantLib { */ virtual bool hasOccurred( const Date& refDate = Date(), - ext::optional includeRefDate = ext::nullopt()) const; + ext::optional includeRefDate = ext::nullopt) const; //@} //! \name Visitability diff --git a/ql/experimental/catbonds/montecarlocatbondengine.hpp b/ql/experimental/catbonds/montecarlocatbondengine.hpp index 883d7f28503..d20f98f3d13 100644 --- a/ql/experimental/catbonds/montecarlocatbondengine.hpp +++ b/ql/experimental/catbonds/montecarlocatbondengine.hpp @@ -36,7 +36,7 @@ namespace QuantLib { explicit MonteCarloCatBondEngine( ext::shared_ptr catRisk, Handle discountCurve = Handle(), - const ext::optional& includeSettlementDateFlows = ext::nullopt()); + const ext::optional& includeSettlementDateFlows = ext::nullopt); void calculate() const override; Handle discountCurve() const { return discountCurve_; } protected: diff --git a/ql/experimental/coupons/lognormalcmsspreadpricer.hpp b/ql/experimental/coupons/lognormalcmsspreadpricer.hpp index ce67e51913f..3328875c8cd 100644 --- a/ql/experimental/coupons/lognormalcmsspreadpricer.hpp +++ b/ql/experimental/coupons/lognormalcmsspreadpricer.hpp @@ -65,7 +65,7 @@ namespace QuantLib { const Handle& correlation, Handle couponDiscountCurve = Handle(), Size IntegrationPoints = 16, - const ext::optional& volatilityType = ext::nullopt(), + const ext::optional& volatilityType = ext::nullopt, Real shift1 = Null(), Real shift2 = Null()); diff --git a/ql/experimental/credit/syntheticcdo.hpp b/ql/experimental/credit/syntheticcdo.hpp index effa0a7cf4e..50e7dedc4d5 100644 --- a/ql/experimental/credit/syntheticcdo.hpp +++ b/ql/experimental/credit/syntheticcdo.hpp @@ -124,7 +124,7 @@ namespace QuantLib { Rate runningRate, const DayCounter& dayCounter, BusinessDayConvention paymentConvention, - ext::optional notional = ext::nullopt()); + ext::optional notional = ext::nullopt); const ext::shared_ptr& basket() const { return basket_; } diff --git a/ql/instruments/creditdefaultswap.cpp b/ql/instruments/creditdefaultswap.cpp index 4c872d303cd..1441057e229 100644 --- a/ql/instruments/creditdefaultswap.cpp +++ b/ql/instruments/creditdefaultswap.cpp @@ -50,7 +50,7 @@ namespace QuantLib { const bool rebatesAccrual, const Date& tradeDate, Natural cashSettlementDays) - : side_(side), notional_(notional), upfront_(ext::nullopt()), runningSpread_(spread), + : side_(side), notional_(notional), upfront_(ext::nullopt), runningSpread_(spread), settlesAccrual_(settlesAccrual), paysAtDefaultTime_(paysAtDefaultTime), claim_(std::move(claim)), protectionStart_(protectionStart == Null() ? schedule[0] : protectionStart), @@ -361,7 +361,7 @@ namespace QuantLib { case ISDA: engine = ext::make_shared( probability, recoveryRate, discountCurve, - ext::nullopt(), + ext::nullopt, IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); @@ -402,7 +402,7 @@ namespace QuantLib { case ISDA: engine = ext::make_shared( probability, conventionalRecovery, discountCurve, - ext::nullopt(), + ext::nullopt, IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); diff --git a/ql/instruments/floatfloatswap.hpp b/ql/instruments/floatfloatswap.hpp index 8172490f540..8b8419ecba2 100644 --- a/ql/instruments/floatfloatswap.hpp +++ b/ql/instruments/floatfloatswap.hpp @@ -65,8 +65,8 @@ namespace QuantLib { Real spread2 = 0.0, Real cappedRate2 = Null(), Real flooredRate2 = Null(), - const ext::optional& paymentConvention1 = ext::nullopt(), - const ext::optional& paymentConvention2 = ext::nullopt()); + const ext::optional& paymentConvention1 = ext::nullopt, + const ext::optional& paymentConvention2 = ext::nullopt); FloatFloatSwap( Swap::Type type, @@ -88,8 +88,8 @@ namespace QuantLib { std::vector spread2 = std::vector(), std::vector cappedRate2 = std::vector(), std::vector flooredRate2 = std::vector(), - const ext::optional& paymentConvention1 = ext::nullopt(), - const ext::optional& paymentConvention2 = ext::nullopt()); + const ext::optional& paymentConvention1 = ext::nullopt, + const ext::optional& paymentConvention2 = ext::nullopt); //! \name Inspectors //@{ diff --git a/ql/instruments/makevanillaswap.cpp b/ql/instruments/makevanillaswap.cpp index 98d89bac0c0..ed8e43accec 100644 --- a/ql/instruments/makevanillaswap.cpp +++ b/ql/instruments/makevanillaswap.cpp @@ -153,7 +153,7 @@ namespace QuantLib { VanillaSwap temp(type_, 100.00, fixedSchedule, 0.0, // fixed rate fixedDayCount, floatSchedule, iborIndex_, floatSpread_, floatDayCount_, - ext::nullopt(), useIndexedCoupons_); + ext::nullopt, useIndexedCoupons_); if (engine_ == nullptr) { Handle disc = iborIndex_->forwardingTermStructure(); @@ -172,7 +172,7 @@ namespace QuantLib { ext::shared_ptr swap(new VanillaSwap( type_, nominal_, fixedSchedule, usedFixedRate, fixedDayCount, floatSchedule, iborIndex_, - floatSpread_, floatDayCount_, ext::nullopt(), useIndexedCoupons_)); + floatSpread_, floatDayCount_, ext::nullopt, useIndexedCoupons_)); if (engine_ == nullptr) { Handle disc = diff --git a/ql/instruments/nonstandardswap.hpp b/ql/instruments/nonstandardswap.hpp index 499012dc1d2..e2ac0ac0dae 100644 --- a/ql/instruments/nonstandardswap.hpp +++ b/ql/instruments/nonstandardswap.hpp @@ -56,7 +56,7 @@ namespace QuantLib { DayCounter floatingDayCount, bool intermediateCapitalExchange = false, bool finalCapitalExchange = false, - ext::optional paymentConvention = ext::nullopt()); + ext::optional paymentConvention = ext::nullopt); NonstandardSwap(Swap::Type type, std::vector fixedNominal, std::vector floatingNominal, @@ -70,7 +70,7 @@ namespace QuantLib { DayCounter floatingDayCount, bool intermediateCapitalExchange = false, bool finalCapitalExchange = false, - ext::optional paymentConvention = ext::nullopt()); + ext::optional paymentConvention = ext::nullopt); //! \name Inspectors //@{ Swap::Type type() const; diff --git a/ql/instruments/vanillaswap.hpp b/ql/instruments/vanillaswap.hpp index f240a6e2de8..3515da552a1 100644 --- a/ql/instruments/vanillaswap.hpp +++ b/ql/instruments/vanillaswap.hpp @@ -76,8 +76,8 @@ namespace QuantLib { ext::shared_ptr iborIndex, Spread spread, DayCounter floatingDayCount, - ext::optional paymentConvention = ext::nullopt(), - ext::optional useIndexedCoupons = ext::nullopt()); + ext::optional paymentConvention = ext::nullopt, + ext::optional useIndexedCoupons = ext::nullopt); //! \name Inspectors //@{ Type type() const; diff --git a/ql/optional.cpp b/ql/optional.cpp new file mode 100644 index 00000000000..9c6dd362de4 --- /dev/null +++ b/ql/optional.cpp @@ -0,0 +1,33 @@ +/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + +/* + Copyright (C) 2023 Jonathan Sweemer + + 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. +*/ + +#include + +namespace QuantLib { + + namespace ext { + + #if !defined(QL_USE_STD_OPTIONAL) + const boost::none_t& nullopt = boost::none; + #endif + + } + +} + diff --git a/ql/optional.hpp b/ql/optional.hpp index 2d6edd4aa1b..bb7c27d0934 100644 --- a/ql/optional.hpp +++ b/ql/optional.hpp @@ -38,10 +38,12 @@ namespace QuantLib { #if defined(QL_USE_STD_OPTIONAL) using std::optional; // NOLINT(misc-unused-using-decls) - constexpr const std::nullopt_t& nullopt() { return std::nullopt; } + // here we can assume C++17 + inline constexpr const std::nullopt_t& nullopt = std::nullopt; #else using boost::optional; // NOLINT(misc-unused-using-decls) - constexpr const boost::none_t& nullopt() { return boost::none; } + // here we can't + extern const boost::none_t& nullopt; #endif } diff --git a/ql/pricingengines/bond/discountingbondengine.hpp b/ql/pricingengines/bond/discountingbondengine.hpp index f518b20dff6..f8b31982a36 100644 --- a/ql/pricingengines/bond/discountingbondengine.hpp +++ b/ql/pricingengines/bond/discountingbondengine.hpp @@ -36,7 +36,7 @@ namespace QuantLib { public: DiscountingBondEngine( Handle discountCurve = Handle(), - const ext::optional& includeSettlementDateFlows = ext::nullopt()); + const ext::optional& includeSettlementDateFlows = ext::nullopt); void calculate() const override; Handle discountCurve() const { return discountCurve_; diff --git a/ql/pricingengines/credit/integralcdsengine.hpp b/ql/pricingengines/credit/integralcdsengine.hpp index dba086e3eac..5bbf787b666 100644 --- a/ql/pricingengines/credit/integralcdsengine.hpp +++ b/ql/pricingengines/credit/integralcdsengine.hpp @@ -36,7 +36,7 @@ namespace QuantLib { Handle, Real recoveryRate, Handle discountCurve, - const ext::optional& includeSettlementDateFlows = ext::nullopt()); + const ext::optional& includeSettlementDateFlows = ext::nullopt); void calculate() const override; private: diff --git a/ql/pricingengines/credit/isdacdsengine.hpp b/ql/pricingengines/credit/isdacdsengine.hpp index 55ee86aacf4..461994262c4 100644 --- a/ql/pricingengines/credit/isdacdsengine.hpp +++ b/ql/pricingengines/credit/isdacdsengine.hpp @@ -98,7 +98,7 @@ namespace QuantLib { IsdaCdsEngine(Handle probability, Real recoveryRate, Handle discountCurve, - const ext::optional& includeSettlementDateFlows = ext::nullopt(), + const ext::optional& includeSettlementDateFlows = ext::nullopt, NumericalFix numericalFix = Taylor, AccrualBias accrualBias = HalfDayBias, ForwardsInCouponPeriod forwardsInCouponPeriod = Piecewise); diff --git a/ql/pricingengines/credit/midpointcdsengine.hpp b/ql/pricingengines/credit/midpointcdsengine.hpp index 172b78531d8..8637fc484e3 100644 --- a/ql/pricingengines/credit/midpointcdsengine.hpp +++ b/ql/pricingengines/credit/midpointcdsengine.hpp @@ -36,7 +36,7 @@ namespace QuantLib { MidPointCdsEngine(Handle, Real recoveryRate, Handle discountCurve, - const ext::optional& includeSettlementDateFlows = ext::nullopt()); + const ext::optional& includeSettlementDateFlows = ext::nullopt); void calculate() const override; private: diff --git a/ql/pricingengines/mclongstaffschwartzengine.hpp b/ql/pricingengines/mclongstaffschwartzengine.hpp index 9483fb43236..d7342d7671a 100644 --- a/ql/pricingengines/mclongstaffschwartzengine.hpp +++ b/ql/pricingengines/mclongstaffschwartzengine.hpp @@ -80,8 +80,8 @@ namespace QuantLib { Size maxSamples, BigNatural seed, Size nCalibrationSamples = Null(), - ext::optional brownianBridgeCalibration = ext::nullopt(), - ext::optional antitheticVariateCalibration = ext::nullopt(), + ext::optional brownianBridgeCalibration = ext::nullopt, + ext::optional antitheticVariateCalibration = ext::nullopt, BigNatural seedCalibration = Null()); void calculate() const override; diff --git a/ql/pricingengines/swap/discountingswapengine.hpp b/ql/pricingengines/swap/discountingswapengine.hpp index 7a5a0c16a9e..14be47d4628 100644 --- a/ql/pricingengines/swap/discountingswapengine.hpp +++ b/ql/pricingengines/swap/discountingswapengine.hpp @@ -36,7 +36,7 @@ namespace QuantLib { public: DiscountingSwapEngine( Handle discountCurve = Handle(), - const ext::optional& includeSettlementDateFlows = ext::nullopt(), + const ext::optional& includeSettlementDateFlows = ext::nullopt, Date settlementDate = Date(), Date npvDate = Date()); void calculate() const override; diff --git a/ql/pricingengines/vanilla/mcamericanengine.hpp b/ql/pricingengines/vanilla/mcamericanengine.hpp index 41b8f6cd2f4..756692c6b07 100644 --- a/ql/pricingengines/vanilla/mcamericanengine.hpp +++ b/ql/pricingengines/vanilla/mcamericanengine.hpp @@ -65,7 +65,7 @@ namespace QuantLib { Size polynomialOrder, LsmBasisSystem::PolynomialType polynomialType, Size nCalibrationSamples = Null(), - const ext::optional& antitheticVariateCalibration = ext::nullopt(), + const ext::optional& antitheticVariateCalibration = ext::nullopt, BigNatural seedCalibration = Null()); void calculate() const override; @@ -275,7 +275,7 @@ namespace QuantLib { ext::shared_ptr process) : process_(std::move(process)), steps_(Null()), stepsPerYear_(Null()), samples_(Null()), maxSamples_(Null()), tolerance_(Null()), - antitheticCalibration_(ext::nullopt()), seedCalibration_(Null()) {} + antitheticCalibration_(ext::nullopt), seedCalibration_(Null()) {} template inline MakeMCAmericanEngine & diff --git a/ql/termstructures/yield/oisratehelper.hpp b/ql/termstructures/yield/oisratehelper.hpp index c372cb97494..cc5f94f524b 100644 --- a/ql/termstructures/yield/oisratehelper.hpp +++ b/ql/termstructures/yield/oisratehelper.hpp @@ -50,7 +50,7 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), RateAveraging::Type averagingMethod = RateAveraging::Compound, - ext::optional endOfMonth = ext::nullopt()); + ext::optional endOfMonth = ext::nullopt); //! \name RateHelper interface //@{ Real impliedQuote() const override; diff --git a/ql/termstructures/yield/ratehelpers.hpp b/ql/termstructures/yield/ratehelpers.hpp index 570797668ab..409ae7bb947 100644 --- a/ql/termstructures/yield/ratehelpers.hpp +++ b/ql/termstructures/yield/ratehelpers.hpp @@ -267,7 +267,7 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), bool endOfMonth = false, - const ext::optional& useIndexedCoupons = ext::nullopt()); + const ext::optional& useIndexedCoupons = ext::nullopt); SwapRateHelper(const Handle& rate, const Period& tenor, Calendar calendar, @@ -285,7 +285,7 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), bool endOfMonth = false, - const ext::optional& useIndexedCoupons = ext::nullopt()); + const ext::optional& useIndexedCoupons = ext::nullopt); SwapRateHelper(Rate rate, const ext::shared_ptr& swapIndex, Handle spread = {}, @@ -295,7 +295,7 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), bool endOfMonth = false, - const ext::optional& useIndexedCoupons = ext::nullopt()); + const ext::optional& useIndexedCoupons = ext::nullopt); SwapRateHelper(Rate rate, const Period& tenor, Calendar calendar, @@ -313,7 +313,7 @@ namespace QuantLib { Pillar::Choice pillar = Pillar::LastRelevantDate, Date customPillarDate = Date(), bool endOfMonth = false, - const ext::optional& useIndexedCoupons = ext::nullopt()); + const ext::optional& useIndexedCoupons = ext::nullopt); //! \name RateHelper interface //@{ Real impliedQuote() const override; diff --git a/ql/time/schedule.hpp b/ql/time/schedule.hpp index 95b790c65d0..ce11e1c543b 100644 --- a/ql/time/schedule.hpp +++ b/ql/time/schedule.hpp @@ -47,10 +47,10 @@ namespace QuantLib { const std::vector&, Calendar calendar = NullCalendar(), BusinessDayConvention convention = Unadjusted, - const ext::optional& terminationDateConvention = ext::nullopt(), - const ext::optional& tenor = ext::nullopt(), - const ext::optional& rule = ext::nullopt(), - const ext::optional& endOfMonth = ext::nullopt(), + const ext::optional& terminationDateConvention = ext::nullopt, + const ext::optional& tenor = ext::nullopt, + const ext::optional& rule = ext::nullopt, + const ext::optional& endOfMonth = ext::nullopt, std::vector isRegular = std::vector(0)); /*! rule based constructor */ Schedule(Date effectiveDate, diff --git a/test-suite/cashflows.cpp b/test-suite/cashflows.cpp index f81b3fff737..b71b99261c7 100644 --- a/test-suite/cashflows.cpp +++ b/test-suite/cashflows.cpp @@ -68,7 +68,7 @@ void CashFlowsTest::testSettings() { // today's date Settings::instance().includeReferenceDateEvents() = false; - Settings::instance().includeTodaysCashFlows() = ext::nullopt(); + Settings::instance().includeTodaysCashFlows() = ext::nullopt; CHECK_INCLUSION(0, 0, false); CHECK_INCLUSION(0, 1, false); @@ -101,7 +101,7 @@ void CashFlowsTest::testSettings() { // today's date Settings::instance().includeReferenceDateEvents() = true; - Settings::instance().includeTodaysCashFlows() = ext::nullopt(); + Settings::instance().includeTodaysCashFlows() = ext::nullopt; CHECK_INCLUSION(0, 0, true); CHECK_INCLUSION(0, 1, false); @@ -163,7 +163,7 @@ void CashFlowsTest::testSettings() { } while (false); // no override - Settings::instance().includeTodaysCashFlows() = ext::nullopt(); + Settings::instance().includeTodaysCashFlows() = ext::nullopt; CHECK_NPV(false, 2.0); CHECK_NPV(true, 3.0); @@ -409,7 +409,7 @@ void CashFlowsTest::testPartialScheduleLegConstruction() { .backwards(); // same schedule, date based, with metadata Schedule schedule2(schedule.dates(), NullCalendar(), Unadjusted, Unadjusted, - 6 * Months, ext::nullopt(), schedule.endOfMonth(), + 6 * Months, ext::nullopt, schedule.endOfMonth(), schedule.isRegular()); // same schedule, date based, without metadata Schedule schedule3(schedule.dates()); diff --git a/test-suite/creditdefaultswap.cpp b/test-suite/creditdefaultswap.cpp index 558aa76008c..31cbde38312 100644 --- a/test-suite/creditdefaultswap.cpp +++ b/test-suite/creditdefaultswap.cpp @@ -693,7 +693,7 @@ void CreditDefaultSwapTest::testIsdaEngine() { ext::make_shared(0, WeekendsOnly(), h, Actual365Fixed())); ext::shared_ptr engine = ext::make_shared( - probabilityCurve, recovery, discountCurve, ext::nullopt(), IsdaCdsEngine::Taylor, + probabilityCurve, recovery, discountCurve, ext::nullopt, IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); ext::shared_ptr conventionalTrade = @@ -840,7 +840,7 @@ void CreditDefaultSwapTest::testIsdaCalculatorReconcileSingleQuote () ext::make_shared(0, WeekendsOnly(), h, Actual365Fixed())); ext::shared_ptr engine = ext::make_shared( - probabilityCurve, recovery, discountCurve, ext::nullopt(), IsdaCdsEngine::Taylor, + probabilityCurve, recovery, discountCurve, ext::nullopt, IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); ext::shared_ptr conventionalTrade = @@ -954,7 +954,7 @@ void CreditDefaultSwapTest::testIsdaCalculatorReconcileSingleWithIssueDateInTheP ext::make_shared(0, WeekendsOnly(), h, Actual365Fixed())); ext::shared_ptr engine = ext::make_shared( - probabilityCurve, recovery, discountCurve, ext::nullopt(), IsdaCdsEngine::Taylor, + probabilityCurve, recovery, discountCurve, ext::nullopt, IsdaCdsEngine::Taylor, IsdaCdsEngine::HalfDayBias, IsdaCdsEngine::Piecewise); ext::shared_ptr conventionalTrade = diff --git a/test-suite/quantlibtestsuite.cpp b/test-suite/quantlibtestsuite.cpp index eb27ccfe4bd..7762eab02c7 100644 --- a/test-suite/quantlibtestsuite.cpp +++ b/test-suite/quantlibtestsuite.cpp @@ -246,7 +246,7 @@ namespace { */ // QuantLib::Settings::instance().includeReferenceDateCashFlows() = true; - // QuantLib::Settings::instance().includeTodaysCashFlows() = ext::nullopt(); + // QuantLib::Settings::instance().includeTodaysCashFlows() = ext::nullopt; QuantLib::Settings::instance().evaluationDate() = evaluationDate; } From 57668cd87899b6fbaff7a257548bcc544a80ead0 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Thu, 23 Mar 2023 12:04:38 +0100 Subject: [PATCH 067/292] Add relevant link to code comment --- ql/time/calendars/unitedstates.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ql/time/calendars/unitedstates.cpp b/ql/time/calendars/unitedstates.cpp index 1bced512169..af83f754e66 100644 --- a/ql/time/calendars/unitedstates.cpp +++ b/ql/time/calendars/unitedstates.cpp @@ -282,7 +282,8 @@ namespace QuantLib { && y >= 1983) // Washington's birthday (third Monday in February) || isWashingtonBirthday(d, m, y, w) - // Good Friday (2015, 2021, 2023 are half day due to NFP/SIFMA) + // Good Friday (2015, 2021, 2023 are half day due to NFP/SIFMA; + // see ) || (dd == em-3 && y != 2015 && y != 2021 && y != 2023) // Memorial Day (last Monday in May) || isMemorialDay(d, m, y, w) From 3c8c6ed8cc64c8430901cc32de2391d3d2730307 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Thu, 23 Mar 2023 16:56:36 +0100 Subject: [PATCH 068/292] Avoid 'using namespace std;' in test suite. This prevents an ambiguity when performing a unity build in VC++ after specifying the C++17 language standard. The underlying cause is unqualified references to byte in the Windows SDK, which can also match C++17 std::byte. Avoiding 'using namespace' is a workaround. --- test-suite/autocovariances.cpp | 1 - test-suite/cdo.cpp | 17 ++++++++--------- test-suite/fastfouriertransform.cpp | 1 - test-suite/inflationcpicapfloor.cpp | 7 +++---- test-suite/inflationvolatility.cpp | 27 ++++++++++++--------------- test-suite/nthtodefault.cpp | 17 ++++++++--------- test-suite/spreadoption.cpp | 3 --- 7 files changed, 31 insertions(+), 42 deletions(-) diff --git a/test-suite/autocovariances.cpp b/test-suite/autocovariances.cpp index bc064f889fd..c14d7b51e7a 100644 --- a/test-suite/autocovariances.cpp +++ b/test-suite/autocovariances.cpp @@ -23,7 +23,6 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -using namespace std; void AutocovariancesTest::testConvolutions() { BOOST_TEST_MESSAGE("Testing convolutions..."); diff --git a/test-suite/cdo.cpp b/test-suite/cdo.cpp index be1ccce0067..e61d0e871cd 100644 --- a/test-suite/cdo.cpp +++ b/test-suite/cdo.cpp @@ -38,7 +38,6 @@ #include using namespace QuantLib; -using namespace std; using namespace boost::unit_test_framework; #ifndef QL_PATCH_SOLARIS @@ -72,7 +71,7 @@ namespace cdo_test { { 0.3, 5, 5, { 1713, 359, 136, 9 } } }; - void check(int i, int j, const string& desc, Real found, Real expected, + void check(int i, int j, const std::string& desc, Real found, Real expected, Real bpTolerance, Real relativeTolerance) { /* Uncomment to display the full show if your debugging: @@ -116,7 +115,7 @@ void CdoTest::testHW(unsigned dataSet) { Compounding cmp = Continuous; // Simple; Real recovery = 0.4; - vector nominals(poolSize, 100.0); + std::vector nominals(poolSize, 100.0); Real premium = 0.02; Period maxTerm (5, Years); Schedule schedule = MakeSchedule().from(Date (1, September, 2006)) @@ -134,23 +133,23 @@ void CdoTest::testHW(unsigned dataSet) { Handle yieldHandle (yieldPtr); Handle hazardRate(ext::shared_ptr(new SimpleQuote(lambda))); - vector > basket; + std::vector > basket; ext::shared_ptr ptr ( new FlatHazardRate (asofDate, hazardRate, ActualActual(ActualActual::ISDA))); ext::shared_ptr pool (new Pool()); - vector names; + std::vector names; // probability key items - vector issuers; - vector issuers; + std::vector > > probabilities; probabilities.emplace_back( NorthAmericaCorpDefaultKey(EURCurrency(), SeniorSec, Period(0, Weeks), 10.), Handle(ptr)); for (Size i=0; i basketPtr ( new Basket(asofDate, names, nominals, pool, hwAttachment[j], hwDetachment[j])); - ostringstream trancheId; + std::ostringstream trancheId; trancheId << "[" << hwAttachment[j] << " , " << hwDetachment[j] << "]"; SyntheticCDO cdoe(basketPtr, Protection::Seller, diff --git a/test-suite/fastfouriertransform.cpp b/test-suite/fastfouriertransform.cpp index aafed138e73..ad5fc13ae33 100644 --- a/test-suite/fastfouriertransform.cpp +++ b/test-suite/fastfouriertransform.cpp @@ -28,7 +28,6 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -using namespace std; void FastFourierTransformTest::testSimple() { BOOST_TEST_MESSAGE("Testing complex direct FFT..."); diff --git a/test-suite/inflationcpicapfloor.cpp b/test-suite/inflationcpicapfloor.cpp index f2fbe58e706..9406c9b72a3 100644 --- a/test-suite/inflationcpicapfloor.cpp +++ b/test-suite/inflationcpicapfloor.cpp @@ -49,7 +49,6 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -using namespace std; namespace inflation_cpi_capfloor_test { @@ -111,9 +110,9 @@ namespace inflation_cpi_capfloor_test { RelinkableHandle cpiUK; RelinkableHandle hcpi; - vector cStrikesUK; - vector fStrikesUK; - vector cfMaturitiesUK; + std::vector cStrikesUK; + std::vector fStrikesUK; + std::vector cfMaturitiesUK; ext::shared_ptr cPriceUK; ext::shared_ptr fPriceUK; diff --git a/test-suite/inflationvolatility.cpp b/test-suite/inflationvolatility.cpp index cfa5dfa0f73..18f5977236a 100644 --- a/test-suite/inflationvolatility.cpp +++ b/test-suite/inflationvolatility.cpp @@ -46,7 +46,6 @@ //************************************************************************* namespace inflation_volatility_test { - using namespace std; using namespace QuantLib; // local data globals @@ -56,18 +55,18 @@ namespace inflation_volatility_test { RelinkableHandle yoyEU; RelinkableHandle yoyUK; - vector cStrikesEU; - vector fStrikesEU; - vector cfMaturitiesEU; + std::vector cStrikesEU; + std::vector fStrikesEU; + std::vector cfMaturitiesEU; ext::shared_ptr cPriceEU; ext::shared_ptr fPriceEU; ext::shared_ptr yoyIndexUK; ext::shared_ptr yoyIndexEU; - vector cStrikesUK; - vector fStrikesUK; - vector cfMaturitiesUK; + std::vector cStrikesUK; + std::vector fStrikesUK; + std::vector cfMaturitiesUK; ext::shared_ptr cPriceUK; ext::shared_ptr fPriceUK; @@ -129,8 +128,8 @@ namespace inflation_volatility_test { 0.0498998, 0.0490464, 0.04768, 0.0464862, 0.045452, 0.0437699, 0.0425311, 0.0420073, 0.041151}; - vector r; - vector d; + std::vector r; + std::vector d; Size nTimesEUR = LENGTH(timesEUR); Size nTimesGBP = LENGTH(timesGBP); for (Size i = 0; i < nTimesEUR; i++) { @@ -344,8 +343,7 @@ void InflationVolTest::testYoYPriceSurfaceToVol() { }; Date d = yoySurf->baseDate() + Period(1,Years); - pair, vector > someSlice; - someSlice = yoySurf->Dslice(d); + auto someSlice = yoySurf->Dslice(d); Size n = someSlice.first.size(); Real eps = 0.0001; @@ -356,8 +354,7 @@ void InflationVolTest::testYoYPriceSurfaceToVol() { } d = yoySurf->baseDate() + Period(3,Years); - pair, vector > - someOtherSlice = yoySurf->Dslice(d); + auto someOtherSlice = yoySurf->Dslice(d); n = someOtherSlice.first.size(); for(Size i = 0; i < n; i++){ QL_REQUIRE(fabs(someOtherSlice.second[i]-volATyear3[i]) < eps, @@ -383,8 +380,8 @@ void InflationVolTest::testYoYPriceSurfaceToATM() { setupPriceSurface(); - pair, vector > yyATMt = priceSurfEU->atmYoYSwapTimeRates(); - pair, vector > yyATMd = priceSurfEU->atmYoYSwapDateRates(); + auto yyATMt = priceSurfEU->atmYoYSwapTimeRates(); + auto yyATMd = priceSurfEU->atmYoYSwapDateRates(); // Real dy = (Real)lag / 12.0; const Real crv[] = {0.024586, 0.0247575, 0.0249396, 0.0252596, diff --git a/test-suite/nthtodefault.cpp b/test-suite/nthtodefault.cpp index 785e16d1894..38419e32d92 100644 --- a/test-suite/nthtodefault.cpp +++ b/test-suite/nthtodefault.cpp @@ -36,7 +36,6 @@ #include using namespace QuantLib; -using namespace std; using namespace boost::unit_test_framework; #ifndef QL_PATCH_SOLARIS @@ -122,7 +121,7 @@ void NthToDefaultTest::testGauss() { Compounding cmp = Continuous; // Simple; Real recovery = 0.4; - vector lambda (names, 0.01); + std::vector lambda (names, 0.01); Real namesNotional = 100.0; @@ -135,7 +134,7 @@ void NthToDefaultTest::testGauss() { Settings::instance().evaluationDate() = asofDate; - vector gridDates = { + std::vector gridDates = { asofDate, TARGET().advance (asofDate, Period (1, Years)), TARGET().advance (asofDate, Period (5, Years)), @@ -146,7 +145,7 @@ void NthToDefaultTest::testGauss() { new FlatForward (asofDate, rate, dc, cmp)); Handle yieldHandle (yieldPtr); - vector > probabilities; + std::vector > probabilities; Period maxTerm (10, Years); for (Real i : lambda) { Handle h(ext::shared_ptr(new SimpleQuote(i))); @@ -210,7 +209,7 @@ void NthToDefaultTest::testGauss() { ext::shared_ptr engine( new IntegralNtdEngine(timeUnit, yieldHandle)); - vector ntd; + std::vector ntd; for (Size i = 1; i <= probabilities.size(); i++) { ntd.emplace_back(basket, i, Protection::Seller, schedule, 0.0, 0.02, Actual360(), namesNotional * names, true); @@ -268,7 +267,7 @@ void NthToDefaultTest::testStudent() { Real recovery = 0.4; - vector lambda (names, 0.01); + std::vector lambda (names, 0.01); Real namesNotional = 100.0; @@ -281,7 +280,7 @@ void NthToDefaultTest::testStudent() { Settings::instance().evaluationDate() = asofDate; - vector gridDates { + std::vector gridDates { asofDate, TARGET().advance (asofDate, Period (1, Years)), TARGET().advance (asofDate, Period (5, Years)), @@ -292,7 +291,7 @@ void NthToDefaultTest::testStudent() { new FlatForward (asofDate, rate, dc, cmp)); Handle yieldHandle (yieldPtr); - vector > probabilities; + std::vector > probabilities; Period maxTerm (10, Years); for (Real i : lambda) { Handle h(ext::shared_ptr(new SimpleQuote(i))); @@ -340,7 +339,7 @@ void NthToDefaultTest::testStudent() { ext::shared_ptr engine( new IntegralNtdEngine(timeUnit, yieldHandle)); - vector ntd; + std::vector ntd; for (Size i = 1; i <= probabilities.size(); i++) { ntd.emplace_back(basket, i, Protection::Seller, schedule, 0.0, 0.02, Actual360(), namesNotional * names, true); diff --git a/test-suite/spreadoption.cpp b/test-suite/spreadoption.cpp index 964c3cbb34a..bebc7e45a02 100644 --- a/test-suite/spreadoption.cpp +++ b/test-suite/spreadoption.cpp @@ -27,9 +27,6 @@ using namespace QuantLib; using namespace boost::unit_test_framework; -using namespace std; - -//namespace QuantLib { #undef REPORT_FAILURE #define REPORT_FAILURE( \ From dd377ee1c5f6725be9c6e80a03ae16cd0979a67e Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Fri, 24 Mar 2023 09:22:42 +0100 Subject: [PATCH 069/292] Test in Linux CI build --- .github/workflows/linux-full-tests.yml | 2 +- .github/workflows/linux-nondefault.yml | 2 +- .github/workflows/linux.yml | 2 +- configure.ac | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/linux-full-tests.yml b/.github/workflows/linux-full-tests.yml index 874d3ffcfa2..1de8ec4b2b9 100644 --- a/.github/workflows/linux-full-tests.yml +++ b/.github/workflows/linux-full-tests.yml @@ -141,7 +141,7 @@ jobs: tag: rolling cc: gcc cxx: g++ - configureflags: --enable-std-classes + configureflags: --enable-std-classes --enable-std-any --enable-std-optional - name: "Thread-safe observer enabled" shortname: threadsafe tag: rolling diff --git a/.github/workflows/linux-nondefault.yml b/.github/workflows/linux-nondefault.yml index fa2ec78ab50..f372487cd6a 100644 --- a/.github/workflows/linux-nondefault.yml +++ b/.github/workflows/linux-nondefault.yml @@ -130,7 +130,7 @@ jobs: cc: gcc cxx: g++ cxxflags: "-std=c++17" - configureflags: --enable-std-classes + configureflags: --enable-std-classes --enable-std-any --enable-std-optional - name: "OpenMP enabled" shortname: openmp tag: rolling diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index e92e667d923..c3bc130a05f 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -144,7 +144,7 @@ jobs: tag: rolling cc: gcc cxx: g++ - configureflags: --enable-std-classes + configureflags: --enable-std-classes --enable-std-any --enable-std-optional tests: true - name: "Thread-safe observer enabled" shortname: threadsafe diff --git a/configure.ac b/configure.ac index 5c34f71c84b..8e4455e3c7c 100644 --- a/configure.ac +++ b/configure.ac @@ -336,8 +336,8 @@ AC_ARG_ENABLE([std-any], AS_HELP_STRING([--enable-std-any], [If enabled, std::any and related classes and functions will be used instead of boost::any. - If disabled (the default) the Boost facilities - are used.]), + This requires C++17. If disabled (the default) + the Boost facilities are used.]), [ql_use_std_any=$enableval], [ql_use_std_any=no]) if test "$ql_use_std_any" = "yes" ; then @@ -351,7 +351,7 @@ AC_ARG_ENABLE([std-optional], AS_HELP_STRING([--enable-std-optional], [If enabled, std::optional and related classes and functions will be used instead - of boost::optional. + of boost::optional. This requires C++17. If disabled (the default) the Boost facilities are used.]), [ql_use_std_optional=$enableval], From bb814c8b5e3dd26d9a2c67547b9666a31467bec6 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Fri, 24 Mar 2023 09:25:55 +0100 Subject: [PATCH 070/292] Test in Mac OS CI build --- .github/workflows/macos-nondefault.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos-nondefault.yml b/.github/workflows/macos-nondefault.yml index 6b6a57e31cb..c7f4bba3f6b 100644 --- a/.github/workflows/macos-nondefault.yml +++ b/.github/workflows/macos-nondefault.yml @@ -15,13 +15,13 @@ jobs: - os: [macos-11] shortname: stdclasses-11 cxxflags: "-std=c++17" - configureflags: --enable-std-classes + configureflags: --enable-std-classes --enable-std-any --enable-std-optional - os: [macos-12] shortname: default-12 - os: [macos-12] shortname: stdclasses-12 cxxflags: "-std=c++17" - configureflags: --enable-std-classes + configureflags: --enable-std-classes --enable-std-any --enable-std-optional steps: - uses: actions/checkout@v3 - name: Setup From a0aa6435a2e2bf0ff5f556282053dfc94747a890 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 22 Mar 2023 14:32:44 +0000 Subject: [PATCH 071/292] Update copyright list in license --- LICENSE.TXT | 2 ++ 1 file changed, 2 insertions(+) diff --git a/LICENSE.TXT b/LICENSE.TXT index 20aedb9503c..05dda49d2f0 100644 --- a/LICENSE.TXT +++ b/LICENSE.TXT @@ -162,6 +162,8 @@ QuantLib is Copyright (C) 2022 Jonghee Lee Copyright (C) 2022, 2023 Ignacio Anguita + Copyright (C) 2023 Jonathan Sweemer + QuantLib includes code taken from Peter Jäckel's book "Monte Carlo Methods in Finance". From ec1927aa55ecc82bbefac183e5c5fe6c69c3c74d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 22 Mar 2023 14:34:58 +0000 Subject: [PATCH 072/292] Update generated headers --- ql/quantlib.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ql/quantlib.hpp b/ql/quantlib.hpp index c68572f3e3c..ef135c4bbb4 100644 --- a/ql/quantlib.hpp +++ b/ql/quantlib.hpp @@ -7,6 +7,7 @@ # include #endif +#include #include #include #include @@ -25,6 +26,7 @@ #include #include #include +#include #include #include #include From 0124ab3b7b51a7de3ab051bcd0d9f2b5349e16d5 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Sun, 26 Mar 2023 12:20:58 +0200 Subject: [PATCH 073/292] Avoid std::any_cast on Mac OS 10.11 and 10.12. --- .github/workflows/macos-nondefault.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/macos-nondefault.yml b/.github/workflows/macos-nondefault.yml index c7f4bba3f6b..8a53b505e60 100644 --- a/.github/workflows/macos-nondefault.yml +++ b/.github/workflows/macos-nondefault.yml @@ -15,13 +15,13 @@ jobs: - os: [macos-11] shortname: stdclasses-11 cxxflags: "-std=c++17" - configureflags: --enable-std-classes --enable-std-any --enable-std-optional + configureflags: --enable-std-classes --enable-std-optional - os: [macos-12] shortname: default-12 - os: [macos-12] shortname: stdclasses-12 cxxflags: "-std=c++17" - configureflags: --enable-std-classes --enable-std-any --enable-std-optional + configureflags: --enable-std-classes --enable-std-optional steps: - uses: actions/checkout@v3 - name: Setup From b7f3dc2f6bffe4f63bf8fc7382e942062991ace0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Mar 2023 11:56:44 +0000 Subject: [PATCH 074/292] Bump actions/stale from 7 to 8 Bumps [actions/stale](https://github.com/actions/stale) from 7 to 8. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/stale/compare/v7...v8) --- updated-dependencies: - dependency-name: actions/stale dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index aa734cbc9a0..d09494439aa 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -6,7 +6,7 @@ jobs: staleness-check: runs-on: ubuntu-latest steps: - - uses: actions/stale@v7 + - uses: actions/stale@v8 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'This issue was automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment, or this will be closed in two weeks.' From e3a177d48b2da4c82da02afa4a2c9599061fecdd Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Tue, 28 Mar 2023 14:18:55 +0200 Subject: [PATCH 075/292] Test regression for at-par FRA --- test-suite/piecewiseyieldcurve.cpp | 192 +++++++++++++++++++---------- test-suite/piecewiseyieldcurve.hpp | 2 + 2 files changed, 126 insertions(+), 68 deletions(-) diff --git a/test-suite/piecewiseyieldcurve.cpp b/test-suite/piecewiseyieldcurve.cpp index a49d2d3b458..243b96ef10a 100644 --- a/test-suite/piecewiseyieldcurve.cpp +++ b/test-suite/piecewiseyieldcurve.cpp @@ -166,11 +166,32 @@ namespace piecewise_yield_curve_test { Size deposits, fras, immFuts, asxFuts, swaps, bonds, bmas; std::vector > rates, fraRates, - immFutPrices, asxFutPrices, - prices, fractions; - std::vector > instruments, fraHelpers, - immFutHelpers, asxFutHelpers, - bondHelpers, bmaHelpers; + immFutPrices, asxFutPrices, + prices, fractions; + std::vector > instruments, + immFutHelpers, asxFutHelpers, + bondHelpers, bmaHelpers; + + std::vector > fraHelpers(bool useIndexedFra) const { + auto helpers = std::vector >(fras); + auto euribor3m = ext::make_shared(); + for (Size i=0; i r(fraRates[i]); + helpers[i] = ext::make_shared( + r, fraData[i].n, fraData[i].n + 3, + euribor3m->fixingDays(), + euribor3m->fixingCalendar(), + euribor3m->businessDayConvention(), + euribor3m->endOfMonth(), + euribor3m->dayCounter(), + Pillar::LastRelevantDate, + Date(), + useIndexedFra); + } + + return helpers; + } + std::vector schedules; ext::shared_ptr termStructure; @@ -179,11 +200,11 @@ namespace piecewise_yield_curve_test { IndexHistoryCleaner cleaner; // setup - CommonVars() { + CommonVars(Date evaluationDate = Date()) { // data calendar = TARGET(); settlementDays = 2; - today = calendar.adjust(Date::todaysDate()); + today = calendar.adjust(evaluationDate != Date() ? evaluationDate : Date::todaysDate()); Settings::instance().evaluationDate() = today; settlement = calendar.advance(today,settlementDays,Days); fixedLegConvention = Unadjusted; @@ -206,8 +227,7 @@ namespace piecewise_yield_curve_test { bmas = LENGTH(bmaData); // market elements - rates = - std::vector >(deposits+swaps); + rates = std::vector >(deposits+swaps); fraRates = std::vector >(fras); immFutPrices = std::vector >(immFuts); asxFutPrices = std::vector >(asxFuts); @@ -243,9 +263,7 @@ namespace piecewise_yield_curve_test { } // rate helpers - instruments = - std::vector >(deposits+swaps); - fraHelpers = std::vector >(fras); + instruments = std::vector >(deposits+swaps); immFutHelpers = std::vector >(immFuts); asxFutHelpers = std::vector >(); bondHelpers = std::vector >(bonds); @@ -269,28 +287,8 @@ namespace piecewise_yield_curve_test { fixedLegDayCounter, euribor6m)); } - -#ifdef QL_USE_INDEXED_COUPON - bool useIndexedFra = false; -#else - bool useIndexedFra = true; -#endif - - ext::shared_ptr euribor3m(new Euribor3M()); - for (Size i=0; i r(fraRates[i]); - fraHelpers[i] = ext::shared_ptr(new - FraRateHelper(r, fraData[i].n, fraData[i].n + 3, - euribor3m->fixingDays(), - euribor3m->fixingCalendar(), - euribor3m->businessDayConvention(), - euribor3m->endOfMonth(), - euribor3m->dayCounter(), - Pillar::LastRelevantDate, - Date(), - useIndexedFra)); - } Date immDate = Date(); + auto euribor3m = ext::make_shared(); for (Size i = 0; i r(immFutPrices[i]); immDate = IMM::nextDate(immDate, false); @@ -434,20 +432,50 @@ namespace piecewise_yield_curve_test { } } - // check FRA + // check FRA, use indexed + + bool useIndexedFra = true; + ext::shared_ptr euribor3m(new Euribor3M(curveHandle)); + vars.termStructure = ext::shared_ptr(new - PiecewiseYieldCurve(vars.settlement, vars.fraHelpers, + PiecewiseYieldCurve(vars.settlement, vars.fraHelpers(useIndexedFra), Actual360(), interpolator)); curveHandle.linkTo(vars.termStructure); -#ifdef QL_USE_INDEXED_COUPON - bool useIndexedFra = false; -#else - bool useIndexedFra = true; -#endif + for (Size i=0; ibusinessDayConvention(), + euribor3m->endOfMonth()); + BOOST_REQUIRE(fraData[i].units == Months); + + ForwardRateAgreement fra(start, Position::Long, + fraData[i].rate/100, 100.0, + euribor3m, curveHandle, + useIndexedFra); + Rate expectedRate = fraData[i].rate/100, + estimatedRate = fra.forwardRate(); + if (std::fabs(expectedRate-estimatedRate) > tolerance) { + BOOST_ERROR(io::ordinal(i+1) << " FRA (indexed) failure:" << + std::setprecision(8) << + "\n estimated rate: " << io::rate(estimatedRate) << + "\n expected rate: " << io::rate(expectedRate)); + } + } + + // check FRA, don't use indexed + + useIndexedFra = false; + + vars.termStructure = ext::shared_ptr(new + PiecewiseYieldCurve(vars.settlement, vars.fraHelpers(useIndexedFra), + Actual360(), + interpolator)); + curveHandle.linkTo(vars.termStructure); - ext::shared_ptr euribor3m(new Euribor3M(curveHandle)); for (Size i=0; i tolerance) { - BOOST_ERROR(io::ordinal(i+1) << " FRA failure:" << + BOOST_ERROR(io::ordinal(i+1) << " FRA (at par) failure:" << std::setprecision(8) << "\n estimated rate: " << io::rate(estimatedRate) << "\n expected rate: " << io::rate(expectedRate)); @@ -801,6 +829,44 @@ void PiecewiseYieldCurveTest::testLocalBootstrapConsistency() { vars, ConvexMonotone(), 1.0e-7); } +void PiecewiseYieldCurveTest::testParFraRegression() { + BOOST_TEST_MESSAGE("Testing regression for at-par FRA..."); + + using namespace piecewise_yield_curve_test; + + CommonVars vars(Date(23, February, 2023)); + + bool useIndexedFra = false; + RelinkableHandle curveHandle; + auto euribor3m = ext::make_shared(curveHandle); + + vars.termStructure = ext::make_shared>( + vars.settlement, vars.fraHelpers(useIndexedFra), Actual360()); + curveHandle.linkTo(vars.termStructure); + + for (Size i=0; ibusinessDayConvention(), + euribor3m->endOfMonth()); + BOOST_REQUIRE(fraData[i].units == Months); + + ForwardRateAgreement fra(start, Position::Long, + fraData[i].rate/100, 100.0, + euribor3m, curveHandle, + useIndexedFra); + Rate expectedRate = fraData[i].rate/100; + Rate estimatedRate = fra.forwardRate(); + Real tolerance = 1.0e-6; + if (std::fabs(expectedRate-estimatedRate) > tolerance) { + BOOST_ERROR(io::ordinal(i+1) << " FRA (at par) failure:" << + std::setprecision(8) << + "\n estimated rate: " << io::rate(estimatedRate) << + "\n expected rate: " << io::rate(expectedRate)); + } + } +} void PiecewiseYieldCurveTest::testObservability() { @@ -1427,40 +1493,30 @@ test_suite* PiecewiseYieldCurveTest::suite() { auto* suite = BOOST_TEST_SUITE("Piecewise yield curve tests"); // unstable - //suite->add(QUANTLIB_TEST_CASE( - // &PiecewiseYieldCurveTest::testLogCubicDiscountConsistency)); - suite->add(QUANTLIB_TEST_CASE( - &PiecewiseYieldCurveTest::testLogLinearDiscountConsistency)); - suite->add(QUANTLIB_TEST_CASE( - &PiecewiseYieldCurveTest::testLinearDiscountConsistency)); - - suite->add(QUANTLIB_TEST_CASE( - &PiecewiseYieldCurveTest::testLinearZeroConsistency)); - suite->add(QUANTLIB_TEST_CASE( - &PiecewiseYieldCurveTest::testSplineZeroConsistency)); - - suite->add(QUANTLIB_TEST_CASE( - &PiecewiseYieldCurveTest::testLinearForwardConsistency)); - suite->add(QUANTLIB_TEST_CASE( - &PiecewiseYieldCurveTest::testFlatForwardConsistency)); + // suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testLogCubicDiscountConsistency)); + suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testLogLinearDiscountConsistency)); + suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testLinearDiscountConsistency)); + + suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testLinearZeroConsistency)); + suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testSplineZeroConsistency)); + + suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testLinearForwardConsistency)); + suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testFlatForwardConsistency)); // unstable - //suite->add(QUANTLIB_TEST_CASE( - // &PiecewiseYieldCurveTest::testSplineForwardConsistency)); + // suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testSplineForwardConsistency)); + + suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testConvexMonotoneForwardConsistency)); + suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testLocalBootstrapConsistency)); - suite->add(QUANTLIB_TEST_CASE( - &PiecewiseYieldCurveTest::testConvexMonotoneForwardConsistency)); - suite->add(QUANTLIB_TEST_CASE( - &PiecewiseYieldCurveTest::testLocalBootstrapConsistency)); + suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testParFraRegression)); suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testObservability)); suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testLiborFixing)); suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testJpyLibor)); - suite->add(QUANTLIB_TEST_CASE( - &PiecewiseYieldCurveTest::testSwapRateHelperLastRelevantDate)); - suite->add(QUANTLIB_TEST_CASE( - &PiecewiseYieldCurveTest::testSwapRateHelperSpotDate)); + suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testSwapRateHelperLastRelevantDate)); + suite->add(QUANTLIB_TEST_CASE(&PiecewiseYieldCurveTest::testSwapRateHelperSpotDate)); if (IborCoupon::Settings::instance().usingAtParCoupons()) { // This regression test didn't work with indexed coupons anyway. diff --git a/test-suite/piecewiseyieldcurve.hpp b/test-suite/piecewiseyieldcurve.hpp index b5731764a7d..3b420b12ac7 100644 --- a/test-suite/piecewiseyieldcurve.hpp +++ b/test-suite/piecewiseyieldcurve.hpp @@ -41,6 +41,8 @@ class PiecewiseYieldCurveTest { static void testConvexMonotoneForwardConsistency(); static void testLocalBootstrapConsistency(); + static void testParFraRegression(); + static void testObservability(); static void testLiborFixing(); From 96dc6df64df7908e619e7cbd6594bcb13afbde54 Mon Sep 17 00:00:00 2001 From: RalfKonrad Date: Thu, 30 Mar 2023 15:57:21 +0200 Subject: [PATCH 076/292] Incorp. feedback --- .github/workflows/cmake.yml | 4 ++-- CMakePresets.json | 4 +++- cmake/Platform.cmake | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index b54a4a3a382..98bf54b8886 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -45,7 +45,7 @@ jobs: cmake-linux-ci-opts- - name: Compile run: | - cmake --preset linux-ci-build-with-nonstandard-options -DQL_COMPILE_WARNING_AS_ERROR=ON -L + cmake --preset linux-ci-build-with-nonstandard-options -L cmake --build --preset linux-ci-build-with-nonstandard-options --verbose - name: Test run: | @@ -144,7 +144,7 @@ jobs: shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Vc\Auxiliary\Build\vcvarsall.bat" amd64 -vcvars_ver=14.3 || exit 1 - cmake --preset windows-ci-build-with-nonstandard-options -DQL_COMPILE_WARNING_AS_ERROR=ON -L + cmake --preset windows-ci-build-with-nonstandard-options -L cmake --build --preset windows-ci-build-with-nonstandard-options --verbose - name: Test run: | diff --git a/CMakePresets.json b/CMakePresets.json index c3d473953be..910bc50bf31 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -116,7 +116,8 @@ "QL_HIGH_RESOLUTION_DATE": "ON", "QL_NULL_AS_FUNCTIONS": "ON", "QL_USE_INDEXED_COUPON": "ON", - "QL_USE_STD_CLASSES": "ON" + "QL_USE_STD_CLASSES": "ON", + "QL_COMPILE_WARNING_AS_ERROR": "ON" } }, { @@ -137,6 +138,7 @@ "QL_NULL_AS_FUNCTIONS": "ON", "QL_USE_INDEXED_COUPON": "ON", "QL_USE_STD_CLASSES": "ON", + "QL_COMPILE_WARNING_AS_ERROR": "ON", "CMAKE_CXX_COMPILER_LAUNCHER": "sccache" }, "vendor": { diff --git a/cmake/Platform.cmake b/cmake/Platform.cmake index 2d6a5887fbb..1da2834bce3 100644 --- a/cmake/Platform.cmake +++ b/cmake/Platform.cmake @@ -32,7 +32,7 @@ if (MSVC) add_compile_options(/wd4267 /wd4819 /wd26812) # prevent warnings when using /std:c++17 and above - if(CMAKE_CXX_STANDARD GREATER 14) + if(CMAKE_CXX_STANDARD GREATER_EQUAL 17) # E.g. caused by #include # In c++17 std::iterator is deprecated. As of boost 1.81 boost::ublas has not provided a fix for this. add_compile_definitions(_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING) From 93187ab648bfda382fa8e112d9299f226e70a47f Mon Sep 17 00:00:00 2001 From: Xcelerit Dev Team Date: Sat, 1 Apr 2023 07:19:25 +0100 Subject: [PATCH 077/292] Fixes ternary operator for conistent Real use --- test-suite/equitycashflow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-suite/equitycashflow.cpp b/test-suite/equitycashflow.cpp index db70292de6f..74d1404e8c2 100644 --- a/test-suite/equitycashflow.cpp +++ b/test-suite/equitycashflow.cpp @@ -158,7 +158,7 @@ namespace equitycashflow_test { Real time = vars.localCcyInterestHandle->timeFromReference(cf->fixingDate()); Real rf = vars.localCcyInterestHandle->zeroRate(time, Continuous); - Real q = includeDividend ? vars.dividendHandle->zeroRate(time, Continuous) : 0.0; + Real q = includeDividend ? vars.dividendHandle->zeroRate(time, Continuous) : Real(0.0); Real eqVol = vars.equityVolHandle->blackVol(cf->fixingDate(), strike); Real fxVol = vars.fxVolHandle->blackVol(cf->fixingDate(), 1.0); Real rho = vars.correlationHandle->value(); @@ -327,4 +327,4 @@ test_suite* EquityCashFlowTest::suite() { QUANTLIB_TEST_CASE(&EquityCashFlowTest::testErrorWhenInconsistentMarketDataReferenceDate)); return suite; -} \ No newline at end of file +} From a723850784d41b162c0a214c7b2ffb61bd321486 Mon Sep 17 00:00:00 2001 From: Xcelerit Dev Team Date: Sat, 1 Apr 2023 08:01:39 +0100 Subject: [PATCH 078/292] Fixes Size -> double conversion warnings with VC++ and higher warning level --- ql/experimental/catbonds/montecarlocatbondengine.cpp | 6 +++--- ql/experimental/credit/homogeneouspooldef.hpp | 2 +- ql/experimental/credit/inhomogeneouspooldef.hpp | 2 +- ql/experimental/exoticoptions/mchimalayaengine.cpp | 2 +- ql/experimental/exoticoptions/mcpagodaengine.cpp | 2 +- .../mcbasket/longstaffschwartzmultipathpricer.cpp | 6 +++--- ql/models/equity/hestonslvmcmodel.cpp | 2 +- .../evolvers/volprocesses/squarerootandersen.cpp | 2 +- .../marketmodels/pathwisegreeks/swaptionpseudojacobian.cpp | 2 +- ql/models/volatility/garch.cpp | 2 +- ql/pricingengines/asian/turnbullwakemanasianengine.cpp | 2 +- ql/pricingengines/vanilla/analyticptdhestonengine.cpp | 2 +- .../volatility/equityfx/andreasenhugevolatilityinterpl.cpp | 2 +- test-suite/catbonds.cpp | 4 ++-- test-suite/distributions.cpp | 2 +- test-suite/libormarketmodel.cpp | 2 +- test-suite/marketmodel.cpp | 2 +- 17 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ql/experimental/catbonds/montecarlocatbondengine.cpp b/ql/experimental/catbonds/montecarlocatbondengine.cpp index 601eabc4582..88bfc61574e 100644 --- a/ql/experimental/catbonds/montecarlocatbondengine.cpp +++ b/ql/experimental/catbonds/montecarlocatbondengine.cpp @@ -109,9 +109,9 @@ namespace QuantLib { } pathCount++; } - lossProbability/=pathCount; - exhaustionProbability/=pathCount; - expectedLoss/=pathCount; + lossProbability/=Real(pathCount); + exhaustionProbability/=Real(pathCount); + expectedLoss/=Real(pathCount); return totalNPV/(pathCount*discountCurve_->discount(npvDate)); } diff --git a/ql/experimental/credit/homogeneouspooldef.hpp b/ql/experimental/credit/homogeneouspooldef.hpp index 2eb6ab829ff..b5c3563a1e2 100644 --- a/ql/experimental/credit/homogeneouspooldef.hpp +++ b/ql/experimental/credit/homogeneouspooldef.hpp @@ -142,7 +142,7 @@ namespace QuantLib { detachAmount_); //notional_); std::vector mkft(1, min_ + delta_ /2.); - for (Size i = 0; i < nSteps_; i++) { + for (Real i = 0; i < nSteps_; i++) { std::vector conditionalProbs; for(Size iName=0; iName mkft(1, min_ + delta_ /2.); - for (Size i = 0; i < nSteps_; i++) { + for (Real i = 0; i < nSteps_; i++) { std::vector conditionalProbs; for(Size iName=0; iName(0.0, std::min(roof_, averagePerformance)); diff --git a/ql/experimental/mcbasket/longstaffschwartzmultipathpricer.cpp b/ql/experimental/mcbasket/longstaffschwartzmultipathpricer.cpp index a44e0058027..2caddd06f39 100644 --- a/ql/experimental/mcbasket/longstaffschwartzmultipathpricer.cpp +++ b/ql/experimental/mcbasket/longstaffschwartzmultipathpricer.cpp @@ -256,9 +256,9 @@ namespace QuantLib { sumOptimized += lsExercise[j] ? exercise[j] : prices[j]; } - sumOptimized /= n; - sumNoExercise /= n; - sumAlwaysExercise /= n; + sumOptimized /= Real(n); + sumNoExercise /= Real(n); + sumAlwaysExercise /= Real(n); QL_TRACE( "Time index: " << i << ", LowerBound: " << lowerBounds_[i + 1] diff --git a/ql/models/equity/hestonslvmcmodel.cpp b/ql/models/equity/hestonslvmcmodel.cpp index ffd32f6557a..b356569f039 100644 --- a/ql/models/equity/hestonslvmcmodel.cpp +++ b/ql/models/equity/hestonslvmcmodel.cpp @@ -173,7 +173,7 @@ namespace QuantLib { for (Size j=s; j < e; ++j) { sum+=pairs[j].second; } - sum/=inc; + sum/=Real(inc); vStrikes[n]->at(i) = 0.5*(pairs[e-1].first + pairs[s].first); (*L)[i][n] = std::sqrt(squared(localVol_->localVol(t, vStrikes[n]->at(i), true))/sum); diff --git a/ql/models/marketmodels/evolvers/volprocesses/squarerootandersen.cpp b/ql/models/marketmodels/evolvers/volprocesses/squarerootandersen.cpp index 9f4ce7a94ae..618dbb46dd8 100644 --- a/ql/models/marketmodels/evolvers/volprocesses/squarerootandersen.cpp +++ b/ql/models/marketmodels/evolvers/volprocesses/squarerootandersen.cpp @@ -145,7 +145,7 @@ QuantLib for (Size k=0; k < numberSubSteps_; ++k) stepVariance += w1_*vPath_[k+lastStepStart]+w2_*vPath_[k+lastStepStart+1]; - stepVariance /= numberSubSteps_; + stepVariance /= Real(numberSubSteps_); return std::sqrt(stepVariance); } diff --git a/ql/models/marketmodels/pathwisegreeks/swaptionpseudojacobian.cpp b/ql/models/marketmodels/pathwisegreeks/swaptionpseudojacobian.cpp index d16525ff637..13ed706c44d 100644 --- a/ql/models/marketmodels/pathwisegreeks/swaptionpseudojacobian.cpp +++ b/ql/models/marketmodels/pathwisegreeks/swaptionpseudojacobian.cpp @@ -291,7 +291,7 @@ namespace QuantLib } - guess/=numberCaplets; + guess/=Real(numberCaplets); for (Size step =0; step < inputModel->evolution().numberOfSteps(); ++step) diff --git a/ql/models/volatility/garch.cpp b/ql/models/volatility/garch.cpp index 57afe82da11..b27fdbdd495 100644 --- a/ql/models/volatility/garch.cpp +++ b/ql/models/volatility/garch.cpp @@ -338,7 +338,7 @@ namespace QuantLib { } } if (nn > 0) - gamma /= nn; + gamma /= Real(nn); if (gamma < gammaLower) gamma = gammaLower; beta = std::min(gamma, std::max(gamma * (1 - A) - B, 0.0)); omega = mean_r2 * (1 - gamma); diff --git a/ql/pricingengines/asian/turnbullwakemanasianengine.cpp b/ql/pricingengines/asian/turnbullwakemanasianengine.cpp index 946425a4c8b..f0b78d76967 100644 --- a/ql/pricingengines/asian/turnbullwakemanasianengine.cpp +++ b/ql/pricingengines/asian/turnbullwakemanasianengine.cpp @@ -51,7 +51,7 @@ void TurnbullWakemanAsianEngine::calculate() const { // If the effective strike is negative, exercise resp. permanent OTM is guaranteed and the // valuation is made easy - Size m = futureFixings + pastFixings; + Real m = Real(futureFixings + pastFixings); if (effectiveStrike <= 0.0) { // For a reference, see "Option Pricing Formulas", Haug, 2nd ed, p. 193 if (payoff->optionType() == Option::Type::Call) { diff --git a/ql/pricingengines/vanilla/analyticptdhestonengine.cpp b/ql/pricingengines/vanilla/analyticptdhestonengine.cpp index eb3aeb5209f..0144b75b1d8 100644 --- a/ql/pricingengines/vanilla/analyticptdhestonengine.cpp +++ b/ql/pricingengines/vanilla/analyticptdhestonengine.cpp @@ -293,7 +293,7 @@ namespace QuantLib { sigmaAvg += model_->sigma(t); rhoAvg += model_->rho(t); } - kappaAvg/=n; thetaAvg/=n; sigmaAvg/=n; rhoAvg/=n; + kappaAvg/=Real(n); thetaAvg/=Real(n); sigmaAvg/=Real(n); rhoAvg/=Real(n); evaluations_ = 0; diff --git a/ql/termstructures/volatility/equityfx/andreasenhugevolatilityinterpl.cpp b/ql/termstructures/volatility/equityfx/andreasenhugevolatilityinterpl.cpp index 21242a6ca72..5514c083392 100644 --- a/ql/termstructures/volatility/equityfx/andreasenhugevolatilityinterpl.cpp +++ b/ql/termstructures/volatility/equityfx/andreasenhugevolatilityinterpl.cpp @@ -447,7 +447,7 @@ namespace QuantLib { npvCalls= callCostFct->solveFor(dT_[i], sig, npvCalls); } - avgError_ /= calibrationSet_.size(); + avgError_ /= Real(calibrationSet_.size()); } Date AndreasenHugeVolatilityInterpl::maxDate() const { diff --git a/test-suite/catbonds.cpp b/test-suite/catbonds.cpp index 40e6764837b..fb03553a6aa 100644 --- a/test-suite/catbonds.cpp +++ b/test-suite/catbonds.cpp @@ -162,8 +162,8 @@ void CatBondTest::testBetaRisk() { processValue += j.second; sum+=processValue; sumSquares+=processValue*processValue; - poissonSum+=path.size(); - poissonSumSquares+=path.size()*path.size(); + poissonSum+=Real(path.size()); + poissonSumSquares+=Real(path.size()*path.size()); } Real poissonMean = poissonSum/PATHS; QL_CHECK_CLOSE(Real(3.0/100.0), poissonMean, 2); diff --git a/test-suite/distributions.cpp b/test-suite/distributions.cpp index bfbb36b8917..682d9cdbd2c 100644 --- a/test-suite/distributions.cpp +++ b/test-suite/distributions.cpp @@ -618,7 +618,7 @@ void DistributionTest::testBivariateCumulativeStudentVsBivariate() { ++m; } } - avgDiff /= m; + avgDiff /= Real(m); if (avgDiff > 3.0e-6) BOOST_ERROR("Failed to reproduce average limit value:" << "\n rho: " << rho << diff --git a/test-suite/libormarketmodel.cpp b/test-suite/libormarketmodel.cpp index 4599de5c11b..a4da60b8f00 100644 --- a/test-suite/libormarketmodel.cpp +++ b/test-suite/libormarketmodel.cpp @@ -172,7 +172,7 @@ void LiborMarketModelTest::testSimpleCovarianceModels() { for (Size k=0; k2*t) { + if (Real(k)>2*t) { const Real T = fixingTimes[k]; expected=(a*(T-t)+d)*std::exp(-b*(T-t)) + c; } diff --git a/test-suite/marketmodel.cpp b/test-suite/marketmodel.cpp index 861e6e1404b..e98ff9f0f84 100644 --- a/test-suite/marketmodel.cpp +++ b/test-suite/marketmodel.cpp @@ -178,7 +178,7 @@ namespace market_model_test { todaysForwards[i] = 0.03 + 0.0010*i; meanForward+= todaysForwards[i]; } - meanForward /= todaysForwards.size(); + meanForward /= Real(todaysForwards.size()); From d7de07f72a4617e57d13a87dcd42d8cd40a5748b Mon Sep 17 00:00:00 2001 From: Xcelerit Dev Team Date: Sat, 1 Apr 2023 09:04:22 +0000 Subject: [PATCH 079/292] Explicit return type for lambdas with expressions to allow expression templates --- ql/experimental/math/convolvedstudentt.cpp | 2 +- ql/experimental/math/gaussiancopulapolicy.hpp | 2 +- ql/experimental/math/multidimquadrature.hpp | 4 ++-- ql/legacy/libormarketmodels/lfmcovarproxy.cpp | 2 +- .../finitedifferences/meshers/concentrating1dmesher.cpp | 4 ++-- .../finitedifferences/utilities/gbsmrndcalculator.cpp | 2 +- .../utilities/riskneutraldensitycalculator.cpp | 2 +- ql/models/volatility/garch.cpp | 8 ++++---- ql/pricingengines/vanilla/qdplusamericanengine.cpp | 2 +- test-suite/distributions.cpp | 2 +- test-suite/hestonslvmodel.cpp | 2 +- test-suite/riskneutraldensitycalculator.cpp | 2 +- test-suite/squarerootclvmodel.cpp | 4 ++-- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ql/experimental/math/convolvedstudentt.cpp b/ql/experimental/math/convolvedstudentt.cpp index 042f9134144..e42a340907c 100644 --- a/ql/experimental/math/convolvedstudentt.cpp +++ b/ql/experimental/math/convolvedstudentt.cpp @@ -172,7 +172,7 @@ namespace QuantLib { // (q is very close to 1.), in a bad combination fails around 1.-1.e-7 Real xMax = 1.e6; return sign * - Brent().solve([&](Real x){ return distrib_(x) - effectiveq; }, + Brent().solve([&](Real x) -> Real { return distrib_(x) - effectiveq; }, accuracy_, (xMin+xMax)/2., xMin, xMax); } diff --git a/ql/experimental/math/gaussiancopulapolicy.hpp b/ql/experimental/math/gaussiancopulapolicy.hpp index bda2ef38c33..039ae7a692b 100644 --- a/ql/experimental/math/gaussiancopulapolicy.hpp +++ b/ql/experimental/math/gaussiancopulapolicy.hpp @@ -84,7 +84,7 @@ namespace QuantLib { */ Probability density(const std::vector& m) const { return std::accumulate(m.begin(), m.end(), Real(1.), - [&](Real x, Real y){ return x*density_(y); }); + [&](Real x, Real y) -> Real { return x*density_(y); }); } /*! Returns the inverse of the cumulative distribution of the (modelled) latent variable (as indexed by iVariable). The normal stability avoids diff --git a/ql/experimental/math/multidimquadrature.hpp b/ql/experimental/math/multidimquadrature.hpp index 63b7a6f0484..1e7a3404210 100644 --- a/ql/experimental/math/multidimquadrature.hpp +++ b/ql/experimental/math/multidimquadrature.hpp @@ -60,7 +60,7 @@ namespace QuantLib { Integer i = order()-1; std::vector term = f(x_[i]);// potential copy! @#$%^!!! std::for_each(term.begin(), term.end(), - [&](Real x){ return x * w_[i]; }); + [&](Real x) -> Real { return x * w_[i]; }); std::vector sum = term; for (i--; i >= 0; --i) { @@ -68,7 +68,7 @@ namespace QuantLib { // sum[j] += term[j] * w_[i]; std::transform(term.begin(), term.end(), sum.begin(), sum.begin(), - [&](Real x, Real y){ return w_[i]*x + y; }); + [&](Real x, Real y) -> Real { return w_[i]*x + y; }); } return sum; } diff --git a/ql/legacy/libormarketmodels/lfmcovarproxy.cpp b/ql/legacy/libormarketmodels/lfmcovarproxy.cpp index d3b01af208a..1d573dc313e 100644 --- a/ql/legacy/libormarketmodels/lfmcovarproxy.cpp +++ b/ql/legacy/libormarketmodels/lfmcovarproxy.cpp @@ -51,7 +51,7 @@ namespace QuantLib { for (Size i=0; i Real { return x * vol[i]; }); } return pca; diff --git a/ql/methods/finitedifferences/meshers/concentrating1dmesher.cpp b/ql/methods/finitedifferences/meshers/concentrating1dmesher.cpp index e2730100166..dabc7782301 100644 --- a/ql/methods/finitedifferences/meshers/concentrating1dmesher.cpp +++ b/ql/methods/finitedifferences/meshers/concentrating1dmesher.cpp @@ -162,7 +162,7 @@ namespace QuantLib { OdeIntegrationFct fct(points, betas, tol); const Real a = Brent().solve( - [&](Real x) { return fct.solve(x, start, 0.0, 1.0) - end; }, + [&](Real x) -> Real { return fct.solve(x, start, 0.0, 1.0) - end; }, tol, aInit, 0.1*aInit); // solve ODE for all grid points @@ -192,7 +192,7 @@ namespace QuantLib { std::lower_bound(y.begin(), y.end(), points[i])); const Real e = Brent().solve( - [&](Real x){ return odeSolution(x, true) - points[i]; }, + [&](Real x) -> Real { return odeSolution(x, true) - points[i]; }, QL_EPSILON, x[j], 0.5/size); w.emplace_back(std::min(x[size - 2], x[j]), e); diff --git a/ql/methods/finitedifferences/utilities/gbsmrndcalculator.cpp b/ql/methods/finitedifferences/utilities/gbsmrndcalculator.cpp index 58383ee727d..d56504007f5 100644 --- a/ql/methods/finitedifferences/utilities/gbsmrndcalculator.cpp +++ b/ql/methods/finitedifferences/utilities/gbsmrndcalculator.cpp @@ -96,7 +96,7 @@ namespace QuantLib { << cdf(lower, t) << ", " << cdf(upper, t) << ")"); return Brent().solve( - [&](Real _k){ return cdf(_k, t) - q; }, + [&](Real _k) -> Real { return cdf(_k, t) - q; }, 1e-10, 0.5*(lower+upper), lower, upper); } } diff --git a/ql/methods/finitedifferences/utilities/riskneutraldensitycalculator.cpp b/ql/methods/finitedifferences/utilities/riskneutraldensitycalculator.cpp index c3816dca47a..7d426c16e48 100644 --- a/ql/methods/finitedifferences/utilities/riskneutraldensitycalculator.cpp +++ b/ql/methods/finitedifferences/utilities/riskneutraldensitycalculator.cpp @@ -36,7 +36,7 @@ namespace QuantLib { Real RiskNeutralDensityCalculator::InvCDFHelper::inverseCDF(Real p, Time t) const { Brent solver; solver.setMaxEvaluations(maxEvaluations_); - return solver.solve([&](Real _x){ return calculator_->cdf(_x, t) - p; }, + return solver.solve([&](Real _x) -> Real { return calculator_->cdf(_x, t) - p; }, accuracy_, guess_, stepSize_); } diff --git a/ql/models/volatility/garch.cpp b/ql/models/volatility/garch.cpp index b27fdbdd495..2acafba642a 100644 --- a/ql/models/volatility/garch.cpp +++ b/ql/models/volatility/garch.cpp @@ -71,7 +71,7 @@ namespace QuantLib { Real retval(0.0); Real sigma2 = 0; Real u2 = 0; - for (const auto r2 : r2_) { + for (const auto& r2 : r2_) { sigma2 = x[0] + x[1] * u2 + x[2] * sigma2; u2 = r2; retval += std::log(sigma2) + u2 / sigma2; @@ -84,7 +84,7 @@ namespace QuantLib { Real sigma2 = 0; Real u2 = 0; Size i = 0; - for (const auto r2 : r2_) { + for (const auto& r2 : r2_) { sigma2 = x[0] + x[1] * u2 + x[2] * sigma2; u2 = r2; retval[i++] = (std::log(sigma2) + u2 / sigma2)/(2.0*r2_.size()); @@ -99,7 +99,7 @@ namespace QuantLib { Real sigma2prev = sigma2; Real u2prev = u2; Real norm = 2.0 * r2_.size(); - for (const auto r2 : r2_) { + for (const auto& r2 : r2_) { sigma2 = x[0] + x[1] * u2 + x[2] * sigma2; u2 = r2; Real w = (sigma2 - u2) / (sigma2*sigma2); @@ -122,7 +122,7 @@ namespace QuantLib { Real sigma2prev = sigma2; Real u2prev = u2; Real norm = 2.0 * r2_.size(); - for (const auto r2 : r2_) { + for (const auto& r2 : r2_) { sigma2 = x[0] + x[1] * u2 + x[2] * sigma2; u2 = r2; retval += std::log(sigma2) + u2 / sigma2; diff --git a/ql/pricingengines/vanilla/qdplusamericanengine.cpp b/ql/pricingengines/vanilla/qdplusamericanengine.cpp index 2624174e93a..f505aa10bee 100644 --- a/ql/pricingengines/vanilla/qdplusamericanengine.cpp +++ b/ql/pricingengines/vanilla/qdplusamericanengine.cpp @@ -209,7 +209,7 @@ namespace QuantLib { vol*std::sqrt(T), std::exp(-r*T)).value()); if (close(vol, 0.0)) { - const auto intrinsic = [&](Real t) { + const auto intrinsic = [&](Real t) -> Real { return std::max(0.0, K*std::exp(-r*t)-S*std::exp(-q*t)); }; const Real npv0 = intrinsic(0.0); diff --git a/test-suite/distributions.cpp b/test-suite/distributions.cpp index 682d9cdbd2c..f0902fc7f38 100644 --- a/test-suite/distributions.cpp +++ b/test-suite/distributions.cpp @@ -263,7 +263,7 @@ void DistributionTest::testNormal() { MaddockInverseCumulativeNormal mInvCum(average, sigma); std::transform(x.begin(), x.end(), diff.begin(), - [&](Real x) { + [&](Real x) -> Real { return x - mInvCum(cum(x)); }); diff --git a/test-suite/hestonslvmodel.cpp b/test-suite/hestonslvmodel.cpp index 86d8d5fe1a3..52e5be83371 100644 --- a/test-suite/hestonslvmodel.cpp +++ b/test-suite/hestonslvmodel.cpp @@ -665,7 +665,7 @@ namespace { const AnalyticPDFHestonEngine pdfEngine(model); const Real sInit = model->process()->s0()->value(); const Real xMin = Brent().solve( - [&](Real x){ return pdfEngine.cdf(x, maturity) - eps; }, + [&](Real x) -> Real { return pdfEngine.cdf(x, maturity) - eps; }, sInit*1e-3, sInit, sInit*0.001, 1000*sInit); return xMin; diff --git a/test-suite/riskneutraldensitycalculator.cpp b/test-suite/riskneutraldensitycalculator.cpp index cc909d2e2a1..e664172cb78 100644 --- a/test-suite/riskneutraldensitycalculator.cpp +++ b/test-suite/riskneutraldensitycalculator.cpp @@ -737,7 +737,7 @@ void RiskNeutralDensityCalculatorTest::testMassAtZeroCEVProcessRND() { const Real ax = 15.0*std::sqrt(t)*alpha*std::pow(f0, beta); const Real calculated = GaussLobattoIntegral(1000, 1e-8)( - [&](Real _x) { return calculator->pdf(_x, t); }, std::max(QL_EPSILON, f0-ax), f0+ax) + + [&](Real _x) -> Real { return calculator->pdf(_x, t); }, std::max(QL_EPSILON, f0-ax), f0+ax) + calculator->massAtZero(t); if (std::fabs(calculated - 1.0) > tol) { diff --git a/test-suite/squarerootclvmodel.cpp b/test-suite/squarerootclvmodel.cpp index 52f3d19e24c..e4c167788f9 100644 --- a/test-suite/squarerootclvmodel.cpp +++ b/test-suite/squarerootclvmodel.cpp @@ -140,7 +140,7 @@ void SquareRootCLVModelTest::testSquareRootCLVVanillaPricing() { const CLVModelPayoff clvModelPayoff(optionType, strike, g); - const ext::function f = [&](Real xi) { + const ext::function f = [&](Real xi) -> Real { return clvModelPayoff(xi) * boost::math::pdf(dist, xi); }; @@ -238,7 +238,7 @@ void SquareRootCLVModelTest::testSquareRootCLVMappingFunction() { const CLVModelPayoff clvModelPayoff(optionType, strike, [&](Real x) { return g(t, x); }); - const ext::function f = [&](Real xi) { + const ext::function f = [&](Real xi) -> Real { return clvModelPayoff(xi) * boost::math::pdf(dist, xi); }; From 6a1706f6bdfc296d4b0f3fb2a8c8c5cd254de23d Mon Sep 17 00:00:00 2001 From: Xcelerit Dev Team Date: Sat, 1 Apr 2023 17:49:08 +0000 Subject: [PATCH 080/292] Revert "Fixes Size -> double conversion warnings with VC++ and higher warning level" This reverts commit a723850784d41b162c0a214c7b2ffb61bd321486. --- ql/experimental/catbonds/montecarlocatbondengine.cpp | 6 +++--- ql/experimental/credit/homogeneouspooldef.hpp | 2 +- ql/experimental/credit/inhomogeneouspooldef.hpp | 2 +- ql/experimental/exoticoptions/mchimalayaengine.cpp | 2 +- ql/experimental/exoticoptions/mcpagodaengine.cpp | 2 +- .../mcbasket/longstaffschwartzmultipathpricer.cpp | 6 +++--- ql/models/equity/hestonslvmcmodel.cpp | 2 +- .../evolvers/volprocesses/squarerootandersen.cpp | 2 +- .../marketmodels/pathwisegreeks/swaptionpseudojacobian.cpp | 2 +- ql/models/volatility/garch.cpp | 2 +- ql/pricingengines/asian/turnbullwakemanasianengine.cpp | 2 +- ql/pricingengines/vanilla/analyticptdhestonengine.cpp | 2 +- .../volatility/equityfx/andreasenhugevolatilityinterpl.cpp | 2 +- test-suite/catbonds.cpp | 4 ++-- test-suite/distributions.cpp | 2 +- test-suite/libormarketmodel.cpp | 2 +- test-suite/marketmodel.cpp | 2 +- 17 files changed, 22 insertions(+), 22 deletions(-) diff --git a/ql/experimental/catbonds/montecarlocatbondengine.cpp b/ql/experimental/catbonds/montecarlocatbondengine.cpp index 88bfc61574e..601eabc4582 100644 --- a/ql/experimental/catbonds/montecarlocatbondengine.cpp +++ b/ql/experimental/catbonds/montecarlocatbondengine.cpp @@ -109,9 +109,9 @@ namespace QuantLib { } pathCount++; } - lossProbability/=Real(pathCount); - exhaustionProbability/=Real(pathCount); - expectedLoss/=Real(pathCount); + lossProbability/=pathCount; + exhaustionProbability/=pathCount; + expectedLoss/=pathCount; return totalNPV/(pathCount*discountCurve_->discount(npvDate)); } diff --git a/ql/experimental/credit/homogeneouspooldef.hpp b/ql/experimental/credit/homogeneouspooldef.hpp index b5c3563a1e2..2eb6ab829ff 100644 --- a/ql/experimental/credit/homogeneouspooldef.hpp +++ b/ql/experimental/credit/homogeneouspooldef.hpp @@ -142,7 +142,7 @@ namespace QuantLib { detachAmount_); //notional_); std::vector mkft(1, min_ + delta_ /2.); - for (Real i = 0; i < nSteps_; i++) { + for (Size i = 0; i < nSteps_; i++) { std::vector conditionalProbs; for(Size iName=0; iName mkft(1, min_ + delta_ /2.); - for (Real i = 0; i < nSteps_; i++) { + for (Size i = 0; i < nSteps_; i++) { std::vector conditionalProbs; for(Size iName=0; iName(0.0, std::min(roof_, averagePerformance)); diff --git a/ql/experimental/mcbasket/longstaffschwartzmultipathpricer.cpp b/ql/experimental/mcbasket/longstaffschwartzmultipathpricer.cpp index 2caddd06f39..a44e0058027 100644 --- a/ql/experimental/mcbasket/longstaffschwartzmultipathpricer.cpp +++ b/ql/experimental/mcbasket/longstaffschwartzmultipathpricer.cpp @@ -256,9 +256,9 @@ namespace QuantLib { sumOptimized += lsExercise[j] ? exercise[j] : prices[j]; } - sumOptimized /= Real(n); - sumNoExercise /= Real(n); - sumAlwaysExercise /= Real(n); + sumOptimized /= n; + sumNoExercise /= n; + sumAlwaysExercise /= n; QL_TRACE( "Time index: " << i << ", LowerBound: " << lowerBounds_[i + 1] diff --git a/ql/models/equity/hestonslvmcmodel.cpp b/ql/models/equity/hestonslvmcmodel.cpp index b356569f039..ffd32f6557a 100644 --- a/ql/models/equity/hestonslvmcmodel.cpp +++ b/ql/models/equity/hestonslvmcmodel.cpp @@ -173,7 +173,7 @@ namespace QuantLib { for (Size j=s; j < e; ++j) { sum+=pairs[j].second; } - sum/=Real(inc); + sum/=inc; vStrikes[n]->at(i) = 0.5*(pairs[e-1].first + pairs[s].first); (*L)[i][n] = std::sqrt(squared(localVol_->localVol(t, vStrikes[n]->at(i), true))/sum); diff --git a/ql/models/marketmodels/evolvers/volprocesses/squarerootandersen.cpp b/ql/models/marketmodels/evolvers/volprocesses/squarerootandersen.cpp index 618dbb46dd8..9f4ce7a94ae 100644 --- a/ql/models/marketmodels/evolvers/volprocesses/squarerootandersen.cpp +++ b/ql/models/marketmodels/evolvers/volprocesses/squarerootandersen.cpp @@ -145,7 +145,7 @@ QuantLib for (Size k=0; k < numberSubSteps_; ++k) stepVariance += w1_*vPath_[k+lastStepStart]+w2_*vPath_[k+lastStepStart+1]; - stepVariance /= Real(numberSubSteps_); + stepVariance /= numberSubSteps_; return std::sqrt(stepVariance); } diff --git a/ql/models/marketmodels/pathwisegreeks/swaptionpseudojacobian.cpp b/ql/models/marketmodels/pathwisegreeks/swaptionpseudojacobian.cpp index 13ed706c44d..d16525ff637 100644 --- a/ql/models/marketmodels/pathwisegreeks/swaptionpseudojacobian.cpp +++ b/ql/models/marketmodels/pathwisegreeks/swaptionpseudojacobian.cpp @@ -291,7 +291,7 @@ namespace QuantLib } - guess/=Real(numberCaplets); + guess/=numberCaplets; for (Size step =0; step < inputModel->evolution().numberOfSteps(); ++step) diff --git a/ql/models/volatility/garch.cpp b/ql/models/volatility/garch.cpp index 2acafba642a..2c27b819e3b 100644 --- a/ql/models/volatility/garch.cpp +++ b/ql/models/volatility/garch.cpp @@ -338,7 +338,7 @@ namespace QuantLib { } } if (nn > 0) - gamma /= Real(nn); + gamma /= nn; if (gamma < gammaLower) gamma = gammaLower; beta = std::min(gamma, std::max(gamma * (1 - A) - B, 0.0)); omega = mean_r2 * (1 - gamma); diff --git a/ql/pricingengines/asian/turnbullwakemanasianengine.cpp b/ql/pricingengines/asian/turnbullwakemanasianengine.cpp index f0b78d76967..946425a4c8b 100644 --- a/ql/pricingengines/asian/turnbullwakemanasianengine.cpp +++ b/ql/pricingengines/asian/turnbullwakemanasianengine.cpp @@ -51,7 +51,7 @@ void TurnbullWakemanAsianEngine::calculate() const { // If the effective strike is negative, exercise resp. permanent OTM is guaranteed and the // valuation is made easy - Real m = Real(futureFixings + pastFixings); + Size m = futureFixings + pastFixings; if (effectiveStrike <= 0.0) { // For a reference, see "Option Pricing Formulas", Haug, 2nd ed, p. 193 if (payoff->optionType() == Option::Type::Call) { diff --git a/ql/pricingengines/vanilla/analyticptdhestonengine.cpp b/ql/pricingengines/vanilla/analyticptdhestonengine.cpp index 0144b75b1d8..eb3aeb5209f 100644 --- a/ql/pricingengines/vanilla/analyticptdhestonengine.cpp +++ b/ql/pricingengines/vanilla/analyticptdhestonengine.cpp @@ -293,7 +293,7 @@ namespace QuantLib { sigmaAvg += model_->sigma(t); rhoAvg += model_->rho(t); } - kappaAvg/=Real(n); thetaAvg/=Real(n); sigmaAvg/=Real(n); rhoAvg/=Real(n); + kappaAvg/=n; thetaAvg/=n; sigmaAvg/=n; rhoAvg/=n; evaluations_ = 0; diff --git a/ql/termstructures/volatility/equityfx/andreasenhugevolatilityinterpl.cpp b/ql/termstructures/volatility/equityfx/andreasenhugevolatilityinterpl.cpp index 5514c083392..21242a6ca72 100644 --- a/ql/termstructures/volatility/equityfx/andreasenhugevolatilityinterpl.cpp +++ b/ql/termstructures/volatility/equityfx/andreasenhugevolatilityinterpl.cpp @@ -447,7 +447,7 @@ namespace QuantLib { npvCalls= callCostFct->solveFor(dT_[i], sig, npvCalls); } - avgError_ /= Real(calibrationSet_.size()); + avgError_ /= calibrationSet_.size(); } Date AndreasenHugeVolatilityInterpl::maxDate() const { diff --git a/test-suite/catbonds.cpp b/test-suite/catbonds.cpp index fb03553a6aa..40e6764837b 100644 --- a/test-suite/catbonds.cpp +++ b/test-suite/catbonds.cpp @@ -162,8 +162,8 @@ void CatBondTest::testBetaRisk() { processValue += j.second; sum+=processValue; sumSquares+=processValue*processValue; - poissonSum+=Real(path.size()); - poissonSumSquares+=Real(path.size()*path.size()); + poissonSum+=path.size(); + poissonSumSquares+=path.size()*path.size(); } Real poissonMean = poissonSum/PATHS; QL_CHECK_CLOSE(Real(3.0/100.0), poissonMean, 2); diff --git a/test-suite/distributions.cpp b/test-suite/distributions.cpp index f0902fc7f38..f430955c421 100644 --- a/test-suite/distributions.cpp +++ b/test-suite/distributions.cpp @@ -618,7 +618,7 @@ void DistributionTest::testBivariateCumulativeStudentVsBivariate() { ++m; } } - avgDiff /= Real(m); + avgDiff /= m; if (avgDiff > 3.0e-6) BOOST_ERROR("Failed to reproduce average limit value:" << "\n rho: " << rho << diff --git a/test-suite/libormarketmodel.cpp b/test-suite/libormarketmodel.cpp index a4da60b8f00..4599de5c11b 100644 --- a/test-suite/libormarketmodel.cpp +++ b/test-suite/libormarketmodel.cpp @@ -172,7 +172,7 @@ void LiborMarketModelTest::testSimpleCovarianceModels() { for (Size k=0; k2*t) { + if (k>2*t) { const Real T = fixingTimes[k]; expected=(a*(T-t)+d)*std::exp(-b*(T-t)) + c; } diff --git a/test-suite/marketmodel.cpp b/test-suite/marketmodel.cpp index e98ff9f0f84..861e6e1404b 100644 --- a/test-suite/marketmodel.cpp +++ b/test-suite/marketmodel.cpp @@ -178,7 +178,7 @@ namespace market_model_test { todaysForwards[i] = 0.03 + 0.0010*i; meanForward+= todaysForwards[i]; } - meanForward /= Real(todaysForwards.size()); + meanForward /= todaysForwards.size(); From 4642500dfc2eee216c9d768b5dfbefd5ae80ccac Mon Sep 17 00:00:00 2001 From: Xcelerit Dev Team Date: Sat, 1 Apr 2023 18:28:04 +0000 Subject: [PATCH 081/292] Changes from reviews: no conversion for /=, nSteps should be Size --- ql/experimental/credit/homogeneouspooldef.hpp | 4 ++-- ql/experimental/credit/inhomogeneouspooldef.hpp | 4 ++-- ql/models/volatility/garch.cpp | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ql/experimental/credit/homogeneouspooldef.hpp b/ql/experimental/credit/homogeneouspooldef.hpp index 2eb6ab829ff..fe1ea97452a 100644 --- a/ql/experimental/credit/homogeneouspooldef.hpp +++ b/ql/experimental/credit/homogeneouspooldef.hpp @@ -51,7 +51,7 @@ namespace QuantLib { Size nBuckets, Real max = 5., Real min = -5., - Real nSteps = 50) + Size nSteps = 50) : copula_(copula), nBuckets_(nBuckets), max_(max), min_(min), nSteps_(nSteps), delta_((max - min)/nSteps) @@ -92,7 +92,7 @@ namespace QuantLib { // multifactor version const Real max_;// redundant? const Real min_; - const Real nSteps_; + const Size nSteps_; const Real delta_; }; // \todo Add other loss distribution statistics diff --git a/ql/experimental/credit/inhomogeneouspooldef.hpp b/ql/experimental/credit/inhomogeneouspooldef.hpp index d8e20e1ecc4..1b2a0e1e73e 100644 --- a/ql/experimental/credit/inhomogeneouspooldef.hpp +++ b/ql/experimental/credit/inhomogeneouspooldef.hpp @@ -58,7 +58,7 @@ namespace QuantLib { Size nBuckets, Real max = 5., Real min = -5., - Real nSteps = 50) + Size nSteps = 50) : copula_(copula), nBuckets_(nBuckets), max_(max), min_(min), nSteps_(nSteps), delta_((max - min)/nSteps) @@ -100,7 +100,7 @@ namespace QuantLib { // multifactor version const Real max_;// redundant? const Real min_; - const Real nSteps_; + const Size nSteps_; const Real delta_; }; // \todo Add other loss distribution statistics diff --git a/ql/models/volatility/garch.cpp b/ql/models/volatility/garch.cpp index 2c27b819e3b..4e3a493f3b5 100644 --- a/ql/models/volatility/garch.cpp +++ b/ql/models/volatility/garch.cpp @@ -71,7 +71,7 @@ namespace QuantLib { Real retval(0.0); Real sigma2 = 0; Real u2 = 0; - for (const auto& r2 : r2_) { + for (auto r2 : r2_) { sigma2 = x[0] + x[1] * u2 + x[2] * sigma2; u2 = r2; retval += std::log(sigma2) + u2 / sigma2; @@ -84,7 +84,7 @@ namespace QuantLib { Real sigma2 = 0; Real u2 = 0; Size i = 0; - for (const auto& r2 : r2_) { + for (auto r2 : r2_) { sigma2 = x[0] + x[1] * u2 + x[2] * sigma2; u2 = r2; retval[i++] = (std::log(sigma2) + u2 / sigma2)/(2.0*r2_.size()); @@ -99,7 +99,7 @@ namespace QuantLib { Real sigma2prev = sigma2; Real u2prev = u2; Real norm = 2.0 * r2_.size(); - for (const auto& r2 : r2_) { + for (auto r2 : r2_) { sigma2 = x[0] + x[1] * u2 + x[2] * sigma2; u2 = r2; Real w = (sigma2 - u2) / (sigma2*sigma2); @@ -122,7 +122,7 @@ namespace QuantLib { Real sigma2prev = sigma2; Real u2prev = u2; Real norm = 2.0 * r2_.size(); - for (const auto& r2 : r2_) { + for (auto r2 : r2_) { sigma2 = x[0] + x[1] * u2 + x[2] * sigma2; u2 = r2; retval += std::log(sigma2) + u2 / sigma2; From c2ac9965c4f7abb2fb5a58f000d1bad7e5102b63 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Mon, 3 Apr 2023 10:17:40 +0200 Subject: [PATCH 082/292] Deprecated both implementations of registerWithObservables --- ql/patterns/observable.hpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/ql/patterns/observable.hpp b/ql/patterns/observable.hpp index 1523307c533..a2241092dce 100644 --- a/ql/patterns/observable.hpp +++ b/ql/patterns/observable.hpp @@ -127,10 +127,11 @@ namespace QuantLib { itself. \deprecated This method was introduced to work around incorrect behaviour - caused by limiting notifications from LazyObject instances to the first - notification. The default behaviour of LazyObject was changed to forward - all notifications so that a call to this method should no longer be - necessary. + caused by limiting notifications from LazyObject instances to + the first notification. The default behaviour of LazyObject was + changed to forward all notifications so that a call to this + method should no longer be necessary. + Deprecated in version 1.30. */ QL_DEPRECATED void registerWithObservables(const ext::shared_ptr&); Size unregisterWith(const ext::shared_ptr&); @@ -301,8 +302,16 @@ namespace QuantLib { registerWith(const ext::shared_ptr&); /*! register with all observables of a given observer. Note that this does not include registering with the observer - itself. */ - void registerWithObservables(const ext::shared_ptr&); + itself. + + \deprecated This method was introduced to work around incorrect behaviour + caused by limiting notifications from LazyObject instances to + the first notification. The default behaviour of LazyObject was + changed to forward all notifications so that a call to this + method should no longer be necessary. + Deprecated in version 1.30. + */ + QL_DEPRECATED void registerWithObservables(const ext::shared_ptr&); Size unregisterWith(const ext::shared_ptr&); void unregisterWithAll(); From 74cb1dde1cfa21d9cd8d0760131cfa4102cd3637 Mon Sep 17 00:00:00 2001 From: Jonathan Sweemer Date: Thu, 30 Mar 2023 21:38:11 +0900 Subject: [PATCH 083/292] Add operators taking Matrix by rvalue reference --- ql/math/matrix.hpp | 108 +++++++++++++++++++++++++++++++++++++++- test-suite/array.cpp | 2 +- test-suite/matrices.cpp | 68 +++++++++++++++++++++++++ test-suite/matrices.hpp | 1 + 4 files changed, 177 insertions(+), 2 deletions(-) diff --git a/ql/math/matrix.hpp b/ql/math/matrix.hpp index fb080dead13..9e61e98c821 100644 --- a/ql/math/matrix.hpp +++ b/ql/math/matrix.hpp @@ -57,6 +57,7 @@ namespace QuantLib { Matrix(const Matrix&); Matrix(Matrix&&) noexcept; Matrix(std::initializer_list>); + ~Matrix() = default; Matrix& operator=(const Matrix&); Matrix& operator=(Matrix&&) noexcept; @@ -152,16 +153,35 @@ namespace QuantLib { /*! \relates Matrix */ Matrix operator+(const Matrix&, const Matrix&); /*! \relates Matrix */ + Matrix operator+(const Matrix&, Matrix&&); + /*! \relates Matrix */ + Matrix operator+(Matrix&&, const Matrix&); + /*! \relates Matrix */ + Matrix operator+(Matrix&&, Matrix&&); + /*! \relates Matrix */ Matrix operator-(const Matrix&); /*! \relates Matrix */ + Matrix operator-(Matrix&&); + /*! \relates Matrix */ Matrix operator-(const Matrix&, const Matrix&); /*! \relates Matrix */ + Matrix operator-(const Matrix&, Matrix&&); + /*! \relates Matrix */ + Matrix operator-(Matrix&&, const Matrix&); + /*! \relates Matrix */ + Matrix operator-(Matrix&&, Matrix&&); + /*! \relates Matrix */ Matrix operator*(const Matrix&, Real); /*! \relates Matrix */ + Matrix operator*(Matrix&&, Real); + /*! \relates Matrix */ Matrix operator*(Real, const Matrix&); /*! \relates Matrix */ + Matrix operator*(Real, Matrix&&); + /*! \relates Matrix */ Matrix operator/(const Matrix&, Real); - + /*! \relates Matrix */ + Matrix operator/(Matrix&&, Real); // vectorial products @@ -513,12 +533,50 @@ namespace QuantLib { return temp; } + inline Matrix operator+(const Matrix& m1, Matrix&& m2) { + QL_REQUIRE(m1.rows() == m2.rows() && + m1.columns() == m2.columns(), + "matrices with different sizes (" << + m1.rows() << "x" << m1.columns() << ", " << + m2.rows() << "x" << m2.columns() << ") cannot be " + "added"); + std::transform(m1.begin(), m1.end(), m2.begin(), m2.begin(), std::plus<>()); + return std::move(m2); + } + + inline Matrix operator+(Matrix&& m1, const Matrix& m2) { + QL_REQUIRE(m1.rows() == m2.rows() && + m1.columns() == m2.columns(), + "matrices with different sizes (" << + m1.rows() << "x" << m1.columns() << ", " << + m2.rows() << "x" << m2.columns() << ") cannot be " + "added"); + std::transform(m1.begin(), m1.end(), m2.begin(), m1.begin(), std::plus<>()); + return std::move(m1); + } + + inline Matrix operator+(Matrix&& m1, Matrix&& m2) { + QL_REQUIRE(m1.rows() == m2.rows() && + m1.columns() == m2.columns(), + "matrices with different sizes (" << + m1.rows() << "x" << m1.columns() << ", " << + m2.rows() << "x" << m2.columns() << ") cannot be " + "added"); + std::transform(m1.begin(), m1.end(), m2.begin(), m1.begin(), std::plus<>()); + return std::move(m1); + } + inline Matrix operator-(const Matrix& m1) { Matrix temp(m1.rows(), m1.columns()); std::transform(m1.begin(), m1.end(), temp.begin(), std::negate<>()); return temp; } + inline Matrix operator-(Matrix&& m1) { + std::transform(m1.begin(), m1.end(), m1.begin(), std::negate<>()); + return std::move(m1); + } + inline Matrix operator-(const Matrix& m1, const Matrix& m2) { QL_REQUIRE(m1.rows() == m2.rows() && m1.columns() == m2.columns(), @@ -531,24 +589,72 @@ namespace QuantLib { return temp; } + inline Matrix operator-(const Matrix& m1, Matrix&& m2) { + QL_REQUIRE(m1.rows() == m2.rows() && + m1.columns() == m2.columns(), + "matrices with different sizes (" << + m1.rows() << "x" << m1.columns() << ", " << + m2.rows() << "x" << m2.columns() << ") cannot be " + "subtracted"); + std::transform(m1.begin(), m1.end(), m2.begin(), m2.begin(), std::minus<>()); + return std::move(m2); + } + + inline Matrix operator-(Matrix&& m1, const Matrix& m2) { + QL_REQUIRE(m1.rows() == m2.rows() && + m1.columns() == m2.columns(), + "matrices with different sizes (" << + m1.rows() << "x" << m1.columns() << ", " << + m2.rows() << "x" << m2.columns() << ") cannot be " + "subtracted"); + std::transform(m1.begin(), m1.end(), m2.begin(), m1.begin(), std::minus<>()); + return std::move(m1); + } + + inline Matrix operator-(Matrix&& m1, Matrix&& m2) { + QL_REQUIRE(m1.rows() == m2.rows() && + m1.columns() == m2.columns(), + "matrices with different sizes (" << + m1.rows() << "x" << m1.columns() << ", " << + m2.rows() << "x" << m2.columns() << ") cannot be " + "subtracted"); + std::transform(m1.begin(), m1.end(), m2.begin(), m1.begin(), std::minus<>()); + return std::move(m1); + } + inline Matrix operator*(const Matrix& m, Real x) { Matrix temp(m.rows(),m.columns()); std::transform(m.begin(), m.end(), temp.begin(), [=](Real y) -> Real { return y * x; }); return temp; } + inline Matrix operator*(Matrix&& m, Real x) { + std::transform(m.begin(), m.end(), m.begin(), [=](Real y) -> Real { return y * x; }); + return std::move(m); + } + inline Matrix operator*(Real x, const Matrix& m) { Matrix temp(m.rows(),m.columns()); std::transform(m.begin(), m.end(), temp.begin(), [=](Real y) -> Real { return x * y; }); return temp; } + inline Matrix operator*(Real x, Matrix&& m) { + std::transform(m.begin(), m.end(), m.begin(), [=](Real y) -> Real { return x * y; }); + return std::move(m); + } + inline Matrix operator/(const Matrix& m, Real x) { Matrix temp(m.rows(),m.columns()); std::transform(m.begin(), m.end(), temp.begin(), [=](Real y) -> Real { return y / x; }); return temp; } + inline Matrix operator/(Matrix&& m, Real x) { + std::transform(m.begin(), m.end(), m.begin(), [=](Real y) -> Real { return y / x; }); + return std::move(m); + } + inline Array operator*(const Array& v, const Matrix& m) { QL_REQUIRE(v.size() == m.rows(), "vectors and matrices with different sizes (" diff --git a/test-suite/array.cpp b/test-suite/array.cpp index 04f3ad9c7b9..96c6b9e3529 100644 --- a/test-suite/array.cpp +++ b/test-suite/array.cpp @@ -322,7 +322,7 @@ void ArrayTest::testArrayOperators() { const auto real_rvalue_quotient = 1.1 / get_array(); QL_CHECK_CLOSE_ARRAY(lvalue_real_quotient, scalar_quotient_1); - QL_CHECK_CLOSE_ARRAY(lvalue_real_quotient, scalar_quotient_1); + QL_CHECK_CLOSE_ARRAY(rvalue_real_quotient, scalar_quotient_1); QL_CHECK_CLOSE_ARRAY(real_lvalue_quotient, scalar_quotient_2); QL_CHECK_CLOSE_ARRAY(real_rvalue_quotient, scalar_quotient_2); } diff --git a/test-suite/matrices.cpp b/test-suite/matrices.cpp index 001dcd23ef2..5e8260a0e0d 100644 --- a/test-suite/matrices.cpp +++ b/test-suite/matrices.cpp @@ -791,6 +791,73 @@ void MatricesTest::testSparseMatrixMemory() { } +#define QL_CHECK_CLOSE_MATRIX(actual, expected) \ + BOOST_REQUIRE(actual.rows() == expected.rows() && \ + actual.columns() == expected.columns()); \ + for (auto i = 0u; i < actual.rows(); i++) { \ + for (auto j = 0u; j < actual.columns(); j++) { \ + QL_CHECK_CLOSE(actual(i, j), expected(i, j), 100 * QL_EPSILON); \ + } \ + } \ + +void MatricesTest::testOperators() { + + BOOST_TEST_MESSAGE("Testing matrix operators..."); + + auto get_matrix = []() { + return Matrix(2, 3, 4.0); + }; + + const auto m = get_matrix(); + + const auto negative = Matrix(2, 3, -4.0); + const auto lvalue_negative = -m; + const auto rvalue_negative = -get_matrix(); + + QL_CHECK_CLOSE_MATRIX(lvalue_negative, negative); + QL_CHECK_CLOSE_MATRIX(rvalue_negative, negative); + + const auto matrix_sum = Matrix(2, 3, 8.0); + const auto lvalue_lvalue_sum = m + m; + const auto lvalue_rvalue_sum = m + get_matrix(); + const auto rvalue_lvalue_sum = get_matrix() + m; + const auto rvalue_rvalue_sum = get_matrix() + get_matrix(); + + QL_CHECK_CLOSE_MATRIX(lvalue_lvalue_sum, matrix_sum); + QL_CHECK_CLOSE_MATRIX(lvalue_rvalue_sum, matrix_sum); + QL_CHECK_CLOSE_MATRIX(rvalue_lvalue_sum, matrix_sum); + QL_CHECK_CLOSE_MATRIX(rvalue_rvalue_sum, matrix_sum); + + const auto matrix_difference = Matrix(2, 3, 0.0); + const auto lvalue_lvalue_difference = m - m; + const auto lvalue_rvalue_difference = m - get_matrix(); + const auto rvalue_lvalue_difference = get_matrix() - m; + const auto rvalue_rvalue_difference = get_matrix() - get_matrix(); + + QL_CHECK_CLOSE_MATRIX(lvalue_lvalue_difference, matrix_difference); + QL_CHECK_CLOSE_MATRIX(lvalue_rvalue_difference, matrix_difference); + QL_CHECK_CLOSE_MATRIX(rvalue_lvalue_difference, matrix_difference); + QL_CHECK_CLOSE_MATRIX(rvalue_rvalue_difference, matrix_difference); + + const auto scalar_product = Matrix(2, 3, 6.0); + const auto lvalue_real_product = m * 1.5; + const auto rvalue_real_product = get_matrix() * 1.5; + const auto real_lvalue_product = 1.5 * m; + const auto real_rvalue_product = 1.5 * get_matrix(); + + QL_CHECK_CLOSE_MATRIX(lvalue_real_product, scalar_product); + QL_CHECK_CLOSE_MATRIX(rvalue_real_product, scalar_product); + QL_CHECK_CLOSE_MATRIX(real_lvalue_product, scalar_product); + QL_CHECK_CLOSE_MATRIX(real_rvalue_product, scalar_product); + + const auto scalar_quotient = Matrix(2, 3, 2.0); + const auto lvalue_real_quotient = m / 2.0; + const auto rvalue_real_quotient = get_matrix() / 2.0; + + QL_CHECK_CLOSE_MATRIX(lvalue_real_quotient, scalar_quotient); + QL_CHECK_CLOSE_MATRIX(rvalue_real_quotient, scalar_quotient); +} + test_suite* MatricesTest::suite() { auto* suite = BOOST_TEST_SUITE("Matrix tests"); @@ -808,6 +875,7 @@ test_suite* MatricesTest::suite() { suite->add(QUANTLIB_TEST_CASE(&MatricesTest::testMoorePenroseInverse)); suite->add(QUANTLIB_TEST_CASE(&MatricesTest::testIterativeSolvers)); suite->add(QUANTLIB_TEST_CASE(&MatricesTest::testInitializers)); + suite->add(QUANTLIB_TEST_CASE(&MatricesTest::testOperators)); return suite; } diff --git a/test-suite/matrices.hpp b/test-suite/matrices.hpp index f1dc68bad61..16bf168003c 100644 --- a/test-suite/matrices.hpp +++ b/test-suite/matrices.hpp @@ -43,6 +43,7 @@ class MatricesTest { static void testIterativeSolvers(); static void testInitializers(); static void testSparseMatrixMemory(); + static void testOperators(); static boost::unit_test_framework::test_suite* suite(); }; From 3840448446991af44b729069f4d4e9fd16cb0013 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Wed, 5 Apr 2023 10:45:28 +0200 Subject: [PATCH 084/292] Add LazyObject configuration --- ql/patterns/lazyobject.hpp | 42 +++++++++++++++-- test-suite/lazyobject.cpp | 96 +++++++++++++++++++++++++++++++++----- test-suite/lazyobject.hpp | 2 + 3 files changed, 125 insertions(+), 15 deletions(-) diff --git a/ql/patterns/lazyobject.hpp b/ql/patterns/lazyobject.hpp index 2f6fd0ebd39..5225956ec22 100644 --- a/ql/patterns/lazyobject.hpp +++ b/ql/patterns/lazyobject.hpp @@ -34,7 +34,7 @@ namespace QuantLib { class LazyObject : public virtual Observable, public virtual Observer { public: - LazyObject() = default; + LazyObject(); ~LazyObject() override = default; //! \name Observer interface //@{ @@ -107,12 +107,48 @@ namespace QuantLib { */ virtual void performCalculations() const = 0; //@} - mutable bool calculated_ = false, frozen_ = false, alwaysForward_ = true; + mutable bool calculated_ = false, frozen_ = false, alwaysForward_; + }; + + //! Per-session settings for the LazyObject class + class LazyObjectSettings : public Singleton { + friend class Singleton; + private: + LazyObjectSettings() = default; + + public: + /*! by default, lazy objects created after calling this method + will only forward the first notification after successful + recalculation; see + LazyObject::forwardFirstNotificationOnly for details. + */ + void forwardFirstNotificationOnly() { + forwardsAllNotifications_ = false; + } + + /*! by default, lazy objects created after calling this method + will always forward notifications; see + LazyObject::alwaysForwardNotifications for details. + */ + void alwaysForwardNotifications() { + forwardsAllNotifications_ = true; + } + + //! returns the current default + bool forwardsAllNotifications() const { + return forwardsAllNotifications_; + } + + private: + bool forwardsAllNotifications_ = true; }; // inline definitions + inline LazyObject::LazyObject() + : alwaysForward_(LazyObjectSettings::instance().forwardsAllNotifications()) {} + inline void LazyObject::update() { // forwards notifications only the first time if (calculated_ || alwaysForward_) { @@ -128,7 +164,7 @@ namespace QuantLib { // already true because of non-lazy observers } } - + inline void LazyObject::recalculate() { bool wasFrozen = frozen_; calculated_ = frozen_ = false; diff --git a/test-suite/lazyobject.cpp b/test-suite/lazyobject.cpp index 10846a49cde..78d20fa85e1 100644 --- a/test-suite/lazyobject.cpp +++ b/test-suite/lazyobject.cpp @@ -26,10 +26,25 @@ using namespace QuantLib; using namespace boost::unit_test_framework; using ext::shared_ptr; +namespace lazy_object_test { + + class TearDown { + bool alwaysForward; + public: + TearDown() : alwaysForward(LazyObjectSettings::instance().forwardsAllNotifications()) {} + ~TearDown() { + if (alwaysForward) + LazyObjectSettings::instance().alwaysForwardNotifications(); + else + LazyObjectSettings::instance().forwardFirstNotificationOnly(); + } + }; + +} + void LazyObjectTest::testDiscardingNotifications() { - BOOST_TEST_MESSAGE( - "Testing that lazy objects discard notifications after the first (if requested)..."); + BOOST_TEST_MESSAGE("Testing that lazy objects can discard notifications after the first..."); ext::shared_ptr q(new SimpleQuote(0.0)); ext::shared_ptr s(new Stock(Handle(q))); @@ -43,7 +58,7 @@ void LazyObjectTest::testDiscardingNotifications() { q->setValue(1.0); if (!f.isUp()) BOOST_FAIL("Observer was not notified of change"); - + f.lower(); q->setValue(2.0); if (f.isUp()) @@ -57,22 +72,80 @@ void LazyObjectTest::testDiscardingNotifications() { } +void LazyObjectTest::testDiscardingNotificationsByDefault() { + + BOOST_TEST_MESSAGE("Testing that lazy objects can discard notifications after the first by default..."); + + lazy_object_test::TearDown teardown; + + LazyObjectSettings::instance().forwardFirstNotificationOnly(); + + ext::shared_ptr q(new SimpleQuote(0.0)); + ext::shared_ptr s(new Stock(Handle(q))); + + Flag f; + f.registerWith(s); + + s->NPV(); + q->setValue(1.0); + if (!f.isUp()) + BOOST_FAIL("Observer was not notified of change"); + + f.lower(); + q->setValue(2.0); + if (f.isUp()) + BOOST_FAIL("Observer was notified of second change"); + + f.lower(); + s->NPV(); + q->setValue(3.0); + if (!f.isUp()) + BOOST_FAIL("Observer was not notified of change after recalculation"); +} + + +void LazyObjectTest::testForwardingNotificationsByDefault() { + + BOOST_TEST_MESSAGE("Testing that lazy objects forward all notifications by default..."); + + ext::shared_ptr q(new SimpleQuote(0.0)); + ext::shared_ptr s(new Stock(Handle(q))); + + Flag f; + f.registerWith(s); + + s->NPV(); + q->setValue(1.0); + if (!f.isUp()) + BOOST_FAIL("Observer was not notified of change"); + + f.lower(); + q->setValue(2.0); + if (!f.isUp()) + BOOST_FAIL("Observer was not notified of second change"); +} + void LazyObjectTest::testForwardingNotifications() { - BOOST_TEST_MESSAGE( - "Testing that lazy objects forward all notifications (default behaviour)..."); + BOOST_TEST_MESSAGE("Testing that lazy objects can forward all notifications against default..."); + + lazy_object_test::TearDown teardown; + + LazyObjectSettings::instance().forwardFirstNotificationOnly(); ext::shared_ptr q(new SimpleQuote(0.0)); ext::shared_ptr s(new Stock(Handle(q))); Flag f; f.registerWith(s); - + + s->alwaysForwardNotifications(); + s->NPV(); q->setValue(1.0); if (!f.isUp()) BOOST_FAIL("Observer was not notified of change"); - + f.lower(); q->setValue(2.0); if (!f.isUp()) @@ -82,10 +155,9 @@ void LazyObjectTest::testForwardingNotifications() { test_suite* LazyObjectTest::suite() { auto* suite = BOOST_TEST_SUITE("LazyObject tests"); - suite->add( - QUANTLIB_TEST_CASE(&LazyObjectTest::testDiscardingNotifications)); - suite->add( - QUANTLIB_TEST_CASE(&LazyObjectTest::testForwardingNotifications)); + suite->add(QUANTLIB_TEST_CASE(&LazyObjectTest::testDiscardingNotifications)); + suite->add(QUANTLIB_TEST_CASE(&LazyObjectTest::testDiscardingNotificationsByDefault)); + suite->add(QUANTLIB_TEST_CASE(&LazyObjectTest::testForwardingNotificationsByDefault)); + suite->add(QUANTLIB_TEST_CASE(&LazyObjectTest::testForwardingNotifications)); return suite; } - diff --git a/test-suite/lazyobject.hpp b/test-suite/lazyobject.hpp index c156f4c924e..9d859930a60 100644 --- a/test-suite/lazyobject.hpp +++ b/test-suite/lazyobject.hpp @@ -28,6 +28,8 @@ class LazyObjectTest { public: static void testDiscardingNotifications(); + static void testDiscardingNotificationsByDefault(); + static void testForwardingNotificationsByDefault(); static void testForwardingNotifications(); static boost::unit_test_framework::test_suite* suite(); }; From 72b97c46e8f426d8e75068281ef7915adced8016 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Wed, 5 Apr 2023 12:36:15 +0200 Subject: [PATCH 085/292] Reorganize docs --- ql/patterns/lazyobject.hpp | 39 +++++++++++++++++++++++--------------- ql/patterns/observable.hpp | 36 +++++++++++++++++++---------------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/ql/patterns/lazyobject.hpp b/ql/patterns/lazyobject.hpp index 5225956ec22..6d715cbdbb4 100644 --- a/ql/patterns/lazyobject.hpp +++ b/ql/patterns/lazyobject.hpp @@ -68,21 +68,6 @@ namespace QuantLib { method, thus re-enabling recalculations. */ void unfreeze(); - /*! This method causes the object to forward the first notification received, - and discard the others until recalculated; the rationale is that observers - were already notified, and don't need further notifications until they - recalculate, at which point this object would be recalculated too. - After recalculation, this object would again forward the first notification - received. - - The behaviour is not always correct though and should only be enabled in - appropriate configurations. - */ - void forwardFirstNotificationOnly(); - - /*! Restore the default behaviour after a call to forwardFirstNotificationOnly(), - see above. */ - void alwaysForwardNotifications(); protected: /*! This method performs all needed calculations by calling @@ -107,6 +92,30 @@ namespace QuantLib { */ virtual void performCalculations() const = 0; //@} + + public: + //! \name Notification settings + //@{ + /*! This method causes the object to forward the first notification received, + and discard the others until recalculated; the rationale is that observers + were already notified, and don't need further notifications until they + recalculate, at which point this object would be recalculated too. + After recalculation, this object would again forward the first notification + received. + + The behaviour is not always correct though and should only be enabled in + appropriate configurations. In if doubt, do not use it. + */ + void forwardFirstNotificationOnly(); + + /*! This method causes the object to forward all notifications received. + The behaviour is already the default, unless changed by calling + LazyObjectSettings::forwardFirstNotificationOnly(). + */ + void alwaysForwardNotifications(); + //@} + + protected: mutable bool calculated_ = false, frozen_ = false, alwaysForward_; }; diff --git a/ql/patterns/observable.hpp b/ql/patterns/observable.hpp index a2241092dce..e2dcc18ccf4 100644 --- a/ql/patterns/observable.hpp +++ b/ql/patterns/observable.hpp @@ -126,14 +126,16 @@ namespace QuantLib { that this does not include registering with the observer itself. - \deprecated This method was introduced to work around incorrect behaviour + \deprecated This method was introduced to work around incorrect behaviour caused by limiting notifications from LazyObject instances to - the first notification. The default behaviour of LazyObject was - changed to forward all notifications so that a call to this - method should no longer be necessary. - Deprecated in version 1.30. + the first notification. The default behaviour of LazyObject was + changed to forward all notifications so that a call to this + method should no longer be necessary. + Deprecated in version 1.30. */ - QL_DEPRECATED void registerWithObservables(const ext::shared_ptr&); + [[deprecated("no longer necessary")]] + void registerWithObservables(const ext::shared_ptr&); + Size unregisterWith(const ext::shared_ptr&); void unregisterWithAll(); @@ -304,14 +306,16 @@ namespace QuantLib { that this does not include registering with the observer itself. - \deprecated This method was introduced to work around incorrect behaviour + \deprecated This method was introduced to work around incorrect behaviour caused by limiting notifications from LazyObject instances to - the first notification. The default behaviour of LazyObject was - changed to forward all notifications so that a call to this - method should no longer be necessary. - Deprecated in version 1.30. - */ - QL_DEPRECATED void registerWithObservables(const ext::shared_ptr&); + the first notification. The default behaviour of LazyObject was + changed to forward all notifications so that a call to this + method should no longer be necessary. + Deprecated in version 1.30. + */ + [[deprecated("no longer necessary")]] + void registerWithObservables(const ext::shared_ptr&); + Size unregisterWith(const ext::shared_ptr&); void unregisterWithAll(); @@ -377,9 +381,9 @@ namespace QuantLib { QL_DEPRECATED_ENABLE_WARNING }; - namespace detail { - class Signal; - } + namespace detail { + class Signal; + } //! Object that notifies its changes to a set of observers /*! \ingroup patterns */ From e99427b572344cf5df763bcddb6bf77538c1f54c Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Wed, 5 Apr 2023 12:51:49 +0200 Subject: [PATCH 086/292] Some changes in docs --- ql/instruments/forwardrateagreement.hpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ql/instruments/forwardrateagreement.hpp b/ql/instruments/forwardrateagreement.hpp index 73b59c47ae7..1a8e29180d2 100644 --- a/ql/instruments/forwardrateagreement.hpp +++ b/ql/instruments/forwardrateagreement.hpp @@ -65,11 +65,8 @@ namespace QuantLib { */ class ForwardRateAgreement: public Instrument { public: - /*! \deprecated use the new constructors - the second one without the maturityDate - or the third one without the index and - with the term structure handle - deprecated in version 1.30 + /*! \deprecated Use one of the other constructors. + Deprecated in version 1.30. */ QL_DEPRECATED ForwardRateAgreement( @@ -81,6 +78,10 @@ namespace QuantLib { const ext::shared_ptr& index, Handle discountCurve = Handle(), bool useIndexedCoupon = true); + + /*! When using this constructor, the forward rate will be + forecast from the passed index. + */ ForwardRateAgreement( const Date& valueDate, Position::Type type, @@ -90,12 +91,11 @@ namespace QuantLib { Handle discountCurve = Handle(), bool useIndexedCoupon = true); - /*! \brief constructor not taking the index - \details constructor not taking the index, Handle must be provided - with calendar, dayCounter, Compounding and Frequency - the FRA evaluationDate must be specified in Settings::instance().evaluationDate() - the number of fixingDays must be specified for the fixingDate calculation - as well as the businessDayConvention + /*! When using this constructor, the forward rate will be + forecast directly from the passed term structure. Lacking + an index, we need to pass the number of fixing days and + the business day convention explicitly to calculate the + relevant dates. */ ForwardRateAgreement( const Date& valueDate, From 2f0703e544a2ece7e9c36d7793278a574c7e84c1 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Fri, 7 Apr 2023 13:08:29 +0200 Subject: [PATCH 087/292] Fix for workflows creating pull requests. The existing branch name started causing the PR creation to fail. Simplifying it seems to fix the problem. --- .github/workflows/copyrights.yml | 2 +- .github/workflows/generated-headers.yml | 2 +- .github/workflows/misspell.yml | 2 +- .github/workflows/tidy.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/copyrights.yml b/.github/workflows/copyrights.yml index 758d57d8a84..c11ac31d778 100644 --- a/.github/workflows/copyrights.yml +++ b/.github/workflows/copyrights.yml @@ -14,7 +14,7 @@ jobs: - uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - branch: update-copyright-list-${{ github.ref }} + branch: update-copyright-list-${{ github.ref_name }} delete-branch: true commit-message: 'Update copyright list in license' title: 'Update copyright list in license' diff --git a/.github/workflows/generated-headers.yml b/.github/workflows/generated-headers.yml index 98792e4296b..ba38325be83 100644 --- a/.github/workflows/generated-headers.yml +++ b/.github/workflows/generated-headers.yml @@ -24,7 +24,7 @@ jobs: - uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - branch: update-generated-headers-${{ github.ref }} + branch: update-generated-headers-${{ github.ref_name }} delete-branch: true commit-message: 'Update generated headers' title: 'Update generated headers' diff --git a/.github/workflows/misspell.yml b/.github/workflows/misspell.yml index 8168bad0e29..7384ad45a21 100644 --- a/.github/workflows/misspell.yml +++ b/.github/workflows/misspell.yml @@ -12,7 +12,7 @@ jobs: - uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - branch: misspell-fixes-${{ github.ref }} + branch: misspell-fixes-${{ github.ref_name }} delete-branch: true commit-message: 'Fixes by misspell-fixer' title: 'Typos fixed by misspell-fixer' diff --git a/.github/workflows/tidy.yml b/.github/workflows/tidy.yml index c67c456ee19..50c79bce345 100644 --- a/.github/workflows/tidy.yml +++ b/.github/workflows/tidy.yml @@ -19,7 +19,7 @@ jobs: - uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - branch: clang-tidy-fixes-${{ github.ref }} + branch: clang-tidy-fixes-${{ github.ref_name }} delete-branch: true commit-message: 'Automated fixes by clang-tidy' title: 'Automated fixes by clang-tidy' From 9252763b32708b4fd35ea864a4c854c28df2030e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 11:56:37 +0000 Subject: [PATCH 088/292] Bump peter-evans/create-pull-request from 4 to 5 Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 4 to 5. - [Release notes](https://github.com/peter-evans/create-pull-request/releases) - [Commits](https://github.com/peter-evans/create-pull-request/compare/v4...v5) --- updated-dependencies: - dependency-name: peter-evans/create-pull-request dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/copyrights.yml | 2 +- .github/workflows/generated-headers.yml | 2 +- .github/workflows/misspell.yml | 2 +- .github/workflows/tidy.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/copyrights.yml b/.github/workflows/copyrights.yml index c11ac31d778..6c8b4b94069 100644 --- a/.github/workflows/copyrights.yml +++ b/.github/workflows/copyrights.yml @@ -11,7 +11,7 @@ jobs: - name: Check run: | ./tools/check_copyrights.sh - - uses: peter-evans/create-pull-request@v4 + - uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} branch: update-copyright-list-${{ github.ref_name }} diff --git a/.github/workflows/generated-headers.yml b/.github/workflows/generated-headers.yml index ba38325be83..b078946af70 100644 --- a/.github/workflows/generated-headers.yml +++ b/.github/workflows/generated-headers.yml @@ -21,7 +21,7 @@ jobs: find ql -name *.am | xargs touch make dist rm QuantLib-*.tar.gz - - uses: peter-evans/create-pull-request@v4 + - uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} branch: update-generated-headers-${{ github.ref_name }} diff --git a/.github/workflows/misspell.yml b/.github/workflows/misspell.yml index 7384ad45a21..45e3f4d3f18 100644 --- a/.github/workflows/misspell.yml +++ b/.github/workflows/misspell.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v3 - uses: sobolevn/misspell-fixer-action@master - - uses: peter-evans/create-pull-request@v4 + - uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} branch: misspell-fixes-${{ github.ref_name }} diff --git a/.github/workflows/tidy.yml b/.github/workflows/tidy.yml index 50c79bce345..0eff1e09b8c 100644 --- a/.github/workflows/tidy.yml +++ b/.github/workflows/tidy.yml @@ -16,7 +16,7 @@ jobs: run: | cmake --preset linux-ci-build-with-clang-tidy cmake --build --preset linux-ci-build-with-clang-tidy -j1 - - uses: peter-evans/create-pull-request@v4 + - uses: peter-evans/create-pull-request@v5 with: token: ${{ secrets.GITHUB_TOKEN }} branch: clang-tidy-fixes-${{ github.ref_name }} From 8153cd9fb51f5bcbf44819725bfe06452e102bb5 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Tue, 11 Apr 2023 13:24:55 +0200 Subject: [PATCH 089/292] Update docs for library configuration --- Docs/pages/config.docs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Docs/pages/config.docs b/Docs/pages/config.docs index cf1b19ee73a..bfd1e24df02 100644 --- a/Docs/pages/config.docs +++ b/Docs/pages/config.docs @@ -121,6 +121,20 @@ are used instead of `boost::tuple`. If disabled (the default) the Boost facilities are used. + \code + #define QL_USE_STD_ANY + \endcode + If enabled, `std::any` and related classes and functions will be + used instead of `boost::any`. This requires C++17. If disabled + (the default) the Boost facilities are used. + + \code + #define QL_USE_STD_OPTIONAL + \endcode + If enabled, `std::optional` and related classes and functions will + be used instead of `boost::optional`. This requires C++17. If + disabled (the default) the Boost facilities are used. + \code #define QL_NULL_AS_FUNCTIONS \endcode From f4b14465e0dd542536a8858a4952c522690a8bc4 Mon Sep 17 00:00:00 2001 From: Jonathan Sweemer Date: Mon, 20 Feb 2023 21:56:12 +0900 Subject: [PATCH 090/292] Pass dim by value to FdmLinearOpLayout and move --- ql/experimental/volatility/zabr.cpp | 9 +++++++++ .../finitedifferences/meshers/fdmmeshercomposite.cpp | 2 +- .../finitedifferences/operators/fdmlinearoplayout.hpp | 8 ++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ql/experimental/volatility/zabr.cpp b/ql/experimental/volatility/zabr.cpp index f5e87a8d797..8c6fa39e4ba 100644 --- a/ql/experimental/volatility/zabr.cpp +++ b/ql/experimental/volatility/zabr.cpp @@ -130,11 +130,20 @@ std::vector ZabrModel::fdPrice(const std::vector &strikes) const { (Size)std::ceil(expiryTime_ * 24); // number of steps in dimension t const Size dampingSteps = 5; // thereof damping steps +#if defined(__GNUC__) && (__GNUC__ >= 12) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif + // Layout std::vector dim(1, size); const ext::shared_ptr layout( new FdmLinearOpLayout(dim)); +#if defined(__GNUC__) && (__GNUC__ >= 12) +#pragma GCC diagnostic pop +#endif + // Mesher const ext::shared_ptr m1(new Concentrating1dMesher( start, end, size, std::pair(forward_, density), true)); diff --git a/ql/methods/finitedifferences/meshers/fdmmeshercomposite.cpp b/ql/methods/finitedifferences/meshers/fdmmeshercomposite.cpp index 96dc0582e4d..d73a440bf34 100644 --- a/ql/methods/finitedifferences/meshers/fdmmeshercomposite.cpp +++ b/ql/methods/finitedifferences/meshers/fdmmeshercomposite.cpp @@ -33,7 +33,7 @@ namespace QuantLib { for (Size i=0; i < dim.size(); ++i) { dim[i] = meshers[i]->size(); } - return ext::make_shared(dim); + return ext::make_shared(std::move(dim)); } } diff --git a/ql/methods/finitedifferences/operators/fdmlinearoplayout.hpp b/ql/methods/finitedifferences/operators/fdmlinearoplayout.hpp index 1188df2105e..fd39fc38be2 100644 --- a/ql/methods/finitedifferences/operators/fdmlinearoplayout.hpp +++ b/ql/methods/finitedifferences/operators/fdmlinearoplayout.hpp @@ -33,13 +33,13 @@ namespace QuantLib { class FdmLinearOpLayout { public: - explicit FdmLinearOpLayout(const std::vector& dim) - : dim_(dim), spacing_(dim.size()) { + explicit FdmLinearOpLayout(std::vector dim) + : dim_(std::move(dim)), spacing_(dim_.size()) { spacing_[0] = 1; - std::partial_sum(dim.begin(), dim.end()-1, + std::partial_sum(dim_.begin(), dim_.end()-1, spacing_.begin()+1, std::multiplies<>()); - size_ = spacing_.back()*dim.back(); + size_ = spacing_.back()*dim_.back(); } FdmLinearOpIterator begin() const { From d8f602c27b45b677a38ef2c7b7cb6b0c0a4fe5e7 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Tue, 11 Apr 2023 15:15:33 +0200 Subject: [PATCH 091/292] Convert a few non-unicode characters in comments --- ql/currencies/africa.cpp | 4 +--- ql/currencies/africa.hpp | 3 ++- ql/currencies/europe.cpp | 8 ++++---- .../swaptions/haganirregularswaptionengine.cpp | 2 +- .../swaptions/haganirregularswaptionengine.hpp | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ql/currencies/africa.cpp b/ql/currencies/africa.cpp index 0b5e6aa5c08..cf0ab088953 100644 --- a/ql/currencies/africa.cpp +++ b/ql/currencies/africa.cpp @@ -108,9 +108,6 @@ namespace QuantLib { } // South-African rand - /* The ISO three-letter code is ZAR; the numeric code is 710. - It is divided into 100 cents. - */ ZARCurrency::ZARCurrency() { static ext::shared_ptr zarData( new Data("South-African rand", "ZAR", 710, "R", "", 100, Rounding(), "%3% %1$.2f")); @@ -123,4 +120,5 @@ namespace QuantLib { new Data("Zambian kwacha", "ZMW", 967, "ZMW", "", 100, Rounding(), "1$.2f %3%")); data_ = zmwData; } + } diff --git a/ql/currencies/africa.hpp b/ql/currencies/africa.hpp index 365700e1b2f..2f07b9da341 100644 --- a/ql/currencies/africa.hpp +++ b/ql/currencies/africa.hpp @@ -39,7 +39,7 @@ namespace QuantLib { // Angolan kwanza /*! The ISO three-letter code is AOA; the numeric code is 973. - It is divided into 100 cêntimo. + It is divided into 100 cêntimo. \ingroup currencies */ class AOACurrency : public Currency { @@ -177,6 +177,7 @@ namespace QuantLib { public: ZMWCurrency(); }; + } #if defined(QL_PATCH_MSVC) diff --git a/ql/currencies/europe.cpp b/ql/currencies/europe.cpp index 8f157858276..f83c990a5ae 100644 --- a/ql/currencies/europe.cpp +++ b/ql/currencies/europe.cpp @@ -94,7 +94,7 @@ namespace QuantLib { // Danish krone /* The ISO three-letter code is DKK; the numeric code is 208. - It is divided in 100 øre. + It is divided in 100 øre. */ DKKCurrency::DKKCurrency() { static ext::shared_ptr dkkData( @@ -198,7 +198,7 @@ namespace QuantLib { // Norwegian krone /* The ISO three-letter code is NOK; the numeric code is 578. - It is divided in 100 øre. + It is divided in 100 øre. */ NOKCurrency::NOKCurrency() { static ext::shared_ptr nokData( @@ -265,7 +265,7 @@ namespace QuantLib { // Swedish krona /* The ISO three-letter code is SEK; the numeric code is 752. - It is divided in 100 öre. + It is divided in 100 öre. */ SEKCurrency::SEKCurrency() { static ext::shared_ptr sekData( @@ -376,7 +376,7 @@ namespace QuantLib { // Finnish markka /* The ISO three-letter code was FIM; the numeric code was 246. - It was divided in 100 penniä. + It was divided in 100 penniä. */ FIMCurrency::FIMCurrency() { static ext::shared_ptr fimData( diff --git a/ql/experimental/swaptions/haganirregularswaptionengine.cpp b/ql/experimental/swaptions/haganirregularswaptionengine.cpp index c317494b43d..d3e5182817e 100644 --- a/ql/experimental/swaptions/haganirregularswaptionengine.cpp +++ b/ql/experimental/swaptions/haganirregularswaptionengine.cpp @@ -349,7 +349,7 @@ namespace QuantLib { ///////////////////////////////////////////////////////////////////////////////////////// // Computes irregular swaption price according to P.J. Hunt, J.E. Kennedy: // - // "Implied interest rate pricing models", Finance Stochast. 2, 275–293 (1998) // + // "Implied interest rate pricing models", Finance Stochast. 2, 275-293 (1998) // ///////////////////////////////////////////////////////////////////////////////////////// Real HaganIrregularSwaptionEngine::HKPrice(Basket& basket,ext::shared_ptr& exercise) const { diff --git a/ql/experimental/swaptions/haganirregularswaptionengine.hpp b/ql/experimental/swaptions/haganirregularswaptionengine.hpp index 632fdd58ff8..7112e9c51f0 100644 --- a/ql/experimental/swaptions/haganirregularswaptionengine.hpp +++ b/ql/experimental/swaptions/haganirregularswaptionengine.hpp @@ -39,7 +39,7 @@ namespace QuantLib { 1. P.S. Hagan: "Methodology for Callable Swaps and Bermudan 'Exercise into Swaptions'" 2. P.J. Hunt, J.E. Kennedy: "Implied interest rate pricing - models", Finance Stochast. 2, 275–293 (1998) + models", Finance Stochast. 2, 275-293 (1998) \warning Currently a spread is not handled correctly; it should be a minor exercise to account for this From d9caed0bcefd9b360e9f006a90c975b2caf49a75 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Tue, 11 Apr 2023 15:17:42 +0200 Subject: [PATCH 092/292] Convert tool to Python 3 syntax --- tools/check_inclusions.py | 61 +++++++++++++++++++++------------------ 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/tools/check_inclusions.py b/tools/check_inclusions.py index 1943f851643..4c18b7cdfce 100755 --- a/tools/check_inclusions.py +++ b/tools/check_inclusions.py @@ -1,15 +1,15 @@ -#!/usr/bin/python +#!/usr/bin/python3 import sys, re if len(sys.argv) != 2: - print 'Usage: %s ' % sys.argv[0] + print(f"Usage: {sys.argv[0]} ") sys.exit() filename = sys.argv[1] -print 'Checking %s' % filename +print(f"Checking {filename}") -regex = re.compile('^#include.*<(.*)>') +regex = re.compile("^#include.*<(.*)>") ql_headers = [] boost_headers = [] std_headers = [] @@ -18,54 +18,59 @@ for n, line in enumerate(source): match = regex.search(line) if match: - header, = match.groups() - line_num = n+1 - if header.startswith('ql/'): - ql_headers.append((header,line_num)) - if header.startswith('ql/experimental') and 'internal' not in line: - experimental_headers.append((header,line_num)) - elif header.startswith('boost/'): - boost_headers.append((header,line_num)) + (header,) = match.groups() + line_num = n + 1 + if header.startswith("ql/"): + ql_headers.append((header, line_num)) + if header.startswith("ql/experimental") and "internal" not in line: + experimental_headers.append((header, line_num)) + elif header.startswith("boost/"): + boost_headers.append((header, line_num)) else: - std_headers.append((header,line_num)) + std_headers.append((header, line_num)) source.close() # At least one QuantLib header muct be included (which, hopefully, # ultimately leads to including ql/qldefines.hpp) if not ql_headers: - print "./%s:1: error: no QuantLib header included" % filename + print(f"./{filename}:1: error: no QuantLib header included") sys.exit(1) -if 'ql/experimental' not in filename: +if "ql/experimental" not in filename: # files in core library can't include stuff in experimental if experimental_headers: - for f,n in experimental_headers: - print "./%s:%d: error: experimental header '%s' included" % (filename, n, f) + for f, n in experimental_headers: + print(f"./{filename}:{n}: error: experimental header '{f}' included") sys.exit(1) -for f,n in ql_headers: - if f.endswith('/all.hpp'): - print "./%s:%d: error: generated header '%s' included" % (filename, n, f) +for f, n in ql_headers: + if f.endswith("/all.hpp"): + print(f"./{filename}:{n}: error: generated header '{f}' included") sys.exit(1) # All Boost headers must be included after QuantLib ones -last_ql_header = max([ n for _,n in ql_headers]) +last_ql_header = max([n for _, n in ql_headers]) -for _,n in boost_headers: +for _, n in boost_headers: if n < last_ql_header: - print "./%s:%d: error: Boost header included before last QuantLib header" % (filename, n) + print( + f"./{filename}:{n}: error: Boost header included before last QuantLib header" + ) sys.exit(1) # All standard headers must be included after QuantLib and Boost ones if boost_headers: - last_boost_header = max([ n for _,n in boost_headers]) + last_boost_header = max([n for _, n in boost_headers]) -for _,n in std_headers: +for _, n in std_headers: if n < last_ql_header: - print "./%s:%d: error: standard header included before last QuantLib header" % (filename, n) + print( + f"./{filename}:{n}: error: standard header included before last QuantLib header" + ) sys.exit(1) if boost_headers and n < last_boost_header: - print "./%s:%d: error: standard header included before last Boost header" % (filename, n) + print( + f"./{filename}:{n}: error: standard header included before last Boost header" + ) sys.exit(1) - From 7adec475e255d360beb2dc1409d2f1983cf83266 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Tue, 11 Apr 2023 15:38:12 +0200 Subject: [PATCH 093/292] Fix a few test messages --- test-suite/equityindex.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test-suite/equityindex.cpp b/test-suite/equityindex.cpp index a40ceeb8a35..7e0fc9b2578 100644 --- a/test-suite/equityindex.cpp +++ b/test-suite/equityindex.cpp @@ -88,7 +88,7 @@ namespace equityindex_test { } void EquityIndexTest::testTodaysFixing() { - BOOST_TEST_MESSAGE("Testing todays fixing..."); + BOOST_TEST_MESSAGE("Testing today's fixing..."); using namespace equityindex_test; @@ -113,7 +113,7 @@ void EquityIndexTest::testTodaysFixing() { } void EquityIndexTest::testTodaysFixingWithSpotAsProxy() { - BOOST_TEST_MESSAGE("Testing todays fixing with spot as proxy..."); + BOOST_TEST_MESSAGE("Testing today's fixing with spot as proxy..."); using namespace equityindex_test; @@ -304,7 +304,7 @@ void EquityIndexTest::testFixingObservability() { } void EquityIndexTest::testNoErrorIfTodayIsNotBusinessDay() { - BOOST_TEST_MESSAGE("Testing no error if today is not a business day..."); + BOOST_TEST_MESSAGE("Testing that no error is thrown if today is not a business day..."); using namespace equityindex_test; From 8ac7f751df6c7304ccf4faef5b0ca555c6bd48a2 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Tue, 11 Apr 2023 16:15:34 +0200 Subject: [PATCH 094/292] Disable a few false positives from clang-tidy --- test-suite/array.cpp | 4 ++-- test-suite/matrices.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test-suite/array.cpp b/test-suite/array.cpp index 96c6b9e3529..33cc2abe197 100644 --- a/test-suite/array.cpp +++ b/test-suite/array.cpp @@ -259,7 +259,7 @@ void ArrayTest::testArrayOperators() { QL_CHECK_CLOSE_ARRAY(real_rvalue_sum, scalar_sum); const auto array_difference = Array{0.0, 0.0, 0.0}; - const auto lvalue_lvalue_difference = a - a; + const auto lvalue_lvalue_difference = a - a; // NOLINT(misc-redundant-expression) const auto lvalue_rvalue_difference = a - get_array(); const auto rvalue_lvalue_difference = get_array() - a; const auto rvalue_rvalue_difference = get_array() - get_array(); @@ -304,7 +304,7 @@ void ArrayTest::testArrayOperators() { QL_CHECK_CLOSE_ARRAY(real_rvalue_product, scalar_product); const auto array_quotient = Array{1.0, 1.0, 1.0}; - const auto lvalue_lvalue_quotient = a / a; + const auto lvalue_lvalue_quotient = a / a; // NOLINT(misc-redundant-expression) const auto lvalue_rvalue_quotient = a / get_array(); const auto rvalue_lvalue_quotient = get_array() / a; const auto rvalue_rvalue_quotient = get_array() / get_array(); diff --git a/test-suite/matrices.cpp b/test-suite/matrices.cpp index 5e8260a0e0d..f61806523d9 100644 --- a/test-suite/matrices.cpp +++ b/test-suite/matrices.cpp @@ -829,7 +829,7 @@ void MatricesTest::testOperators() { QL_CHECK_CLOSE_MATRIX(rvalue_rvalue_sum, matrix_sum); const auto matrix_difference = Matrix(2, 3, 0.0); - const auto lvalue_lvalue_difference = m - m; + const auto lvalue_lvalue_difference = m - m; // NOLINT(misc-redundant-expression) const auto lvalue_rvalue_difference = m - get_matrix(); const auto rvalue_lvalue_difference = get_matrix() - m; const auto rvalue_rvalue_difference = get_matrix() - get_matrix(); From 77cb89eff775bf4687496426e43785ded03057a6 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Wed, 12 Apr 2023 12:11:53 +0200 Subject: [PATCH 095/292] Update news and contributors --- ChangeLog.txt | 4042 +++++++++++++++++---------------------- Contributors.txt | 2 + Docs/pages/history.docs | 109 +- News.md | 198 +- 4 files changed, 1949 insertions(+), 2402 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index d1832a6e3cf..d042238bf30 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,279 +1,240 @@ -commit 051afbcd73dd8b11165449b1f905e4c964e74aec +commit 8ac7f751df6c7304ccf4faef5b0ca555c6bd48a2 Author: Luigi Ballabio -Date: Mon, 12 Jul 2021 09:46:54 +0200 +Date: Tue, 11 Apr 2023 16:15:34 +0200 - Set version to 1.29 final. + Disable a few false positives from clang-tidy - CMakeLists.txt | 4 ++-- - configure.ac | 2 +- - ql/version.hpp | 4 ++-- - 3 files changed, 5 insertions(+), 5 deletions(-) - -commit 0305de0259df6902d268060ae251c0d951ca637b -Author: Luigi Ballabio -Date: Fri, 13 Jan 2023 09:22:08 +0100 - - Avoid weird error on 32-bit VC++2015 - - test-suite/inflation.cpp | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) - -commit df7eeb4ecc450fd63ffe244e8a7a2ad6be8f4b18 -Author: Luigi Ballabio -Date: Wed, 11 Jan 2023 11:49:29 +0100 - - Avoid some deprecation warnings on VC++15 - - ql/math/functional.hpp | 32 +++++++++++++++++++++++++++++++- - 1 file changed, 31 insertions(+), 1 deletion(-) - -commit c95610040ef9337b99ce34320476dff9458a56bd -Author: Luigi Ballabio -Date: Thu, 1 Apr 2021 11:28:16 +0200 - - Set version to 1.29 rc - - CMakeLists.txt | 4 ++-- - configure.ac | 2 +- - ql/version.hpp | 4 ++-- - 3 files changed, 5 insertions(+), 5 deletions(-) - -commit 5c4605be3d5e217092e58776fd09964a42737f3b -Author: Luigi Ballabio -Date: Mon, 9 Jan 2023 18:07:02 +0100 - - Update news and changelog - - ChangeLog.txt | 3694 +++++++++++++++++++++++++++++++---------------- - Contributors.txt | 2 + - Docs/pages/history.docs | 100 +- - News.md | 201 +-- - 4 files changed, 2643 insertions(+), 1354 deletions(-) - -commit 87be46e7c5a59d25eb0bb691174caccf296252f3 -Author: Luigi Ballabio -Date: Mon, 9 Jan 2023 14:56:29 +0100 - - Cosmetic changes to a few test messages - - test-suite/americanoption.cpp | 10 +++++----- - test-suite/fdheston.cpp | 6 +++--- - 2 files changed, 8 insertions(+), 8 deletions(-) - -commit 75cbaf6d86b3e658e9fc6262f2da2cd9b871419c -Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> -Date: Mon, 9 Jan 2023 09:33:57 +0000 - - Fixes by misspell-fixer - - ql/experimental/termstructures/crosscurrencyratehelpers.cpp | 2 +- - ql/termstructures/credit/defaultprobabilityhelpers.hpp | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -commit c7d81455809e1055643cd80e7a1e206bce5cae12 -Author: Luigi Ballabio -Date: Mon, 9 Jan 2023 09:51:18 +0100 - - Avoid a couple of clang-tidy warnings - - ql/math/matrix.hpp | 2 +- - ql/pricingengines/vanilla/qdplusamericanengine.cpp | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) + test-suite/array.cpp | 4 ++-- + test-suite/matrices.cpp | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) -commit 3261d7c5d056da571086c36c096dae30eb9be4b5 +commit 7adec475e255d360beb2dc1409d2f1983cf83266 Author: Luigi Ballabio -Date: Thu, 5 Jan 2023 16:08:11 +0100 +Date: Tue, 11 Apr 2023 15:38:12 +0200 - Update qldefines.hpp.cfg + Fix a few test messages - ql/qldefines.hpp.cfg | 15 ++++++++++++++- - 1 file changed, 14 insertions(+), 1 deletion(-) + test-suite/equityindex.cpp | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) -commit b1b89051548404b65ad2726c07bc9cf092b93fd4 +commit d9caed0bcefd9b360e9f006a90c975b2caf49a75 Author: Luigi Ballabio -Date: Thu, 5 Jan 2023 15:23:05 +0100 - - Don't configure version.hpp in cmake +Date: Tue, 11 Apr 2023 15:17:42 +0200 - CMakeLists.txt | 1 - - ql/CMakeLists.txt | 4 ++-- - ql/Makefile.am | 3 +-- - ql/version.hpp.cfg | 51 --------------------------------------------------- - 4 files changed, 3 insertions(+), 56 deletions(-) - -commit 86f51dd912ff80ef64f1f657d5c2117d3797948f -Merge: d0d00b372 65b59c403 -Author: Luigi Ballabio -Date: Thu, 5 Jan 2023 17:24:56 +0100 + Convert tool to Python 3 syntax - Enable usage of MSVC dynamic runtime in cmake build (#1553) + tools/check_inclusions.py | 61 +++++++++++++++++++++++++---------------------- + 1 file changed, 33 insertions(+), 28 deletions(-) -commit 65b59c403adf7d518b006d0d6d43830c1911c4dd +commit d8f602c27b45b677a38ef2c7b7cb6b0c0a4fe5e7 Author: Luigi Ballabio -Date: Thu, 5 Jan 2023 09:32:57 +0100 +Date: Tue, 11 Apr 2023 15:15:33 +0200 - Enable dynamic runtime on Windows with cmake + Convert a few non-unicode characters in comments - .github/workflows/cmake.yml | 37 ++++++++++++++++++++++++++++++++++++- - CMakeLists.txt | 9 +++++---- - cmake/Platform.cmake | 6 ++++-- - 3 files changed, 45 insertions(+), 7 deletions(-) + ql/currencies/africa.cpp | 4 +--- + ql/currencies/africa.hpp | 3 ++- + ql/currencies/europe.cpp | 8 ++++---- + ql/experimental/swaptions/haganirregularswaptionengine.cpp | 2 +- + ql/experimental/swaptions/haganirregularswaptionengine.hpp | 2 +- + 5 files changed, 9 insertions(+), 10 deletions(-) -commit d0d00b3721e1f0ce2070599354d1ba8f0cec251e -Merge: 13179807b 7ceb42941 +commit 8153cd9fb51f5bcbf44819725bfe06452e102bb5 Author: Luigi Ballabio -Date: Tue, 3 Jan 2023 22:25:43 +0100 +Date: Tue, 11 Apr 2023 13:24:55 +0200 - Avoid null-pointer access (#1551) + Update docs for library configuration -commit 7ceb42941eef07a9cbf63fb1dc4ebd693607594e -Author: Luigi Ballabio -Date: Tue, 3 Jan 2023 17:35:38 +0100 - - Avoid null-pointer access - - ql/processes/merton76process.cpp | 2 +- - ql/processes/merton76process.hpp | 6 +++--- - 2 files changed, 4 insertions(+), 4 deletions(-) - -commit 13179807b592d0aac855815f60673b0afe809c39 -Merge: 83468a248 ad62af2cd -Author: Luigi Ballabio -Date: Tue, 3 Jan 2023 17:15:00 +0100 - - Reorder header for European currencies. (#1549) + Docs/pages/config.docs | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) -commit ad62af2cd9de2ec6ed6a030cada586d5a68a0003 -Author: Luigi Ballabio -Date: Tue, 3 Jan 2023 14:28:44 +0100 +commit 9252763b32708b4fd35ea864a4c854c28df2030e +Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> +Date: Mon, 10 Apr 2023 11:56:37 +0000 - Reorder header for European currencies. + Bump peter-evans/create-pull-request from 4 to 5 - The alphabetical order was restored, and the entrance of Croatia - into Eurozone in 2023 was documented. - - ql/currencies/europe.hpp | 108 +++++++++++++++++++++++++---------------------- - 1 file changed, 57 insertions(+), 51 deletions(-) - -commit 83468a24885a81563eb9cce916a2e79968636c7a -Merge: a372709ae f7773e8bd -Author: Luigi Ballabio -Date: Tue, 3 Jan 2023 09:40:57 +0100 + Bumps [peter-evans/create-pull-request](https://github.com/peter-evans/create-pull-request) from 4 to 5. + - [Release notes](https://github.com/peter-evans/create-pull-request/releases) + - [Commits](https://github.com/peter-evans/create-pull-request/compare/v4...v5) + + --- + updated-dependencies: + - dependency-name: peter-evans/create-pull-request + dependency-type: direct:production + update-type: version-update:semver-major + ... + + Signed-off-by: dependabot[bot] - added china calendar for the year 2023 (#1547) + .github/workflows/copyrights.yml | 2 +- + .github/workflows/generated-headers.yml | 2 +- + .github/workflows/misspell.yml | 2 +- + .github/workflows/tidy.yml | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) -commit a372709ae082f73b445d1520b16a66159019b2f5 -Merge: 8f3f010f2 48c3689d5 +commit 2f0703e544a2ece7e9c36d7793278a574c7e84c1 Author: Luigi Ballabio -Date: Tue, 3 Jan 2023 09:40:27 +0100 - - Add required packages for icpx compiler (#1545) +Date: Fri, 7 Apr 2023 13:08:29 +0200 -commit f7773e8bd4b88bd0a1430301b6e1bb8e0db98444 -Author: wegamekinglc -Date: Sun, 1 Jan 2023 17:47:40 +0800 - - added china calendar for the year 2023 + Fix for workflows creating pull requests. + + The existing branch name started causing the PR creation to fail. + Simplifying it seems to fix the problem. - ql/time/calendars/china.cpp | 20 +++++++++++++++++--- - test-suite/calendars.cpp | 35 ++++++++++++++++++++++++++++++++--- - 2 files changed, 49 insertions(+), 6 deletions(-) + .github/workflows/copyrights.yml | 2 +- + .github/workflows/generated-headers.yml | 2 +- + .github/workflows/misspell.yml | 2 +- + .github/workflows/tidy.yml | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) -commit 8f3f010f2d9144bc3d09f2e74ab32ecd8e299a3a -Merge: 5faade57e 91feb6e07 +commit 57edc245d7eac8c6a15279a8fe163576fde4613f +Merge: 56fa1a651 74cb1dde1 Author: Luigi Ballabio -Date: Fri, 30 Dec 2022 11:06:41 +0100 +Date: Tue, 4 Apr 2023 11:28:15 +0200 - Avoid out parameters in `npvbps` signature (#1544) + Add operators taking Matrix by rvalue reference (#1626) -commit 48c3689d51d81a8bfdaa7e1db9405afe10b1c13d +commit 74cb1dde1cfa21d9cd8d0760131cfa4102cd3637 Author: Jonathan Sweemer -Date: Fri, 30 Dec 2022 10:17:35 +0900 +Date: Thu, 30 Mar 2023 21:38:11 +0900 - Add required packages for icpx compiler + Add operators taking Matrix by rvalue reference - CMakeLists.txt | 4 ++++ - 1 file changed, 4 insertions(+) + ql/math/matrix.hpp | 108 +++++++++++++++++++++++++++++++++++++++++++++++- + test-suite/array.cpp | 2 +- + test-suite/matrices.cpp | 68 ++++++++++++++++++++++++++++++ + test-suite/matrices.hpp | 1 + + 4 files changed, 177 insertions(+), 2 deletions(-) -commit 91feb6e07c0063049edc930c44d6ff90083aef96 +commit 56fa1a65165024ce2944229d6ca2cfc0b182da94 +Merge: 617c043f8 4642500df Author: Luigi Ballabio -Date: Thu, 29 Dec 2022 17:28:19 +0100 +Date: Mon, 3 Apr 2023 09:53:02 +0200 - Avoid out parameters in npvbps signature + Real usage consistency and warning fixes (#1625) - ql/cashflows/cashflows.cpp | 23 +++++++++-- - ql/cashflows/cashflows.hpp | 12 +++++- - .../termstructures/crosscurrencyratehelpers.cpp | 44 +++++++++++----------- - ql/pricingengines/swap/discountingswapengine.cpp | 13 +++---- - 4 files changed, 58 insertions(+), 34 deletions(-) - -commit 5faade57eb0b1f5e1d6f404f6291189b5e98d34a -Author: Luigi Ballabio -Date: Thu, 29 Dec 2022 13:17:23 +0100 +commit 4642500dfc2eee216c9d768b5dfbefd5ae80ccac +Author: Xcelerit Dev Team +Date: Sat, 1 Apr 2023 18:28:04 +0000 - Use both processors for CI header check + Changes from reviews: no conversion for /=, nSteps should be Size - tools/check_all_headers.sh | 2 +- - tools/check_header.py | 22 +++++++++++++--------- - 2 files changed, 14 insertions(+), 10 deletions(-) + ql/experimental/credit/homogeneouspooldef.hpp | 4 ++-- + ql/experimental/credit/inhomogeneouspooldef.hpp | 4 ++-- + ql/models/volatility/garch.cpp | 8 ++++---- + 3 files changed, 8 insertions(+), 8 deletions(-) -commit 94e93a15aa3cc25b33804b048a6661110514435a -Merge: bf3b9ee74 5b0fc0e23 -Author: Luigi Ballabio -Date: Thu, 29 Dec 2022 14:26:41 +0100 +commit 6a1706f6bdfc296d4b0f3fb2a8c8c5cd254de23d +Author: Xcelerit Dev Team +Date: Sat, 1 Apr 2023 17:49:08 +0000 - Allow sharing engines between dividend and non-dividend options (#1543) + Revert "Fixes Size -> double conversion warnings with VC++ and higher warning level" + + This reverts commit a723850784d41b162c0a214c7b2ffb61bd321486. + + ql/experimental/catbonds/montecarlocatbondengine.cpp | 6 +++--- + ql/experimental/credit/homogeneouspooldef.hpp | 2 +- + ql/experimental/credit/inhomogeneouspooldef.hpp | 2 +- + ql/experimental/exoticoptions/mchimalayaengine.cpp | 2 +- + ql/experimental/exoticoptions/mcpagodaengine.cpp | 2 +- + ql/experimental/mcbasket/longstaffschwartzmultipathpricer.cpp | 6 +++--- + ql/models/equity/hestonslvmcmodel.cpp | 2 +- + ql/models/marketmodels/evolvers/volprocesses/squarerootandersen.cpp | 2 +- + ql/models/marketmodels/pathwisegreeks/swaptionpseudojacobian.cpp | 2 +- + ql/models/volatility/garch.cpp | 2 +- + ql/pricingengines/asian/turnbullwakemanasianengine.cpp | 2 +- + ql/pricingengines/vanilla/analyticptdhestonengine.cpp | 2 +- + .../volatility/equityfx/andreasenhugevolatilityinterpl.cpp | 2 +- + test-suite/catbonds.cpp | 4 ++-- + test-suite/distributions.cpp | 2 +- + test-suite/libormarketmodel.cpp | 2 +- + test-suite/marketmodel.cpp | 2 +- + 17 files changed, 22 insertions(+), 22 deletions(-) + +commit d7de07f72a4617e57d13a87dcd42d8cd40a5748b +Author: Xcelerit Dev Team +Date: Sat, 1 Apr 2023 09:04:22 +0000 + + Explicit return type for lambdas with expressions to allow expression templates + + ql/experimental/math/convolvedstudentt.cpp | 2 +- + ql/experimental/math/gaussiancopulapolicy.hpp | 2 +- + ql/experimental/math/multidimquadrature.hpp | 4 ++-- + ql/legacy/libormarketmodels/lfmcovarproxy.cpp | 2 +- + ql/methods/finitedifferences/meshers/concentrating1dmesher.cpp | 4 ++-- + ql/methods/finitedifferences/utilities/gbsmrndcalculator.cpp | 2 +- + .../finitedifferences/utilities/riskneutraldensitycalculator.cpp | 2 +- + ql/models/volatility/garch.cpp | 8 ++++---- + ql/pricingengines/vanilla/qdplusamericanengine.cpp | 2 +- + test-suite/distributions.cpp | 2 +- + test-suite/hestonslvmodel.cpp | 2 +- + test-suite/riskneutraldensitycalculator.cpp | 2 +- + test-suite/squarerootclvmodel.cpp | 4 ++-- + 13 files changed, 19 insertions(+), 19 deletions(-) + +commit a723850784d41b162c0a214c7b2ffb61bd321486 +Author: Xcelerit Dev Team +Date: Sat, 1 Apr 2023 08:01:39 +0100 + + Fixes Size -> double conversion warnings with VC++ and higher warning level + + ql/experimental/catbonds/montecarlocatbondengine.cpp | 6 +++--- + ql/experimental/credit/homogeneouspooldef.hpp | 2 +- + ql/experimental/credit/inhomogeneouspooldef.hpp | 2 +- + ql/experimental/exoticoptions/mchimalayaengine.cpp | 2 +- + ql/experimental/exoticoptions/mcpagodaengine.cpp | 2 +- + ql/experimental/mcbasket/longstaffschwartzmultipathpricer.cpp | 6 +++--- + ql/models/equity/hestonslvmcmodel.cpp | 2 +- + ql/models/marketmodels/evolvers/volprocesses/squarerootandersen.cpp | 2 +- + ql/models/marketmodels/pathwisegreeks/swaptionpseudojacobian.cpp | 2 +- + ql/models/volatility/garch.cpp | 2 +- + ql/pricingengines/asian/turnbullwakemanasianengine.cpp | 2 +- + ql/pricingengines/vanilla/analyticptdhestonengine.cpp | 2 +- + .../volatility/equityfx/andreasenhugevolatilityinterpl.cpp | 2 +- + test-suite/catbonds.cpp | 4 ++-- + test-suite/distributions.cpp | 2 +- + test-suite/libormarketmodel.cpp | 2 +- + test-suite/marketmodel.cpp | 2 +- + 17 files changed, 22 insertions(+), 22 deletions(-) + +commit 93187ab648bfda382fa8e112d9299f226e70a47f +Author: Xcelerit Dev Team +Date: Sat, 1 Apr 2023 07:19:25 +0100 -commit bf3b9ee74214f36b1b5000f3d9590deeee07cfb6 -Merge: 58e5aadb9 bef111c99 -Author: Luigi Ballabio -Date: Thu, 29 Dec 2022 13:19:24 +0100 + Fixes ternary operator for conistent Real use - Adds public holiday in lieu of Christmas 2022 to South Africa calendar (#1542) + test-suite/equitycashflow.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) -commit 5b0fc0e23a66f99e970ceff3c6c37687fff96d28 +commit 617c043f82f70eb08549759647d3559243d9ef1d +Merge: b7f3dc2f6 96dc6df64 Author: Luigi Ballabio -Date: Thu, 29 Dec 2022 10:42:51 +0100 - - Allow sharing engines between dividend and non-dividend options - - ql/instruments/barrieroption.cpp | 9 ++++++ - ql/instruments/vanillaoption.cpp | 12 ++++++++ - ql/instruments/vanillaoption.hpp | 2 ++ - test-suite/barrieroption.cpp | 50 +++++++++++++++++++++++++++---- - test-suite/barrieroption.hpp | 1 + - test-suite/europeanoption.cpp | 65 ++++++++++++++++++++++++++++++---------- - test-suite/europeanoption.hpp | 1 + - 7 files changed, 118 insertions(+), 22 deletions(-) +Date: Fri, 31 Mar 2023 17:44:22 +0200 -commit bef111c99120fc44cde63dd8f6c9448da845c2ed -Author: Josh Hayes -Date: Thu, 29 Dec 2022 10:33:28 +0200 + Enable default warning levels in `cmake` build (#1611) - Adds note to docstring about one-off holidays - - ql/time/calendars/southafrica.hpp | 3 +++ - 1 file changed, 3 insertions(+) - -commit e5184d92a016575f85d1269b2af863c37cf7c294 -Author: Josh Hayes -Date: Thu, 29 Dec 2022 10:32:30 +0200 +commit 96dc6df64df7908e619e7cbd6594bcb13afbde54 +Author: RalfKonrad +Date: Thu, 30 Mar 2023 15:57:21 +0200 - Adds holiday in lieu of Christmas on Sunday + Incorp. feedback - ql/time/calendars/southafrica.cpp | 2 ++ - 1 file changed, 2 insertions(+) + .github/workflows/cmake.yml | 4 ++-- + CMakePresets.json | 4 +++- + cmake/Platform.cmake | 2 +- + 3 files changed, 6 insertions(+), 4 deletions(-) -commit 58e5aadb99f8b31189ceb352e7ff85a10c24f899 +commit b7f3dc2f6bffe4f63bf8fc7382e942062991ace0 Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> -Date: Mon, 26 Dec 2022 11:00:28 +0000 +Date: Mon, 27 Mar 2023 11:56:44 +0000 - Bump actions/stale from 6 to 7 + Bump actions/stale from 7 to 8 - Bumps [actions/stale](https://github.com/actions/stale) from 6 to 7. + Bumps [actions/stale](https://github.com/actions/stale) from 7 to 8. - [Release notes](https://github.com/actions/stale/releases) - [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md) - - [Commits](https://github.com/actions/stale/compare/v6...v7) + - [Commits](https://github.com/actions/stale/compare/v7...v8) --- updated-dependencies: @@ -287,2613 +248,2074 @@ Date: Mon, 26 Dec 2022 11:00:28 +0000 .github/workflows/stale.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -commit da7292ad9123ab327024d0caac3703bd6a0f23af +commit 0124ab3b7b51a7de3ab051bcd0d9f2b5349e16d5 Author: Luigi Ballabio -Date: Tue, 27 Dec 2022 09:45:06 +0100 +Date: Sun, 26 Mar 2023 12:20:58 +0200 - Avoid brew errors during CI setup + Avoid std::any_cast on Mac OS 10.11 and 10.12. - .github/workflows/doxygen.yml | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -commit e4e16e7347a13272f130cc5d4bb2fd172a45771f -Author: Luigi Ballabio -Date: Wed, 21 Dec 2022 10:37:09 +0100 - - Upgrade Boost in cmake CI build - - .github/workflows/cmake.yml | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) + .github/workflows/macos-nondefault.yml | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) -commit 4c879d243cdb53eb7f25c87fd48f4c5e42e65054 -Merge: a2b25185b d52126369 +commit 383d218559e5693368d5056fdda3051661712a75 +Merge: 6033d6c13 ec1927aa5 Author: Luigi Ballabio -Date: Thu, 15 Dec 2022 09:12:16 +0100 +Date: Sat, 25 Mar 2023 09:52:01 +0100 - Bugfix for ZeroCouponInflationSwapHelper (#1539) + Add support for std::any and std::optional (#1617) -commit d52126369d490c1cf71a8fddecc0063f11315e27 -Author: Matthias Groncki -Date: Thu, 15 Dec 2022 10:09:03 +0700 +commit ec1927aa55ecc82bbefac183e5c5fe6c69c3c74d +Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> +Date: Wed, 22 Mar 2023 14:34:58 +0000 - Bugfix ZeroCouponInflationSwapHelper - - Dont need to interpolate the maturity of the rate helper falls the on the first date of the inflation period + Update generated headers - ql/termstructures/inflation/inflationhelpers.cpp | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) + ql/quantlib.hpp | 2 ++ + 1 file changed, 2 insertions(+) -commit a2b25185b597ee0d9578dd8e61a88fe31a33c043 +commit a0aa6435a2e2bf0ff5f556282053dfc94747a890 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> -Date: Tue, 13 Dec 2022 15:28:56 +0000 +Date: Wed, 22 Mar 2023 14:32:44 +0000 Update copyright list in license - LICENSE.TXT | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + LICENSE.TXT | 2 ++ + 1 file changed, 2 insertions(+) -commit fcdd14c2a42d149fd7512c3665a1f27ba0924a5b -Merge: e5fa7ba6e 134d2b85e +commit 6033d6c1392530812fe2949b15117ad1453418c4 +Merge: 1ca77f102 49bbdf1ed Author: Luigi Ballabio -Date: Tue, 13 Dec 2022 16:28:18 +0100 +Date: Fri, 24 Mar 2023 12:59:18 +0100 - Add indexFixing method to indexed cashflows (#1499) + Remove copy on key compare (#1616) -commit 134d2b85e1cfd05e392494f63c9283ecccd7d723 -Author: Matthias Groncki -Date: Tue, 13 Dec 2022 08:50:53 +0700 - - move baseFixing method to base class indexedcashflow - - ql/cashflows/cpicoupon.cpp | 10 ---------- - ql/cashflows/cpicoupon.hpp | 7 ++----- - ql/cashflows/indexedcashflow.cpp | 4 ++-- - ql/cashflows/indexedcashflow.hpp | 1 + - 4 files changed, 5 insertions(+), 17 deletions(-) - -commit 59264ca1bdc52730175b6c4dbbc9251781326f2c -Author: Matthias Groncki -Date: Thu, 8 Dec 2022 07:41:33 +0700 - - avoid code duplication - - ql/cashflows/cpicoupon.cpp | 23 +---------------------- - 1 file changed, 1 insertion(+), 22 deletions(-) - -commit e5fa7ba6e63b300eb16d54ff23b3ba893933582c -Merge: 5e5380e36 9b572ef39 +commit 1ca77f1024698ddb35dd24de7ea5ffa5cc92ad3f +Merge: 6fef826a6 5889314e6 Author: Luigi Ballabio -Date: Wed, 7 Dec 2022 22:36:24 +0100 +Date: Fri, 24 Mar 2023 12:55:58 +0100 - Casts to Real to maintain AAD compatibility (#1536) + Equity cash flow and quanto pricing (#1610) -commit 5e5380e36fabbd40ddea97437901d44003105edb -Merge: 1b16c6c1e c3a8da34b +commit 6fef826a65fba45aff023cd6e0532ad2f1bac784 +Merge: 3c8c6ed8c 6523f36a3 Author: Luigi Ballabio -Date: Wed, 7 Dec 2022 22:35:52 +0100 +Date: Fri, 24 Mar 2023 12:46:33 +0100 - Deprecate unneeded typedefs (#1418) + CPICoupon with baseDate (#1498) -commit 9b572ef393b587089329c97b8a7f42851e600e94 -Author: Xcelerit Dev Team -Date: Wed, 7 Dec 2022 15:15:00 +0000 +commit bb814c8b5e3dd26d9a2c67547b9666a31467bec6 +Author: Luigi Ballabio +Date: Fri, 24 Mar 2023 09:25:55 +0100 - Casts to Real to maintain AAD compatibility + Test in Mac OS CI build - ql/pricingengines/vanilla/qdplusamericanengine.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + .github/workflows/macos-nondefault.yml | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) -commit c3a8da34b0d79ad50976e3c042c4191c89dc2cdd -Author: Jonathan Sweemer -Date: Tue, 28 Jun 2022 21:13:38 +0900 - - Deprecate unneeded typedefs - - ql/cashflow.hpp | 14 ++++++ - ql/cashflows/conundrumpricer.hpp | 9 ++++ - ql/experimental/math/convolvedstudentt.hpp | 18 ++++++++ - ql/experimental/math/latentmodel.hpp | 5 ++ - ql/math/abcdmathfunction.hpp | 9 ++++ - ql/math/comparison.hpp | 14 ++++++ - ql/math/copulas/alimikhailhaqcopula.hpp | 14 ++++++ - ql/math/copulas/claytoncopula.hpp | 14 ++++++ - ql/math/copulas/farliegumbelmorgensterncopula.hpp | 14 ++++++ - ql/math/copulas/frankcopula.hpp | 14 ++++++ - ql/math/copulas/galamboscopula.hpp | 14 ++++++ - ql/math/copulas/gaussiancopula.hpp | 14 ++++++ - ql/math/copulas/gumbelcopula.hpp | 14 ++++++ - ql/math/copulas/huslerreisscopula.hpp | 14 ++++++ - ql/math/copulas/independentcopula.hpp | 14 ++++++ - ql/math/copulas/marshallolkincopula.hpp | 14 ++++++ - ql/math/copulas/maxcopula.hpp | 14 ++++++ - ql/math/copulas/mincopula.hpp | 14 ++++++ - ql/math/copulas/plackettcopula.hpp | 14 ++++++ - ql/math/distributions/binomialdistribution.hpp | 18 ++++++++ - ql/math/distributions/chisquaredistribution.hpp | 36 +++++++++++++++ - ql/math/distributions/gammadistribution.hpp | 18 ++++++++ - ql/math/distributions/normaldistribution.hpp | 54 ++++++++++++++++++++++ - ql/math/distributions/poissondistribution.hpp | 27 +++++++++++ - ql/math/distributions/studenttdistribution.hpp | 27 +++++++++++ - ql/math/errorfunction.hpp | 9 ++++ - ql/math/interpolation.hpp | 10 ++++ - ql/math/interpolations/interpolation2d.hpp | 14 ++++++ - ql/math/linearleastsquaresregression.hpp | 9 ++++ - ql/math/polynomialmathfunction.hpp | 9 ++++ - .../randomnumbers/stochasticcollocationinvcdf.hpp | 9 ++++ - .../operators/numericaldifferentiation.hpp | 9 ++++ - ql/methods/montecarlo/pathpricer.hpp | 4 ++ - ql/payoff.hpp | 9 ++++ - ql/termstructures/volatility/abcd.hpp | 9 ++++ - 35 files changed, 522 insertions(+) - -commit 1b16c6c1e00ad136610b1d2040864cae00957e8b -Merge: 035ab3e92 559371a6b -Author: Luigi Ballabio -Date: Mon, 5 Dec 2022 23:03:06 +0100 - - Better error messages for interpolated curves (#1535) - -commit 035ab3e929b6765771c2882397d04f45b2c39894 -Merge: 4019bee67 eabb11aec -Author: Luigi Ballabio -Date: Mon, 5 Dec 2022 22:51:48 +0100 - - allow negative dividend yields for QD+ American engines (#1534) - -commit 559371a6b43b7fa2c7546d4a9f61d18abc2edbc7 -Author: Luigi Ballabio -Date: Mon, 5 Dec 2022 16:14:53 +0100 - - Better error messages for interpolated curves - - .../credit/interpolatedaffinehazardratecurve.hpp | 18 ++---------- - .../credit/interpolateddefaultdensitycurve.hpp | 33 ++++++---------------- - .../credit/interpolatedhazardratecurve.hpp | 17 ++--------- - .../interpolatedsurvivalprobabilitycurve.hpp | 16 ++--------- - .../inflation/interpolatedyoyinflationcurve.hpp | 18 ++---------- - .../inflation/interpolatedzeroinflationcurve.hpp | 17 ++--------- - ql/termstructures/interpolatedcurve.hpp | 21 ++++++++++++++ - ql/termstructures/yield/discountcurve.hpp | 16 ++--------- - ql/termstructures/yield/forwardcurve.hpp | 20 ++----------- - .../yield/interpolatedsimplezerocurve.hpp | 19 ++++--------- - ql/termstructures/yield/zerocurve.hpp | 26 ++++------------- - 11 files changed, 58 insertions(+), 163 deletions(-) - -commit eabb11aec1a3483c2bd1e8a0a7ce1a009d65202e -Author: klausspanderen -Date: Mon, 5 Dec 2022 00:21:51 +0100 +commit dd377ee1c5f6725be9c6e80a03ae16cd0979a67e +Author: Luigi Ballabio +Date: Fri, 24 Mar 2023 09:22:42 +0100 - allow negative dividend yields for QD+ and QD+ fixed point American - engines + Test in Linux CI build - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 2 +- - ql/pricingengines/vanilla/qdplusamericanengine.cpp | 50 ++++++++++----- - test-suite/americanoption.cpp | 74 ++++++++++++++++++++++ - test-suite/americanoption.hpp | 2 + - 4 files changed, 111 insertions(+), 17 deletions(-) + .github/workflows/linux-full-tests.yml | 2 +- + .github/workflows/linux-nondefault.yml | 2 +- + .github/workflows/linux.yml | 2 +- + configure.ac | 6 +++--- + 4 files changed, 6 insertions(+), 6 deletions(-) -commit 4019bee67ac10b8fb242648fd62e0e2525a1d597 +commit 3c8c6ed8cc64c8430901cc32de2391d3d2730307 Author: Luigi Ballabio -Date: Sun, 4 Dec 2022 13:35:39 +0100 +Date: Thu, 23 Mar 2023 16:56:36 +0100 - Add configure switch to skip test suite. + Avoid 'using namespace std;' in test suite. - Not advised in normal usage. Mostly for automated jobs building - wheels or other artifacts, after the code is already verified. + This prevents an ambiguity when performing a unity build + in VC++ after specifying the C++17 language standard. + The underlying cause is unqualified references to byte + in the Windows SDK, which can also match C++17 std::byte. + Avoiding 'using namespace' is a workaround. - configure.ac | 12 +++++++++++- - test-suite/Makefile.am | 2 +- - 2 files changed, 12 insertions(+), 2 deletions(-) + test-suite/autocovariances.cpp | 1 - + test-suite/cdo.cpp | 17 ++++++++--------- + test-suite/fastfouriertransform.cpp | 1 - + test-suite/inflationcpicapfloor.cpp | 7 +++---- + test-suite/inflationvolatility.cpp | 27 ++++++++++++--------------- + test-suite/nthtodefault.cpp | 17 ++++++++--------- + test-suite/spreadoption.cpp | 3 --- + 7 files changed, 31 insertions(+), 42 deletions(-) -commit 7f69bb6fbe4ac76f0262b717cbf97c6dcd7b69d9 -Merge: 61041b0f1 bb3c5eb9b +commit d88ed7c85144bbf7b791df8cfaa1ba4907330d36 +Merge: 7220d2c33 57668cd87 Author: Luigi Ballabio -Date: Wed, 23 Nov 2022 14:37:52 +0100 +Date: Thu, 23 Mar 2023 16:09:18 +0100 - Use Real instead of double in amortizingbond test (#1531) + Make Gov USA bond 2023 Good Friday working day (#1620) -commit bb3c5eb9bb3dbdc3842ab0c84aff39e178736539 -Author: Xcelerit Dev Team <107129969+xcelerit-dev@users.noreply.github.com> -Date: Wed, 23 Nov 2022 09:48:43 +0000 +commit 57668cd87899b6fbaff7a257548bcc544a80ead0 +Author: Luigi Ballabio +Date: Thu, 23 Mar 2023 12:04:38 +0100 - Fix vector -> vector in amortizingbond test + Add relevant link to code comment - test-suite/amortizingbond.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) + ql/time/calendars/unitedstates.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) -commit 61041b0f191b8788b82443462eea62a46f56ff2d -Merge: 222bccec3 e6e5b9208 -Author: Luigi Ballabio -Date: Wed, 23 Nov 2022 10:05:32 +0100 +commit 055cf6b5c30123b0dc006c9b83a2692db47b3165 +Author: Luigi Ballabio +Date: Wed, 22 Mar 2023 15:20:08 +0100 + + ext::nullopt as variable + + QuantLib.vcxproj | 3 +- + QuantLib.vcxproj.filters | 3 +- + ql/CMakeLists.txt | 1 + + ql/Makefile.am | 1 + + ql/cashflow.hpp | 2 +- + ql/cashflows/couponpricer.hpp | 4 +-- + ql/event.hpp | 2 +- + .../catbonds/montecarlocatbondengine.hpp | 2 +- + .../coupons/lognormalcmsspreadpricer.hpp | 2 +- + ql/experimental/credit/syntheticcdo.hpp | 2 +- + ql/instruments/creditdefaultswap.cpp | 6 ++-- + ql/instruments/floatfloatswap.hpp | 8 +++--- + ql/instruments/makevanillaswap.cpp | 4 +-- + ql/instruments/nonstandardswap.hpp | 4 +-- + ql/instruments/vanillaswap.hpp | 4 +-- + ql/optional.cpp | 33 ++++++++++++++++++++++ + ql/optional.hpp | 6 ++-- + ql/pricingengines/bond/discountingbondengine.hpp | 2 +- + ql/pricingengines/credit/integralcdsengine.hpp | 2 +- + ql/pricingengines/credit/isdacdsengine.hpp | 2 +- + ql/pricingengines/credit/midpointcdsengine.hpp | 2 +- + ql/pricingengines/mclongstaffschwartzengine.hpp | 4 +-- + ql/pricingengines/swap/discountingswapengine.hpp | 2 +- + ql/pricingengines/vanilla/mcamericanengine.hpp | 4 +-- + ql/termstructures/yield/oisratehelper.hpp | 2 +- + ql/termstructures/yield/ratehelpers.hpp | 8 +++--- + ql/time/schedule.hpp | 8 +++--- + test-suite/cashflows.cpp | 8 +++--- + test-suite/creditdefaultswap.cpp | 6 ++-- + test-suite/quantlibtestsuite.cpp | 2 +- + 30 files changed, 89 insertions(+), 50 deletions(-) + +commit 90a6026a3b79844dfa4c89a314218b6e7ebbb7db +Author: Anastasiia Shumyk +Date: Tue, 21 Mar 2023 19:35:30 +0200 + + Make GOV bond USA 2023 Good Friday working day + + ql/time/calendars/unitedstates.cpp | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +commit 7220d2c3333fb68f194367c5b21a451e7f84200b +Author: Luigi Ballabio +Date: Mon, 20 Mar 2023 11:25:14 +0100 + + Avoid deprecation warnings in VC++22 when including quantlib.hpp + + ql/termstructures/yield/drifttermstructure.hpp | 5 +++++ + 1 file changed, 5 insertions(+) - Updated Readme (#1530) +commit c347a1ebb934e07f236d0de81c830da851c1d82d +Author: Luigi Ballabio +Date: Mon, 20 Mar 2023 11:12:52 +0100 -commit e6e5b92081895b31e6261a48e4a865058af51704 -Author: Nijaz Kovacevic -Date: Tue, 22 Nov 2022 19:28:40 -0800 + Don't include obsolete headers - Updated Readme - - Added Basket losses, CVAIRS, Gaussian1dModels, Latent Models, and Market Models in the example Readme file. + ql/experimental/volatility/Makefile.am | 2 +- + ql/experimental/volatility/all.hpp | 1 - + ql/termstructures/volatility/swaption/Makefile.am | 2 +- + ql/termstructures/volatility/swaption/all.hpp | 2 -- + 4 files changed, 2 insertions(+), 5 deletions(-) - Examples/README.txt | 35 +++++++++++++++++++++++++++++++++++ - 1 file changed, 35 insertions(+) +commit 49bbdf1edeeacf21b33b674a986aee3efea4e443 +Author: Jonathan Sweemer +Date: Sun, 12 Mar 2023 05:36:07 +0000 -commit 222bccec371dc24c29466d58b65b6569b4eb7684 -Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> -Date: Tue, 22 Nov 2022 15:25:45 +0000 + Remove copy on key compare - Update copyright list in license + ql/indexes/indexmanager.cpp | 28 ++++++++++++---------------- + ql/indexes/indexmanager.hpp | 13 +++++++++++-- + test-suite/indexes.cpp | 18 +++++++++++++++++- + 3 files changed, 40 insertions(+), 19 deletions(-) - LICENSE.TXT | 2 +- +commit 05a278be334f055c7ad17651195fe6c9a1176dac +Author: Jonathan Sweemer +Date: Thu, 16 Mar 2023 21:46:37 +0900 + + Add support for std::any and std::optional + + CMakeLists.txt | 47 +++++++++++++------- + QuantLib.vcxproj | 2 + + QuantLib.vcxproj.filters | 2 + + configure.ac | 31 +++++++++++++ + ql/CMakeLists.txt | 2 + + ql/Makefile.am | 2 + + ql/any.hpp | 51 ++++++++++++++++++++++ + ql/cashflow.cpp | 4 +- + ql/cashflow.hpp | 3 +- + ql/cashflows/couponpricer.cpp | 3 +- + ql/cashflows/couponpricer.hpp | 5 ++- + ql/cashflows/iborcoupon.cpp | 3 +- + ql/cashflows/iborcoupon.hpp | 5 ++- + ql/config.hpp.cfg | 2 + + ql/event.cpp | 3 +- + ql/event.hpp | 4 +- + .../catbonds/montecarlocatbondengine.cpp | 3 +- + .../catbonds/montecarlocatbondengine.hpp | 5 ++- + ql/experimental/commodities/commodity.hpp | 3 +- + ql/experimental/commodities/energycommodity.cpp | 8 ++-- + .../coupons/lognormalcmsspreadpricer.cpp | 6 +-- + .../coupons/lognormalcmsspreadpricer.hpp | 3 +- + ql/experimental/credit/syntheticcdo.cpp | 5 ++- + ql/experimental/credit/syntheticcdo.hpp | 3 +- + ql/experimental/swaptions/irregularswap.hpp | 1 - + ql/experimental/swaptions/irregularswaption.cpp | 3 +- + ql/instrument.hpp | 14 +++--- + ql/instruments/callabilityschedule.hpp | 4 +- + ql/instruments/capfloor.cpp | 3 +- + ql/instruments/creditdefaultswap.cpp | 9 ++-- + ql/instruments/creditdefaultswap.hpp | 7 +-- + ql/instruments/floatfloatswap.cpp | 13 +++--- + ql/instruments/floatfloatswap.hpp | 14 +++--- + ql/instruments/makecds.hpp | 6 +-- + ql/instruments/makeswaption.cpp | 3 +- + ql/instruments/makeswaption.hpp | 5 ++- + ql/instruments/makevanillaswap.cpp | 7 +-- + ql/instruments/makevanillaswap.hpp | 4 +- + ql/instruments/nonstandardswap.cpp | 5 ++- + ql/instruments/nonstandardswap.hpp | 6 +-- + ql/instruments/swaption.cpp | 3 +- + ql/instruments/vanillaswap.cpp | 5 ++- + ql/instruments/vanillaswap.hpp | 6 +-- + ql/optional.hpp | 51 ++++++++++++++++++++++ + ql/pricingengines/bond/discountingbondengine.cpp | 3 +- + ql/pricingengines/bond/discountingbondengine.hpp | 5 ++- + .../capfloor/analyticcapfloorengine.cpp | 3 +- + ql/pricingengines/credit/integralcdsengine.cpp | 3 +- + ql/pricingengines/credit/integralcdsengine.hpp | 5 ++- + ql/pricingengines/credit/isdacdsengine.cpp | 3 +- + ql/pricingengines/credit/isdacdsengine.hpp | 5 ++- + ql/pricingengines/credit/midpointcdsengine.cpp | 3 +- + ql/pricingengines/credit/midpointcdsengine.hpp | 5 ++- + ql/pricingengines/mclongstaffschwartzengine.hpp | 10 ++--- + ql/pricingengines/swap/discountingswapengine.cpp | 3 +- + ql/pricingengines/swap/discountingswapengine.hpp | 5 ++- + .../vanilla/bjerksundstenslandengine.cpp | 4 +- + ql/pricingengines/vanilla/mcamericanengine.hpp | 9 ++-- + ql/settings.hpp | 14 +++--- + ql/termstructures/yield/oisratehelper.cpp | 2 +- + ql/termstructures/yield/oisratehelper.hpp | 5 ++- + ql/termstructures/yield/ratehelpers.cpp | 9 ++-- + ql/termstructures/yield/ratehelpers.hpp | 17 ++++---- + ql/time/schedule.cpp | 11 ++--- + ql/time/schedule.hpp | 32 +++++++------- + ql/userconfig.hpp | 10 +++++ + test-suite/americanoption.cpp | 5 ++- + test-suite/cashflows.cpp | 10 ++--- + test-suite/creditdefaultswap.cpp | 7 +-- + test-suite/defaultprobabilitycurves.cpp | 2 +- + test-suite/period.cpp | 2 +- + test-suite/quantlibtestsuite.cpp | 11 ++--- + 72 files changed, 392 insertions(+), 185 deletions(-) + +commit d9e8af7f294b7fc3e8d7ea48b0d408e143b29d31 +Merge: 860d1e39f 30c263fdd +Author: Luigi Ballabio +Date: Fri, 17 Mar 2023 22:54:11 +0100 + + Avoid compilation error using `PiecewiseYieldCurve` (#1615) + +commit 30c263fdd9ce9fca20d2f2539cbeace146335b5a +Author: Luigi Ballabio +Date: Fri, 17 Mar 2023 15:38:10 +0100 + + Avoid compilation error using ConvexMonotone interpolation + + .../interpolations/convexmonotoneinterpolation.hpp | 6 +-- + test-suite/piecewiseyieldcurve.cpp | 63 +++++++++++++--------- + test-suite/piecewiseyieldcurve.hpp | 2 + + 3 files changed, 42 insertions(+), 29 deletions(-) + +commit 860d1e39fc2672f53fd68f99d6761af5b797ddb5 +Author: Luigi Ballabio +Date: Wed, 15 Mar 2023 10:52:59 +0100 + + Remove outdated comments + + ql/math/matrixutilities/tqreigendecomposition.cpp | 1 - + ql/pricingengines/vanilla/juquadraticengine.cpp | 1 - + ql/time/daycounters/actualactual.cpp | 1 - + test-suite/americanoption.cpp | 1 - + test-suite/basketoption.cpp | 1 - + test-suite/batesmodel.cpp | 6 +----- + test-suite/capfloor.cpp | 2 -- + test-suite/digitaloption.cpp | 1 - + test-suite/europeanoption.cpp | 1 - + test-suite/extendedtrees.cpp | 1 - + test-suite/hestonmodel.cpp | 3 --- + test-suite/hybridhestonhullwhiteprocess.cpp | 6 ------ + test-suite/marketmodel.cpp | 1 - + test-suite/marketmodel_smmcaplethomocalibration.cpp | 1 - + test-suite/operators.cpp | 4 ---- + test-suite/pathgenerator.cpp | 1 - + test-suite/swaption.cpp | 6 ------ + 17 files changed, 1 insertion(+), 37 deletions(-) + +commit 5b494c651149b9fcb5c2961f9bbadee789ad5cc4 +Merge: 230ce8319 851edb0a6 +Author: Luigi Ballabio +Date: Tue, 14 Mar 2023 15:17:29 +0100 + + Allow moving value into ObservableValue (#1601) + +commit 5889314e6dcf686d5f9cd30447ebd220e8be8d59 +Author: Marcin Rybacki +Date: Mon, 13 Mar 2023 09:16:06 +0100 + + Keep alphabetic order of imports. + + ql/instruments/equitytotalreturnswap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -commit 13cc9e99872223c930de446bdd6a38a08975e8b2 -Merge: f271efd89 32cf78c60 -Author: Luigi Ballabio -Date: Tue, 22 Nov 2022 16:23:10 +0100 - - removed check for increasing notionals as there are bonds with draw down (#1437) +commit 34183e99ee9fea97ffb045f450128800f926796e +Author: Marcin Rybacki +Date: Mon, 13 Mar 2023 09:15:18 +0100 -commit 32cf78c60c322cb0d55411d1bf0d8d5c78c13a19 -Author: Luigi Ballabio -Date: Tue, 22 Nov 2022 14:59:41 +0100 + Fixed build. - Convert example into test case + ql/instruments/equitytotalreturnswap.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) - Examples/AmortizingBonds/AmortizingBond.cpp | 178 ---------------------------- - Examples/AmortizingBonds/CMakeLists.txt | 2 - - Examples/AmortizingBonds/ReadMe.txt | 1 - - test-suite/amortizingbond.cpp | 63 ++++++++++ - test-suite/amortizingbond.hpp | 4 +- - 5 files changed, 65 insertions(+), 183 deletions(-) +commit 230ce83196fecf03acfaefca4566a55df2cd53e2 +Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> +Date: Sun, 12 Mar 2023 01:52:32 +0000 -commit f271efd89bb874612ebd69667dccf976e68f841e -Merge: 0bc43aad3 e630cd890 -Author: Luigi Ballabio -Date: Tue, 22 Nov 2022 09:03:12 +0100 + Automated fixes by clang-tidy - Added `MakeSwaption::withIndexedCoupons(...)` and `MakeSwaption::withAtParCoupons(...)` (#1527) + ql/instruments/equitytotalreturnswap.cpp | 40 +++++++++++++++++--------------- + ql/instruments/equitytotalreturnswap.hpp | 2 +- + 2 files changed, 22 insertions(+), 20 deletions(-) -commit e630cd8903d9dca3b2d7b56824a1768052ed54a2 +commit 81302912e6b5984d9b0107c1240a911c97351c6e Author: RalfKonrad -Date: Mon, 21 Nov 2022 19:28:20 +0100 - - Added MakeSwaption::withIndexedCoupons(...) and MakeSwaption::withAtParCoupons(...) - - ql/instruments/makeswaption.cpp | 13 ++++++++++++- - ql/instruments/makeswaption.hpp | 3 +++ - 2 files changed, 15 insertions(+), 1 deletion(-) +Date: Sun, 12 Mar 2023 18:59:17 +0100 -commit 0bc43aad3b0964847ba07c5be3af79f4a46e3594 -Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> -Date: Sun, 20 Nov 2022 05:41:37 +0000 + Adding a bit of documentation - Automated fixes by clang-tidy + CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) - test-suite/inflation.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) +commit e7bc1c4ee5d0410dbbccd4f8e10512d6593c688e +Author: RalfKonrad +Date: Sun, 12 Mar 2023 18:44:04 +0100 -commit 8cf030858a88e6b9aef658b1b74212068151a263 -Merge: faed2ceb3 0de363d13 -Author: Luigi Ballabio -Date: Sun, 20 Nov 2022 21:14:29 +0100 + Added add_compile_definitions(_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING) to prevent deprecation warnings from boost::ublas - Make Option::payoff() and Option::exercise() const (#1526) + cmake/Platform.cmake | 9 +++++++++ + 1 file changed, 9 insertions(+) -commit 0de363d1392434986d567a3a6c51394b490bb982 +commit c89d4bb4225343c72d2b32ef924046d17ac581f4 Author: RalfKonrad -Date: Sun, 20 Nov 2022 18:26:48 +0100 - - Option::payoff() and Option::exercise() are now const +Date: Sat, 11 Mar 2023 20:45:58 +0100 - ql/option.hpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) + Define QL_ENABLE_DEFAULT_WARNING_LEVEL and QL_COMPILE_WARNING_AS_ERROR in CMakeLists.txt and use them in the cmake workflow. -commit faed2ceb3b255d03b307bd2e459a70776a2e3778 -Author: Luigi Ballabio -Date: Fri, 18 Nov 2022 22:55:11 +0100 + .github/workflows/cmake.yml | 20 ++++++++++---------- + CMakeLists.txt | 29 +++++++++++++++++++++++++++++ + cmake/Platform.cmake | 1 + + 3 files changed, 40 insertions(+), 10 deletions(-) - Try to reduce number of cache entries on actions +commit 2e48157bef16b7135f1d06b15b7a51768db1a9ba +Author: Marcin Rybacki +Date: Sat, 11 Mar 2023 20:19:18 +0100 - .github/workflows/cmake.yml | 35 +++++++++++++++------------------- - .github/workflows/linux-full-tests.yml | 7 +++---- - .github/workflows/linux.yml | 7 +++---- - .github/workflows/macos.yml | 9 ++++----- - .github/workflows/test-times.yml | 9 ++++----- - 5 files changed, 29 insertions(+), 38 deletions(-) + Adjusted checks when initiating quanto cash flow pricer. -commit 95cc21495fa842205fbdeb0b1cd956e03b09c268 -Merge: 80874acf5 630569a16 -Author: Luigi Ballabio -Date: Fri, 18 Nov 2022 22:45:01 +0100 + ql/cashflows/equitycashflow.cpp | 12 ++- + test-suite/equitycashflow.cpp | 165 ++++++++++++++++++++++++---------------- + test-suite/equitycashflow.hpp | 5 +- + 3 files changed, 111 insertions(+), 71 deletions(-) - Accelerated Build via Ninja generator with CMake (#1429) +commit 851edb0a68c2813eb4750c33a17960a6eb574abf +Author: Jonathan Sweemer +Date: Fri, 17 Feb 2023 00:00:10 +0000 -commit 630569a16ff771b0999af048208d063a0418f033 -Author: Xcelerit Dev Team -Date: Fri, 18 Nov 2022 16:02:11 +0000 + Allow values to be moved into ObservableValue - Adds /bigobj in unity builds for benchmarks as well + ql/indexes/indexmanager.cpp | 8 ++++---- + ql/indexes/indexmanager.hpp | 5 ++--- + ql/utilities/observablevalue.hpp | 14 ++++++++++++++ + 3 files changed, 20 insertions(+), 7 deletions(-) - test-suite/CMakeLists.txt | 4 ++++ - 1 file changed, 4 insertions(+) +commit 23bb2710d97214266a78eb080dc723985507edf5 +Author: Marcin Rybacki +Date: Fri, 10 Mar 2023 12:11:46 +0100 -commit 3536ad4d1ac602b0ac2d745bcbad1b6164423b1f -Author: Xcelerit Dev Team -Date: Fri, 18 Nov 2022 14:20:48 +0000 + Updated CMake- and Makefiles. - Sets /bigobj for MSVC unit builds + ql/CMakeLists.txt | 2 ++ + ql/cashflows/Makefile.am | 2 ++ + ql/cashflows/all.hpp | 1 + + test-suite/CMakeLists.txt | 2 ++ + test-suite/Makefile.am | 2 ++ + 5 files changed, 9 insertions(+) - ql/CMakeLists.txt | 7 ++----- - test-suite/CMakeLists.txt | 7 ++----- - 2 files changed, 4 insertions(+), 10 deletions(-) +commit b60b649e7db908611c136d580ff5cf135d3bafbd +Author: Marcin Rybacki +Date: Fri, 10 Mar 2023 12:03:59 +0100 -commit a758f145401c1bdb3c2fc9d67c3c0d600eabc954 -Author: Xcelerit Dev Team -Date: Fri, 18 Nov 2022 12:52:59 +0000 + Added more unit tests for equity cash flow and quanto pricer. - Enables sccache on Windows in CI cmake builds + ql/cashflows/equitycashflow.cpp | 23 ++++- + test-suite/equitycashflow.cpp | 187 ++++++++++++++++++++++++++++++++++------ + test-suite/equitycashflow.hpp | 4 + + 3 files changed, 187 insertions(+), 27 deletions(-) - .github/workflows/cmake.yml | 22 +++++++++++++++++++++- - CMakePresets.json | 3 ++- - 2 files changed, 23 insertions(+), 2 deletions(-) +commit 325327550fda7dcc7eef5e772a8e271d18c54b25 +Author: Marcin Rybacki +Date: Thu, 9 Mar 2023 18:08:22 +0100 -commit 022273a7a1843975b2323aec177bc8363e897985 -Author: Xcelerit Dev Team -Date: Fri, 18 Nov 2022 12:44:10 +0000 + Removed protected section from the TRS. - Adds /bigobj on CMake unity builds with Ninja + ql/instruments/equitytotalreturnswap.hpp | 2 -- + 1 file changed, 2 deletions(-) - ql/CMakeLists.txt | 8 ++++++++ - test-suite/CMakeLists.txt | 7 +++++++ - 2 files changed, 15 insertions(+) +commit 12b2efd8c74ce22d590f4a587e9952b036e5abce +Author: Marcin Rybacki +Date: Thu, 9 Mar 2023 18:07:16 +0100 -commit 80874acf512570ed3be7714698de1901a909a2c7 -Merge: 75602fedc 002d9e388 -Author: Luigi Ballabio -Date: Mon, 14 Nov 2022 13:23:07 +0100 + Adjusted equity leg creation approach in the TRS. - Consistent Real usage, testing macros, and constant initialisation (#1524) + ql/instruments/equitytotalreturnswap.cpp | 38 +++++++++++++++++++------------- + ql/instruments/equitytotalreturnswap.hpp | 1 - + test-suite/equitycashflow.cpp | 4 ++-- + test-suite/equitycashflow.hpp | 2 +- + 4 files changed, 26 insertions(+), 19 deletions(-) -commit 75602fedca7b585ad8791e32a18b58e740539e36 -Merge: af69ee35a 3cfa4eb26 +commit c0e20ac22ccbd1ebe82a4bd08bae77b90fb93535 +Merge: 9f2806534 81f905373 Author: Luigi Ballabio -Date: Mon, 14 Nov 2022 12:25:26 +0100 +Date: Thu, 9 Mar 2023 12:57:19 +0100 - Deprecate internal interpolation in `InflationIndex` and `ZeroInflationIndex` (#1051) - -commit 002d9e388d459227a4ecdbb4dcf3785518cfb6f8 -Author: Xcelerit Dev Team -Date: Mon, 14 Nov 2022 10:10:19 +0000 + Add move semantics for `Array` operators and functions (#1606) - Removes needless explicit norm template parameter +commit 47b0558a80e38a16f42119a4bcdcd4bf3d8767f6 +Author: Marcin Rybacki +Date: Thu, 9 Mar 2023 11:12:21 +0100 - test-suite/fastfouriertransform.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Introduced general equity cash flow. -commit 9b1593636d518bc131f66256f9f40fd506c817ea -Author: Xcelerit Dev Team -Date: Mon, 14 Nov 2022 10:09:46 +0000 + QuantLib.vcxproj | 4 +- + QuantLib.vcxproj.filters | 4 +- + ...equityquantocashflow.cpp => equitycashflow.cpp} | 63 ++++++++++--------- + ...equityquantocashflow.hpp => equitycashflow.hpp} | 71 ++++++++++++---------- + ql/instruments/equitytotalreturnswap.cpp | 5 +- + ...equityquantocashflow.cpp => equitycashflow.cpp} | 23 +++---- + ...equityquantocashflow.hpp => equitycashflow.hpp} | 6 +- + test-suite/quantlibtestsuite.cpp | 4 +- + test-suite/testsuite.vcxproj | 4 +- + test-suite/testsuite.vcxproj.filters | 4 +- + 10 files changed, 100 insertions(+), 88 deletions(-) - Consistently use testing macros +commit 9e089821190ce56779723949560f023202c2b2a7 +Author: Marcin Rybacki +Date: Wed, 8 Mar 2023 15:24:12 +0100 - test-suite/americanoption.cpp | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) + Added unit test files for equity quanto cash flow. -commit 46d7233bd53ecd13e2fcf30f6bf62727bbfce64e -Author: Xcelerit Dev Team -Date: Mon, 14 Nov 2022 10:08:53 +0000 + test-suite/equityquantocashflow.cpp | 159 +++++++++++++++++++++++++++++++++++ + test-suite/equityquantocashflow.hpp | 32 +++++++ + test-suite/quantlibtestsuite.cpp | 2 + + test-suite/testsuite.vcxproj | 2 + + test-suite/testsuite.vcxproj.filters | 6 ++ + 5 files changed, 201 insertions(+) - Explicit casts to Real on ternary operator +commit 79d29b6403a28cec4c6714dd0b65be6193766a61 +Author: Marcin Rybacki +Date: Wed, 8 Mar 2023 13:52:56 +0100 - ql/pricingengines/vanilla/qdplusamericanengine.cpp | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) + Introduced inheritance from IndexedCashFlow. -commit 5826ac838c8d09d5817f128d7a3e15e4afac3f83 -Author: Xcelerit Dev Team -Date: Mon, 14 Nov 2022 10:08:10 +0000 + ql/cashflows/equityquantocashflow.cpp | 31 +++++++++++++++---------------- + ql/cashflows/equityquantocashflow.hpp | 33 ++++++++++++--------------------- + 2 files changed, 27 insertions(+), 37 deletions(-) - Initialises large constant arrays as double, reducing compile time +commit 61d2ee807403fb8eb02aaa7e1a99051d8d869e92 +Author: Marcin Rybacki +Date: Tue, 7 Mar 2023 22:29:52 +0100 - ql/experimental/math/zigguratrng.cpp | 2 +- - ql/math/factorial.cpp | 2 +- - ql/pricingengines/vanilla/exponentialfittinghestonengine.cpp | 4 ++-- - 3 files changed, 4 insertions(+), 4 deletions(-) + Setting up equity quanto cash flow and the pricer. -commit a9e30354e273df2fc676b2cca19ca4ab135d5cd9 -Author: Xcelerit Dev Team -Date: Mon, 14 Nov 2022 10:04:36 +0000 + ql/cashflows/equityquantocashflow.cpp | 20 ++++++++++++++------ + ql/cashflows/equityquantocashflow.hpp | 2 ++ + 2 files changed, 16 insertions(+), 6 deletions(-) - Removes needless type specification for complex norm +commit a1d34ac730e96cc3b4a395eccd6b7f3515604f3c +Author: Marcin Rybacki +Date: Tue, 7 Mar 2023 18:18:56 +0100 - ql/math/autocovariance.hpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Added equity quanto cash flow. -commit 05d1338877fbe25ce7d15d4052085c679aff1c05 -Author: Oleg Kulkov -Date: Sun, 13 Nov 2022 20:01:32 +0100 + QuantLib.vcxproj | 2 + + QuantLib.vcxproj.filters | 6 ++ + ql/cashflows/equityquantocashflow.cpp | 100 +++++++++++++++++++++++++++++ + ql/cashflows/equityquantocashflow.hpp | 107 +++++++++++++++++++++++++++++++ + ql/instruments/equitytotalreturnswap.cpp | 39 +++++------ + ql/instruments/equitytotalreturnswap.hpp | 3 + + 6 files changed, 234 insertions(+), 23 deletions(-) - new example showing the bond with cahnging notional +commit 9f2806534f7a943b61b143e26abe8b42e0bb9d91 +Merge: 1fb6118ce 85001dbf9 +Author: Luigi Ballabio +Date: Mon, 6 Mar 2023 15:42:45 +0100 - Examples/AmortizingBonds/AmortizingBond.cpp | 178 ++++++++++++++++++++++++++++ - Examples/AmortizingBonds/CMakeLists.txt | 2 + - Examples/AmortizingBonds/ReadMe.txt | 1 + - ql/instruments/bond.cpp | 1 + - 4 files changed, 182 insertions(+) + Equity total return swap (#1604) -commit 3cfa4eb26085f0f65d3686fb6aa964937f64ea83 +commit 1fb6118cee883aa414c3eec52479f63d23c3f740 +Merge: 1f44afeb5 3875659da Author: Luigi Ballabio -Date: Sun, 13 Nov 2022 14:53:58 +0100 +Date: Mon, 6 Mar 2023 15:36:36 +0100 - Remove custom macros + Change FdmLinearOpIterator to pass by value and move (#1609) - ql/indexes/inflationindex.hpp | 10 ---------- - test-suite/inflation.cpp | 7 ------- - test-suite/inflationcapfloor.cpp | 4 ---- - test-suite/inflationcpibond.cpp | 4 ---- - test-suite/inflationcpicapfloor.cpp | 19 ++----------------- - test-suite/inflationcpiswap.cpp | 8 -------- - 6 files changed, 2 insertions(+), 50 deletions(-) - -commit 55083131193436c716eac7f7364d052bc92bff71 -Author: Luigi Ballabio -Date: Sun, 13 Nov 2022 14:36:36 +0100 - - Document deprecated data member - - ql/experimental/inflation/genericindexes.hpp | 4 ++-- - ql/indexes/inflation/aucpi.hpp | 4 ++-- - ql/indexes/inflation/euhicp.hpp | 8 +++---- - ql/indexes/inflation/frhicp.hpp | 4 ++-- - ql/indexes/inflation/ukrpi.hpp | 4 ++-- - ql/indexes/inflation/uscpi.hpp | 4 ++-- - ql/indexes/inflation/zacpi.hpp | 4 ++-- - ql/indexes/inflationindex.cpp | 32 ++++++++++++++-------------- - ql/indexes/inflationindex.hpp | 21 ++++++------------ - 9 files changed, 39 insertions(+), 46 deletions(-) - -commit 99ba217022d77679f3fa3be2789c6b4f4eb6d2d2 -Author: Luigi Ballabio -Date: Sun, 13 Nov 2022 14:16:12 +0100 - - Document deprecated method - - ql/indexes/inflationindex.cpp | 5 +++-- - ql/indexes/inflationindex.hpp | 21 +++++++-------------- - ql/instruments/zerocouponinflationswap.cpp | 2 -- - test-suite/inflation.cpp | 4 ++-- - 4 files changed, 12 insertions(+), 20 deletions(-) - -commit c2a476179454926a88ac568ab19e1a103a9a1d69 -Author: Luigi Ballabio -Date: Fri, 11 Nov 2022 23:39:08 +0100 - - Document deprecated constructors, avoid some deprecated calls - - ql/experimental/inflation/genericindexes.hpp | 30 ++++++++-------- - ql/indexes/inflation/aucpi.hpp | 23 ++++++------ - ql/indexes/inflation/euhicp.hpp | 52 +++++++++++++++------------- - ql/indexes/inflation/frhicp.hpp | 20 ++++++----- - ql/indexes/inflation/ukrpi.hpp | 20 ++++++----- - ql/indexes/inflation/uscpi.hpp | 30 ++++++++-------- - ql/indexes/inflation/zacpi.hpp | 20 ++++++----- - ql/indexes/inflationindex.hpp | 39 ++++++--------------- - test-suite/inflation.cpp | 43 ++++++++++------------- - test-suite/inflationcpibond.cpp | 7 +--- - test-suite/inflationcpicapfloor.cpp | 8 +---- - test-suite/inflationcpiswap.cpp | 8 +---- - 12 files changed, 136 insertions(+), 164 deletions(-) - -commit af69ee35a8e446072e2b7125b7af6b62c13e5776 -Merge: 0b0caf116 934764f1f -Author: Luigi Ballabio -Date: Fri, 11 Nov 2022 20:55:45 +0100 - - Make `Handle` default constructor non-explicit. (#1523) - -commit 0b0caf116cbce50e6512c1d7d91c94abb9fc0dda -Merge: 7d865a7c1 40e0adfe9 -Author: Luigi Ballabio -Date: Fri, 11 Nov 2022 19:18:49 +0100 - - Fix declaration and error message for tanh-sinh fallback (#1522) - -commit 934764f1fbd47d28253db0e4c8e74ac2d06c3271 -Author: Luigi Ballabio -Date: Fri, 11 Nov 2022 16:48:04 +0100 - - Use shorter syntax - - ql/indexes/bmaindex.hpp | 3 +- - ql/indexes/ibor/aonia.hpp | 3 +- - ql/indexes/ibor/audlibor.hpp | 3 +- - ql/indexes/ibor/bbsw.hpp | 21 ++--- - ql/indexes/ibor/bibor.hpp | 24 ++---- - ql/indexes/ibor/bkbm.hpp | 21 ++--- - ql/indexes/ibor/cadlibor.hpp | 6 +- - ql/indexes/ibor/cdor.hpp | 3 +- - ql/indexes/ibor/chflibor.hpp | 6 +- - ql/indexes/ibor/dkklibor.hpp | 3 +- - ql/indexes/ibor/eonia.hpp | 3 +- - ql/indexes/ibor/estr.hpp | 3 +- - ql/indexes/ibor/euribor.hpp | 96 ++++++++-------------- - ql/indexes/ibor/eurlibor.hpp | 51 ++++-------- - ql/indexes/ibor/fedfunds.hpp | 3 +- - ql/indexes/ibor/gbplibor.hpp | 9 +- - ql/indexes/ibor/jibar.hpp | 3 +- - ql/indexes/ibor/jpylibor.hpp | 6 +- - ql/indexes/ibor/libor.hpp | 6 +- - ql/indexes/ibor/mosprime.hpp | 3 +- - ql/indexes/ibor/nzdlibor.hpp | 3 +- - ql/indexes/ibor/nzocr.hpp | 3 +- - ql/indexes/ibor/pribor.hpp | 3 +- - ql/indexes/ibor/robor.hpp | 3 +- - ql/indexes/ibor/seklibor.hpp | 3 +- - ql/indexes/ibor/shibor.hpp | 2 +- - ql/indexes/ibor/sofr.hpp | 3 +- - ql/indexes/ibor/sonia.hpp | 3 +- - ql/indexes/ibor/thbfix.hpp | 3 +- - ql/indexes/ibor/tibor.hpp | 3 +- - ql/indexes/ibor/tona.hpp | 3 +- - ql/indexes/ibor/trlibor.hpp | 3 +- - ql/indexes/ibor/usdlibor.hpp | 9 +- - ql/indexes/ibor/wibor.hpp | 3 +- - ql/indexes/ibor/zibor.hpp | 3 +- - ql/indexes/iborindex.hpp | 5 +- - ql/indexes/swap/chfliborswap.hpp | 3 +- - ql/indexes/swap/euriborswap.hpp | 9 +- - ql/indexes/swap/eurliborswap.hpp | 9 +- - ql/indexes/swap/gbpliborswap.hpp | 3 +- - ql/indexes/swap/jpyliborswap.hpp | 10 +-- - ql/indexes/swap/usdliborswap.hpp | 6 +- - .../credit/defaultdensitystructure.hpp | 12 +-- - ql/termstructures/credit/hazardratestructure.hpp | 12 +-- - .../credit/interpolateddefaultdensitycurve.hpp | 25 +++--- - .../credit/interpolatedhazardratecurve.hpp | 25 +++--- - .../interpolatedsurvivalprobabilitycurve.hpp | 24 +++--- - ql/termstructures/credit/piecewisedefaultcurve.hpp | 37 ++++----- - .../credit/survivalprobabilitystructure.hpp | 12 +-- - ql/termstructures/defaulttermstructure.hpp | 12 +-- - .../volatility/optionlet/optionletstripper.hpp | 2 +- - .../volatility/optionlet/optionletstripper1.hpp | 2 +- - ql/termstructures/yield/discountcurve.hpp | 20 ++--- - ql/termstructures/yield/forwardcurve.hpp | 21 +++-- - ql/termstructures/yield/forwardstructure.hpp | 8 +- - .../yield/interpolatedsimplezerocurve.hpp | 20 ++--- - ql/termstructures/yield/oisratehelper.hpp | 4 +- - .../yield/overnightindexfutureratehelper.hpp | 6 +- - ql/termstructures/yield/piecewiseyieldcurve.hpp | 31 +++---- - ql/termstructures/yield/ratehelpers.hpp | 22 ++--- - ql/termstructures/yield/zerocurve.hpp | 21 +++-- - ql/termstructures/yield/zeroyieldstructure.hpp | 8 +- - ql/termstructures/yieldtermstructure.hpp | 8 +- - 63 files changed, 284 insertions(+), 419 deletions(-) - -commit 12fe0e94b6350906b9ddff733ee1aa9d66b775ee -Author: Luigi Ballabio -Date: Fri, 11 Nov 2022 15:10:43 +0100 - - Make Handle default constructor non-explicit. - - This allows using {} for default parameters. +commit 3875659da9ce8273fbc6aebac7dd740ac318980c +Author: Jonathan Sweemer +Date: Sat, 4 Mar 2023 02:53:15 +0000 - ql/handle.hpp | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) + Change FdmLinearOpIterator to pass by value and move -commit 8074fddad00e91734f81062d2c83859c7ed261d3 -Author: Luigi Ballabio -Date: Fri, 11 Nov 2022 13:16:59 +0100 + ql/methods/finitedifferences/operators/fdmlinearopiterator.hpp | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) - Never mind forward declarations. - - This reverts commit 0555333bd7ffd269c62b431aac51cc387dd3721c. +commit 1f44afeb57b3b9dee1ee869ba24ece72a73ad3c4 +Merge: 512002bd1 20318a895 +Author: Luigi Ballabio +Date: Sat, 4 Mar 2023 10:01:37 +0100 - ql/cashflows/cpicouponpricer.cpp | 1 - - ql/cashflows/inflationcouponpricer.hpp | 1 - - ql/indexes/inflationindex.hpp | 4 +--- - ql/instruments/inflationcapfloor.cpp | 1 - - ql/instruments/zerocouponinflationswap.cpp | 1 - - ql/pricingengines/inflation/inflationcapfloorengines.cpp | 1 - - 6 files changed, 1 insertion(+), 8 deletions(-) + Add operator*() to FdmLinearOpIterator (#1603) -commit f3d9eecabfd8b20f25454b578bc2264aa9f8d6b8 +commit 512002bd13e2e835522313b202e1cf633a5744bf +Merge: 13f8acd77 ae800a157 Author: Luigi Ballabio -Date: Fri, 11 Nov 2022 10:50:32 +0100 - - More tests for interpolated fixings, removed redundant ones +Date: Sat, 4 Mar 2023 09:59:31 +0100 - test-suite/CMakeLists.txt | 2 - - test-suite/Makefile.am | 2 - - test-suite/inflation.cpp | 182 ++++++++++++++----- - test-suite/inflation.hpp | 3 +- - test-suite/inflationzciisinterpolation.cpp | 283 ----------------------------- - test-suite/inflationzciisinterpolation.hpp | 39 ---- - test-suite/quantlibtestsuite.cpp | 2 - - test-suite/testsuite.vcxproj | 2 - - test-suite/testsuite.vcxproj.filters | 6 - - 9 files changed, 143 insertions(+), 378 deletions(-) + Add suppressions for clang-tidy 16 (#1602) -commit 0555333bd7ffd269c62b431aac51cc387dd3721c +commit ae800a1575fbf50c5183a141dbabc08f02c408cb Author: Luigi Ballabio -Date: Thu, 10 Nov 2022 18:37:55 +0100 +Date: Fri, 3 Mar 2023 12:57:10 +0100 - Use forward declarations where possible + Use unity build for clang-tidy CI checks - ql/cashflows/cpicouponpricer.cpp | 1 + - ql/cashflows/inflationcouponpricer.hpp | 1 + - ql/indexes/inflationindex.hpp | 1 - - ql/instruments/inflationcapfloor.cpp | 1 + - ql/instruments/zerocouponinflationswap.cpp | 1 + - ql/pricingengines/inflation/inflationcapfloorengines.cpp | 1 + - 6 files changed, 5 insertions(+), 1 deletion(-) + CMakePresets.json | 1 + + 1 file changed, 1 insertion(+) -commit 7d865a7c15584df9c74941fad06c8f6e00d30045 -Merge: efe46c1e7 5dc08d220 +commit e793072f6b0c833c206fefdb40bf6094c3001903 Author: Luigi Ballabio -Date: Thu, 10 Nov 2022 14:48:24 +0100 - - add equality operators for matrix (#1521) - -commit 5dc08d2202e420c10278f16fc66b0295a446c39f -Author: Matthias Groncki -Date: Thu, 10 Nov 2022 17:22:15 +0700 +Date: Fri, 3 Mar 2023 12:25:02 +0100 - add equality operators for matrix + Upgrade to clang-tidy 15 - ql/math/matrix.hpp | 12 ++++++++++++ - 1 file changed, 12 insertions(+) + .github/workflows/tidy.yml | 2 +- + CMakePresets.json | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) -commit efe46c1e7e086ecb96b310639a67b900b4132bb5 -Merge: 00ae31ebf e4af81902 +commit fd640899c70eeb6adf2c0f2f726340d19b88147f Author: Luigi Ballabio -Date: Thu, 10 Nov 2022 00:47:13 +0100 +Date: Fri, 3 Mar 2023 17:08:34 +0100 + + Suppress a couple of warnings from clang-tidy 15 - Expose underlying rate in capped/floored YoY inflation coupon (#1520) + .clang-tidy | 2 ++ + 1 file changed, 2 insertions(+) -commit 00ae31ebfd38d596091cd0d7278d1be504f76920 -Merge: 864d0edad 50c5c3036 +commit 13f8acd773574fa43a702847b363ee4584897fb0 Author: Luigi Ballabio -Date: Wed, 9 Nov 2022 23:59:22 +0100 +Date: Fri, 3 Mar 2023 12:18:23 +0100 - Avoid out-of-memory access in empty `Exercise` instance (#1519) + CI builds use all 3 cores on Mac runners -commit e4af819025d50bbc7f0d13c4873f1104686fd69d -Author: Luigi Ballabio -Date: Wed, 9 Nov 2022 17:22:44 +0100 + .github/workflows/macos-nondefault.yml | 2 +- + .github/workflows/macos.yml | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) - Expose underlying rate in capped/floored YoY inflation coupon +commit 81f905373ccfb27ed52ae822c197a7185e44165d +Author: Jonathan Sweemer +Date: Sat, 25 Feb 2023 02:45:04 +0000 - ql/cashflows/capflooredinflationcoupon.cpp | 33 +++++++++++------------------- - ql/cashflows/capflooredinflationcoupon.hpp | 3 +++ - 2 files changed, 15 insertions(+), 21 deletions(-) + Add functions taking rvalue reference -commit 50c5c3036c72bdbe60fd7af91feda529d888680e -Author: Luigi Ballabio -Date: Wed, 9 Nov 2022 16:51:24 +0100 + ql/math/array.hpp | 257 ++++++++++++++++++++++++++++++++++++++++++++++++++- + test-suite/array.cpp | 181 ++++++++++++++++++++++++++++++++---- + test-suite/array.hpp | 1 + + 3 files changed, 421 insertions(+), 18 deletions(-) - Avoid out-of-memory access in empty Exercise instance +commit 85001dbf98bc0bf5895ece4b0383770dabdda396 +Author: Marcin Rybacki +Date: Fri, 24 Feb 2023 11:22:12 +0100 - ql/exercise.cpp | 5 +++++ - ql/exercise.hpp | 2 +- - 2 files changed, 6 insertions(+), 1 deletion(-) + Day counter and calendar inspectors should return a const ref. -commit 864d0edad3e6accaafa77e7b828eb392a4e55833 -Merge: ff382343c 97506f7b5 -Author: Luigi Ballabio -Date: Wed, 9 Nov 2022 16:08:34 +0100 + ql/instruments/equitytotalreturnswap.hpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) - Use `Handle` in constant CPI volatility instead of immutable `Real` value (#1518) +commit 9c23cf8e5ded7118cb7232f8f80ca5095d8bac59 +Author: Marcin Rybacki +Date: Fri, 24 Feb 2023 11:12:17 +0100 -commit ff382343c2bd5f51923a4ee11266ca12d757562c -Merge: 317e3e2a2 83fec02d4 -Author: Luigi Ballabio -Date: Wed, 9 Nov 2022 15:23:46 +0100 + Added docstrings. - Add King Charles III coronation holiday to UK calendar (#1516) + ql/instruments/equitytotalreturnswap.cpp | 4 +++- + ql/instruments/equitytotalreturnswap.hpp | 18 ++++++++++++++++-- + 2 files changed, 19 insertions(+), 3 deletions(-) -commit 317e3e2a2fda701f04798ed4333e19fa3ec1a920 -Merge: 3c7c5b93c e25424573 -Author: Luigi Ballabio -Date: Wed, 9 Nov 2022 14:44:24 +0100 +commit 1df36a751ff6bab5a0f1f25959a8edfd28970050 +Author: Marcin Rybacki +Date: Thu, 23 Feb 2023 20:56:09 +0100 - Add holiday for National Day of Mourning to Australian calendar (#1517) + Removed hard-coded test values. -commit e25424573d0bdfa2231dea977ce6ba38997261a2 -Author: Fredrik Gerdin Börjesson -Date: Wed, 9 Nov 2022 12:41:24 +0100 + test-suite/equitytotalreturnswap.cpp | 31 ++++++++++--------------------- + 1 file changed, 10 insertions(+), 21 deletions(-) - Add AU holiday for national day of mourning +commit da725fddfc0cca12053f0439e199773cd9334137 +Author: Marcin Rybacki +Date: Thu, 23 Feb 2023 19:26:03 +0100 - ql/time/calendars/australia.cpp | 4 +++- - ql/time/calendars/australia.hpp | 1 + - 2 files changed, 4 insertions(+), 1 deletion(-) + Removed unused variable. -commit 97506f7b55f96529bbb772ac2918d7c83513c3f2 -Author: Luigi Ballabio -Date: Wed, 9 Nov 2022 11:10:00 +0100 + test-suite/equitytotalreturnswap.cpp | 1 - + 1 file changed, 1 deletion(-) - Use correct payment calendar +commit 754bf506a9da90055b53eae425c720c27013a0eb +Author: Marcin Rybacki +Date: Thu, 23 Feb 2023 18:28:17 +0100 - ql/instruments/cpicapfloor.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Added new files in CMakeLists and Makefile. -commit 83fec02d4030d937f95212c79c1368e9288b40d9 -Author: Fredrik Gerdin Börjesson -Date: Wed, 9 Nov 2022 10:57:57 +0100 + ql/CMakeLists.txt | 2 ++ + ql/instruments/Makefile.am | 2 ++ + ql/instruments/all.hpp | 1 + + test-suite/CMakeLists.txt | 2 ++ + test-suite/Makefile.am | 2 ++ + 5 files changed, 9 insertions(+) - Add comment on special holidays in docstring +commit fa824e8820285c376122b9a03a5ecc5b423f708f +Author: Marcin Rybacki +Date: Thu, 23 Feb 2023 17:42:03 +0100 - ql/time/calendars/unitedkingdom.hpp | 3 +++ - 1 file changed, 3 insertions(+) + Uncomment accidental changes in testsuite file. -commit 1d12e222258605567a65382d625d42ad5c5e9cab -Author: Luigi Ballabio -Date: Wed, 9 Nov 2022 10:24:06 +0100 + test-suite/quantlibtestsuite.cpp | 256 +++++++++++++++++++-------------------- + 1 file changed, 128 insertions(+), 128 deletions(-) - Use Handle in constant CPI volatility +commit 7586a793e09c31e1bccdb3600554d27e2fcfd36b +Author: Marcin Rybacki +Date: Thu, 23 Feb 2023 17:40:48 +0100 - .../volatility/inflation/constantcpivolatility.cpp | 19 ++++++++++++++++--- - .../volatility/inflation/constantcpivolatility.hpp | 17 +++++++++++++---- - 2 files changed, 29 insertions(+), 7 deletions(-) + Added a few more unit tests. -commit f3d1e609c3fdbb26e3dfca1c8e3312894c2c721a -Author: Fredrik Gerdin Börjesson -Date: Wed, 9 Nov 2022 10:12:32 +0100 + ql/instruments/equitytotalreturnswap.cpp | 4 +- + test-suite/equitytotalreturnswap.cpp | 220 ++++++++++++++++++++++++++++--- + test-suite/equitytotalreturnswap.hpp | 4 + + 3 files changed, 207 insertions(+), 21 deletions(-) - Add King Charles III coronation holiday to UK cal +commit e41c529a10ca6beeee80146586b95e20f6b506f9 +Author: Marcin Rybacki +Date: Wed, 22 Feb 2023 17:35:25 +0100 - ql/time/calendars/unitedkingdom.cpp | 2 ++ - 1 file changed, 2 insertions(+) + Implemented fair margin calculations. -commit 3c7c5b93c1082bbbe5cebae406c1b156fd8efa3e -Merge: f6d65ce9f 3180e5718 -Author: Luigi Ballabio -Date: Tue, 8 Nov 2022 09:34:33 +0100 + ql/instruments/equitytotalreturnswap.cpp | 9 +++++++++ + ql/instruments/equitytotalreturnswap.hpp | 11 ++++++++--- + test-suite/equitytotalreturnswap.cpp | 18 +++++++++++------- + test-suite/equitytotalreturnswap.hpp | 2 +- + 4 files changed, 29 insertions(+), 11 deletions(-) - Remove dependency on BOOST_FOREACH (#1515) +commit 1a51af00bbbfb7f259161875de1a12f57e5ce2b8 +Author: Marcin Rybacki +Date: Wed, 22 Feb 2023 11:34:19 +0100 -commit 3180e5718906be26a3b4184ce23b7dd20954eeff -Author: Jonathan Sweemer -Date: Mon, 7 Nov 2022 21:21:04 +0900 + Working on unit tests for a TRS. - Remove dependency on BOOST_FOREACH + ql/instruments/equitytotalreturnswap.cpp | 2 +- + test-suite/equitytotalreturnswap.cpp | 98 +++++++++++- + test-suite/quantlibtestsuite.cpp | 256 +++++++++++++++---------------- + 3 files changed, 219 insertions(+), 137 deletions(-) - ql/models/volatility/garch.cpp | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) +commit a706374608efc551e14eb6f400a17f3c62ba1425 +Author: Marcin Rybacki +Date: Tue, 21 Feb 2023 13:58:09 +0100 -commit f6d65ce9fac26f8a7eb36796f898079234b6b4af -Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> -Date: Sun, 6 Nov 2022 06:16:43 +0000 + Templatized interest leg creation. - Automated fixes by clang-tidy + ql/instruments/equitytotalreturnswap.cpp | 34 +++++++++----------------------- + 1 file changed, 9 insertions(+), 25 deletions(-) - ql/math/integrals/gaussianquadratures.hpp | 5 +- - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 78 +++++++++++----------- - ql/pricingengines/vanilla/qdplusamericanengine.cpp | 37 ++++------ - ql/pricingengines/vanilla/qdplusamericanengine.hpp | 11 ++- - test-suite/americanoption.cpp | 10 ++- - 5 files changed, 68 insertions(+), 73 deletions(-) +commit 92281bc4ce2510f1c441f54afa3bfc86caded98c +Author: Marcin Rybacki +Date: Tue, 21 Feb 2023 13:51:16 +0100 -commit 549cd6dfa1679b31c9eb7ce7bc65bd6f64a84e72 -Merge: 4a96abc27 a1a589398 -Author: Luigi Ballabio -Date: Sun, 6 Nov 2022 14:10:00 +0100 + Removed commented section. - fixed QD+ fixed point engine for high precision Gauss-Lobatto integration (#1512) + ql/instruments/equitytotalreturnswap.cpp | 6 ++---- + 1 file changed, 2 insertions(+), 4 deletions(-) -commit a1a589398c594afcc8d41b84fae725ef43a89a7e -Author: klausspanderen -Date: Sat, 5 Nov 2022 16:02:25 +0100 +commit a7340f85c356b0605795cbd11f068a477fabebc5 +Author: Marcin Rybacki +Date: Tue, 21 Feb 2023 13:49:05 +0100 - fixed QD+ fixed point engine with high precision Lobatto integration + Fixed build - rearranged constructor arguments. - Examples/EquityOption/EquityOption.cpp | 4 - - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 51 +++++++-- - test-suite/americanoption.cpp | 137 +++++++++++++++++++++-- - test-suite/americanoption.hpp | 1 + - 4 files changed, 170 insertions(+), 23 deletions(-) + ql/instruments/equitytotalreturnswap.cpp | 29 ++++++++++++++++------------- + ql/instruments/equitytotalreturnswap.hpp | 10 +++++----- + 2 files changed, 21 insertions(+), 18 deletions(-) -commit 40e0adfe958a48619a2a01d7fefc209bb9e0444a -Author: Luigi Ballabio -Date: Fri, 4 Nov 2022 11:30:04 +0100 +commit 9ab9dc52d6c6e90367f874f183685a7e6d84a296 +Author: Marcin Rybacki +Date: Tue, 21 Feb 2023 13:30:56 +0100 - Fix declaration and error message for tanh-sinh fallback + Added equity total return swap related files. - ql/math/integrals/tanhsinhintegral.hpp | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) + QuantLib.vcxproj | 4 +- + QuantLib.vcxproj.filters | 6 + + ql/instruments/equitytotalreturnswap.cpp | 197 +++++++++++++++++++++++++++++++ + ql/instruments/equitytotalreturnswap.hpp | 113 ++++++++++++++++++ + test-suite/equityindex.cpp | 1 - + test-suite/equitytotalreturnswap.cpp | 89 ++++++++++++++ + test-suite/equitytotalreturnswap.hpp | 32 +++++ + test-suite/quantlibtestsuite.cpp | 2 + + test-suite/testsuite.vcxproj | 4 +- + test-suite/testsuite.vcxproj.filters | 8 +- + 10 files changed, 452 insertions(+), 4 deletions(-) -commit 4a96abc278f311c8384b2e4d42491ee354cd5d3f -Merge: 5868429ef 7258eb182 -Author: Luigi Ballabio -Date: Fri, 4 Nov 2022 11:18:07 +0100 +commit 20318a895077108dac5eb45cae8513246d26cab1 +Author: Jonathan Sweemer +Date: Tue, 21 Feb 2023 19:17:03 +0900 - Replace boost::thread with std::thread (#1504) + Add operator*() to FdmLinearOpIterator -commit 7258eb182042098ef7cf0541df26bfe27c76c9e2 + ql/methods/finitedifferences/operators/fdmlinearopiterator.hpp | 5 +++++ + 1 file changed, 5 insertions(+) + +commit 2ff6eb9af92bce5f3e284087251bd5ce5ade665d Author: Jonathan Sweemer -Date: Fri, 28 Oct 2022 21:50:06 +0900 +Date: Sat, 18 Feb 2023 17:08:18 +0900 - Replace boost::thread with std::thread + Add suppressions for clang-tidy 16 - CMakeLists.txt | 26 +++++------------ - Examples/Makefile.am | 2 +- - acinclude.m4 | 69 +++++++++++++++------------------------------- - configure.ac | 16 ++--------- - ql/CMakeLists.txt | 3 -- - ql/auto_link.hpp | 11 -------- - ql/patterns/observable.cpp | 12 ++++---- - ql/patterns/observable.hpp | 41 ++++++++++++++------------- - quantlib-config.in | 2 +- - quantlib.pc.in | 2 +- - test-suite/Makefile.am | 4 +-- - test-suite/observable.cpp | 33 +++++++++++----------- - 12 files changed, 79 insertions(+), 142 deletions(-) + .clang-tidy | 10 ++++++++++ + 1 file changed, 10 insertions(+) -commit 5868429ef3b0e1f0224016b1bcf14345e1e8642c -Merge: 7876651df 2f5650e0c +commit 422ae3737555c2df4840d9d99a9948049b465d50 +Merge: b71fde5f8 9b2fd49f2 Author: Luigi Ballabio -Date: Wed, 2 Nov 2022 23:41:27 +0100 +Date: Tue, 14 Feb 2023 08:55:46 +0100 - Add workaround for GCC bug (#1511) + Add Australian calendar for ASX (#1599) -commit 2f5650e0cf0a0aee22556feeaaa4854354293d42 -Author: Jonathan Sweemer -Date: Tue, 1 Nov 2022 12:10:44 +0900 +commit 9b2fd49f2080ab16e3c16a23916ce17a5b4df149 +Author: Trent Maetzold +Date: Mon, 13 Feb 2023 11:29:07 -0600 - Add workaround for GCC bug + Rename ASX calendar from Exchange - ql/patterns/singleton.hpp | 23 ++++++++++++++++++++--- - 1 file changed, 20 insertions(+), 3 deletions(-) + ql/time/calendars/australia.cpp | 10 +++++----- + ql/time/calendars/australia.hpp | 4 ++-- + 2 files changed, 7 insertions(+), 7 deletions(-) -commit 7876651df25b6efc91582c19a8e2446afe300eae -Author: Luigi Ballabio -Date: Wed, 2 Nov 2022 11:34:50 +0100 +commit 1d26d6c89835b17c6c4c04b7d5be1dadd76bded1 +Author: Trent Maetzold +Date: Fri, 10 Feb 2023 21:25:31 -0600 - Disable high-precision engine if not available + Add Australia.Exchange calendar for ASX - Examples/EquityOption/EquityOption.cpp | 5 +++++ - 1 file changed, 5 insertions(+) + ql/time/calendars/australia.cpp | 54 +++++++++++++++++++++++++++++++++++++---- + ql/time/calendars/australia.hpp | 17 +++++++++---- + 2 files changed, 61 insertions(+), 10 deletions(-) -commit 608a9c2323cec7609d05134ac030735590252899 -Merge: d2f413940 821f1a10f +commit b71fde5f892d7c292505bab79033ad29ef18f732 +Merge: 44a192199 0ee1be072 Author: Luigi Ballabio -Date: Tue, 1 Nov 2022 17:15:45 +0100 +Date: Fri, 10 Feb 2023 23:13:06 +0100 - Add full tests and nondefault tests to weekly schedule (#1508) + Fixing consistent Real type usage for AAD compatibility (#1598) -commit d2f413940ada8a622ddddbfc4a941ad3151cfbd5 -Merge: 7fa23eea8 3ca376438 -Author: Luigi Ballabio -Date: Tue, 1 Nov 2022 17:14:53 +0100 +commit 0ee1be07221ae3f630c97f1b2a30d5ea1a590889 +Author: Xcelerit Dev Team <107129969+xcelerit-dev@users.noreply.github.com> +Date: Fri, 10 Feb 2023 16:02:05 +0000 - avoid bug in early versions of tanh_sinh implementation (#1507) + Further fixes for Real datatype -commit 821f1a10f6b1ad199f7a24e55c973af7a4e8f77e -Author: Jonathan Sweemer -Date: Tue, 1 Nov 2022 21:33:16 +0900 + ql/pricingengines/barrier/analyticbarrierengine.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) - Add full tests and nondefault tests to weekly schedule +commit e26e349457a947437e3a6bf35e58e356684b68e1 +Author: Xcelerit Dev Team <107129969+xcelerit-dev@users.noreply.github.com> +Date: Fri, 10 Feb 2023 14:54:04 +0000 - .github/workflows/linux-full-tests.yml | 5 ++++- - .github/workflows/linux-nondefault.yml | 5 ++++- - .github/workflows/macos-nondefault.yml | 5 ++++- - 3 files changed, 12 insertions(+), 3 deletions(-) + Fixes consistent Real type for ternary operator -commit 3ca376438ca7ae600abec5813abba9e785d21e04 -Author: klausspanderen -Date: Tue, 1 Nov 2022 13:07:20 +0100 + ql/pricingengines/barrier/analyticbarrierengine.cpp | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) - avoid bug in early versions of tanh_sinh implementation +commit 44a1921996e291947dc78a0e94f334130587f676 +Merge: ef7b5e414 115fd75c4 +Author: Luigi Ballabio +Date: Fri, 10 Feb 2023 12:21:12 +0100 - ql/math/integrals/tanhsinhintegral.hpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Move clang-analyzer-optin.cplusplus.VirtualCall suppressions to comments (#1473) -commit 7fa23eea8097fcf37ad8ef915a2ed34ef4e4f8e6 +commit ef7b5e414cc63794a28e51928ba34e917d8127f0 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> -Date: Tue, 1 Nov 2022 01:15:09 +0000 +Date: Fri, 10 Feb 2023 11:18:21 +0000 Update copyright list in license - LICENSE.TXT | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + LICENSE.TXT | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) -commit 3e74b288798103072d074b5bddaa50a90bd24eb9 -Merge: 88a7cc8ba 2a2e4f100 +commit 7a7ca9fb19e1cc7fe018ce91ab5a7981b37a3ea3 +Merge: 5086c8718 38a4f004f Author: Luigi Ballabio -Date: Tue, 1 Nov 2022 02:14:48 +0100 +Date: Fri, 10 Feb 2023 10:54:49 +0100 - QD+ fixed point American option engine (#1495) + Improve naming of swaption volatility structures (#1589) -commit 2a2e4f100cd14b5e65ba44d443383590d2366953 +commit 5086c8718aba7ef1ef96ea85a7ce15a4100840f6 +Merge: 4fbc7c06f f466112cc Author: Luigi Ballabio -Date: Tue, 1 Nov 2022 00:02:16 +0100 - - Add to equity option example +Date: Fri, 10 Feb 2023 09:38:12 +0100 - Examples/EquityOption/EquityOption.cpp | 43 +++++++++++++++++++++++++++++----- - 1 file changed, 37 insertions(+), 6 deletions(-) + Equity index (#1590) -commit babf9e562a31164462a911516054bc51cf270568 +commit 38a4f004f0eaf370be96c685bbeefbafdd6c975d Author: Luigi Ballabio -Date: Mon, 31 Oct 2022 23:53:36 +0100 +Date: Thu, 9 Feb 2023 12:21:11 +0100 - Move factory methods to engine + Add deprecated attribute to enable warnings - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 38 +++++++++++++----------- - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 14 ++++----- - test-suite/americanoption.cpp | 4 +-- - 3 files changed, 27 insertions(+), 29 deletions(-) + .../volatility/noarbsabrswaptionvolatilitycube.hpp | 2 ++ + ql/qldefines.hpp | 6 ++++++ + .../swaption/interpolatedswaptionvolatilitycube.hpp | 4 ++-- + .../volatility/swaption/sabrswaptionvolatilitycube.hpp | 11 +++++++---- + 4 files changed, 17 insertions(+), 6 deletions(-) -commit 71c6b4d18671ab631928ebbc0286b01d89311808 +commit f466112cc94eedd165e0b20982f9ebea8ca02193 Author: Luigi Ballabio -Date: Fri, 28 Oct 2022 13:13:46 +0200 - - Format documentation - - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 34 +++++++++++------------- - 1 file changed, 16 insertions(+), 18 deletions(-) +Date: Thu, 9 Feb 2023 17:37:49 +0100 -commit 88a7cc8ba874a4352074ed8502eb82f9ce1e4ce9 -Merge: df42c2adb 26e4678d9 -Author: Luigi Ballabio -Date: Fri, 28 Oct 2022 12:16:33 +0200 + Rename variable - Check and retrieve inflation fixings on first day of inflation period (#1503) + ql/indexes/equityindex.cpp | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) -commit 7ddb55c0f1ee59e0a1f37a67d0ef7efdd80519cc -Author: Luigi Ballabio -Date: Fri, 28 Oct 2022 12:06:39 +0200 +commit a4c8efdc8bb47e7c39fcf459867cfda9d655917e +Author: Marcin Rybacki +Date: Thu, 9 Feb 2023 17:08:41 +0100 - Avoid static data members + Implemented PR feedback. - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 21 ++++++--------------- - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 4 ---- - 2 files changed, 6 insertions(+), 19 deletions(-) + ql/indexes/equityindex.cpp | 12 ++++++------ + ql/indexes/equityindex.hpp | 4 ++-- + 2 files changed, 8 insertions(+), 8 deletions(-) -commit 4b91f445eb7bb1bc588d64e0a4dd74f7e1430a13 -Author: Luigi Ballabio -Date: Fri, 28 Oct 2022 11:38:16 +0200 +commit c8954396f6bbd2b22e7882229440ab5ef2436888 +Author: Marcin Rybacki +Date: Thu, 9 Feb 2023 15:21:10 +0100 - Move documentation to the correct class + Implemented PR feedback. - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 65 ++++++++++------------ - ql/pricingengines/vanilla/qdplusamericanengine.hpp | 26 +++++---- - 2 files changed, 43 insertions(+), 48 deletions(-) + ql/indexes/equityindex.cpp | 1 + + test-suite/equityindex.cpp | 21 ++++++++++++++++++++- + test-suite/equityindex.hpp | 1 + + 3 files changed, 22 insertions(+), 1 deletion(-) -commit f2e107bad529bb5b9facc581a3b250644e603fd5 +commit 252be29b70c8ebee4fdf71087cfac36108b76587 Author: Luigi Ballabio -Date: Fri, 28 Oct 2022 11:20:47 +0200 +Date: Thu, 9 Feb 2023 11:59:23 +0100 - Clear executable bit + Add back header stubs for backward compatibility - ql/math/integrals/gaussianquadratures.hpp | 0 - 1 file changed, 0 insertions(+), 0 deletions(-) + QuantLib.vcxproj | 11 +++++--- + QuantLib.vcxproj.filters | 21 ++++++++++---- + ql/CMakeLists.txt | 11 +++++--- + ql/experimental/volatility/Makefile.am | 3 +- + ql/experimental/volatility/all.hpp | 3 +- + .../volatility/noarbsabrswaptionvolatilitycube.hpp | 6 ++-- + ql/experimental/volatility/swaptionvolcube1a.hpp | 31 ++++++++++++++++++++ + ql/termstructures/volatility/swaption/Makefile.am | 8 ++++-- + ql/termstructures/volatility/swaption/all.hpp | 6 ++-- + .../interpolatedswaptionvolatilitycube.hpp | 4 +-- + .../swaption/sabrswaptionvolatilitycube.hpp | 13 ++++----- + .../volatility/swaption/swaptionvolcube1.hpp | 33 ++++++++++++++++++++++ + .../volatility/swaption/swaptionvolcube2.hpp | 32 +++++++++++++++++++++ + 13 files changed, 149 insertions(+), 33 deletions(-) -commit df42c2adbc6b9f964edd67e7d43e9544d0c6a73d -Merge: 4c5833ae8 38da65f84 -Author: Luigi Ballabio -Date: Thu, 27 Oct 2022 19:41:53 +0200 +commit 4a44cf502b0d1b64b62f1aab30b0477ef26aefa9 +Author: Marcin Rybacki +Date: Thu, 9 Feb 2023 11:31:44 +0100 - Use fixing date correctly in inflation caplet (#1502) + Removed unused variable. -commit 26e4678d9e3645e931ebcfe24e389806fbba8813 -Author: Luigi Ballabio -Date: Thu, 27 Oct 2022 18:06:26 +0200 + test-suite/equityindex.cpp | 1 - + 1 file changed, 1 deletion(-) - Relax condition on observation lag +commit b2c5931b5cbb5e096f3328b139993f0058d623dd +Author: Marcin Rybacki +Date: Thu, 9 Feb 2023 11:20:58 +0100 - ql/instruments/zerocouponinflationswap.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Fixed case when both spot and today's fixing are not provided. -commit 84e451dc985d203dfa9d1eef48a18803d554828c -Author: Luigi Ballabio -Date: Thu, 27 Oct 2022 15:41:57 +0200 + ql/indexes/equityindex.cpp | 10 +++++++++- + test-suite/equityindex.cpp | 21 +++++++++++++++++++++ + test-suite/equityindex.hpp | 1 + + 3 files changed, 31 insertions(+), 1 deletion(-) - Check and retrieve inflation fixings on first day of period +commit 7104f1a3fab66e90657e49672609aa2c9c29b2f8 +Author: Marcin Rybacki +Date: Thu, 9 Feb 2023 10:49:02 +0100 - ql/indexes/inflationindex.cpp | 52 ++++++++++++++++++------------------------- - 1 file changed, 22 insertions(+), 30 deletions(-) + Adjusted fixing method. -commit 4c5833ae8f2ad3c4c675e1883071940ebfb2a6a0 -Author: Luigi Ballabio -Date: Thu, 27 Oct 2022 15:08:17 +0200 + ql/indexes/equityindex.cpp | 15 +++++++++----- + test-suite/equityindex.cpp | 49 +++++++++++++++++++++++++++++++--------------- + test-suite/equityindex.hpp | 1 + + 3 files changed, 44 insertions(+), 21 deletions(-) - Run coverage only on PRs and on pushes to master +commit 4fbc7c06f746b22f8f70a6cd3557159ed3b5d3bc +Merge: 9a78a9267 94f3d3d55 +Author: Luigi Ballabio +Date: Thu, 9 Feb 2023 09:06:37 +0100 - .github/workflows/coveralls.yml | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) + Add Botswanan pula currency (BWP) (#1591) -commit 38da65f849f3589fdd3107a1e6337b5384e60f5b -Author: Luigi Ballabio -Date: Thu, 27 Oct 2022 13:17:23 +0200 +commit abd125ab890721e24e52188237d5c31abe50d4c9 +Author: EUROPE\igangu +Date: Wed, 8 Feb 2023 18:42:45 +0100 - Use fixing date correctly in inflation caplet + Adding feedback - ql/cashflows/inflationcouponpricer.cpp | 11 ++++++----- - 1 file changed, 6 insertions(+), 5 deletions(-) + QuantLib.vcxproj | 2 +- + QuantLib.vcxproj.filters | 2 +- + ql/CMakeLists.txt | 2 +- + ql/experimental/volatility/Makefile.am | 2 +- + ql/experimental/volatility/all.hpp | 2 +- + ...ptionvolcube1a.hpp => noarbsabrswaptionvolatilitycube.hpp} | 8 +++++++- + .../swaption/interpolatedswaptionvolatilitycube.hpp | 2 +- + .../volatility/swaption/sabrswaptionvolatilitycube.hpp | 11 +++++++---- + test-suite/assetswap.cpp | 2 -- + 9 files changed, 20 insertions(+), 13 deletions(-) -commit d9e55201c974602303318ccfa79fbdec5c57cfe7 -Merge: b942a80d4 e06ae2203 +commit 9a78a9267e958e7e13682e90171bbf314e0b5d24 +Merge: 94b218ead cfaa06d85 Author: Luigi Ballabio -Date: Thu, 27 Oct 2022 00:12:05 +0200 +Date: Wed, 8 Feb 2023 20:31:46 +0100 - simplify singleton implementation (#1377) + Avoid NaNs in analytic barrier engine for low volatility values (#1592) -commit e06ae2203235f3d0c0b0c6c2bc28381f74649c38 +commit 115fd75c43b680f548bd72fad1921d673926dbf4 Author: Luigi Ballabio -Date: Wed, 26 Oct 2022 18:39:02 +0200 - - Update documentation +Date: Wed, 8 Feb 2023 20:10:12 +0100 - Docs/pages/config.docs | 8 -------- - 1 file changed, 8 deletions(-) + Avoid the warning in a few cases -commit 88cf055ab690bec196f18d91c894ce1ae25e2866 -Author: Luigi Ballabio -Date: Wed, 26 Oct 2022 18:37:45 +0200 + ql/cashflows/capflooredinflationcoupon.cpp | 2 ++ + ql/cashflows/capflooredinflationcoupon.hpp | 14 ++++++++++++-- + .../vanilla/analytichestonhullwhiteengine.cpp | 13 ++++++++----- + .../vanilla/analytichestonhullwhiteengine.hpp | 1 + + ql/processes/hestonslvprocess.cpp | 20 +++++++++++++------- + ql/processes/hestonslvprocess.hpp | 4 ++++ + ql/termstructures/volatility/kahalesmilesection.cpp | 14 +++++--------- + 7 files changed, 45 insertions(+), 23 deletions(-) - Remove reference to obsolete cmake option +commit 4cbc2649b24ab8ccf589e248f165fd57c665e6c2 +Author: Marcin Rybacki +Date: Wed, 8 Feb 2023 17:59:12 +0100 - CMakeLists.txt | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Added spot quote handle to the constructor. -commit 64fe40ef2b901f17428eeb9052527bb7988fb9bb -Author: Luigi Ballabio -Date: Wed, 26 Oct 2022 18:30:21 +0200 + ql/indexes/equityindex.cpp | 18 +++++--- + ql/indexes/equityindex.hpp | 19 +++++--- + test-suite/equityindex.cpp | 108 ++++++++++++++++++++++++++++++++++++--------- + test-suite/equityindex.hpp | 4 +- + 4 files changed, 116 insertions(+), 33 deletions(-) - Update CI matrix +commit 94f3d3d55109ed3b904969e0e1dd84c378de5845 +Author: Fredrik Gerdin Börjesson +Date: Wed, 8 Feb 2023 15:45:53 +0100 - .github/workflows/linux-full-tests.yml | 9 --------- - .github/workflows/linux-nondefault.yml | 2 +- - .github/workflows/linux.yml | 10 ---------- - 3 files changed, 1 insertion(+), 20 deletions(-) + Cleanup docstrings of African currencies -commit 40af9c13b8317e6de7129a01751cbfd4f6cf833b -Author: Luigi Ballabio -Date: Wed, 26 Oct 2022 18:26:55 +0200 + ql/currencies/africa.cpp | 9 --------- + ql/currencies/africa.hpp | 8 ++++++-- + 2 files changed, 6 insertions(+), 11 deletions(-) - Restore unused typedef for compatibility +commit 450846b816dd6a8b25ef18fff740682047a2b248 +Author: Fredrik Gerdin Börjesson +Date: Wed, 8 Feb 2023 15:20:59 +0100 - ql/patterns/singleton.hpp | 20 +++++++++++++++++++- - 1 file changed, 19 insertions(+), 1 deletion(-) + Sort African currencies alphabetically -commit 95ad0028b7dc262a7b3886a3e33a3c85bfc99a27 -Author: Luigi Ballabio -Date: Wed, 26 Oct 2022 16:57:23 +0200 + ql/currencies/africa.cpp | 136 ++++++++++++++++++++++------------------------- + ql/currencies/africa.hpp | 119 +++++++++++++++++++++-------------------- + 2 files changed, 125 insertions(+), 130 deletions(-) - Add missing include +commit dbc294e696ec1b5f04aece1929fa89c00464dd6a +Author: Fredrik Gerdin Börjesson +Date: Wed, 8 Feb 2023 14:14:17 +0100 - ql/patterns/singleton.hpp | 1 + - 1 file changed, 1 insertion(+) + Add Botswanan pula currency (BWP) -commit 90fe9d2b6aa3b948a1d9db647c33c71233e9c153 -Author: Luigi Ballabio -Date: Wed, 26 Oct 2022 16:50:22 +0200 + ql/currencies/africa.cpp | 9 +++++++++ + ql/currencies/africa.hpp | 11 +++++++++++ + 2 files changed, 20 insertions(+) - Cleanup comments and included headers +commit b4a42f02e7a7bcfec661535ee00ce8ff8f709a48 +Author: Marcin Rybacki +Date: Wed, 8 Feb 2023 14:01:23 +0100 - ql/patterns/singleton.hpp | 24 +++++++++++++++--------- - 1 file changed, 15 insertions(+), 9 deletions(-) + Implemented PR feedback. -commit b942a80d4401513414e4942cc11226d2efb4f44d -Merge: a9fa1efc0 5a8b7f8de -Author: Luigi Ballabio -Date: Tue, 25 Oct 2022 20:04:39 +0200 + ql/indexes/equityindex.cpp | 21 ++++++--------------- + ql/indexes/equityindex.hpp | 10 ++-------- + test-suite/equityindex.cpp | 12 +++++------- + 3 files changed, 13 insertions(+), 30 deletions(-) - Remove features deprecated in version 1.24 (#1501) +commit 439d0d8081bfc9b7e13e6c6c2810231012cb4a3b +Author: Jonathan Sweemer +Date: Sat, 2 Jul 2022 20:34:59 +0900 + + Move clang-analyzer-optin.cplusplus.VirtualCall suppressions to comments + + .clang-tidy | 1 - + ql/cashflows/capflooredinflationcoupon.cpp | 3 +- + .../averageois/arithmeticoisratehelper.cpp | 2 +- + ql/experimental/lattices/extendedbinomialtree.cpp | 2 +- + .../termstructures/basisswapratehelpers.cpp | 4 +-- + .../termstructures/crosscurrencyratehelpers.cpp | 3 +- + .../variancegamma/variancegammamodel.cpp | 2 +- + ql/indexes/inflationindex.cpp | 2 +- + ql/legacy/libormarketmodels/lmexpcorrmodel.cpp | 2 +- + ql/legacy/libormarketmodels/lmlinexpcorrmodel.cpp | 2 +- + .../interpolations/bicubicsplineinterpolation.hpp | 2 +- + ql/math/interpolations/bilinearinterpolation.hpp | 2 +- + ql/math/interpolations/flatextrapolation2d.hpp | 2 +- + ql/models/equity/gjrgarchmodel.cpp | 2 +- + .../onefactormodels/extendedcoxingersollross.cpp | 2 +- + ql/models/shortrate/onefactormodels/hullwhite.cpp | 2 +- + ql/models/shortrate/twofactormodels/g2.cpp | 2 +- + .../vanilla/analytichestonhullwhiteengine.cpp | 6 ++-- + ql/processes/hestonslvprocess.cpp | 2 +- + ql/termstructures/inflation/seasonality.cpp | 5 ++- + .../equityfx/gridmodellocalvolsurface.cpp | 2 +- + .../volatility/kahalesmilesection.cpp | 9 ++--- + ql/termstructures/volatility/smilesection.cpp | 2 +- + .../volatility/swaption/cmsmarket.cpp | 2 +- + .../yield/nonlinearfittingmethods.cpp | 6 ++-- + ql/termstructures/yield/oisratehelper.cpp | 2 +- + ql/termstructures/yield/ratehelpers.cpp | 40 +++++++++++----------- + 27 files changed, 56 insertions(+), 57 deletions(-) + +commit cfaa06d85346a2e3afc7a32dd42a09d352870b83 +Author: Luigi Ballabio +Date: Wed, 8 Feb 2023 12:12:32 +0100 + + Use default values for implied volatility call + + test-suite/barrieroption.cpp | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) -commit a9fa1efc04b052d6f1b82f7ef315addf5e3883d1 -Merge: ff8e034bc 1f8729cd1 +commit 71892cfabe87d709a28b5b8d9ef160265c890adf Author: Luigi Ballabio -Date: Tue, 25 Oct 2022 19:06:31 +0200 +Date: Wed, 8 Feb 2023 12:08:15 +0100 - init member in ExchangeRate default constructor (#1497) + Avoid NaNs in analytic barrier engine for low volatility -commit 5a8b7f8de52103b6844dba34d51436ac5412469d -Author: Luigi Ballabio -Date: Tue, 25 Oct 2022 16:55:45 +0200 + .../barrier/analyticbarrierengine.cpp | 28 ++-- + test-suite/barrieroption.cpp | 153 +++++++++++++++++---- + test-suite/barrieroption.hpp | 1 + + 3 files changed, 145 insertions(+), 37 deletions(-) - Avoid warning in gcc +commit 8b5129de5daec3b088fcd9890eaee367b9b45910 +Author: EUROPE\igangu +Date: Tue, 24 Jan 2023 19:06:03 +0100 - ql/cashflows/inflationcouponpricer.hpp | 1 + - 1 file changed, 1 insertion(+) + Improve Naming of Swaptions Vol Structures -commit 3ab1272f0ea3fc7056e2fdc8227121ab0a31dbdb -Author: Luigi Ballabio -Date: Tue, 25 Oct 2022 15:12:18 +0200 + Docs/pages/history.docs | 4 +- + QuantLib.vcxproj | 6 +- + QuantLib.vcxproj.filters | 6 +- + ql/CMakeLists.txt | 6 +- + ql/experimental/volatility/swaptionvolcube1a.hpp | 4 +- + ql/termstructures/volatility/swaption/Makefile.am | 6 +- + ql/termstructures/volatility/swaption/all.hpp | 4 +- + .../volatility/swaption/cmsmarketcalibration.cpp | 38 +++---- + ....cpp => interpolatedswaptionvolatilitycube.cpp} | 11 +- + ....hpp => interpolatedswaptionvolatilitycube.hpp} | 20 +++- + ...volcube1.hpp => sabrswaptionvolatilitycube.hpp} | 112 ++++++++++++--------- + test-suite/assetswap.cpp | 4 +- + test-suite/cms.cpp | 10 +- + test-suite/markovfunctional.cpp | 8 +- + test-suite/rangeaccrual.cpp | 16 +-- + test-suite/swaptionvolatilitycube.cpp | 28 +++--- + 16 files changed, 158 insertions(+), 125 deletions(-) - Deprecate now unused data member +commit da51b060630156e309d96ecac863b6086cbf2aed +Author: Marcin Rybacki +Date: Tue, 7 Feb 2023 14:46:35 +0100 - ql/cashflows/cpicouponpricer.cpp | 8 +++----- - ql/cashflows/inflationcouponpricer.cpp | 8 +++----- - ql/cashflows/inflationcouponpricer.hpp | 10 ++++++++-- - 3 files changed, 14 insertions(+), 12 deletions(-) + Use ExpErrorPred explicitly using the namespace. -commit 1b460a318b473569186296194d5ac89eba661f94 -Author: Luigi Ballabio -Date: Tue, 25 Oct 2022 13:36:13 +0200 + test-suite/equityindex.cpp | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) - Remove deprecated static methods from IborCoupon +commit b5129db3c4a1b30b0fc2ee3158777c35d238571e +Author: Marcin Rybacki +Date: Tue, 7 Feb 2023 14:43:47 +0100 - ql/cashflows/iborcoupon.cpp | 12 ------------ - ql/cashflows/iborcoupon.hpp | 12 ------------ - 2 files changed, 24 deletions(-) + Added docstring. -commit 0e34afb68a71352c26520831aed39bdba70365ca -Author: Luigi Ballabio -Date: Tue, 25 Oct 2022 13:28:08 +0200 + ql/indexes/equityindex.hpp | 28 +++++++++++++++++++++++++++- + 1 file changed, 27 insertions(+), 1 deletion(-) - Remove deprecated nominalTermStructure method from inflation curves +commit c51de775fae5afb768a2dea31569730b02a607a9 +Author: Marcin Rybacki +Date: Tue, 7 Feb 2023 13:34:46 +0100 - ql/cashflows/cpicouponpricer.cpp | 9 +------- - ql/cashflows/inflationcouponpricer.cpp | 9 +------- - ql/instruments/makeyoyinflationcapfloor.cpp | 15 ++----------- - .../inflation/inflationcapfloorengines.cpp | 14 +++--------- - ql/termstructures/inflation/inflationhelpers.cpp | 15 +++---------- - ql/termstructures/inflationtermstructure.hpp | 25 ---------------------- - 6 files changed, 10 insertions(+), 77 deletions(-) + Corrected expected error message. -commit 0fa7abaffe2bc8fd613e222bc93a44cf8d48c249 -Author: Luigi Ballabio -Date: Tue, 25 Oct 2022 12:58:34 +0200 + test-suite/equityindex.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) - Remove deprecated static data members from Money class +commit 7467bb4cd2f81f2f9844a44a5dc482cd2917568e +Author: Marcin Rybacki +Date: Tue, 7 Feb 2023 13:31:57 +0100 - ql/money.cpp | 4 ---- - ql/money.hpp | 10 ---------- - 2 files changed, 14 deletions(-) + Use make_shared instead. -commit c5f1d929f3bedff3b7cd3b69161d12a91a5813a0 -Author: Luigi Ballabio -Date: Tue, 25 Oct 2022 12:54:32 +0200 + test-suite/equityindex.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) - Remove UnitedStates constructor without an explicit market +commit 0674a6dd9a8124643e20db8aff58cbf2cf94f735 +Author: Marcin Rybacki +Date: Tue, 7 Feb 2023 13:27:46 +0100 - ql/time/calendars/unitedstates.hpp | 7 ------- - 1 file changed, 7 deletions(-) + Minor renaming. -commit d697b5048d08051d159ed44deb9e6e398f866833 -Author: Luigi Ballabio -Date: Tue, 25 Oct 2022 12:49:15 +0200 + test-suite/equityindex.cpp | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) - Remove deprecated data member +commit a44eafc96511e91d5b26a1443d446663efd37993 +Author: Marcin Rybacki +Date: Tue, 7 Feb 2023 13:26:34 +0100 - ql/models/calibrationhelper.hpp | 8 -------- - 1 file changed, 8 deletions(-) + Added a few more unit tests for equity index. -commit e516865dfcbfd5dc2a0fec0c3e7f99c334571352 -Author: Luigi Ballabio -Date: Tue, 25 Oct 2022 12:33:33 +0200 + test-suite/equityindex.cpp | 84 ++++++++++++++++++++++++++++++++++++++++++++++ + test-suite/equityindex.hpp | 4 +++ + 2 files changed, 88 insertions(+) - Remove deprecated CrossCurrencyBasisSwapRateHelper typedef +commit e283afa9c689988f8ffb6c67479502eb3ea8af46 +Author: Marcin Rybacki +Date: Mon, 6 Feb 2023 17:08:58 +0100 - ql/experimental/termstructures/crosscurrencyratehelpers.hpp | 7 ------- - 1 file changed, 7 deletions(-) + Added references to newly added files. -commit 43380185a646ca917525cc169e698fb98d8a9b3b -Author: Luigi Ballabio -Date: Tue, 25 Oct 2022 12:29:49 +0200 - - Remove deprecated RiskyBond classes + ql/CMakeLists.txt | 2 ++ + ql/indexes/Makefile.am | 2 ++ + ql/indexes/all.hpp | 1 + + ql/indexes/equityindex.cpp | 17 ++++++++++------ + ql/indexes/equityindex.hpp | 13 +++++++++--- + test-suite/CMakeLists.txt | 2 ++ + test-suite/Makefile.am | 2 ++ + test-suite/equityindex.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++-- + test-suite/equityindex.hpp | 2 ++ + 9 files changed, 79 insertions(+), 11 deletions(-) - QuantLib.vcxproj | 1 - - QuantLib.vcxproj.filters | 11 +- - ql/CMakeLists.txt | 1 - - ql/experimental/credit/Makefile.am | 3 +- - ql/experimental/credit/all.hpp | 1 - - ql/experimental/credit/riskybond.cpp | 300 ----------------------------------- - ql/experimental/credit/riskybond.hpp | 203 +----------------------- - 7 files changed, 9 insertions(+), 511 deletions(-) +commit af8751760291848bb4383a7e6fc6d03062a54146 +Author: Marcin Rybacki +Date: Mon, 6 Feb 2023 13:57:48 +0100 -commit ff8e034bcb474859a7c9d23a6210befa4eb78214 -Author: Luigi Ballabio -Date: Thu, 15 Apr 2021 16:25:45 +0200 + Adding unit tests. - Set version to 1.29-dev. + test-suite/equityindex.cpp | 89 ++++++++++++++++++++++++++++++++++++ + test-suite/equityindex.hpp | 32 +++++++++++++ + test-suite/quantlibtestsuite.cpp | 2 + + test-suite/testsuite.vcxproj | 2 + + test-suite/testsuite.vcxproj.filters | 6 +++ + 5 files changed, 131 insertions(+) - CMakeLists.txt | 6 +++--- - configure.ac | 2 +- - ql/version.hpp | 4 ++-- - 3 files changed, 6 insertions(+), 6 deletions(-) - -commit 1619ff4d9a2fefbd59316a660ee28cde4924f1f9 -Author: Matthias Groncki -Date: Wed, 19 Oct 2022 08:41:08 +0700 - - Add indexFixing method to indexed cashflows +commit 94b218eadbf8ba42ec1906fe4f3606c778f74639 +Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> +Date: Sun, 5 Feb 2023 06:20:45 +0000 - ql/cashflows/cpicoupon.cpp | 9 +++++++++ - ql/cashflows/cpicoupon.hpp | 2 ++ - ql/cashflows/indexedcashflow.hpp | 2 ++ - 3 files changed, 13 insertions(+) + Automated fixes by clang-tidy -commit 5f461d5eddafae57587734157c0f79fc021cc829 -Author: klausspanderen -Date: Tue, 18 Oct 2022 21:36:36 +0200 + ql/pricingengines/vanilla/fdblackscholesvanillaengine.cpp | 15 ++++++--------- + 1 file changed, 6 insertions(+), 9 deletions(-) - make the error message for the double-boundary case more explicit +commit 89b922d677ad70d8fe48f881945e2d2a85a396f5 +Author: Marcin Rybacki +Date: Sun, 5 Feb 2023 17:30:38 +0100 - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 3 +++ - ql/pricingengines/vanilla/qdplusamericanengine.cpp | 4 ++-- - 2 files changed, 5 insertions(+), 2 deletions(-) + Remove unused include. -commit 1f8729cd12d61e65564d8cfafc605e59d471013b -Author: Peter Caspers -Date: Sun, 16 Oct 2022 14:38:18 +0200 + ql/indexes/equityindex.cpp | 1 - + 1 file changed, 1 deletion(-) - init member in default constructor +commit a3886d705d8912e0f598a13df560cd3fd710ab65 +Author: Marcin Rybacki +Date: Sun, 5 Feb 2023 17:28:56 +0100 - ql/exchangerate.hpp | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) + Specified past fixing logic. -commit 395252e447c621649a02812b181ab9ac9c91589b -Author: klausspanderen -Date: Tue, 11 Oct 2022 20:46:38 +0200 + ql/indexes/equityindex.cpp | 11 ++++++++++- + ql/indexes/equityindex.hpp | 9 --------- + 2 files changed, 10 insertions(+), 10 deletions(-) - performance tuning +commit 545cb78d9eec403b9ff4d46d4640fc8c9d0a5093 +Author: Marcin Rybacki +Date: Sat, 4 Feb 2023 22:34:57 +0100 - ql/math/interpolations/lagrangeinterpolation.hpp | 16 +++++++---- - test-suite/interpolations.cpp | 36 ++++++++++++++++++------ - 2 files changed, 38 insertions(+), 14 deletions(-) + Added methods for past and future fixings. -commit 0c47b06b9ef7304f4bb1c556965e821c774ab4a7 -Author: klausspanderen -Date: Sun, 9 Oct 2022 21:20:11 +0200 + ql/indexes/equityindex.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++- + ql/indexes/equityindex.hpp | 23 +++++++++---------- + 2 files changed, 66 insertions(+), 12 deletions(-) - better iteration start value for QD+ approximation +commit 18eb2e786ef43c8ad4c056810a7e2657fe33d4c9 +Author: Luigi Ballabio +Date: Sat, 4 Feb 2023 14:02:26 +0100 - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 4 ++-- - ql/pricingengines/vanilla/qdplusamericanengine.cpp | 2 +- - 2 files changed, 3 insertions(+), 3 deletions(-) + Cleaning up -commit c1a9ad829b4fb195b3cac5cb3a00bbaa1c428c11 -Author: klausspanderen -Date: Sun, 9 Oct 2022 17:01:16 +0200 + ql/instruments/dividendvanillaoption.cpp | 12 +++++----- + .../barrier/fdblackscholesbarrierengine.cpp | 28 +++++++++------------- + .../barrier/fdhestonbarrierengine.cpp | 28 +++++++++------------- + .../vanilla/analyticdividendeuropeanengine.hpp | 2 +- + 4 files changed, 29 insertions(+), 41 deletions(-) - fixed one argument constructor +commit febdb34828b24fbe50efd1d94f850aeeb1067b20 +Author: Marcin Rybacki +Date: Fri, 3 Feb 2023 20:02:19 +0100 - ql/math/interpolations/chebyshevinterpolation.hpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Created equityindex.hpp and equityindex.cpp -commit cb61a1635c472c11fd4df321bafa430a7371b1c1 -Author: klausspanderen -Date: Sun, 9 Oct 2022 05:35:42 +0200 + QuantLib.vcxproj | 8 ++-- + QuantLib.vcxproj.filters | 6 +++ + ql/indexes/equityindex.cpp | 23 ++++++++++++ + ql/indexes/equityindex.hpp | 94 ++++++++++++++++++++++++++++++++++++++++++++++ + 4 files changed, 128 insertions(+), 3 deletions(-) - clean-up +commit 628461102ee5a8178508d6d6222e86759a061285 +Author: Luigi Ballabio +Date: Fri, 3 Feb 2023 13:13:34 +0100 - QuantLib.vcxproj.filters | 8 ++++---- - ql/math/integrals/gaussianquadratures.hpp | 2 +- - ql/math/interpolations/chebyshevinterpolation.hpp | 2 +- - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 10 +--------- - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 6 +++--- - test-suite/americanoption.cpp | 9 +-------- - 6 files changed, 11 insertions(+), 26 deletions(-) + Deprecate DividendVanillaOption -commit dc32deac83900dde6f91449837710a77f9e02a22 -Author: klausspanderen -Date: Tue, 13 Sep 2022 21:25:05 +0200 + ql/instruments/dividendbarrieroption.hpp | 14 ++------------ + ql/instruments/dividendvanillaoption.hpp | 12 +++++++----- + ql/instruments/vanillaoption.cpp | 2 ++ + ql/pricingengines/vanilla/fdbatesvanillaengine.cpp | 2 ++ + test-suite/dividendoption.cpp | 10 +++++----- + 5 files changed, 18 insertions(+), 22 deletions(-) - - +commit 6cbdd940ee1f76c8edbde756af00a1d35699c103 +Author: Luigi Ballabio +Date: Fri, 3 Feb 2023 12:34:26 +0100 - ql/pricingengines/vanilla/qdplusamericanengine.cpp | 1 - - 1 file changed, 1 deletion(-) + Pass dividends to remaining engines -commit e0b30beb6340d41b641de789017ed3b9279432bb -Author: klausspanderen -Date: Tue, 13 Sep 2022 21:17:05 +0200 + .../fdornsteinuhlenbeckvanillaengine.cpp | 29 ++++++++- + .../fdornsteinuhlenbeckvanillaengine.hpp | 19 +++++- + ql/pricingengines/vanilla/fdbatesvanillaengine.cpp | 35 +++++++++-- + ql/pricingengines/vanilla/fdbatesvanillaengine.hpp | 22 +++++-- + ql/pricingengines/vanilla/fdcirvanillaengine.cpp | 69 ++++++++++++++++++---- + ql/pricingengines/vanilla/fdcirvanillaengine.hpp | 54 +++++++++++------ + .../vanilla/fdhestonhullwhitevanillaengine.cpp | 56 ++++++++++++++---- + .../vanilla/fdhestonhullwhitevanillaengine.hpp | 26 +++++++- + 8 files changed, 250 insertions(+), 60 deletions(-) - fixed single header build +commit c5dd2d16dc8e4ef6f3ed7d6ff299fb1d2a3620a9 +Merge: 5928c0cc4 047b9593d +Author: Luigi Ballabio +Date: Fri, 3 Feb 2023 11:14:46 +0100 - ql/pricingengines/vanilla/qdplusamericanengine.hpp | 1 + - 1 file changed, 1 insertion(+) + Fixing consistent Real usage (#1585) -commit bc9a08dbe7320c9f6736a57e2de82bc6389264f1 -Merge: 77edcb071 aa3315b30 -Author: Klaus Spanderen -Date: Tue, 13 Sep 2022 20:12:40 +0200 +commit 5928c0cc47f23dd44df83643e0ade69534f8574e +Merge: 49875744e 136cfe95c +Author: Luigi Ballabio +Date: Fri, 3 Feb 2023 11:14:25 +0100 - Merge pull request #45 from klausspanderen/update-generated-headers-refs/heads/early_exercise_boundary - - Update generated headers + Corrections to Turkish, Danish, and Austrian calendars (#1581) -commit aa3315b30f34cdfac366839697f48989aa44b37f +commit 49875744ee4e221f616c4ad293bafe5f3cb635bd Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> -Date: Sun, 11 Sep 2022 20:20:24 +0000 +Date: Thu, 2 Feb 2023 14:23:25 +0000 Update generated headers - ql/math/interpolations/all.hpp | 2 +- - ql/pricingengines/vanilla/all.hpp | 3 ++- - 2 files changed, 3 insertions(+), 2 deletions(-) - -commit 77edcb07159e109b24007a7c8b39fb82598a7e7a -Author: klausspanderen -Date: Sun, 11 Sep 2022 22:17:33 +0200 + ql/indexes/inflation/all.hpp | 1 + + 1 file changed, 1 insertion(+) - visual studio build +commit 136cfe95c1e9893adcd39c765c483d511a174b1c +Author: Fredrik Gerdin Börjesson +Date: Thu, 2 Feb 2023 16:47:56 +0100 - QuantLib.vcxproj | 7 +++ - QuantLib.vcxproj.filters | 21 +++++++ - ql/math/integrals/gaussianquadratures.hpp | 2 +- - ql/math/interpolations/chebyshevinterpolation.cpp | 2 - - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 12 ++-- - test-suite/americanoption.cpp | 73 +++++++++++------------ - test-suite/americanoption.hpp | 1 + - 7 files changed, 72 insertions(+), 46 deletions(-) + Add condition on "Day after Ascension" for 2009 + + for historical correctness in the Denmark calendar -commit aa3d876a59018189fcbf06f5cc8572254be4190d -Author: klausspanderen -Date: Sun, 4 Sep 2022 19:54:57 +0200 + ql/time/calendars/denmark.cpp | 2 +- + ql/time/calendars/denmark.hpp | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) - fixed this capture +commit 047b9593d2c527961f8d92e870a426670faac802 +Author: Xcelerit Dev Team +Date: Thu, 2 Feb 2023 15:42:44 +0000 - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) + Fixing consistent Real usage -commit f2cdb59c71892ad1ec19fbe7a98b5339670b99fe -Author: klausspanderen -Date: Sun, 4 Sep 2022 00:51:18 +0200 + ql/experimental/barrieroption/suowangdoublebarrierengine.cpp | 2 +- + ql/experimental/barrieroption/vannavolgabarrierengine.cpp | 8 ++++---- + .../barrieroption/vannavolgadoublebarrierengine.hpp | 4 ++-- + ql/experimental/credit/integralcdoengine.cpp | 2 +- + ql/experimental/credit/integralntdengine.cpp | 2 +- + ql/experimental/credit/midpointcdoengine.cpp | 2 +- + ql/pricingengines/swaption/blackswaptionengine.hpp | 4 ++-- + ql/pricingengines/vanilla/analyticeuropeanengine.cpp | 2 +- + ql/pricingengines/vanilla/bjerksundstenslandengine.cpp | 12 ++++++------ + 9 files changed, 19 insertions(+), 19 deletions(-) - remove unused variables +commit 0d19207d8d151681fa17d81a7bd576e729a93366 +Author: Luigi Ballabio +Date: Thu, 2 Feb 2023 15:48:40 +0100 - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 26 ++++++++++-------------- - 1 file changed, 11 insertions(+), 15 deletions(-) + Pass dividends to FD Heston engine -commit c9b4b10c7fe083f31f4e2a9433b62ef90769c322 -Author: klausspanderen -Date: Sat, 3 Sep 2022 23:27:32 +0200 + .../meshers/fdmblackscholesmesher.hpp | 8 +- + .../barrier/fdhestonbarrierengine.cpp | 14 +-- + ql/pricingengines/vanilla/fdbatesvanillaengine.cpp | 1 + + .../vanilla/fdblackscholesvanillaengine.hpp | 5 +- + .../vanilla/fdhestonvanillaengine.cpp | 133 ++++++++++++++++----- + .../vanilla/fdhestonvanillaengine.hpp | 67 ++++++++--- + test-suite/fdheston.cpp | 76 +++++++----- + test-suite/hestonmodel.cpp | 86 +++++++++---- + test-suite/hestonmodel.hpp | 2 + + test-suite/quantooption.cpp | 9 +- + 10 files changed, 285 insertions(+), 116 deletions(-) - . +commit 543830809ccab42c79cafea4e88a09d6e4e89721 +Merge: 93aac4372 8c4cd3dfb +Author: Luigi Ballabio +Date: Thu, 2 Feb 2023 15:20:06 +0100 - ql/math/integrals/gaussianquadratures.hpp | 4 + - ql/math/interpolations/chebyshevinterpolation.cpp | 6 +- - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 324 ++++++--------------- - ql/pricingengines/vanilla/qdplusamericanengine.cpp | 5 +- - test-suite/americanoption.cpp | 28 +- - 5 files changed, 117 insertions(+), 250 deletions(-) + Add UKHICP inflation index (#1580) -commit c5ed738866b06ebadef934dc5044310f49e54d17 -Author: klausspanderen -Date: Thu, 1 Sep 2022 21:31:37 +0200 - - use equation interface +commit 0245af5217067ea414608b06fb0d3f5dbcb3652f +Author: Fredrik Gerdin Börjesson +Date: Thu, 2 Feb 2023 09:24:08 +0100 - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 488 +++++++++++++---------- - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 9 - - 2 files changed, 277 insertions(+), 220 deletions(-) + Update and test Denmark calendar -commit 92e39662e47b6b56b5772c279580d5cc23165a1b -Author: klausspanderen -Date: Mon, 29 Aug 2022 22:06:06 +0200 + ql/time/calendars/denmark.cpp | 9 ++++++- + ql/time/calendars/denmark.hpp | 6 +++++ + test-suite/calendars.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++ + test-suite/calendars.hpp | 2 ++ + 4 files changed, 79 insertions(+), 1 deletion(-) - first light from fixed point equation interface +commit 93aac43722ff6480af3fbfaa2e4a0eda37c13197 +Merge: 01a1e6719 9f24fd7bf +Author: Luigi Ballabio +Date: Thu, 2 Feb 2023 09:20:20 +0100 - ql/math/interpolations/chebyshevinterpolation.cpp | 8 +- - ql/math/interpolations/chebyshevinterpolation.hpp | 6 +- - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 287 ++++++++++++++-------- - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 9 +- - test-suite/americanoption.cpp | 19 +- - test-suite/interpolations.cpp | 36 ++- - test-suite/interpolations.hpp | 2 + - 7 files changed, 238 insertions(+), 129 deletions(-) + moved expm from experimental to main (#1579) -commit d718a86d706ba58ad0235dccde620fb520f051ef -Author: klausspanderen -Date: Sun, 21 Aug 2022 11:32:28 +0200 +commit b7890028a53e9e60154a42b5803079cccfde4008 +Author: Luigi Ballabio +Date: Wed, 1 Feb 2023 17:56:34 +0100 - fixed unused this capture + Pass dividends to FD shout engine - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 11 +++++------ - 1 file changed, 5 insertions(+), 6 deletions(-) + .../vanilla/fdblackscholesshoutengine.cpp | 26 ++++++- + .../vanilla/fdblackscholesshoutengine.hpp | 14 ++++ + test-suite/americanoption.cpp | 90 ++++++++++++++++------ + 3 files changed, 105 insertions(+), 25 deletions(-) -commit 9c84b7ded1a5cea54d88918fb0e4daea07280628 -Author: klausspanderen -Date: Sun, 21 Aug 2022 04:06:15 +0200 +commit f127397295a0415a1148404ed6d8f6ab2bd9ded7 +Author: Fredrik Gerdin Börjesson +Date: Wed, 1 Feb 2023 17:47:16 +0100 - implemented FP-B + Add explanatory comment to Turkey calendar - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 222 +++++++++++++++-- - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 18 +- - test-suite/americanoption.cpp | 298 +++++++++++++++++++---- - test-suite/americanoption.hpp | 6 +- - 4 files changed, 470 insertions(+), 74 deletions(-) + ql/time/calendars/turkey.cpp | 1 + + 1 file changed, 1 insertion(+) -commit aaebf31edc02c6c9ed6b10070e68c9fea384e7cb -Author: klausspanderen -Date: Sat, 20 Aug 2022 13:55:51 +0200 +commit 8c4cd3dfb41f409cbb7af733d796a11732c57042 +Author: Fredrik Gerdin Börjesson +Date: Wed, 1 Feb 2023 17:35:15 +0100 - small performance improvements + Add missing ukhicp.hpp to CMakeLists.txt - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 92 ++++++++++++++++++---- - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 50 +++++++++++- - ql/pricingengines/vanilla/qdplusamericanengine.cpp | 3 + - 3 files changed, 126 insertions(+), 19 deletions(-) + ql/CMakeLists.txt | 1 + + 1 file changed, 1 insertion(+) -commit a7e4328574dd6d986ecd5201a4e163d9c00e003a -Author: klausspanderen -Date: Wed, 17 Aug 2022 23:18:27 +0200 +commit f368d17def6ea2be37b5ddab08015f77745c612f +Author: Luigi Ballabio +Date: Wed, 1 Feb 2023 16:19:10 +0100 - fixed c++20 compilation + Add implied vol calculation with dividends - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) + ql/instruments/vanillaoption.cpp | 27 +++++++-- + ql/instruments/vanillaoption.hpp | 12 ++++ + test-suite/europeanoption.cpp | 127 ++++++++++++++++++++++++++++++++++++++- + test-suite/europeanoption.hpp | 1 + + 4 files changed, 160 insertions(+), 7 deletions(-) -commit 8cbd6cc60e7500d6c0943482ba8a3d52d4cca3d3 -Author: klausspanderen -Date: Wed, 17 Aug 2022 00:58:02 +0200 +commit 71b6af2f4e5179344bd855119bd76b1321fc5dda +Author: Fredrik Gerdin Börjesson +Date: Wed, 1 Feb 2023 16:15:09 +0100 - fixed compilation + Update Turkey calendar with 2019-2023 holidays - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 2 ++ - test-suite/americanoption.cpp | 2 +- - 2 files changed, 3 insertions(+), 1 deletion(-) + ql/time/calendars/turkey.cpp | 17 +++++++++-------- + ql/time/calendars/turkey.hpp | 4 ++-- + 2 files changed, 11 insertions(+), 10 deletions(-) -commit 9a6f668b32040b5e5791093a74ab5d43edd75e68 -Author: klausspanderen -Date: Tue, 16 Aug 2022 23:50:27 +0200 +commit 158ee2b046038dcee32ff908862fe7888c113afa +Author: Fredrik Gerdin Börjesson +Date: Wed, 1 Feb 2023 15:58:28 +0100 - fixed point engine, only fp-a scheme + Fix bad comment in Austrian calendar enum - ql/math/interpolations/chebyshevinterpolation.cpp | 5 + - ql/math/interpolations/chebyshevinterpolation.hpp | 1 + - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 258 +++++++++++++++++++- - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 68 ++++-- - ql/pricingengines/vanilla/qdplusamericanengine.cpp | 262 +++++++++++---------- - ql/pricingengines/vanilla/qdplusamericanengine.hpp | 69 ++++-- - test-suite/americanoption.cpp | 59 +++-- - test-suite/americanoption.hpp | 1 + - 8 files changed, 540 insertions(+), 183 deletions(-) + ql/time/calendars/austria.hpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) -commit 446ac3d301da9f869936002ae010fbe0beab5978 -Author: klausspanderen -Date: Tue, 26 Jul 2022 15:25:05 +0200 +commit 68fd51eebb347d9115775d83f2ca1fe19e42a772 +Author: Fredrik Gerdin Börjesson +Date: Wed, 1 Feb 2023 15:57:06 +0100 - fixed file extensions + Add UKHICP inflation index - ql/pricingengines/vanilla/Makefile.am | 7 +++---- - 1 file changed, 3 insertions(+), 4 deletions(-) + QuantLib.vcxproj | 1 + + QuantLib.vcxproj.filters | 3 +++ + ql/indexes/inflation/Makefile.am | 1 + + ql/indexes/inflation/ukhicp.hpp | 41 ++++++++++++++++++++++++++++++++++++++++ + test-suite/inflation.cpp | 13 +++++++++++++ + 5 files changed, 59 insertions(+) -commit e465c246a47036be0c74669cd4cd4fb3cbdee126 +commit 9f24fd7bfe0912170a5548e0d22325f1ac72bf0e Author: klausspanderen -Date: Tue, 26 Jul 2022 15:22:16 +0200 +Date: Tue, 31 Jan 2023 22:16:52 +0100 - fixed tab + fixed header files - ql/pricingengines/vanilla/Makefile.am | 73 ++++++++++++++++++----------------- - 1 file changed, 37 insertions(+), 36 deletions(-) + ql/experimental/math/all.hpp | 1 - + ql/math/matrixutilities/all.hpp | 1 + + 2 files changed, 1 insertion(+), 1 deletion(-) -commit f946b877375791884913dd9099004ce066cc54b0 +commit 2a674c7418af4a2068c234ab9d05ec2b867ef756 Author: klausspanderen -Date: Tue, 26 Jul 2022 14:48:36 +0200 +Date: Tue, 31 Jan 2023 22:08:53 +0100 - removed white spaces + formatting - ql/pricingengines/vanilla/Makefile.am | 4 ++-- + ql/math/matrixutilities/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -commit 1e513fb1be2b51f883d9606c6e6604ee8a5c1577 +commit 3eb40821087d436cd196451d5920dc3b04b9ef76 Author: klausspanderen -Date: Tue, 26 Jul 2022 14:37:16 +0200 +Date: Tue, 31 Jan 2023 21:30:42 +0100 - now with empty action caches + moved expm from experimental to main - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit eff49b61504f28ba1a486f0373400c4f299ab1e7 -Author: klausspanderen -Date: Tue, 26 Jul 2022 13:56:15 +0200 + QuantLib.vcxproj | 4 ++-- + QuantLib.vcxproj.filters | 12 ++++++------ + ql/CMakeLists.txt | 4 ++-- + ql/experimental/math/Makefile.am | 2 -- + ql/math/matrixutilities/Makefile.am | 2 ++ + ql/{experimental/math => math/matrixutilities}/expm.cpp | 2 +- + ql/{experimental/math => math/matrixutilities}/expm.hpp | 0 + test-suite/ode.cpp | 2 +- + 8 files changed, 14 insertions(+), 14 deletions(-) - . +commit 01a1e67198b79836fbdbed95b2b9fd0cce36710a +Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> +Date: Tue, 31 Jan 2023 14:43:06 +0000 - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Automated fixes by clang-tidy -commit 9200c6f9a82a626106bf019f9c8aa5405df50823 -Author: klausspanderen -Date: Tue, 26 Jul 2022 13:44:46 +0200 + test-suite/americanoption.cpp | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) - . +commit 84b8ce304d5699357301a5f21084618a4a401fa1 +Author: Luigi Ballabio +Date: Tue, 31 Jan 2023 17:53:26 +0100 - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + Pass dividends to FD Black-Scholes vanilla engine -commit 09972519d2e1ed5ea9ca30ccbd833f0d6ff8a446 -Author: klausspanderen -Date: Tue, 26 Jul 2022 13:33:14 +0200 + .../barrier/fdblackscholesbarrierengine.cpp | 9 +- + .../vanilla/fdblackscholesvanillaengine.cpp | 94 +++++++-- + .../vanilla/fdblackscholesvanillaengine.hpp | 78 +++++-- + test-suite/americanoption.cpp | 171 +++++++++------- + test-suite/dividendoption.cpp | 226 ++++++++++++++++----- + test-suite/europeanoption.cpp | 60 +----- + test-suite/quantooption.cpp | 27 ++- + 7 files changed, 426 insertions(+), 239 deletions(-) - . +commit 4146cd6c1dbf390f4e90f2462e1f852d0382c017 +Author: Luigi Ballabio +Date: Tue, 31 Jan 2023 10:02:16 +0100 - .github/workflows/sanitizer.yml | 4 ++-- - ql/CMakeLists.txt | 4 ++++ - ql/cashflows/cmscoupon.cpp | 3 ++- - .../marketmodels/products/multistep/callspecifiedmultiproduct.cpp | 4 ++-- - .../marketmodels/products/pathwise/pathwiseproductcallspecified.cpp | 4 ++-- - 5 files changed, 12 insertions(+), 7 deletions(-) + More changes suggested by clang-tidy -commit 4f8b198854423c6887b5ee0317d2523177c17ae1 -Author: klausspanderen -Date: Tue, 26 Jul 2022 13:16:00 +0200 + test-suite/inflation.cpp | 32 ++++++++++++++++---------------- + 1 file changed, 16 insertions(+), 16 deletions(-) - . +commit e74e3cdcfcb3cbd3a53e67d406840c8b609949b1 +Merge: e4fdc43e4 586aa7eeb +Author: Luigi Ballabio +Date: Mon, 30 Jan 2023 19:26:56 +0100 - CMakeLists.txt | 10 ++++++++-- - 1 file changed, 8 insertions(+), 2 deletions(-) + moved Heston SLV model from experimental to main (#1576) -commit 6e631070912bfb0b5aaf6b90719903ab74c81ece -Author: klausspanderen -Date: Tue, 26 Jul 2022 13:09:10 +0200 +commit 586aa7eeb0d75eaa64acbf7a581d9c7a80ca0f02 +Author: Luigi Ballabio +Date: Mon, 30 Jan 2023 16:53:33 +0100 - . + Reorder some file lists - ql/math/integrals/gaussianquadratures.cpp | 25 ++++++++++ - ql/math/integrals/gaussianquadratures.hpp | 24 +++++++++ - ql/pricingengines/vanilla/Makefile.am | 66 ++++++++++++------------- - test-suite/americanoption.cpp | 82 ++++++++++++++++++++++++------- - test-suite/americanoption.hpp | 1 + - test-suite/integrals.cpp | 38 ++++++++++++++ - test-suite/integrals.hpp | 3 ++ - 7 files changed, 188 insertions(+), 51 deletions(-) + QuantLib.vcxproj | 72 +++++++-------- + ql/experimental/barrieroption/Makefile.am | 4 +- + ql/experimental/barrieroption/all.hpp | 1 + + ql/experimental/finitedifferences/Makefile.am | 70 +++++++------- + ql/experimental/finitedifferences/all.hpp | 1 + + ql/experimental/models/all.hpp | 1 + + ql/experimental/processes/Makefile.am | 4 +- + ql/experimental/processes/all.hpp | 1 + + ql/instruments/Makefile.am | 12 +-- + ql/instruments/all.hpp | 1 + + ql/methods/finitedifferences/operators/Makefile.am | 102 ++++++++++----------- + ql/methods/finitedifferences/operators/all.hpp | 1 + + ql/methods/finitedifferences/utilities/Makefile.am | 88 +++++++++--------- + ql/methods/finitedifferences/utilities/all.hpp | 1 + + ql/models/equity/all.hpp | 1 + + ql/pricingengines/barrier/Makefile.am | 30 +++--- + ql/pricingengines/barrier/all.hpp | 1 + + ql/processes/Makefile.am | 86 ++++++++--------- + ql/processes/all.hpp | 1 + + 19 files changed, 244 insertions(+), 234 deletions(-) -commit 31e3dee4f7ce9f611468e88ea0050be782d7ccaa -Author: klausspanderen -Date: Mon, 25 Jul 2022 16:01:52 +0200 +commit 17e228079624f27aa91deae46a6fb3b162e6f6c1 +Author: Luigi Ballabio +Date: Mon, 30 Jan 2023 09:49:15 +0100 - . + Pass dividends to analytic engine instead of option - ql/CMakeLists.txt | 2 ++ - ql/pricingengines/vanilla/Makefile.am | 6 ++++-- - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 2 +- - 3 files changed, 7 insertions(+), 3 deletions(-) + ql/instruments/dividendvanillaoption.cpp | 2 + + .../vanilla/analyticdividendeuropeanengine.cpp | 29 +- + .../vanilla/analyticdividendeuropeanengine.hpp | 19 +- + test-suite/dividendoption.cpp | 325 +++++++++++++++++---- + test-suite/dividendoption.hpp | 1 + + 5 files changed, 303 insertions(+), 73 deletions(-) -commit 5a456d684d30574500acebdafa74939d1b961da4 -Author: klausspanderen -Date: Mon, 25 Jul 2022 14:05:14 +0200 +commit e4fdc43e49323ddeff77ce828132a29e622ac053 +Author: Luigi Ballabio +Date: Mon, 30 Jan 2023 11:08:54 +0100 - first stub for new fixed point engine + Apply suggestions by clang-tidy - ql/pricingengines/vanilla/all.hpp | 3 +- - ql/pricingengines/vanilla/qdfpamericanengine.cpp | 39 +++++++++++ - ql/pricingengines/vanilla/qdfpamericanengine.hpp | 80 ++++++++++++++++++++++ - ql/pricingengines/vanilla/qdplusamericanengine.cpp | 4 +- - ql/pricingengines/vanilla/qdplusamericanengine.hpp | 15 +++- - 5 files changed, 136 insertions(+), 5 deletions(-) + ql/termstructures/inflationtermstructure.cpp | 12 ++++++------ + ql/termstructures/inflationtermstructure.hpp | 6 +++--- + 2 files changed, 9 insertions(+), 9 deletions(-) -commit 2d48d15446c3b31e5557260ac9ddc25ffb0fc3cc +commit 02aa753a73d0bfea888dd873fb240ce42ddc8703 Author: klausspanderen -Date: Mon, 25 Jul 2022 11:27:22 +0200 - - rename qr in qd +Date: Sun, 29 Jan 2023 16:17:33 +0100 - ql/CMakeLists.txt | 4 +- - ql/math/interpolations/chebyshevinterpolation.cpp | 69 +++++++++++----------- - ql/math/interpolations/chebyshevinterpolation.hpp | 28 +++++---- - ...americanengine.cpp => qdplusamericanengine.cpp} | 26 ++++---- - ...americanengine.hpp => qdplusamericanengine.hpp} | 8 +-- - test-suite/americanoption.cpp | 62 +++++++++---------- - test-suite/americanoption.hpp | 6 +- - test-suite/interpolations.cpp | 37 ++++++++++++ - test-suite/interpolations.hpp | 1 + - 9 files changed, 142 insertions(+), 99 deletions(-) + removed unsed includes -commit 00735ab16c3ee77f0edda8310c8c6d9615fda68a -Author: Oleg Kulkov -Date: Fri, 22 Jul 2022 23:20:54 +0200 - - removed check for increasing notionals as there are bonds with draw downs - - ql/instruments/bond.cpp | 2 -- + ql/methods/finitedifferences/operators/fdmsquarerootfwdop.cpp | 2 -- 1 file changed, 2 deletions(-) -commit 680c2929e0f74e360e966fa1c169e6afdae6e81a -Author: Xcelerit Dev Team -Date: Wed, 13 Jul 2022 13:05:21 +0100 - - Adding ccache compiler launcher to CMake preset instead - - .github/workflows/cmake.yml | 2 +- - CMakePresets.json | 1 + - 2 files changed, 2 insertions(+), 1 deletion(-) - -commit dffd8b27520ee2e73922992ae70dfdcebcf4cc14 -Author: Xcelerit Dev Team -Date: Wed, 13 Jul 2022 08:43:21 +0100 - - Migrating to ninja generator with CMake - - .github/workflows/cmake.yml | 56 +++++++++++++++++++++++++++++++-------------- - CMakePresets.json | 14 ++++++++---- - 2 files changed, 48 insertions(+), 22 deletions(-) - -commit 88a93877db5c7787adb6b141c1c6ee818e328e70 +commit ae07584be90794bf2fadbeabdc55f8a6f2b1d610 Author: klausspanderen -Date: Mon, 11 Jul 2022 03:00:32 +0200 - - fixed g++4.8 build - - test-suite/americanoption.cpp | 5 +++-- - 1 file changed, 3 insertions(+), 2 deletions(-) - -commit 11ec0aa9ef64d2edaaf725814f86904d3ca6e7b3 -Author: klausspanderen -Date: Mon, 11 Jul 2022 02:11:35 +0200 - - fixed testcases - - ql/pricingengines/vanilla/qrplusamericanengine.cpp | 2 +- - test-suite/americanoption.cpp | 50 +++++++++++----------- - 2 files changed, 26 insertions(+), 26 deletions(-) - -commit 5e05f57b997876531e5e8bdbd0640c842f8642f3 -Author: klausspanderen -Date: Mon, 11 Jul 2022 01:46:00 +0200 - - improve root finding - - ql/pricingengines/vanilla/qrplusamericanengine.cpp | 47 ++++++------ - ql/pricingengines/vanilla/qrplusamericanengine.hpp | 3 +- - test-suite/americanoption.cpp | 89 +++++++++++----------- - 3 files changed, 72 insertions(+), 67 deletions(-) - -commit 549bf21e11ed6cb57807a0bc5e526e1dc445a6d0 -Author: klausspanderen -Date: Sun, 10 Jul 2022 12:52:04 +0200 - - . - - ql/pricingengines/vanilla/qrplusamericanengine.cpp | 212 +++++++++++++++++---- - 1 file changed, 175 insertions(+), 37 deletions(-) - -commit 2c92771ac44ca13cbaf732b0019372678912924e +Date: Sun, 29 Jan 2023 15:14:57 +0100 + + added test case for double binary barrier option + + QuantLib.vcxproj.filters | 2 +- + ql/experimental/barrieroption/all.hpp | 7 +-- + ql/experimental/finitedifferences/all.hpp | 7 --- + ql/experimental/models/all.hpp | 3 - + ql/experimental/processes/all.hpp | 4 +- + ql/instruments/all.hpp | 7 ++- + ql/methods/finitedifferences/operators/all.hpp | 13 ++-- + ql/methods/finitedifferences/utilities/all.hpp | 6 +- + ql/models/equity/all.hpp | 3 +- + ql/pricingengines/barrier/Makefile.am | 2 +- + ql/pricingengines/barrier/all.hpp | 4 +- + ql/processes/all.hpp | 4 +- + test-suite/doublebinaryoption.cpp | 85 ++++++++++++++++++++++++++ + test-suite/doublebinaryoption.hpp | 1 + + 14 files changed, 112 insertions(+), 36 deletions(-) + +commit 3c9150720463cd85d6272105732241fa97b781c6 Author: klausspanderen -Date: Sun, 10 Jul 2022 12:15:09 +0200 - - finished qr plus engine - - ql/math/integrals/tanhsinhintegral.hpp | 8 +- - ql/pricingengines/vanilla/qrplusamericanengine.hpp | 22 +- - test-suite/americanoption.cpp | 352 ++++++++++++++++++--- - test-suite/americanoption.hpp | 1 + - 4 files changed, 328 insertions(+), 55 deletions(-) - -commit 2a5953faf37a0afc5adac3fa7dbc9f3b2bec4ac2 -Author: klausspanderen -Date: Wed, 1 Jun 2022 20:58:15 +0200 - - C++20 compliant this capture - - ql/pricingengines/vanilla/qrplusamericanengine.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 6b1a7fb4f254f25caa934ccac6686788296e29a2 -Author: klausspanderen -Date: Wed, 1 Jun 2022 19:08:27 +0200 +Date: Sun, 29 Jan 2023 14:02:46 +0100 + + moved Heston SLV model from experimental to main + + QuantLib.vcxproj | 50 +++---- + QuantLib.vcxproj.filters | 156 ++++++++++----------- + ql/CMakeLists.txt | 50 +++---- + ql/experimental/barrieroption/Makefile.am | 8 -- + .../discretizeddoublebarrieroption.hpp | 2 +- + .../barrieroption/mcdoublebarrierengine.hpp | 2 +- + .../barrieroption/quantodoublebarrieroption.hpp | 2 +- + .../barrieroption/suowangdoublebarrierengine.hpp | 2 +- + .../vannavolgadoublebarrierengine.hpp | 2 +- + ql/experimental/finitedifferences/Makefile.am | 11 -- + ql/experimental/models/Makefile.am | 4 - + ql/experimental/processes/Makefile.am | 2 - + ql/instruments/Makefile.am | 4 + + .../doublebarrieroption.cpp | 4 +- + .../doublebarrieroption.hpp | 2 +- + .../doublebarriertype.cpp | 2 +- + .../doublebarriertype.hpp | 0 + ql/methods/finitedifferences/operators/Makefile.am | 7 + + .../operators}/fdmblackscholesfwdop.cpp | 2 +- + .../operators}/fdmblackscholesfwdop.hpp | 0 + .../operators}/fdmhestonfwdop.cpp | 4 +- + .../operators}/fdmhestonfwdop.hpp | 2 +- + .../operators}/fdmsquarerootfwdop.cpp | 4 +- + .../operators}/fdmsquarerootfwdop.hpp | 0 + .../operators}/modtriplebandlinearop.hpp | 0 + ql/methods/finitedifferences/utilities/Makefile.am | 2 + + .../utilities}/fdmhestongreensfct.cpp | 2 +- + .../utilities}/fdmhestongreensfct.hpp | 2 +- + ql/models/equity/Makefile.am | 4 + + .../models => models/equity}/hestonslvfdmmodel.cpp | 4 +- + .../models => models/equity}/hestonslvfdmmodel.hpp | 2 +- + .../models => models/equity}/hestonslvmcmodel.cpp | 4 +- + .../models => models/equity}/hestonslvmcmodel.hpp | 0 + ql/pricingengines/barrier/Makefile.am | 8 +- + .../barrier}/analyticdoublebarrierbinaryengine.cpp | 2 +- + .../barrier}/analyticdoublebarrierbinaryengine.hpp | 2 +- + .../barrier}/analyticdoublebarrierengine.cpp | 2 +- + .../barrier}/analyticdoublebarrierengine.hpp | 2 +- + .../barrier}/fdhestondoublebarrierengine.cpp | 2 +- + .../barrier}/fdhestondoublebarrierengine.hpp | 2 +- + ql/processes/Makefile.am | 2 + + .../processes/hestonslvprocess.cpp | 2 +- + .../processes/hestonslvprocess.hpp | 0 + test-suite/doublebarrieroption.cpp | 8 +- + test-suite/doublebinaryoption.cpp | 4 +- + test-suite/hestonslvmodel.cpp | 22 +-- + test-suite/hestonslvmodel.hpp | 2 +- + test-suite/normalclvmodel.cpp | 4 +- + test-suite/quantlibtestsuite.cpp | 2 +- + test-suite/quantooption.cpp | 2 +- + test-suite/squarerootclvmodel.cpp | 8 +- + 51 files changed, 209 insertions(+), 209 deletions(-) + +commit 68b1e46487829ef2ac0c6f9c474175bde32b4e32 +Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> +Date: Sat, 28 Jan 2023 17:51:43 +0000 - removed square() + Update copyright list in license - ql/pricingengines/vanilla/qrplusamericanengine.cpp | 2 +- + LICENSE.TXT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -commit e516f7e39728601a380341e9ed6ea04f341b730e -Author: klausspanderen -Date: Wed, 1 Jun 2022 07:33:05 +0200 - - added QR analytic American engine - - ql/math/integrals/tanhsinhintegral.hpp | 5 +++-- - ql/pricingengines/vanilla/qrplusamericanengine.cpp | 6 +++--- - 2 files changed, 6 insertions(+), 5 deletions(-) - -commit 339545aee793126ed79bd54186724d94dd89b41b -Author: Peter Caspers -Date: Wed, 11 May 2022 16:59:33 +0200 - - remove sessionId() declaration - - .github/workflows/linux-full-tests.yml | 2 +- - .github/workflows/linux-nondefault.yml | 2 +- - .github/workflows/linux.yml | 2 +- - 3 files changed, 3 insertions(+), 3 deletions(-) - -commit f2a311d1ef303932f56cb0a883af1d6b08a48752 -Author: Peter Caspers -Date: Wed, 11 May 2022 16:57:40 +0200 - - Revert "remove sessionId from github workflows" - - This reverts commit 2c11a510ccbeb3e2f6d42877fa8f0d85f92e49be. +commit 97901c27ae13865381f8662a5e4b465c25d2ed8b +Merge: eaf9825b7 3e8cd5c92 +Author: Luigi Ballabio +Date: Sat, 28 Jan 2023 18:51:08 +0100 - .github/workflows/linux-full-tests.yml | 6 +++++- - .github/workflows/linux-nondefault.yml | 3 ++- - .github/workflows/linux.yml | 6 +++++- - 3 files changed, 12 insertions(+), 3 deletions(-) + analytical greeks for Bjerksund Stensland engine (#1573) -commit 2c11a510ccbeb3e2f6d42877fa8f0d85f92e49be -Author: Peter Caspers -Date: Wed, 11 May 2022 15:41:58 +0200 +commit 3e8cd5c92358143a8853ee73d53a1d9df5765e52 +Author: Luigi Ballabio +Date: Fri, 27 Jan 2023 22:18:09 +0100 - remove sessionId from github workflows + Fix typo in test name - .github/workflows/linux-full-tests.yml | 6 +----- - .github/workflows/linux-nondefault.yml | 3 +-- - .github/workflows/linux.yml | 6 +----- - 3 files changed, 3 insertions(+), 12 deletions(-) + test-suite/americanoption.cpp | 4 ++-- + test-suite/americanoption.hpp | 2 +- + 2 files changed, 3 insertions(+), 3 deletions(-) -commit 558d2b3f4756a71f796848829c4d6cbfdc9dd98a +commit 859caf322e5afd34199c24d5f188710456357134 Author: klausspanderen -Date: Wed, 11 May 2022 10:42:46 +0200 +Date: Fri, 27 Jan 2023 20:35:53 +0100 - . + no need to swap intermediate variables back - CMakeLists.txt | 2 +- - ql/CMakeLists.txt | 2 + - ql/math/interpolations/chebyshevinterpolation.hpp | 3 - - ql/pricingengines/vanilla/Makefile.am | 6 +- - ql/pricingengines/vanilla/qrplusamericanengine.cpp | 236 +++++++++++++++++++++ - ql/pricingengines/vanilla/qrplusamericanengine.hpp | 63 ++++++ - test-suite/americanoption.cpp | 137 +++++++++++- - test-suite/americanoption.hpp | 2 + - 8 files changed, 444 insertions(+), 7 deletions(-) + ql/pricingengines/vanilla/bjerksundstenslandengine.cpp | 4 ---- + 1 file changed, 4 deletions(-) -commit cd3986b11b6717cb1383ac642d4743a9ab1c50d4 -Author: Peter Caspers -Date: Wed, 11 May 2022 09:13:13 +0200 - - update description of singleton - - ql/patterns/singleton.hpp | 25 +++++++++---------------- - 1 file changed, 9 insertions(+), 16 deletions(-) - -commit b2cceec6e1ef4e4e71d5efbcb14233b8b7c3ae8a -Author: Peter Caspers -Date: Wed, 11 May 2022 08:41:40 +0200 - - update examples - - Examples/BasketLosses/BasketLosses.cpp | 6 ------ - Examples/BermudanSwaption/BermudanSwaption.cpp | 9 --------- - Examples/Bonds/Bonds.cpp | 9 --------- - Examples/CDS/CDS.cpp | 7 ------- - Examples/CVAIRS/CVAIRS.cpp | 8 -------- - Examples/CallableBonds/CallableBonds.cpp | 7 ------- - Examples/ConvertibleBonds/ConvertibleBonds.cpp | 9 --------- - Examples/DiscreteHedging/DiscreteHedging.cpp | 9 --------- - Examples/EquityOption/EquityOption.cpp | 9 --------- - Examples/FRA/FRA.cpp | 8 -------- - Examples/FittedBondCurve/FittedBondCurve.cpp | 6 ------ - Examples/Gaussian1dModels/Gaussian1dModels.cpp | 8 -------- - Examples/GlobalOptimizer/GlobalOptimizer.cpp | 8 -------- - Examples/LatentModel/LatentModel.cpp | 9 --------- - Examples/MarketModels/MarketModels.cpp | 9 --------- - Examples/MulticurveBootstrapping/MulticurveBootstrapping.cpp | 9 --------- - Examples/MultidimIntegral/MultidimIntegral.cpp | 8 -------- - Examples/Replication/Replication.cpp | 8 -------- - Examples/Repo/Repo.cpp | 8 -------- - 19 files changed, 154 deletions(-) - -commit 7891fb41fff24d03aa8f12d0c513aa539571542a -Author: Peter Caspers -Date: Wed, 11 May 2022 08:41:01 +0200 - - update build system +commit eaf9825b7779ab5db4942d94e93829623a2f596f +Merge: 67979af93 2891bc42e +Author: Luigi Ballabio +Date: Fri, 27 Jan 2023 15:26:15 +0100 - Examples/CMakeLists.txt | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) + Ensure that inflation curves are re-bootstrapped when seasonality is added (#1572) -commit 2bc4a2977ed958cf3fbc6b55adf66a7318abe201 -Author: Peter Caspers -Date: Wed, 11 May 2022 08:39:57 +0200 +commit 2891bc42e2f97c4591fe8a5772cd43101fc19a9f +Author: Luigi Ballabio +Date: Fri, 27 Jan 2023 11:41:55 +0100 - update build system + Less verbose declarations - CMakeLists.txt | 5 ++--- - configure.ac | 16 ---------------- - ql/auto_link.hpp | 2 +- - ql/config.hpp.cfg | 1 - - ql/userconfig.hpp | 8 -------- - test-suite/CMakeLists.txt | 6 ++---- - test-suite/quantlibbenchmark.cpp | 6 ------ - test-suite/quantlibtestsuite.cpp | 8 -------- - 8 files changed, 5 insertions(+), 47 deletions(-) + ql/termstructures/inflationtermstructure.cpp | 24 ++++++++++-------------- + ql/termstructures/inflationtermstructure.hpp | 21 ++++++++++----------- + 2 files changed, 20 insertions(+), 25 deletions(-) -commit 738c9677bef93b0c150255b4f02d515a4b4c802b -Author: Peter Caspers -Date: Tue, 10 May 2022 15:35:28 +0200 +commit 856c362b6850d1797e8f5fae007c4e12e07e7fe6 +Author: Luigi Ballabio +Date: Thu, 26 Jan 2023 19:00:07 +0100 - simplify singleton implementation + Update tests - ql/patterns/singleton.hpp | 114 ++++------------------------------------------ - 1 file changed, 8 insertions(+), 106 deletions(-) + test-suite/inflation.cpp | 650 +++++++++++++++++++++++++++-------------------- + test-suite/inflation.hpp | 1 + + 2 files changed, 369 insertions(+), 282 deletions(-) -commit 6a66a29a78d804c3cfd1061b645122c628e9313e +commit fb4598abfe1457cbbeaf1dcc8936e902c6bc44f0 Author: klausspanderen -Date: Sat, 9 Apr 2022 20:24:45 +0200 +Date: Fri, 27 Jan 2023 00:32:15 +0100 - test call put parity for American option + relax tol - test-suite/americanoption.cpp | 92 ++++++++++++++++++++++++++++++++++ - test-suite/americanoption.hpp | 1 + - test-suite/fdheston.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++ - test-suite/fdheston.hpp | 1 + - 4 files changed, 206 insertions(+) + test-suite/americanoption.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) -commit 643e69bdfe047aac91559c4d892a7e8e20955119 -Author: klausspanderen -Date: Thu, 7 Apr 2022 00:04:04 +0200 +commit 67979af93ad6dd252247afcf22af9a7650347b1b +Author: Luigi Ballabio +Date: Thu, 26 Jan 2023 09:42:00 +0100 - fixed single file compilation + Fix for documentation. - ql/math/integrals/tanhsinhintegral.hpp | 1 + - 1 file changed, 1 insertion(+) + Docs/pages/config.docs | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) -commit 179eda7ae360fb546719b92325eb9c79237b2000 -Author: klausspanderen -Date: Wed, 6 Apr 2022 23:08:00 +0200 +commit a1d5851db5339781526e9819cefa10a15ab5c499 +Author: Luigi Ballabio +Date: Thu, 26 Jan 2023 09:39:26 +0100 - fixed build + Ensure that inflation curves recalculate when seasonality is set - ql/math/Makefile.am | 2 +- - ql/math/interpolations/Makefile.am | 9 ++++----- - 2 files changed, 5 insertions(+), 6 deletions(-) + ql/termstructures/inflationtermstructure.cpp | 23 +++++++++++++++++------ + 1 file changed, 17 insertions(+), 6 deletions(-) -commit 154919949d5e19b26356ee079cf0fd15d1610189 +commit 3607f5bd4df01dfd6d58bfc8eb8c30679dd21e5b Author: klausspanderen -Date: Wed, 6 Apr 2022 22:40:05 +0200 +Date: Wed, 25 Jan 2023 22:34:56 +0100 - add chebyshev interpolation make file + use std namespace - CMakeLists.txt | 2 ++ - ql/math/Makefile.am | 1 + - 2 files changed, 3 insertions(+) + ql/pricingengines/vanilla/bjerksundstenslandengine.cpp | 18 ++++++++++-------- + test-suite/americanoption.cpp | 2 +- + 2 files changed, 11 insertions(+), 9 deletions(-) -commit ffe53ca373794ef7f8b7b17c0f6aa977e83fac41 +commit 90ff94541e4beb9c8ace181d78664d4f76028c90 Author: klausspanderen -Date: Tue, 5 Apr 2022 21:10:31 +0200 - - . - - ql/CMakeLists.txt | 3 + - ql/math/integrals/Makefile.am | 1 + - ql/math/integrals/all.hpp | 1 + - ql/math/integrals/tanhsinhintegral.hpp | 85 +++++++++++++++++++++++ - ql/math/interpolations/Makefile.am | 26 +++++++ - ql/math/interpolations/all.hpp | 1 + - ql/math/interpolations/chebyshevinterpolation.cpp | 73 +++++++++++++++++++ - ql/math/interpolations/chebyshevinterpolation.hpp | 60 ++++++++++++++++ - test-suite/integrals.cpp | 13 ++++ - test-suite/integrals.hpp | 1 + - test-suite/interpolations.cpp | 42 +++++++++++ - test-suite/interpolations.hpp | 1 + - 12 files changed, 307 insertions(+) - -commit 0bb5f1e5d3a074a37f41c6bed5e9e175f8aafb20 -Author: RalfKonrad -Date: Sun, 3 Oct 2021 23:14:34 +0200 - - Prevent (weird !?) -Werror=deprecated-declarations error for gcc compilers +Date: Wed, 25 Jan 2023 22:05:30 +0100 - ql/indexes/inflationindex.cpp | 5 +++++ - 1 file changed, 5 insertions(+) + reduced test runtime -commit acb130cba7c7aef7936fed3aa52651f3bfbcc248 -Author: RalfKonrad -Date: Sun, 3 Oct 2021 19:09:59 +0200 + test-suite/americanoption.cpp | 66 +++++++++++++++++++++---------------------- + 1 file changed, 32 insertions(+), 34 deletions(-) - small enhancements +commit ea123811d9cb8ab8caee259d4f7d11a6622b6caf +Author: klausspanderen +Date: Wed, 25 Jan 2023 21:02:01 +0100 - ql/indexes/inflationindex.cpp | 12 +++++------- - ql/indexes/inflationindex.hpp | 18 ++++++------------ - 2 files changed, 11 insertions(+), 19 deletions(-) + PR candidate -commit c86250cd9ec9057a9b6326fc11e0ad9d77fa14e5 -Author: RalfKonrad -Date: Sat, 2 Oct 2021 17:00:16 +0200 + .../vanilla/bjerksundstenslandengine.cpp | 485 +++++++++++++++------ + .../vanilla/bjerksundstenslandengine.hpp | 5 + + test-suite/americanoption.cpp | 287 +++++++++--- + test-suite/americanoption.hpp | 1 + + 4 files changed, 592 insertions(+), 186 deletions(-) - fixed -Werror,-Wreorder +commit b0d01ab942f5730a086ed21d5477ca555abf4764 +Author: Luigi Ballabio +Date: Wed, 25 Jan 2023 15:23:29 +0100 - ql/indexes/inflationindex.cpp | 8 +++----- - ql/indexes/inflationindex.hpp | 2 +- - 2 files changed, 4 insertions(+), 6 deletions(-) + Use ccache when checking compilation of single headers -commit 6fbb5062fa7430d934b91861367d9c8f45e81250 -Author: RalfKonrad -Date: Sat, 2 Oct 2021 16:47:28 +0200 - - Reverted clang format changes for better comparison. - - ql/cashflows/cpicoupon.cpp | 154 ++++++++++---------- - ql/cashflows/cpicoupon.hpp | 47 +++--- - .../inflation/cpicapfloortermpricesurface.cpp | 1 + - ql/experimental/inflation/genericindexes.hpp | 68 +++++---- - ql/indexes/inflationindex.cpp | 160 +++++++++++---------- - ql/indexes/inflationindex.hpp | 52 ++++--- - ql/instruments/cpicapfloor.cpp | 30 ++-- - ql/termstructures/inflation/inflationhelpers.cpp | 2 +- - test-suite/inflationcapfloor.cpp | 2 + - test-suite/inflationcpibond.cpp | 1 + - test-suite/inflationcpicapfloor.cpp | 1 + - test-suite/inflationcpiswap.cpp | 1 + - 12 files changed, 295 insertions(+), 224 deletions(-) - -commit 78e7537d6728706a87dea5afad9bb45a0b3b9f31 -Author: RalfKonrad -Date: Sun, 28 Feb 2021 18:51:16 +0100 + .github/workflows/headers.yml | 12 +++++++++++- + tools/check_header.py | 16 +++++++++++++--- + 2 files changed, 24 insertions(+), 4 deletions(-) - Own QL_DEPRECATED_[DIS|EN]ABLE_WARNING_III macros to find places I am wroking on... +commit 267769d3ebefb7057d2a7f181d8d098f3627b526 +Merge: 3a9f9c3a0 26ede791d +Author: Luigi Ballabio +Date: Mon, 23 Jan 2023 12:09:51 +0100 - ql/indexes/inflationindex.hpp | 30 ++++----- - ql/qldefines.hpp | 121 +++++++++++++++--------------------- - test-suite/inflation.cpp | 4 +- - test-suite/inflationcapfloor.cpp | 4 +- - test-suite/inflationcpibond.cpp | 4 +- - test-suite/inflationcpicapfloor.cpp | 12 ++-- - test-suite/inflationcpiswap.cpp | 8 +-- - 7 files changed, 81 insertions(+), 102 deletions(-) + Unify barrier options and dividend barrier options (#1568) -commit 8b1ecc0635a960b89acf68a3931fc0850a5dd1b3 -Author: RalfKonrad -Date: Sat, 27 Feb 2021 15:37:11 +0100 +commit 26ede791dd95a4c1bdaf616539902f1d7a9076fb +Author: Luigi Ballabio +Date: Sun, 22 Jan 2023 09:49:59 +0100 - Used PR #1055 in advance... + Deprecate dividend barrier option arguments and engine - ql/indexes/inflationindex.hpp | 31 ---------- - ql/qldefines.hpp | 134 +++++++++++++++++++++++++++--------------- - 2 files changed, 88 insertions(+), 77 deletions(-) + ql/experimental/barrieroption/vannavolgabarrierengine.hpp | 2 +- + ql/instruments/barrieroption.cpp | 2 +- + ql/instruments/dividendbarrieroption.cpp | 2 ++ + ql/instruments/dividendbarrieroption.hpp | 12 +++++++++++- + ql/pricingengines/barrier/fdblackscholesbarrierengine.cpp | 2 ++ + ql/pricingengines/barrier/fdblackscholesrebateengine.cpp | 2 ++ + ql/pricingengines/barrier/fdhestonbarrierengine.cpp | 2 ++ + ql/pricingengines/barrier/fdhestonrebateengine.cpp | 2 ++ + 8 files changed, 23 insertions(+), 3 deletions(-) -commit 24c01e8ab50209a4a0b5d8446dc4f4a5bf83d699 -Author: RalfKonrad -Date: Fri, 26 Feb 2021 18:10:24 +0100 +commit 3a9f9c3a04ba9e03d396e733f994c9ca3fd8b686 +Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> +Date: Sun, 22 Jan 2023 05:44:36 +0000 - Avoid deprecated warnings. + Automated fixes by clang-tidy - ql/instruments/zerocouponinflationswap.cpp | 6 ++++++ - ql/termstructures/inflation/inflationhelpers.cpp | 4 ++++ - 2 files changed, 10 insertions(+) + ql/termstructures/inflation/interpolatedzeroinflationcurve.hpp | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) -commit 308ce7bf3012124ab839da6222fd7846ae795ae6 -Author: RalfKonrad -Date: Fri, 26 Feb 2021 17:02:02 +0100 +commit 1d5f1ec515ec84dc97905a72b9c90f3e812ac8ad +Author: Luigi Ballabio +Date: Sat, 21 Jan 2023 23:05:38 +0100 - Minor changes + Allow implied volatility calculation with dividends - ql/indexes/inflationindex.cpp | 6 +++--- - ql/instruments/cpicapfloor.cpp | 1 + - 2 files changed, 4 insertions(+), 3 deletions(-) + ql/instruments/barrieroption.cpp | 19 +++++++++- + ql/instruments/barrieroption.hpp | 12 ++++++ + test-suite/barrieroption.cpp | 82 ++++++++++++++++++++++++++++++++++++++++ + test-suite/barrieroption.hpp | 1 + + 4 files changed, 112 insertions(+), 2 deletions(-) -commit c68cf714905c3bb663cb239000f68180e1a87d33 -Author: RalfKonrad -Date: Fri, 26 Feb 2021 17:00:41 +0100 +commit 121e500e319673145e65dde232736fadf26166f2 +Author: Luigi Ballabio +Date: Sat, 21 Jan 2023 22:00:15 +0100 - Reverted changes + Vanna/Volga engine doesn't support dividends - ql/instruments/zerocouponinflationswap.cpp | 93 ++++++------------ - ql/instruments/zerocouponinflationswap.hpp | 41 +++----- - ql/termstructures/inflation/inflationhelpers.cpp | 116 +++++++++++------------ - ql/termstructures/inflation/inflationhelpers.hpp | 75 ++++++--------- - 4 files changed, 126 insertions(+), 199 deletions(-) + ql/experimental/barrieroption/vannavolgabarrierengine.hpp | 11 ++--------- + 1 file changed, 2 insertions(+), 9 deletions(-) -commit 89cef04583cd60bfd4d6699ee1d2f764cf694b04 -Author: RalfKonrad -Date: Fri, 26 Feb 2021 16:37:45 +0100 +commit 6eb778c43bc3b7591d2e8bc16393a6658e1354a0 +Author: Luigi Ballabio +Date: Sat, 21 Jan 2023 17:34:03 +0100 - bugfix + Deprecate DividendBarrierOption - ql/instruments/cpicapfloor.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) + .../barrieroption/vannavolgabarrierengine.hpp | 6 ++++- + ql/instruments/barrieroption.cpp | 2 ++ + ql/instruments/dividendbarrieroption.hpp | 7 ++++-- + .../barrier/fdblackscholesbarrierengine.cpp | 14 +++++------ + .../barrier/fdblackscholesbarrierengine.hpp | 10 ++++---- + .../barrier/fdblackscholesrebateengine.hpp | 14 +++++------ + .../barrier/fdhestonbarrierengine.cpp | 27 ++++++++++++---------- + .../barrier/fdhestonbarrierengine.hpp | 11 ++++----- + ql/pricingengines/barrier/fdhestonrebateengine.cpp | 4 ++++ + ql/pricingengines/barrier/fdhestonrebateengine.hpp | 17 ++++++-------- + test-suite/barrieroption.cpp | 16 +++++++++---- + 11 files changed, 73 insertions(+), 55 deletions(-) -commit edf12b298fc9d32d4e677b4c748d8449f417b11e -Author: RalfKonrad -Date: Fri, 26 Feb 2021 16:34:35 +0100 +commit 7d203e6e6b2bb661ea4daf01c46e82342d759211 +Author: Luigi Ballabio +Date: Sat, 21 Jan 2023 09:52:39 +0100 - Added copyrights + Enable FD barrier engines to take dividends directly. + + Being market data, they should be stored in the engine and not + the instrument. This makes it possible to use the BarrierOption + class to calculate prices with discrete dividends. - ql/cashflows/cpicoupon.cpp | 1 + - ql/cashflows/cpicoupon.hpp | 1 + - ql/instruments/zerocouponinflationswap.cpp | 1 + - ql/instruments/zerocouponinflationswap.hpp | 1 + - ql/termstructures/inflation/inflationhelpers.cpp | 1 + - ql/termstructures/inflation/inflationhelpers.hpp | 1 + - 6 files changed, 6 insertions(+) + .../stepconditions/fdmstepconditioncomposite.cpp | 16 +- + .../barrier/fdblackscholesbarrierengine.cpp | 35 +++- + .../barrier/fdblackscholesbarrierengine.hpp | 25 ++- + .../barrier/fdblackscholesrebateengine.cpp | 27 ++- + .../barrier/fdblackscholesrebateengine.hpp | 26 ++- + .../barrier/fdhestonbarrierengine.cpp | 31 +++- + .../barrier/fdhestonbarrierengine.hpp | 27 ++- + ql/pricingengines/barrier/fdhestonrebateengine.cpp | 23 ++- + ql/pricingengines/barrier/fdhestonrebateengine.hpp | 17 +- + test-suite/barrieroption.cpp | 200 ++++++++++++++++++++- + test-suite/barrieroption.hpp | 2 + + 11 files changed, 380 insertions(+), 49 deletions(-) -commit f5a41ffc64bcaa942b754df52c89b89f8302ae02 -Author: RalfKonrad -Date: Fri, 26 Feb 2021 15:45:36 +0100 +commit 2cd3a39cdac84db1b0c2c5ef076331f2bb343217 +Merge: cb441e5d7 870d37b36 +Author: Luigi Ballabio +Date: Wed, 18 Jan 2023 12:20:04 +0100 - Disabled deprecated warning. + Remove features deprecated in version 1.25 (#1565) - ql/experimental/inflation/cpicapfloortermpricesurface.cpp | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) +commit 870d37b3687be3575095ff338a061db34ed76bc5 +Author: Luigi Ballabio +Date: Tue, 17 Jan 2023 16:29:35 +0100 -commit 849abd7f3da03e2bedc8506336bea7dc0415e9aa -Author: RalfKonrad -Date: Fri, 26 Feb 2021 15:41:38 +0100 + Remove features deprecated in version 1.25 - CPI::InterpolationType is specific to CPICoupon based intruments. + ql/cashflows/couponpricer.cpp | 8 +- + ql/cashflows/couponpricer.hpp | 12 --- + .../barrieroption/suowangdoublebarrierengine.hpp | 6 -- + .../inflation/yoycapfloortermpricesurface.cpp | 8 +- + .../inflation/yoycapfloortermpricesurface.hpp | 5 +- + ql/instruments/forwardrateagreement.cpp | 73 +------------ + ql/instruments/forwardrateagreement.hpp | 78 +------------- + .../inflation/interpolatedzeroinflationcurve.hpp | 64 +----------- + .../inflation/piecewisezeroinflationcurve.hpp | 28 ----- + ql/termstructures/inflationtermstructure.cpp | 109 ++------------------ + ql/termstructures/inflationtermstructure.hpp | 113 +-------------------- + .../yield/overnightindexfutureratehelper.cpp | 47 --------- + .../yield/overnightindexfutureratehelper.hpp | 24 ----- + 13 files changed, 22 insertions(+), 553 deletions(-) - ql/cashflows/cpicoupon.cpp | 218 +++++++++++++++++++++--------------------- - ql/cashflows/cpicoupon.hpp | 33 +++++++ - ql/indexes/inflationindex.cpp | 14 --- - ql/indexes/inflationindex.hpp | 45 --------- - 4 files changed, 140 insertions(+), 170 deletions(-) +commit cb441e5d76f8a988a3037001c571a4164428d9e8 +Merge: 93f7dba56 3543dd57b +Author: Luigi Ballabio +Date: Tue, 17 Jan 2023 14:53:58 +0100 -commit 60424a0d6cb0ee15b13b5ade2eb58cfc0c480de0 -Author: RalfKonrad -Date: Fri, 26 Feb 2021 15:30:33 +0100 + Ensure zero is found in Gaussian Random Default Model (#1560) - Reverted to master +commit 93f7dba566ce04ff23feab3c028acddeb45a0589 +Merge: 9883fcf20 dc743e309 +Author: Luigi Ballabio +Date: Tue, 17 Jan 2023 14:53:13 +0100 - .../inflation/cpicapfloortermpricesurface.cpp | 114 +++---- - .../inflation/cpicapfloortermpricesurface.hpp | 338 ++++++++------------- - 2 files changed, 173 insertions(+), 279 deletions(-) + New Zealand calendar missing Matariki holiday #1562 (#1564) -commit b75d5db265409ad778eb4c2923617dbd0e14f065 -Author: RalfKonrad -Date: Fri, 26 Feb 2021 15:20:02 +0100 +commit 9883fcf2095d31688d8bf8a917405dfe1b4d6f1f +Author: Luigi Ballabio +Date: Tue, 17 Jan 2023 13:02:30 +0100 - ZeroCouponInflationSwap is not CPI + Remove obsolete badge - ql/instruments/zerocouponinflationswap.cpp | 22 +++++++++------------- - ql/instruments/zerocouponinflationswap.hpp | 9 +++------ - ql/termstructures/inflation/inflationhelpers.cpp | 14 ++++++++------ - ql/termstructures/inflation/inflationhelpers.hpp | 4 ++-- - 4 files changed, 22 insertions(+), 27 deletions(-) + README.md | 1 - + 1 file changed, 1 deletion(-) -commit 1bf8a054b04960f5a781c86a3487f50dec5b54bf -Author: Ralf Konrad <42419984+ralfkonrad@users.noreply.github.com> -Date: Thu, 25 Feb 2021 23:09:22 +0100 +commit 3cbdbf840b48eb3a2bc03eb674bc1fa9110c73fd +Author: Luigi Ballabio +Date: Thu, 15 Apr 2021 16:25:45 +0200 - Added missing header file. + Set version to 1.30-dev. - ql/instruments/zerocouponinflationswap.hpp | 1 + - 1 file changed, 1 insertion(+) + CMakeLists.txt | 6 +++--- + configure.ac | 2 +- + ql/version.hpp | 4 ++-- + 3 files changed, 6 insertions(+), 6 deletions(-) -commit bab8c96830fc28f17263f5194ce7aaeb07956f07 -Author: Ralf Konrad <42419984+ralfkonrad@users.noreply.github.com> -Date: Thu, 25 Feb 2021 22:12:19 +0100 +commit dc743e309adbb31aa6a9914fc6d7c748282865cd +Author: g.t <113254017+jakeheke75@users.noreply.github.com> +Date: Sun, 15 Jan 2023 22:15:20 +0100 - bugfix + Update newzealand.cpp - test-suite/inflationcpicapfloor.cpp | 4 ++-- + ql/time/calendars/newzealand.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -commit cac9ab3c1fdb30688b1a8e307eb95c8d1b677684 -Author: RalfKonrad -Date: Thu, 25 Feb 2021 21:13:57 +0100 - - Disabled more deprecated warnings in testsuite. - - test-suite/inflationcpicapfloor.cpp | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 9fc5696acbc17473917ccf3560df6a8389d3ccbc -Author: RalfKonrad -Date: Thu, 25 Feb 2021 20:30:37 +0100 - - Disabled more deprecated warnings in testsuite. - - test-suite/inflation.cpp | 4 ++++ - 1 file changed, 4 insertions(+) - -commit 250bdf31d95d2addbd48af3dc90122e236ff9b13 -Author: RalfKonrad -Date: Thu, 25 Feb 2021 20:12:25 +0100 - - Disabled more deprecated warnings in testsuite. - - test-suite/inflationcapfloor.cpp | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -commit 47d4c645adf9d7f9e8af5f0c7ead38e7ca09a836 -Author: RalfKonrad -Date: Thu, 25 Feb 2021 20:01:41 +0100 - - Disabled more deprecated warnings in testsuite. - - test-suite/inflationcpiswap.cpp | 4 ++++ - 1 file changed, 4 insertions(+) - -commit b288ba3279b11fea2cc3e6d28910a3da4639bc1a -Author: RalfKonrad -Date: Thu, 25 Feb 2021 19:56:41 +0100 - - Refactored from detail::effectiveInterpolationType(...) to detail::CPI::effectiveInterpolationType(...) - - .../inflation/cpicapfloortermpricesurface.cpp | 2 +- - .../inflation/cpicapfloortermpricesurface.hpp | 2 +- - ql/indexes/inflationindex.cpp | 8 +++--- - ql/indexes/inflationindex.hpp | 32 ++++++++++++---------- - ql/instruments/cpicapfloor.cpp | 2 +- - ql/instruments/zerocouponinflationswap.cpp | 8 ++++-- - ql/termstructures/inflation/inflationhelpers.cpp | 2 +- - 7 files changed, 30 insertions(+), 26 deletions(-) - -commit fa0186617f25279fd2de09d55d6fe4444625a632 -Author: RalfKonrad -Date: Thu, 25 Feb 2021 19:38:18 +0100 - - Disabled more deprecated warnings in testsuite. - - ql/indexes/inflationindex.hpp | 2 ++ - test-suite/inflationcpibond.cpp | 4 ++++ - test-suite/inflationcpicapfloor.cpp | 8 ++++++++ - test-suite/inflationcpiswap.cpp | 4 ++++ - 4 files changed, 18 insertions(+) - -commit 38df7a95a92a1a9722832f87b3ca831bf02169e1 -Author: RalfKonrad -Date: Thu, 25 Feb 2021 19:06:07 +0100 - - Deprecated CPICapFloorTermPriceSurface constructor because of missing CPI::InterpolationType, silently deprecated ZeroInflationIndex::isInterpolated was used. - - .../inflation/cpicapfloortermpricesurface.cpp | 114 ++++--- - .../inflation/cpicapfloortermpricesurface.hpp | 338 +++++++++++++-------- - 2 files changed, 279 insertions(+), 173 deletions(-) +commit facd7bba57c68cd78719ea7c7b090ab276ff6f82 +Author: g.t <113254017+jakeheke75@users.noreply.github.com> +Date: Sun, 15 Jan 2023 14:40:48 +0100 -commit 5704f7d45312d969b92017fb48d21b69482cc5ad -Author: RalfKonrad -Date: Thu, 25 Feb 2021 18:46:50 +0100 - - Deprecated ZeroCouponInflationSwapHelper constructor because of missing CPI::InterpolationType, silently deprecated ZeroInflationIndex::isInterpolated was used. - - ql/termstructures/inflation/inflationhelpers.cpp | 113 ++++++++++++----------- - ql/termstructures/inflation/inflationhelpers.hpp | 74 +++++++++------ - 2 files changed, 104 insertions(+), 83 deletions(-) - -commit 1445775298ca7b5bf607db2c775b7bce7b90fe8e -Author: RalfKonrad -Date: Thu, 25 Feb 2021 14:52:31 +0100 - - Deprecated ZeroCouponInflationSwap constructor because of missing CPI::InterpolationType, silently deprecated ZeroInflationIndex::isInterpolated was used. - - ql/instruments/zerocouponinflationswap.cpp | 48 ++++++++++++++++++++++++++---- - ql/instruments/zerocouponinflationswap.hpp | 26 ++++++++++++++++ - 2 files changed, 68 insertions(+), 6 deletions(-) - -commit c418ecd13c13899fb026f1ef21fb0dbbd4aaf9f0 -Author: RalfKonrad -Date: Thu, 25 Feb 2021 14:50:09 +0100 - - namespace detail {...} combines calls to ZeroInflationIndex::isInterpolated() and CPI::InterpolationType to get the effective type - - ql/indexes/inflationindex.cpp | 15 +++++++++++++++ - ql/indexes/inflationindex.hpp | 21 +++++++++++++++++++++ - ql/instruments/cpicapfloor.cpp | 9 ++------- - 3 files changed, 38 insertions(+), 7 deletions(-) - -commit dcb158bd3a5c1bf4b95ff0a3b15aec345e9332b6 -Author: RalfKonrad -Date: Thu, 25 Feb 2021 09:09:51 +0100 - - Avoid deprecated warnings. - - ql/instruments/cpicapfloor.cpp | 42 +++++++++++++++++++----------------------- - 1 file changed, 19 insertions(+), 23 deletions(-) - -commit 7d927a038252f506dd6e27d86558609eff12a266 -Author: RalfKonrad -Date: Thu, 25 Feb 2021 09:08:58 +0100 - - Moved 'CPI::InterpolationType' to 'inflationindex.hpp' as it is used together with it ZeroInflationIndex to set up coupons, instruments, termstructures etc. Therefore it avoids including 'cpicoupon.hpp' - - ql/cashflows/cpicoupon.hpp | 24 ------------------------ - ql/indexes/inflationindex.hpp | 25 ++++++++++++++++++++++++- - 2 files changed, 24 insertions(+), 25 deletions(-) - -commit c76eaefdcac43795814b27aa1444d1c85c2c18b4 -Author: RalfKonrad -Date: Wed, 24 Feb 2021 13:19:29 +0100 - - clang format first - - ql/instruments/zerocouponinflationswap.cpp | 48 ++++++++++++++---------------- - ql/instruments/zerocouponinflationswap.hpp | 16 +++------- - 2 files changed, 26 insertions(+), 38 deletions(-) - -commit 4798651308dffa8a6a954e57425449fdc95d28cb -Author: RalfKonrad -Date: Wed, 24 Feb 2021 13:00:18 +0100 - - Added QL_ENABLE_CPI_ASINDEX - - ql/cashflows/cpicoupon.hpp | 65 +++++++++++++++++++++++----------------------- - 1 file changed, 33 insertions(+), 32 deletions(-) - -commit 2f2c33bd3c6c13ed5b83524419159f3b6fdaab7b -Author: RalfKonrad -Date: Wed, 24 Feb 2021 09:08:30 +0100 - - Disabled deprecated warnings. - - test-suite/inflation.cpp | 14 +++++++++++++- - test-suite/inflationcpibond.cpp | 7 +++++-- - test-suite/inflationcpicapfloor.cpp | 8 ++++++-- - test-suite/inflationcpiswap.cpp | 7 +++++-- - 4 files changed, 29 insertions(+), 7 deletions(-) - -commit 17d8f558a2f4197cc98627b88b35fcf010430cb4 -Author: RalfKonrad -Date: Wed, 24 Feb 2021 08:41:57 +0100 - - Reverted changes - - test-suite/inflation.cpp | 988 ++++++++++++++++++++---------------- - test-suite/inflationcpibond.cpp | 171 ++++--- - test-suite/inflationcpicapfloor.cpp | 395 +++++++------- - test-suite/inflationcpiswap.cpp | 432 ++++++++-------- - 4 files changed, 1088 insertions(+), 898 deletions(-) - -commit 980ba9aa65bc76307def9c933f9d0c7b4148b26b -Author: RalfKonrad -Date: Tue, 23 Feb 2021 19:10:25 +0100 - - Avoid deprecated warning in constructor in gcc. - - ql/indexes/inflationindex.cpp | 14 +++++++++----- - 1 file changed, 9 insertions(+), 5 deletions(-) - -commit 7fa0566f793eddb6bfa2c2a36c3b2e02f8848217 -Author: RalfKonrad -Date: Tue, 23 Feb 2021 14:51:06 +0100 - - Override YoYInflationIndex::interpolated_; - - ql/indexes/inflationindex.cpp | 3 --- - ql/indexes/inflationindex.hpp | 10 +++++----- - 2 files changed, 5 insertions(+), 8 deletions(-) - -commit f06626f2e01ab2613f07f7259a4c711621c0f730 -Author: RalfKonrad -Date: Tue, 23 Feb 2021 14:41:29 +0100 - - Initializing and deprecated does not fit together. - - ql/indexes/inflationindex.cpp | 4 ++++ - ql/indexes/inflationindex.hpp | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -commit f7c53f2bca4cf77c0485a81c422d31131a42fa71 -Author: RalfKonrad -Date: Tue, 23 Feb 2021 13:52:08 +0100 - - Added QL_DEPRECATED_[DIS|EN]ABLE_WARNING_III_INTERPOLATED_METHOD - - ql/indexes/inflationindex.hpp | 9 +++++++++ - 1 file changed, 9 insertions(+) - -commit f267c0927be1a307caff1723fca76b408fae9c76 -Author: RalfKonrad -Date: Tue, 23 Feb 2021 12:50:47 +0100 - - Deprecated protected member bool InflationIndex::interpolated_; - - ql/experimental/inflation/genericindexes.hpp | 2 ++ - ql/indexes/inflation/aucpi.hpp | 2 ++ - ql/indexes/inflation/euhicp.hpp | 4 ++++ - ql/indexes/inflation/frhicp.hpp | 2 ++ - ql/indexes/inflation/ukrpi.hpp | 2 ++ - ql/indexes/inflation/uscpi.hpp | 2 ++ - ql/indexes/inflation/zacpi.hpp | 4 +++- - ql/indexes/inflationindex.cpp | 27 +++++++++++++++++++------- - ql/indexes/inflationindex.hpp | 29 ++++++++++++++++++++++------ - 9 files changed, 60 insertions(+), 14 deletions(-) - -commit 96b52d716591017715883075a975d7d2c5b6cbb6 -Author: RalfKonrad -Date: Tue, 23 Feb 2021 10:30:11 +0100 - - try to fix mac os boost::make_shared deprecated error - - test-suite/inflation.cpp | 24 ++++++++++++------------ - test-suite/inflationcpibond.cpp | 4 ++-- - test-suite/inflationcpicapfloor.cpp | 6 +++--- - test-suite/inflationcpiswap.cpp | 6 +++--- - 4 files changed, 20 insertions(+), 20 deletions(-) - -commit b20ed20fd60e7c00becfb2495c44f0d965b6ca2e -Author: RalfKonrad -Date: Tue, 23 Feb 2021 10:27:55 +0100 - - Renamed macro - - ql/indexes/inflationindex.hpp | 31 ++++++++++++++++++------------- - 1 file changed, 18 insertions(+), 13 deletions(-) - -commit 163bd0e223e77a9a26855af160c63529747e45cd -Author: RalfKonrad -Date: Tue, 23 Feb 2021 10:05:49 +0100 - - try to fix macos boost::make_shared deprecated error - - test-suite/inflationcpibond.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit 1d6330ea4e80e962a21e767eb11089dc3a1b9557 -Author: RalfKonrad -Date: Mon, 22 Feb 2021 20:16:59 +0100 - - ..._SKIP_WARNING(CODE) macro does not work with gcc, only with clang and vs c++ - - ql/indexes/inflationindex.hpp | 11 +++-------- - test-suite/inflation.cpp | 25 +++++++++++++++++++------ - test-suite/inflationcpibond.cpp | 4 +++- - test-suite/inflationcpicapfloor.cpp | 4 +++- - test-suite/inflationcpiswap.cpp | 4 +++- - 5 files changed, 31 insertions(+), 17 deletions(-) - -commit dc0b74af647d30a8493ffd2e66e86bcaeb575187 -Author: RalfKonrad -Date: Mon, 22 Feb 2021 19:31:02 +0100 + New Zealand calendar missing Matariki holiday #1562 + + Updated the header file with Doxygen tags and with the link to the NZ government website - Fixed QL_DEPRECATED_SKIP_WARNING_[] macros + ql/time/calendars/newzealand.cpp | 20 ++++++++++++++++++++ + ql/time/calendars/newzealand.hpp | 3 +++ + 2 files changed, 23 insertions(+) - ql/indexes/inflationindex.hpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) +commit 3543dd57b5ae519a5bfe57f5ec2f003ac185a4bf +Author: Peter Caspers +Date: Wed, 11 Jan 2023 11:32:13 +0100 -commit 9e25143862e2ced63a67c051a35dc686dd6de07e -Author: RalfKonrad -Date: Mon, 22 Feb 2021 19:07:08 +0100 + missing include - try QL_DEPRECATED_SKIP_WARNING_[] macros + ql/experimental/credit/randomdefaultmodel.cpp | 1 + + 1 file changed, 1 insertion(+) - test-suite/inflation.cpp | 12 ++++++------ - test-suite/inflationcpibond.cpp | 2 +- - test-suite/inflationcpicapfloor.cpp | 2 +- - test-suite/inflationcpiswap.cpp | 2 +- - 4 files changed, 9 insertions(+), 9 deletions(-) +commit 5a731414b06ceea785ab8d0028d235ab882220fa +Author: Peter Caspers +Date: Wed, 11 Jan 2023 11:25:17 +0100 -commit 58d6db7ef9b49b7b7ebcf480add2b50d63194110 -Author: RalfKonrad -Date: Mon, 22 Feb 2021 19:06:27 +0100 + ensure zero is found - Added QL_DEPRECATED_SKIP_WARNING_[] macros + ql/experimental/credit/randomdefaultmodel.cpp | 21 +++++++++++++++++---- + 1 file changed, 17 insertions(+), 4 deletions(-) - ql/indexes/inflationindex.hpp | 5 ++--- - 1 file changed, 2 insertions(+), 3 deletions(-) +commit 6523f36a34cfe00923fdb310ab3a322fcbb15b28 +Author: Matthias Groncki +Date: Thu, 15 Dec 2022 10:18:13 +0700 -commit a98df48aad5615932c54831ff79bc91db9dadda5 -Author: RalfKonrad -Date: Mon, 22 Feb 2021 18:56:53 +0100 + bugfix unused variables - clang format first + test-suite/inflationcpibond.cpp | 36 +++++++++++++++++++----------------- + 1 file changed, 19 insertions(+), 17 deletions(-) - test-suite/inflation.cpp | 975 ++++++++++++++++-------------------- - test-suite/inflationcpibond.cpp | 165 +++--- - test-suite/inflationcpicapfloor.cpp | 391 +++++++-------- - test-suite/inflationcpiswap.cpp | 428 ++++++++-------- - 4 files changed, 875 insertions(+), 1084 deletions(-) +commit 1acdc04a5c37396bf117e4b65e75064998e75615 +Author: Matthias Groncki +Date: Thu, 15 Dec 2022 09:51:33 +0700 -commit fb7b2b10e8a4129d586406d5b5bc15c197df3949 -Author: RalfKonrad -Date: Mon, 22 Feb 2021 18:40:53 +0100 + bugfix cpi coupons and cpi cashflow + + allow optional baseCPI if baseCPI is null, retrieve use the index fixing on baseDate instead - Added QL_DEPRECATED_SKIP_WARNING_[] macros + ql/cashflows/cpicoupon.cpp | 18 ++++++++- + ql/cashflows/cpicoupon.hpp | 2 + + test-suite/inflationcpibond.cpp | 81 ++++++++++++++++++++++++++++++++++++++++- + test-suite/inflationcpibond.hpp | 1 + + 4 files changed, 100 insertions(+), 2 deletions(-) - ql/indexes/inflationindex.hpp | 43 ++++++++++++++++++++++++++++++++++++++++++- - 1 file changed, 42 insertions(+), 1 deletion(-) +commit 1b66279eb2d8363be27364843afedcc68ce67604 +Author: klausspanderen +Date: Tue, 6 Dec 2022 07:40:26 +0100 -commit 14dc6d75ca1e5c5d5b934f3df12ea43805f39800 -Author: RalfKonrad -Date: Sun, 21 Feb 2021 21:39:23 +0100 + first light from greek engine - Do not inline interpolated(); to avoid deprecated warning on deprected interpolation_ + ql/pricingengines/blackcalculator.cpp | 16 ++ + ql/pricingengines/blackcalculator.hpp | 3 + + .../vanilla/bjerksundstenslandengine.cpp | 210 +++++++++++++++++---- + .../vanilla/bjerksundstenslandengine.hpp | 2 + + test-suite/americanoption.cpp | 182 ++++++++++++++++++ + test-suite/americanoption.hpp | 3 +- + 6 files changed, 376 insertions(+), 40 deletions(-) - ql/indexes/inflationindex.cpp | 5 ++++- - ql/indexes/inflationindex.hpp | 8 ++++---- - 2 files changed, 8 insertions(+), 5 deletions(-) +commit 1f17f68fe25213fd66ffe636e2002bcbaed9570b +Merge: 5f8f9472c 9f58be1bd +Author: Matthias Groncki +Date: Mon, 17 Oct 2022 13:38:26 +0200 -commit f0f760684d0dd1a32dd69629fb7785129613da57 -Author: RalfKonrad -Date: Sun, 21 Feb 2021 21:09:13 +0100 - - Renamed QL_TO_BE_DEPRECATED_INTERPOLATED_INFLATION_INDEXES - - ql/experimental/inflation/genericindexes.hpp | 2 +- - ql/indexes/inflation/aucpi.hpp | 2 +- - ql/indexes/inflation/euhicp.hpp | 4 ++-- - ql/indexes/inflation/frhicp.hpp | 2 +- - ql/indexes/inflation/ukrpi.hpp | 2 +- - ql/indexes/inflation/uscpi.hpp | 2 +- - ql/indexes/inflation/zacpi.hpp | 2 +- - ql/indexes/inflationindex.hpp | 30 +++++++++++++++++++++++----- - 8 files changed, 33 insertions(+), 13 deletions(-) - -commit 02c999929f3c74e090efbb829645b568c9577bca -Merge: 26560c4a3 3eec5b893 -Author: Ralf Konrad <42419984+ralfkonrad@users.noreply.github.com> -Date: Sun, 21 Feb 2021 18:50:59 +0100 - - Merge pull request #43 from ralfkonrad/update-copyright-list-refs/heads/feature/issue_1050__deprecate_inflation-index_interpolation + Merge pull request #2 from mgroncki/update-copyright-list-refs/heads/CPICoupons_withBaseDateInsteadBaseCPI Update copyright list in license -commit 3eec5b893af99e156a56623ba52f965567cf85ec +commit 9f58be1bd8d69431624d39c9ae36c10cbca98608 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> -Date: Sun, 21 Feb 2021 17:38:38 +0000 +Date: Mon, 17 Oct 2022 11:10:46 +0000 Update copyright list in license - LICENSE.TXT | 2 ++ - 1 file changed, 2 insertions(+) - -commit 26560c4a3283d79f5f918c7b2037197acf8cb9db -Author: RalfKonrad -Date: Sun, 21 Feb 2021 18:33:47 +0100 - - Rolled back changes for YoY Indexes - - ql/experimental/inflation/genericindexes.hpp | 28 +++--------------- - ql/indexes/inflation/aucpi.hpp | 18 ++---------- - ql/indexes/inflation/euhicp.hpp | 44 ++++++++++++---------------- - ql/indexes/inflation/frhicp.hpp | 16 ++-------- - ql/indexes/inflation/ukrpi.hpp | 36 +++++++++++------------ - ql/indexes/inflation/uscpi.hpp | 36 +++++++++++------------ - ql/indexes/inflation/zacpi.hpp | 36 +++++++++++------------ - ql/indexes/inflationindex.cpp | 30 +++---------------- - ql/indexes/inflationindex.hpp | 15 ---------- - 9 files changed, 85 insertions(+), 174 deletions(-) - -commit 3770516088ac300bc6e91883ac8244401daaeb5a -Merge: 16183ca67 3e5e39aff -Author: Ralf Konrad <42419984+ralfkonrad@users.noreply.github.com> -Date: Sun, 21 Feb 2021 18:11:14 +0100 - - Merge pull request #42 from ralfkonrad/clang-tidy-fixes-refs/heads/feature/issue_1050__deprecate_inflation-index_interpolation - - Automated fixes by clang-tidy - -commit 3e5e39aff547c34080d0c0237b2d606f561f7eb5 -Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> -Date: Sun, 21 Feb 2021 00:42:15 +0000 - - Automated fixes by clang-tidy - - ql/indexes/inflationindex.cpp | 26 +++++++++++++++++++++----- - 1 file changed, 21 insertions(+), 5 deletions(-) - -commit 16183ca67e70e0979fa16825c62e3146424360ea -Author: RalfKonrad -Date: Sat, 20 Feb 2021 22:12:46 +0100 - - QL_TO_BE_DEPRECATED_INTERPOLATED_YOY_INDEXES: enable deprecation of YoY seperately. - - ql/experimental/inflation/genericindexes.hpp | 4 ++-- - ql/indexes/inflation/aucpi.hpp | 4 ++-- - ql/indexes/inflation/euhicp.hpp | 6 +++--- - ql/indexes/inflation/frhicp.hpp | 4 ++-- - ql/indexes/inflation/ukrpi.hpp | 4 ++-- - ql/indexes/inflation/uscpi.hpp | 4 ++-- - ql/indexes/inflation/zacpi.hpp | 4 ++-- - ql/indexes/inflationindex.hpp | 6 +++++- - 8 files changed, 20 insertions(+), 16 deletions(-) - -commit 2cf5eb043b06948cb06cd24fdd981ad98a9ffbdc -Author: RalfKonrad -Date: Sat, 20 Feb 2021 20:56:26 +0100 - - Forgotten QL_TO_BE_DEPRECATED_INTERPOLATED_INFLATION_INDEXES - - ql/indexes/inflationindex.hpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -commit c44f67f1842edf3e4d54dae3fd8012641d960b4f -Author: RalfKonrad -Date: Sat, 20 Feb 2021 20:51:04 +0100 - - Added copyright - - ql/experimental/inflation/genericindexes.hpp | 1 + - 1 file changed, 1 insertion(+) - -commit 6c518bb6b9af343b25ea19ba3fd2256b14f89423 -Author: RalfKonrad -Date: Sat, 20 Feb 2021 20:48:11 +0100 - - Reoved QL_DEPRECATED to test... - - ql/indexes/inflationindex.hpp | 2 +- + LICENSE.TXT | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -commit 282de037ca03a00eb2d33d6f507c50c181b9014c -Author: RalfKonrad -Date: Sat, 20 Feb 2021 20:44:50 +0100 - - Add new constructors - - ql/experimental/inflation/genericindexes.hpp | 42 ++++++++++++++++++++++++---- - 1 file changed, 36 insertions(+), 6 deletions(-) - -commit c46fbabd5cf7d98f07b5708e943e910b3c71af87 -Author: RalfKonrad -Date: Sat, 20 Feb 2021 20:35:12 +0100 - - clang format first - - ql/experimental/inflation/genericindexes.hpp | 78 ++++++++++------------------ - 1 file changed, 28 insertions(+), 50 deletions(-) - -commit 1dc88c3babcce0d37e29c77eca68387e5a868e0f -Author: RalfKonrad -Date: Sat, 20 Feb 2021 20:33:11 +0100 - - renamed to QL_TO_BE_DEPRECATED_INTERPOLATED_INFLATION_INDEXES - - ql/indexes/inflation/aucpi.hpp | 6 +++--- - ql/indexes/inflation/euhicp.hpp | 10 +++++----- - ql/indexes/inflation/frhicp.hpp | 6 +++--- - ql/indexes/inflation/ukrpi.hpp | 6 +++--- - ql/indexes/inflation/uscpi.hpp | 6 +++--- - ql/indexes/inflation/zacpi.hpp | 6 +++--- - ql/indexes/inflationindex.hpp | 8 ++++---- - 7 files changed, 24 insertions(+), 24 deletions(-) - -commit 2180a56f72f66d57ce0e175406a861e08a040b33 -Author: RalfKonrad -Date: Sat, 20 Feb 2021 19:47:09 +0100 - - Wrong copyright year - - ql/indexes/inflation/aucpi.hpp | 2 +- - ql/indexes/inflation/euhicp.hpp | 2 +- - ql/indexes/inflation/frhicp.hpp | 2 +- - ql/indexes/inflation/ukrpi.hpp | 2 +- - ql/indexes/inflation/uscpi.hpp | 2 +- - ql/indexes/inflation/zacpi.hpp | 2 +- - ql/indexes/inflationindex.cpp | 2 +- - ql/indexes/inflationindex.hpp | 2 +- - 8 files changed, 8 insertions(+), 8 deletions(-) - -commit 3d5faeddfa897e70bba0a54152be5fba48616f3e -Author: RalfKonrad -Date: Sat, 20 Feb 2021 18:13:31 +0100 - - Add new constructors - - ql/indexes/inflation/aucpi.hpp | 36 ++++++++++++++++++-------- - ql/indexes/inflation/euhicp.hpp | 56 +++++++++++++++++++++++++---------------- - ql/indexes/inflation/frhicp.hpp | 31 +++++++++++++++-------- - ql/indexes/inflation/ukrpi.hpp | 51 ++++++++++++++++++------------------- - ql/indexes/inflation/uscpi.hpp | 42 +++++++++++++++++-------------- - ql/indexes/inflation/zacpi.hpp | 51 ++++++++++++++++++------------------- - 6 files changed, 154 insertions(+), 113 deletions(-) - -commit 39c011c6b0df7ddf2ae0fdc426ce55d1cfbe02dc -Author: RalfKonrad -Date: Sat, 20 Feb 2021 17:38:28 +0100 - - Add new constructors - - ql/indexes/inflationindex.cpp | 63 +++++++++++++++++++++++++++++++++++-------- - ql/indexes/inflationindex.hpp | 33 ++++++++++++++++++++++- - 2 files changed, 84 insertions(+), 12 deletions(-) - -commit 6c92a1373160f3dbd110cec596da69931c069d77 -Author: RalfKonrad -Date: Fri, 19 Feb 2021 18:24:09 +0100 - - Deprecated old constructors +commit 5f8f9472cf34f56223b4cb22df363fb9b4a70054 +Author: Matthias Groncki +Date: Mon, 17 Oct 2022 11:55:34 +0200 - ql/indexes/inflation/aucpi.hpp | 3 +++ - ql/indexes/inflation/euhicp.hpp | 24 ++++++++++++++++-------- - ql/indexes/inflation/frhicp.hpp | 18 ++++++++++++------ - ql/indexes/inflation/ukrpi.hpp | 18 ++++++++++++------ - ql/indexes/inflation/uscpi.hpp | 18 ++++++++++++------ - ql/indexes/inflation/zacpi.hpp | 18 ++++++++++++------ - ql/indexes/inflationindex.hpp | 14 +++++++++++++- - 7 files changed, 80 insertions(+), 33 deletions(-) + CPICoupon with baseDate + + add a new CPICoupon constructor which requires a baseDate instead of base CPI fixing value. If baseCPI is provided it will use it, if it baseCPI is NULL the pricer will retriev the index fixing at baseDate from the index. + + If baseDate and baseCPI are null and we have at least two dates in the schedule, CPILag will imply a regular baseDate = firstCouponStartDate - observationLag + If the CPILeg has only one date and one cashflow, a non-null baseDate or baseCPI are still required -commit 3b2de2ebf88790b89e24510c884ba58d17c7546d -Author: RalfKonrad -Date: Fri, 19 Feb 2021 17:50:15 +0100 - - clang format first - - ql/indexes/inflation/aucpi.hpp | 12 ++-- - ql/indexes/inflation/euhicp.hpp | 23 +++---- - ql/indexes/inflation/frhicp.hpp | 12 ++-- - ql/indexes/inflation/ukrpi.hpp | 11 ++- - ql/indexes/inflation/uscpi.hpp | 17 ++--- - ql/indexes/inflation/zacpi.hpp | 11 ++- - ql/indexes/inflationindex.cpp | 149 ++++++++++++++++++---------------------- - ql/indexes/inflationindex.hpp | 55 +++++---------- - 8 files changed, 116 insertions(+), 174 deletions(-) + ql/cashflows/cpicoupon.cpp | 116 ++++++++++++++++++++++++++++++++++++--- + ql/cashflows/cpicoupon.hpp | 44 +++++++++++++++ + ql/cashflows/cpicouponpricer.cpp | 14 ++++- + 3 files changed, 163 insertions(+), 11 deletions(-) diff --git a/Contributors.txt b/Contributors.txt index f5d98862c72..647bfd6d093 100644 --- a/Contributors.txt +++ b/Contributors.txt @@ -163,6 +163,7 @@ André Louw, Benson Luk, Matthias Lungwitz, Jasen Mackie, +Trent Maetzold, Andrea Maffezzoli, Joao Paulo Magalhaes, Jose Magana, @@ -240,6 +241,7 @@ Michael Sharpe, Kirill Shemyakin, Eugene Shevkoplyas, Mohammad Shojatalab, +Anastasiia Shumyk, Piotr Siejda, Matthias Siemering, Adityakumar Sinha, diff --git a/Docs/pages/history.docs b/Docs/pages/history.docs index 608c18e889a..18dec30bd90 100644 --- a/Docs/pages/history.docs +++ b/Docs/pages/history.docs @@ -17,7 +17,114 @@ /*! \page history Version history - Release 1.29 - January 2023 + Release 1.30 - April 2023 + + PORTABILITY + - **Future end of support:** as announced in the notes for the + previous release, after this release and the next, using + `std::tuple`, `std::function` and `std::bind` (instead of their + `boost` counterparts) will become the default. If you're using + `ext::tuple` etc. in your code (which is suggested), this should be + a transparent change. If not, you'll still be able to choose the + `boost` versions via a configure switch for a while; but we do + suggest you start using `ext::tuple` etc. in the meantime. + - CMake builds now use a stricter warning level by default; thanks to + Ralf Konrad. + - Is it now possible to use `std::any` and `std::optional` (and the + related `std::any_cast` and `std::nullopt`) instead of their `boost` + counterparts by setting new compilation switches; thanks to Jonathan + Sweemer. Using the `std` classes requires C++17. We + expect the `boost` classes to remain the default for a while, but in + the meantime we encourage to start using `ext::any` and + `ext::optional` in preparation for a new default. + + DATE/TIME + - Good Friday 2023 is now a business day for the US government bond + calendar; thanks to Anastasiia Shumyk. + - Added specialized Australian calendar for ASX; thanks to Trent + Maetzold. + - Fixed Turkish holidays between 2019 and 2023; thanks to Fredrik + Gerdin Börjesson. + - Added a few missing holidays to Danish calendar; thanks to Fredrik + Gerdin Börjesson. + - Added the Matariki holiday to the New Zealand calendar; thanks to + GitHub user jakeheke75. + + CASHFLOWS + - Added a new equity cash flow class to model equity legs in total + return swaps; thanks to Marcin Rybacki. Quanto + pricing is also supported. + - Added an overloaded constructor for CPI coupons that allows to + specify a base date instead of a base CPI value; thanks to Matthias + Groncki. + + INSTRUMENTS + - Added a new total-return swap; thanks to Marcin Rybacki. + An equity-index class was also added to support + this instrument. + - The analytic engine for barrier options would return NaN for low + values of volatility; this is now fixed. + - The `VanillaOption` and `BarrierOption` classes can now be used to + model vanilla and barrier options with discrete dividends; the + future dividends (not being part of the terms and conditions of the + contract) should be passed to the pricing engine instead. + - Added analytical Greeks to Bjerksund-Stensland engine; thanks to + Klaus Spanderen. + + INDEXES + - Added UKHICP inflation index; thanks to Fredrik Gerdin Börjesson. + + TERM STRUCTURES + - Renamed `SwaptionVolCube1`, `SwaptionVolCube1x`, `SwaptionVolCube1a` + and `SwaptionVolCube2` to `SabrSwaptionVolatilityCube`, + `XabrSwaptionVolatilityCube`, `NoArbSabrSwaptionVolatilityCube` and + `InterpolatedSwaptionVolatilityCube`, respectively; thanks to + Ignacio Anguita. The old names are deprecated but + still available for a few releases. + - Ensure that inflation curves are re-bootstrapped correctly when + seasonality is added. + + MODELS + - Moved the Heston SLV model from experimental to main; thanks to + Klaus Spanderen. + + MATH + - Added a few overloads to Array and Matrix operators taking rvalue + references for increased speed; thanks to Jonathan Sweemer. + + DEPRECATED FEATURES + - **Removed** features deprecated in version 1.24: + - the protected `spreadLegValue_` data member of `BlackIborCouponPricer`; + - the `WulinYongDoubleBarrierEngine` alias for `SuoWangDoubleBarrierEngine`; + - the `settlementDate`, `incomeDiscountCurve`, `spotIncome`, + `spotValue`, `impliedYield` and `forwardValue` methods of + `ForwardRateAgreement`, as well as its protected + `underlyingIncome_`, `underlyingSpotValue_`, `settlementDays_`, + `payoff_` and `incomeDiscountCurve_` data members; + - constructors for `InflationTermStructure`, + `ZeroInflationTermStructure`, `InterpolatedZeroInflationCurve`, + `PiecewiseZeroInflationCurve` taking an `indexIsInterpolated` + parameter; + - the `indexIsInterpolated` method of `InflationTermStructure` and + its protected `indexIsInterpolated_` data member; + - some overloaded constructors of `SofrFutureRateHelper`. + - Deprecated the `DividendVanillaOption` and `DividendBarrierOption` + classes; use `VanillaOption` and `BarrierOption` instead (see + above). + - Deprecated the constructor of `AnalyticDividendEuropeanEngine` that + takes no dividend information; use the other overload instead. + - Deprecated the names `SwaptionVolCube1`, `SwaptionVolCube1x`, + `SwaptionVolCube1a` and `SwaptionVolCube2` (see above). + - Deprecated the protected `setCommon` method of + `CappedFlooredYoYInflationCoupon`. + + Thanks go also to Jonathan Sweemer, the Xcelerit Dev + Team, Fredrik Gerdin Börjesson, Klaus + Spanderen and Peter Caspers for a number + of smaller fixes and improvements, and to Matthias Groncki + and GitHub user lukey8767 for raising issues. + + Release 1.29 - January 17th, 2023 PORTABILITY - End of support: as announced in the notes for the previous diff --git a/News.md b/News.md index af00988453a..9dd90365f98 100644 --- a/News.md +++ b/News.md @@ -1,25 +1,18 @@ -Changes for QuantLib 1.29: +Changes for QuantLib 1.30: ========================== -QuantLib 1.29 includes 42 pull requests from several contributors. +QuantLib 1.30 includes 34 pull requests from several contributors. Some of the most notable changes are included below. A detailed list of changes is available in ChangeLog.txt and at -. +. Portability ----------- -- **End of support:** as announced in the notes for the previous - release, this release no longer manages thread-local singletons via - a user-provided `sessionId` function, and therefore the latter is no - longer needed. Instead, the code now uses the built-in language - support for thread-local variables. Thanks go to Peter Caspers - (@pcaspers). - - **Future end of support:** as announced in the notes for the - previous release, after the next couple of releases, using + previous release, after this release and the next, using `std::tuple`, `std::function` and `std::bind` (instead of their `boost` counterparts) will become the default. If you're using `ext::tuple` etc. in your code (which is suggested), this should be @@ -27,116 +20,139 @@ Portability `boost` versions via a configure switch for a while; but we do suggest you start using `ext::tuple` etc. in the meantime. -- Replaced internal usage of `boost::thread` with `std::thread`; - thanks to Jonathan Sweemer (@sweemer). This removed our last - dependency on Boost binaries and makes it possible to compile - QuantLib using a header-only Boost installation. - -- On Windows, it is now possible to use the MSVC dynamic runtime when - using cmake by passing - `-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL` - on the command line; thanks to Jonathan Sweemer (@sweemer). The - static runtime remains the default. +- CMake builds now use a stricter warning level by default; thanks to + Ralf Konrad (@ralfkonrad). -- It is now possible to build QuantLib with Intel's `icpx` compiler - using cmake; thanks to Jonathan Sweemer (@sweemer). Note that in - order to get all the unit tests passing, `-fp-model=precise` must be - added to `CMAKE_CXX_FLAGS`. +- Is it now possible to use `std::any` and `std::optional` (and the + related `std::any_cast` and `std::nullopt`) instead of their `boost` + counterparts by setting new compilation switches; thanks to Jonathan + Sweemer (@sweemer). Using the `std` classes requires C++17. We + expect the `boost` classes to remain the default for a while, but in + the meantime we encourage to start using `ext::any` and + `ext::optional` in preparation for a new default. Date/time --------- -- Updated Chinese holidays for 2023; thanks to Cheng Li - (@wegamekinglc). +- Good Friday 2023 is now a business day for the US government bond + calendar; thanks to Anastasiia Shumyk (@ashumyk). + +- Added specialized Australian calendar for ASX; thanks to Trent + Maetzold (@trentmaetzold). + +- Fixed Turkish holidays between 2019 and 2023; thanks to Fredrik + Gerdin Börjesson (@gbfredrik). -- Added in-lieu holiday for Christmas 2022 to South-African calendar; - thanks to Joshua Hayes (@JoshHayes). +- Added a few missing holidays to Danish calendar; thanks to Fredrik + Gerdin Börjesson (@gbfredrik). + +- Added the Matariki holiday to the New Zealand calendar; thanks to + g.t. (@jakeheke75). + + +Cashflows +--------- -- Added King Charles III coronation holiday to UK calendar; thanks to - Fredrik Gerdin Börjesson (@gbfredrik). +- Added a new equity cash flow class to model equity legs in total + return swaps; thanks to Marcin Rybacki (@marcin-rybacki). Quanto + pricing is also supported. -- Added holiday for National Day of Mourning to Australian calendar; - thanks to Fredrik Gerdin Börjesson (@gbfredrik). +- Added an overloaded constructor for CPI coupons that allows to + specify a base date instead of a base CPI value; thanks to Matthias + Groncki (@mgroncki). Instruments ----------- -- Added high performance/precision American engine based on - fixed-point iteration for the exercise boundary; thanks to Klaus - Spanderen (@klausspanderen). +- Added a new total-return swap; thanks to Marcin Rybacki + (@marcin-rybacki). An equity-index class was also added to support + this instrument. -- Bonds with draw-down (i.e., increasing notionals) are now allowed; - thanks to Oleg Kulkov (@Borgomi42 ). +- The analytic engine for barrier options would return NaN for low + values of volatility; this is now fixed (@lballabio). -- Added `withIndexedCoupons` and `withAtParCoupons` methods to - `MakeSwaption` for easier initialization; thanks to Ralf Konrad - (@ralfkonrad). +- The `VanillaOption` and `BarrierOption` classes can now be used to + model vanilla and barrier options with discrete dividends; the + future dividends (not being part of the terms and conditions of the + contract) should be passed to the pricing engine instead (@lballabio). -- It is now possible to use the same pricing engine for vanilla and - dividend vanilla options, or for barrier and dividend barrier - options (@lballabio). +- Added analytical Greeks to Bjerksund-Stensland engine; thanks to + Klaus Spanderen (@klausspanderen). Indexes ------- -- Creating a zero inflation index as "interpolated" is now deprecated; - thanks to Ralf Konrad (@ralfkonrad). The index should only return - monthly fixings. Interpolation is now the responsibility of - inflation-based coupons. +- Added UKHICP inflation index; thanks to Fredrik Gerdin Börjesson + (@gbfredrik). Term structures --------------- -- The `ConstantCPIVolatility` constructor can now take a handle to a - volatility quote, instead of just an immutable number (@lballabio). +- Renamed `SwaptionVolCube1`, `SwaptionVolCube1x`, `SwaptionVolCube1a` + and `SwaptionVolCube2` to `SabrSwaptionVolatilityCube`, + `XabrSwaptionVolatilityCube`, `NoArbSabrSwaptionVolatilityCube` and + `InterpolatedSwaptionVolatilityCube`, respectively; thanks to + Ignacio Anguita (@IgnacioAnguita). The old names are deprecated but + still available for a few releases. + +- Ensure that inflation curves are re-bootstrapped correctly when + seasonality is added (@lballabio). + + +Models +------ + +- Moved the Heston SLV model from experimental to main; thanks to + Klaus Spanderen (@klausspanderen). + + +Math +---- + +- Added a few overloads to Array and Matrix operators taking rvalue + references for increased speed; thanks to Jonathan Sweemer (@sweemer). Deprecated features ------------------- - **Removed** features deprecated in version 1.24: - - the `createAtParCoupons`, `createIndexedCoupons` and - `usingAtParCoupons` methods of `IborCoupon`; - - the `RiskyBond` class and its subclasses `RiskyFixedBond` and - `RiskyFloatingBond`; - - the `CrossCurrencyBasisSwapRateHelper` typedef; - - the `termStructure_` data member of `BlackCalibrationHelper`; - - the static `baseCurrency` and `conversionType` data members of `Money`; - - the `nominalTermStructure` method and the `nominalTermStructure_` - data member of `InflationTermStructure`; - - the constructor of the `UnitedStates` calendar not taking an - explicit market. - -- Deprecated the `argument_type`, `first_argument_type`, - `second_argument_type` and `result_type` typedefs in a number of - classes; use `auto` or `decltype` instead. - -- Deprecated the constructors of `InflationIndex`, - `ZeroInflationIndex`, `FRHICP`, `ZACPI`, `UKRPI`, `EUHICP`, - `EUHICPXT`, `USCPI`, `AUCPI` and `GenericCPI` taking an - `interpolated` parameter; use another constructor. - -- Deprecated the `interpolated` method and the `interpolated_` data - member of `InflationIndex`. - -- Deprecated the `ThreadKey` typedef. It was used in the signature of - `sessionId`, which is no longer needed after the changes in the - `Singleton` implementation. - -- Deprecated the `rateCurve_` data member of the - `InflationCouponPricer` base class. If you need it, provide it in - your derived class. - -- Deprecated the `npvbps` function taking NPV and BPS as references. - Use the overload returning a pair of `Real`s. - - -**Thanks go also** to Matthias Groncki (@mgroncki), Jonathan Sweemer -(@sweemer) and Nijaz Kovacevic (@NijazK) for a number of smaller fixes -and improvements, to the Xcelerit Dev Team (@xcelerit-dev) for -improvements to the automated CI builds, and to Vincenzo Ferrazzanno -(@vincferr), @alienbrett, @xuruilong100 and @philippb90 for raising issues. + - the protected `spreadLegValue_` data member of `BlackIborCouponPricer`; + - the `WulinYongDoubleBarrierEngine` alias for `SuoWangDoubleBarrierEngine`; + - the `settlementDate`, `incomeDiscountCurve`, `spotIncome`, + `spotValue`, `impliedYield` and `forwardValue` methods of + `ForwardRateAgreement`, as well as its protected + `underlyingIncome_`, `underlyingSpotValue_`, `settlementDays_`, + `payoff_` and `incomeDiscountCurve_` data members; + - constructors for `InflationTermStructure`, + `ZeroInflationTermStructure`, `InterpolatedZeroInflationCurve`, + `PiecewiseZeroInflationCurve` taking an `indexIsInterpolated` + parameter; + - the `indexIsInterpolated` method of `InflationTermStructure` and + its protected `indexIsInterpolated_` data member; + - some overloaded constructors of `SofrFutureRateHelper`. + +- Deprecated the `DividendVanillaOption` and `DividendBarrierOption` + classes; use `VanillaOption` and `BarrierOption` instead (see + above). + +- Deprecated the constructor of `AnalyticDividendEuropeanEngine` that + takes no dividend information; use the other overload instead. + +- Deprecated the names `SwaptionVolCube1`, `SwaptionVolCube1x`, + `SwaptionVolCube1a` and `SwaptionVolCube2` (see above). + +- Deprecated the protected `setCommon` method of + `CappedFlooredYoYInflationCoupon`. + + +**Thanks go also** to Jonathan Sweemer (@sweemer), the Xcelerit Dev +Team (@xcelerit-dev), Fredrik Gerdin Börjesson (@gbfredrik), Klaus +Spanderen (@klausspanderen) and Peter Caspers (@pcaspers) for a number +of smaller fixes and improvements, and to Matthias Groncki (@mgroncki) +and @lukey8767 for raising issues. + From 27415c3a841a328d449c491ecf8e719d204c0165 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Wed, 12 Apr 2023 14:23:58 +0200 Subject: [PATCH 096/292] Strip local path from docs correctly in out-of-source build --- Docs/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Docs/Makefile.am b/Docs/Makefile.am index e2c1511de78..aa560d2885f 100644 --- a/Docs/Makefile.am +++ b/Docs/Makefile.am @@ -10,7 +10,7 @@ DOXYGEN_CUSTOM := quantlibextra.css quantlibheader.html quantlibfooter.html DOXYGEN_INPUT := $(shell find ${top_srcdir} -name *.hpp) \ $(wildcard pages/*.docs) -BASEPATH = @abs_top_srcdir@ +BASEPATH = $(shell cd @abs_top_srcdir@ && pwd) .PHONY: docs docs-clean From 7f5beceea34cf6a4d59255e90528db43a149f074 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Thu, 1 Apr 2021 11:28:16 +0200 Subject: [PATCH 097/292] Set version to 1.30 rc --- CMakeLists.txt | 4 ++-- configure.ac | 2 +- ql/version.hpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 61fb0e2f88d..a08369825e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,8 @@ set(QUANTLIB_VERSION ${QUANTLIB_VERSION_MAJOR}.${QUANTLIB_VERSION_MINOR}.${QUANT # Project Info set(PACKAGE_NAME "QuantLib") -set(PACKAGE_VERSION "${QUANTLIB_VERSION}-dev") -set(PACKAGE_VERSION_HEX "0x01300000") +set(PACKAGE_VERSION "${QUANTLIB_VERSION}-rc") +set(PACKAGE_VERSION_HEX "0x013000c0") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/lballabio/QuantLib/issues/") diff --git a/configure.ac b/configure.ac index 8e4455e3c7c..bed586859c6 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # Process this file with autoconf to produce a configure script. -AC_INIT([QuantLib], [1.30-dev], +AC_INIT([QuantLib], [1.30-rc], [quantlib-dev@lists.sourceforge.net], [QuantLib]) AC_PREREQ(2.62) diff --git a/ql/version.hpp b/ql/version.hpp index 488f994b45a..0847da59a45 100644 --- a/ql/version.hpp +++ b/ql/version.hpp @@ -31,10 +31,10 @@ /*! @{ */ //! version string -#define QL_VERSION "1.30-dev" +#define QL_VERSION "1.30-rc" //! version hexadecimal number -#define QL_HEX_VERSION 0x01300000 +#define QL_HEX_VERSION 0x013000c0 /*! @} */ From 416dd3f214f641fa4280189323222042e6bb3a09 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Thu, 13 Apr 2023 13:16:19 +0200 Subject: [PATCH 098/292] Fix typo in news --- News.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/News.md b/News.md index 9dd90365f98..533b2e2ecf8 100644 --- a/News.md +++ b/News.md @@ -120,7 +120,7 @@ Math Deprecated features ------------------- -- **Removed** features deprecated in version 1.24: +- **Removed** features deprecated in version 1.25: - the protected `spreadLegValue_` data member of `BlackIborCouponPricer`; - the `WulinYongDoubleBarrierEngine` alias for `SuoWangDoubleBarrierEngine`; - the `settlementDate`, `incomeDiscountCurve`, `spotIncome`, From e5a2a96cdaf6dd0067d19a5ea8102ae20192cd21 Mon Sep 17 00:00:00 2001 From: jakeheke75 Date: Thu, 13 Apr 2023 17:43:49 +0200 Subject: [PATCH 099/292] New ctor with forecast-discount curve and new helper class --- ql/instruments/forwardrateagreement.cpp | 38 ++++++++++++++++++------- ql/instruments/forwardrateagreement.hpp | 8 ++++-- ql/termstructures/yield/ratehelpers.cpp | 10 +++++-- 3 files changed, 41 insertions(+), 15 deletions(-) diff --git a/ql/instruments/forwardrateagreement.cpp b/ql/instruments/forwardrateagreement.cpp index eccbb9f75fb..cfdedcb627d 100644 --- a/ql/instruments/forwardrateagreement.cpp +++ b/ql/instruments/forwardrateagreement.cpp @@ -85,25 +85,30 @@ namespace QuantLib { Position::Type type, Rate strikeForwardRate, Real notionalAmount, - Handle discountCurve, + //Handle discountCurve, + Handle forecastCurve, Natural fixingDays, - BusinessDayConvention businessDayConvention) + BusinessDayConvention businessDayConvention, + Handle discountCurve) : fraType_(type), notionalAmount_(notionalAmount), useIndexedCoupon_(false), dayCounter_(discountCurve->dayCounter()), calendar_(discountCurve->calendar()), businessDayConvention_(businessDayConvention), valueDate_(valueDate), maturityDate_(maturityDate), - discountCurve_(std::move(discountCurve)), fixingDays_(fixingDays) { + discountCurve_(std::move(discountCurve)), fixingDays_(fixingDays), + forecastCurve_(std::move(forecastCurve)) { QL_REQUIRE(notionalAmount > 0.0, "notionalAmount must be positive"); registerWith(Settings::instance().evaluationDate()); - registerWith(discountCurve_); maturityDate_ = calendar_.adjust(maturityDate_, businessDayConvention_); QL_REQUIRE(valueDate_ < maturityDate_, "valueDate must be earlier than maturityDate"); strikeForwardRate_ = InterestRate(strikeForwardRate, - discountCurve_->dayCounter(), + forecastCurve_->dayCounter(), Simple, Once); + + registerWith(discountCurve_); + registerWith(forecastCurve_); } Date ForwardRateAgreement::fixingDate() const { @@ -139,8 +144,15 @@ namespace QuantLib { void ForwardRateAgreement::performCalculations() const { calculateAmount(); - Handle discount = - discountCurve_.empty() ? index_->forwardingTermStructure() : discountCurve_; +/* Handle discount = + discountCurve_.empty() ? index_->forwardingTermStructure() : discountCurve_; */ + Handle discount; + if (discountCurve_.empty() && index_) + discount = index_->forwardingTermStructure(); + else if (!discountCurve_.empty()) + discount = discountCurve_; + else + discount = forecastCurve_; NPV_ = amount_ * discount->discount(valueDate_); } @@ -157,14 +169,18 @@ namespace QuantLib { 1.0) / index_->dayCounter().yearFraction(valueDate_, maturityDate_), index_->dayCounter(), Simple, Once); - else // calculating forward rate using the term structure + else // calculating forward rate using the forecast curve forwardRate_ = - InterestRate((discountCurve_->discount(valueDate_) / +/* InterestRate((discountCurve_->discount(valueDate_) / discountCurve_->discount(maturityDate_) - 1.0) / discountCurve_->dayCounter().yearFraction(valueDate_, maturityDate_), - discountCurve_->dayCounter(), Simple, Once); - + discountCurve_->dayCounter(), Simple, Once); */ + InterestRate((forecastCurve_->discount(valueDate_) / + forecastCurve_->discount(maturityDate_) - + 1.0) / + forecastCurve_->dayCounter().yearFraction(valueDate_, maturityDate_), + forecastCurve_->dayCounter(), Simple, Once); } void ForwardRateAgreement::calculateAmount() const { diff --git a/ql/instruments/forwardrateagreement.hpp b/ql/instruments/forwardrateagreement.hpp index 1a8e29180d2..cb5a9458245 100644 --- a/ql/instruments/forwardrateagreement.hpp +++ b/ql/instruments/forwardrateagreement.hpp @@ -103,9 +103,11 @@ namespace QuantLib { Position::Type type, Rate strikeForwardRate, Real notionalAmount, - Handle discountCurve, + //Handle discountCurve, + Handle forecastCurve, Natural fixingDays, - BusinessDayConvention businessDayConvention); + BusinessDayConvention businessDayConvention, + Handle discountCurve = Handle()); //! \name Calculations //@{ @@ -149,6 +151,8 @@ namespace QuantLib { Handle discountCurve_; //! the number of fixingDays for fixingDate calculation without the index Natural fixingDays_; + //! forecasting curve for fixings calculation + Handle forecastCurve_; private: void calculateForwardRate() const; diff --git a/ql/termstructures/yield/ratehelpers.cpp b/ql/termstructures/yield/ratehelpers.cpp index 95210b406e5..907a431267c 100644 --- a/ql/termstructures/yield/ratehelpers.cpp +++ b/ql/termstructures/yield/ratehelpers.cpp @@ -624,9 +624,15 @@ namespace QuantLib { spotDate, *periodToStart_, iborIndex_->businessDayConvention(), iborIndex_->endOfMonth()); // maturity date is calculated from spot date - maturityDate_ = iborIndex_->fixingCalendar().advance( +/* maturityDate_ = iborIndex_->fixingCalendar().advance( spotDate, *periodToStart_ + iborIndex_->tenor(), iborIndex_->businessDayConvention(), - iborIndex_->endOfMonth()); + iborIndex_->endOfMonth()); */ + // maturity date is calculated from earliest date + // coherently with the instrument logic + maturityDate_ = iborIndex_->fixingCalendar().advance( + earliestDate_, iborIndex_->tenor(), iborIndex_->businessDayConvention(), + iborIndex_->endOfMonth()); + } else if ((immOffsetStart_) && (immOffsetEnd_)) { // NOLINT(readability-implicit-bool-conversion) earliestDate_ = iborIndex_->fixingCalendar().adjust(nthImmDate(spotDate, *immOffsetStart_)); maturityDate_ = iborIndex_->fixingCalendar().adjust(nthImmDate(spotDate, *immOffsetEnd_)); From 53ed4b5711abab65e1050a2bfb4d55fb067dd688 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Fri, 14 Apr 2023 09:29:45 +0200 Subject: [PATCH 100/292] Fix deprecation message --- ql/experimental/amortizingbonds/amortizingcmsratebond.hpp | 2 +- ql/experimental/amortizingbonds/amortizingfixedratebond.hpp | 2 +- ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ql/experimental/amortizingbonds/amortizingcmsratebond.hpp b/ql/experimental/amortizingbonds/amortizingcmsratebond.hpp index 8f09cd72c7e..43a67c6ad73 100644 --- a/ql/experimental/amortizingbonds/amortizingcmsratebond.hpp +++ b/ql/experimental/amortizingbonds/amortizingcmsratebond.hpp @@ -18,6 +18,6 @@ */ // Deprecated in version 1.28 -#pragma message("Warning: this file will disappear in a future release; include .") +#pragma message("Warning: this file will disappear in a future release; include instead.") #include diff --git a/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp b/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp index 24e1dea2ac4..7c803eafca2 100644 --- a/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp +++ b/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp @@ -18,6 +18,6 @@ */ // Deprecated in version 1.28 -#pragma message("Warning: this file will disappear in a future release; include .") +#pragma message("Warning: this file will disappear in a future release; include instead.") #include diff --git a/ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp b/ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp index 6c105f97156..bc9777c0000 100644 --- a/ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp +++ b/ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp @@ -18,6 +18,6 @@ */ // Deprecated in version 1.28 -#pragma message("Warning: this file will disappear in a future release; include .") +#pragma message("Warning: this file will disappear in a future release; include instead.") #include From 27a247409a927c8056281ccd2251a768d6af12c6 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Fri, 14 Apr 2023 10:38:37 +0200 Subject: [PATCH 101/292] Avoid including deprecated files --- cmake/GenerateHeaders.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/GenerateHeaders.cmake b/cmake/GenerateHeaders.cmake index 3cd49c7c2e4..3e032e53758 100644 --- a/cmake/GenerateHeaders.cmake +++ b/cmake/GenerateHeaders.cmake @@ -44,6 +44,13 @@ function(generate_dir_headers source_dir binary_dir) list(FILTER children_hpp EXCLUDE REGEX "fddividendshoutengine.hpp") list(FILTER children_hpp EXCLUDE REGEX "americancondition.hpp") list(FILTER children_hpp EXCLUDE REGEX "disposable.hpp") + list(FILTER children_hpp EXCLUDE REGEX "swaptionvolcube1.hpp") + list(FILTER children_hpp EXCLUDE REGEX "swaptionvolcube2.hpp") + list(FILTER children_hpp EXCLUDE REGEX "swaptionvolcube1a.hpp") + list(FILTER children_hpp EXCLUDE REGEX "amortizingfixedratebond.hpp") + list(FILTER children_hpp EXCLUDE REGEX "amortizingfloatingratebond.hpp") + list(FILTER children_hpp EXCLUDE REGEX "amortizingcmsratebond.hpp") + list(FILTER children_hpp EXCLUDE REGEX "riskybond.hpp") file(GLOB children_dir RELATIVE ${source_dir} "${source_dir}/*") list(FILTER children_dir EXCLUDE REGEX "CMakeFiles") list(FILTER children_dir EXCLUDE REGEX "^\\..*") From 71f59ce9e807e3e7ce6328fef73ec7bb54cd0b01 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Fri, 14 Apr 2023 11:04:01 +0200 Subject: [PATCH 102/292] Use latest Boost in cmake Windows build --- .github/workflows/cmake.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 98bf54b8886..23dde194e75 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -66,7 +66,7 @@ jobs: variant: sccache - name: Setup run: | - $Url = "https://boostorg.jfrog.io/artifactory/main/release/1.81.0/binaries/boost_1_81_0-msvc-14.3-64.exe" + $Url = "https://boostorg.jfrog.io/artifactory/main/release/1.82.0/binaries/boost_1_82_0-msvc-14.3-64.exe" (New-Object System.Net.WebClient).DownloadFile($Url, "$env:TEMP\boost.exe") Start-Process -Wait -FilePath "$env:TEMP\boost.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES","/DIR=C:\local\boost" choco install -y ninja @@ -100,7 +100,7 @@ jobs: variant: sccache - name: Setup run: | - $Url = "https://boostorg.jfrog.io/artifactory/main/release/1.81.0/binaries/boost_1_81_0-msvc-14.3-64.exe" + $Url = "https://boostorg.jfrog.io/artifactory/main/release/1.82.0/binaries/boost_1_82_0-msvc-14.3-64.exe" (New-Object System.Net.WebClient).DownloadFile($Url, "$env:TEMP\boost.exe") Start-Process -Wait -FilePath "$env:TEMP\boost.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES","/DIR=C:\local\boost" choco install -y ninja @@ -134,7 +134,7 @@ jobs: variant: sccache - name: Setup run: | - $Url = "https://boostorg.jfrog.io/artifactory/main/release/1.81.0/binaries/boost_1_81_0-msvc-14.3-64.exe" + $Url = "https://boostorg.jfrog.io/artifactory/main/release/1.82.0/binaries/boost_1_82_0-msvc-14.3-64.exe" (New-Object System.Net.WebClient).DownloadFile($Url, "$env:TEMP\boost.exe") Start-Process -Wait -FilePath "$env:TEMP\boost.exe" "/SILENT","/SP-","/SUPPRESSMSGBOXES","/DIR=C:\local\boost" choco install -y ninja From 621660f8043e0e2158a5e65b4dcad8e241517884 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Mon, 12 Jul 2021 09:46:54 +0200 Subject: [PATCH 103/292] Set version to 1.30 final. --- CMakeLists.txt | 4 ++-- configure.ac | 2 +- ql/version.hpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a08369825e3..54287716311 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,8 @@ set(QUANTLIB_VERSION ${QUANTLIB_VERSION_MAJOR}.${QUANTLIB_VERSION_MINOR}.${QUANT # Project Info set(PACKAGE_NAME "QuantLib") -set(PACKAGE_VERSION "${QUANTLIB_VERSION}-rc") -set(PACKAGE_VERSION_HEX "0x013000c0") +set(PACKAGE_VERSION "${QUANTLIB_VERSION}") +set(PACKAGE_VERSION_HEX "0x013000f0") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/lballabio/QuantLib/issues/") diff --git a/configure.ac b/configure.ac index bed586859c6..61cd03f3a66 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # Process this file with autoconf to produce a configure script. -AC_INIT([QuantLib], [1.30-rc], +AC_INIT([QuantLib], [1.30], [quantlib-dev@lists.sourceforge.net], [QuantLib]) AC_PREREQ(2.62) diff --git a/ql/version.hpp b/ql/version.hpp index 0847da59a45..1fae4a02258 100644 --- a/ql/version.hpp +++ b/ql/version.hpp @@ -31,10 +31,10 @@ /*! @{ */ //! version string -#define QL_VERSION "1.30-rc" +#define QL_VERSION "1.30" //! version hexadecimal number -#define QL_HEX_VERSION 0x013000c0 +#define QL_HEX_VERSION 0x013000f0 /*! @} */ From 83e585413a9cd9c949d7445e6e0876473783bf4c Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Mon, 17 Apr 2023 12:28:24 +0200 Subject: [PATCH 104/292] Update changelog --- ChangeLog.txt | 81 +++++++++++++++++++++++++++++++++++++++++ Contributors.txt | 1 + Docs/pages/history.docs | 2 +- News.md | 2 +- 4 files changed, 84 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index d042238bf30..07f72d473f2 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,84 @@ +commit 621660f8043e0e2158a5e65b4dcad8e241517884 +Author: Luigi Ballabio +Date: Mon, 12 Jul 2021 09:46:54 +0200 + + Set version to 1.30 final. + + CMakeLists.txt | 4 ++-- + configure.ac | 2 +- + ql/version.hpp | 4 ++-- + 3 files changed, 5 insertions(+), 5 deletions(-) + +commit 71f59ce9e807e3e7ce6328fef73ec7bb54cd0b01 +Author: Luigi Ballabio +Date: Fri, 14 Apr 2023 11:04:01 +0200 + + Use latest Boost in cmake Windows build + + .github/workflows/cmake.yml | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +commit 27a247409a927c8056281ccd2251a768d6af12c6 +Author: Luigi Ballabio +Date: Fri, 14 Apr 2023 10:38:37 +0200 + + Avoid including deprecated files + + cmake/GenerateHeaders.cmake | 7 +++++++ + 1 file changed, 7 insertions(+) + +commit 53ed4b5711abab65e1050a2bfb4d55fb067dd688 +Author: Luigi Ballabio +Date: Fri, 14 Apr 2023 09:29:45 +0200 + + Fix deprecation message + + ql/experimental/amortizingbonds/amortizingcmsratebond.hpp | 2 +- + ql/experimental/amortizingbonds/amortizingfixedratebond.hpp | 2 +- + ql/experimental/amortizingbonds/amortizingfloatingratebond.hpp | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +commit 416dd3f214f641fa4280189323222042e6bb3a09 +Author: Luigi Ballabio +Date: Thu, 13 Apr 2023 13:16:19 +0200 + + Fix typo in news + + News.md | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 7f5beceea34cf6a4d59255e90528db43a149f074 +Author: Luigi Ballabio +Date: Thu, 1 Apr 2021 11:28:16 +0200 + + Set version to 1.30 rc + + CMakeLists.txt | 4 ++-- + configure.ac | 2 +- + ql/version.hpp | 4 ++-- + 3 files changed, 5 insertions(+), 5 deletions(-) + +commit 27415c3a841a328d449c491ecf8e719d204c0165 +Author: Luigi Ballabio +Date: Wed, 12 Apr 2023 14:23:58 +0200 + + Strip local path from docs correctly in out-of-source build + + Docs/Makefile.am | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 77cb89eff775bf4687496426e43785ded03057a6 +Author: Luigi Ballabio +Date: Wed, 12 Apr 2023 12:11:53 +0200 + + Update news and contributors + + ChangeLog.txt | 4042 ++++++++++++++++++++--------------------------- + Contributors.txt | 2 + + Docs/pages/history.docs | 109 +- + News.md | 198 +-- + 4 files changed, 1949 insertions(+), 2402 deletions(-) + commit 8ac7f751df6c7304ccf4faef5b0ca555c6bd48a2 Author: Luigi Ballabio Date: Tue, 11 Apr 2023 16:15:34 +0200 diff --git a/Contributors.txt b/Contributors.txt index 647bfd6d093..48b3ab2b8eb 100644 --- a/Contributors.txt +++ b/Contributors.txt @@ -103,6 +103,7 @@ Cavit Hafizoglu, Lew Wei Hao, Joshua Hayes, Michael Heckl, +Jake Heke, Andres Hernandez, Chris Higgs, Laurent Hoffmann, diff --git a/Docs/pages/history.docs b/Docs/pages/history.docs index 18dec30bd90..a2009c19c7f 100644 --- a/Docs/pages/history.docs +++ b/Docs/pages/history.docs @@ -48,7 +48,7 @@ - Added a few missing holidays to Danish calendar; thanks to Fredrik Gerdin Börjesson. - Added the Matariki holiday to the New Zealand calendar; thanks to - GitHub user jakeheke75. + Jake Heke. CASHFLOWS - Added a new equity cash flow class to model equity legs in total diff --git a/News.md b/News.md index 533b2e2ecf8..1999eae2152 100644 --- a/News.md +++ b/News.md @@ -48,7 +48,7 @@ Date/time Gerdin Börjesson (@gbfredrik). - Added the Matariki holiday to the New Zealand calendar; thanks to - g.t. (@jakeheke75). + Jake Heke (@jakeheke75). Cashflows From 6d63eaf1729b33976eed5ae6d806916111ea7b84 Mon Sep 17 00:00:00 2001 From: Jonathan Sweemer Date: Fri, 14 Apr 2023 21:19:08 +0900 Subject: [PATCH 105/292] Make swap functions noexcept --- ql/math/array.hpp | 11 +++++------ ql/math/interpolations/multicubicspline.hpp | 4 ++-- ql/math/matrix.hpp | 13 ++++++------- ql/math/sampledcurve.hpp | 9 ++++----- .../operators/fdmlinearopiterator.hpp | 2 +- .../operators/ninepointlinearop.cpp | 4 ++-- .../operators/ninepointlinearop.hpp | 2 +- .../operators/triplebandlinearop.cpp | 4 ++-- .../operators/triplebandlinearop.hpp | 2 +- .../finitedifferences/tridiagonaloperator.hpp | 13 ++++++------- ql/utilities/clone.hpp | 8 ++++---- 11 files changed, 34 insertions(+), 38 deletions(-) diff --git a/ql/math/array.hpp b/ql/math/array.hpp index c969c343f24..d3b8135ab45 100644 --- a/ql/math/array.hpp +++ b/ql/math/array.hpp @@ -137,7 +137,7 @@ namespace QuantLib { //! \name Utilities //@{ void resize(Size n); - void swap(Array&); // never throws + void swap(Array&) noexcept; //@} private: @@ -271,7 +271,7 @@ namespace QuantLib { // utilities /*! \relates Array */ - void swap(Array&, Array&); + void swap(Array&, Array&) noexcept; // format /*! \relates Array */ @@ -542,10 +542,9 @@ namespace QuantLib { } } - inline void Array::swap(Array& from) { - using std::swap; + inline void Array::swap(Array& from) noexcept { data_.swap(from.data_); - swap(n_,from.n_); + std::swap(n_, from.n_); } // dot product and norm @@ -900,7 +899,7 @@ namespace QuantLib { return result; } - inline void swap(Array& v, Array& w) { + inline void swap(Array& v, Array& w) noexcept { v.swap(w); } diff --git a/ql/math/interpolations/multicubicspline.hpp b/ql/math/interpolations/multicubicspline.hpp index 93a5f14d05e..3e1039c9f20 100644 --- a/ql/math/interpolations/multicubicspline.hpp +++ b/ql/math/interpolations/multicubicspline.hpp @@ -93,7 +93,7 @@ namespace QuantLib { : first(*i), second(i + 1) {} Data(const SplineGrid &v) : first(v[0]), second(v.begin()+1) {} - void swap(Data &d) { + void swap(Data &d) noexcept { first.swap(d.first); second.swap(d.second); } @@ -108,7 +108,7 @@ namespace QuantLib { Data(const SplineGrid &v) : first(v[0]) {} Data(std::vector v) : first(std::move(v)) {} - void swap(Data, EmptyArg> &d) { + void swap(Data, EmptyArg> &d) noexcept { first.swap(d.first); } Real operator[](Size n) const {return first[n];} diff --git a/ql/math/matrix.hpp b/ql/math/matrix.hpp index 9e61e98c821..f5364c1e138 100644 --- a/ql/math/matrix.hpp +++ b/ql/math/matrix.hpp @@ -141,7 +141,7 @@ namespace QuantLib { //! \name Utilities //@{ - void swap(Matrix&); + void swap(Matrix&) noexcept; //@} private: std::unique_ptr data_; @@ -205,7 +205,7 @@ namespace QuantLib { Matrix outerProduct(Iterator1 v1begin, Iterator1 v1end, Iterator2 v2begin, Iterator2 v2end); /*! \relates Matrix */ - void swap(Matrix&, Matrix&); + void swap(Matrix&, Matrix&) noexcept; /*! \relates Matrix */ std::ostream& operator<<(std::ostream&, const Matrix&); @@ -287,11 +287,10 @@ namespace QuantLib { return !this->operator==(to); } - inline void Matrix::swap(Matrix& from) { - using std::swap; + inline void Matrix::swap(Matrix& from) noexcept { data_.swap(from.data_); - swap(rows_,from.rows_); - swap(columns_,from.columns_); + std::swap(rows_, from.rows_); + std::swap(columns_, from.columns_); } inline const Matrix& Matrix::operator+=(const Matrix& m) { @@ -729,7 +728,7 @@ namespace QuantLib { return result; } - inline void swap(Matrix& m1, Matrix& m2) { + inline void swap(Matrix& m1, Matrix& m2) noexcept { m1.swap(m2); } diff --git a/ql/math/sampledcurve.hpp b/ql/math/sampledcurve.hpp index 89d97832fd5..4465d2844be 100644 --- a/ql/math/sampledcurve.hpp +++ b/ql/math/sampledcurve.hpp @@ -82,7 +82,7 @@ namespace QuantLib { //! \name utilities //@{ - void swap(SampledCurve&); + void swap(SampledCurve&) noexcept; void setLogGrid(Real min, Real max) { setGrid(BoundedLogGrid(min, max, size()-1)); } @@ -153,7 +153,7 @@ namespace QuantLib { }; /* \relates SampledCurve */ - void swap(SampledCurve&, SampledCurve&); + void swap(SampledCurve&, SampledCurve&) noexcept; typedef SampledCurve SampledCurveSet; @@ -214,13 +214,12 @@ namespace QuantLib { values_ = g; } - inline void SampledCurve::swap(SampledCurve& from) { - using std::swap; + inline void SampledCurve::swap(SampledCurve& from) noexcept { grid_.swap(from.grid_); values_.swap(from.values_); } - inline void swap(SampledCurve& c1, SampledCurve& c2) { + inline void swap(SampledCurve& c1, SampledCurve& c2) noexcept { c1.swap(c2); } diff --git a/ql/methods/finitedifferences/operators/fdmlinearopiterator.hpp b/ql/methods/finitedifferences/operators/fdmlinearopiterator.hpp index 6c67cf19739..ecc3e462a95 100644 --- a/ql/methods/finitedifferences/operators/fdmlinearopiterator.hpp +++ b/ql/methods/finitedifferences/operators/fdmlinearopiterator.hpp @@ -75,7 +75,7 @@ namespace QuantLib { return coordinates_; } - void swap(FdmLinearOpIterator& iter) { + void swap(FdmLinearOpIterator& iter) noexcept { std::swap(iter.index_, index_); dim_.swap(iter.dim_); coordinates_.swap(iter.coordinates_); diff --git a/ql/methods/finitedifferences/operators/ninepointlinearop.cpp b/ql/methods/finitedifferences/operators/ninepointlinearop.cpp index fd0dd1ef822..1c3b171d897 100644 --- a/ql/methods/finitedifferences/operators/ninepointlinearop.cpp +++ b/ql/methods/finitedifferences/operators/ninepointlinearop.cpp @@ -179,7 +179,7 @@ namespace QuantLib { return retVal; } - void NinePointLinearOp::swap(NinePointLinearOp& m) { + void NinePointLinearOp::swap(NinePointLinearOp& m) noexcept { std::swap(d0_, m.d0_); std::swap(d1_, m.d1_); @@ -190,6 +190,6 @@ namespace QuantLib { a01_.swap(m.a01_); a21_.swap(m.a21_); a02_.swap(m.a02_); a12_.swap(m.a12_); a22_.swap(m.a22_); a11_.swap(m.a11_); - std::swap(mesher_, m.mesher_); + mesher_.swap(m.mesher_); } } diff --git a/ql/methods/finitedifferences/operators/ninepointlinearop.hpp b/ql/methods/finitedifferences/operators/ninepointlinearop.hpp index 4eb24c48908..24a5ad586f4 100644 --- a/ql/methods/finitedifferences/operators/ninepointlinearop.hpp +++ b/ql/methods/finitedifferences/operators/ninepointlinearop.hpp @@ -46,7 +46,7 @@ namespace QuantLib { Array apply(const Array& r) const override; NinePointLinearOp mult(const Array& u) const; - void swap(NinePointLinearOp& m); + void swap(NinePointLinearOp& m) noexcept; SparseMatrix toMatrix() const override; diff --git a/ql/methods/finitedifferences/operators/triplebandlinearop.cpp b/ql/methods/finitedifferences/operators/triplebandlinearop.cpp index 15879763a2e..5111f73a394 100644 --- a/ql/methods/finitedifferences/operators/triplebandlinearop.cpp +++ b/ql/methods/finitedifferences/operators/triplebandlinearop.cpp @@ -80,8 +80,8 @@ namespace QuantLib { std::copy(m.upper_.get(), m.upper_.get() + len, upper_.get()); } - void TripleBandLinearOp::swap(TripleBandLinearOp& m) { - std::swap(mesher_, m.mesher_); + void TripleBandLinearOp::swap(TripleBandLinearOp& m) noexcept { + mesher_.swap(m.mesher_); std::swap(direction_, m.direction_); i0_.swap(m.i0_); i2_.swap(m.i2_); diff --git a/ql/methods/finitedifferences/operators/triplebandlinearop.hpp b/ql/methods/finitedifferences/operators/triplebandlinearop.hpp index 1fbb5693a39..6ca4b9eda09 100644 --- a/ql/methods/finitedifferences/operators/triplebandlinearop.hpp +++ b/ql/methods/finitedifferences/operators/triplebandlinearop.hpp @@ -58,7 +58,7 @@ namespace QuantLib { void axpyb(const Array& a, const TripleBandLinearOp& x, const TripleBandLinearOp& y, const Array& b); - void swap(TripleBandLinearOp& m); + void swap(TripleBandLinearOp& m) noexcept; SparseMatrix toMatrix() const override; diff --git a/ql/methods/finitedifferences/tridiagonaloperator.hpp b/ql/methods/finitedifferences/tridiagonaloperator.hpp index f69154b79c1..9e6a7ec3d61 100644 --- a/ql/methods/finitedifferences/tridiagonaloperator.hpp +++ b/ql/methods/finitedifferences/tridiagonaloperator.hpp @@ -101,7 +101,7 @@ namespace QuantLib { //@} //! \name Utilities //@{ - void swap(TridiagonalOperator&); + void swap(TridiagonalOperator&) noexcept; //@} //! encapsulation of time-setting logic class TimeSetter { @@ -118,7 +118,7 @@ namespace QuantLib { }; /* \relates TridiagonalOperator */ - void swap(TridiagonalOperator&, TridiagonalOperator&); + void swap(TridiagonalOperator&, TridiagonalOperator&) noexcept; // inline definitions @@ -178,14 +178,13 @@ namespace QuantLib { timeSetter_->setTime(t, *this); } - inline void TridiagonalOperator::swap(TridiagonalOperator& from) { - using std::swap; - swap(n_, from.n_); + inline void TridiagonalOperator::swap(TridiagonalOperator& from) noexcept { + std::swap(n_, from.n_); diagonal_.swap(from.diagonal_); lowerDiagonal_.swap(from.lowerDiagonal_); upperDiagonal_.swap(from.upperDiagonal_); temp_.swap(from.temp_); - swap(timeSetter_, from.timeSetter_); + timeSetter_.swap(from.timeSetter_); } @@ -250,7 +249,7 @@ namespace QuantLib { } inline void swap(TridiagonalOperator& L1, - TridiagonalOperator& L2) { + TridiagonalOperator& L2) noexcept { L1.swap(L2); } diff --git a/ql/utilities/clone.hpp b/ql/utilities/clone.hpp index e8d71da55a8..52ac84a794c 100644 --- a/ql/utilities/clone.hpp +++ b/ql/utilities/clone.hpp @@ -50,14 +50,14 @@ namespace QuantLib { T& operator*() const; T* operator->() const; bool empty() const; - void swap(Clone& t); + void swap(Clone& t) noexcept; private: std::unique_ptr ptr_; }; /*! \relates Clone */ template - void swap(Clone&, Clone&); + void swap(Clone&, Clone&) noexcept; // inline definitions @@ -114,12 +114,12 @@ namespace QuantLib { } template - inline void Clone::swap(Clone& t) { + inline void Clone::swap(Clone& t) noexcept { this->ptr_.swap(t.ptr_); } template - inline void swap(Clone& t, Clone& u) { + inline void swap(Clone& t, Clone& u) noexcept { t.swap(u); } From 08aa5476e4193792cb9aa05158baf37b97c5052c Mon Sep 17 00:00:00 2001 From: jakeheke75 Date: Tue, 18 Apr 2023 22:53:20 +0200 Subject: [PATCH 106/292] -removed the ctor without the index -cleaned up comments/unnecessary spaces --- ql/instruments/forwardrateagreement.cpp | 73 ++----------------------- ql/instruments/forwardrateagreement.hpp | 23 -------- ql/termstructures/yield/ratehelpers.cpp | 6 +- 3 files changed, 7 insertions(+), 95 deletions(-) diff --git a/ql/instruments/forwardrateagreement.cpp b/ql/instruments/forwardrateagreement.cpp index cfdedcb627d..dba9ec9819a 100644 --- a/ql/instruments/forwardrateagreement.cpp +++ b/ql/instruments/forwardrateagreement.cpp @@ -80,45 +80,8 @@ namespace QuantLib { registerWith(index_); } - ForwardRateAgreement::ForwardRateAgreement(const Date& valueDate, - const Date& maturityDate, - Position::Type type, - Rate strikeForwardRate, - Real notionalAmount, - //Handle discountCurve, - Handle forecastCurve, - Natural fixingDays, - BusinessDayConvention businessDayConvention, - Handle discountCurve) - : fraType_(type), notionalAmount_(notionalAmount), - useIndexedCoupon_(false), dayCounter_(discountCurve->dayCounter()), - calendar_(discountCurve->calendar()), businessDayConvention_(businessDayConvention), - valueDate_(valueDate), maturityDate_(maturityDate), - discountCurve_(std::move(discountCurve)), fixingDays_(fixingDays), - forecastCurve_(std::move(forecastCurve)) { - - QL_REQUIRE(notionalAmount > 0.0, "notionalAmount must be positive"); - - registerWith(Settings::instance().evaluationDate()); - - maturityDate_ = calendar_.adjust(maturityDate_, businessDayConvention_); - QL_REQUIRE(valueDate_ < maturityDate_, "valueDate must be earlier than maturityDate"); - strikeForwardRate_ = InterestRate(strikeForwardRate, - forecastCurve_->dayCounter(), - Simple, Once); - - registerWith(discountCurve_); - registerWith(forecastCurve_); - } - Date ForwardRateAgreement::fixingDate() const { - if (index_) - return index_->fixingDate(valueDate_); - else { - Date fixingDate_ = calendar_.advance(valueDate_, - -static_cast(fixingDays_), Days, businessDayConvention_); - return fixingDate_; - } + return index_->fixingDate(valueDate_); } bool ForwardRateAgreement::isExpired() const { @@ -137,60 +100,36 @@ namespace QuantLib { void ForwardRateAgreement::setupExpired() const { Instrument::setupExpired(); - calculateForwardRate(); } void ForwardRateAgreement::performCalculations() const { calculateAmount(); - -/* Handle discount = - discountCurve_.empty() ? index_->forwardingTermStructure() : discountCurve_; */ - Handle discount; - if (discountCurve_.empty() && index_) - discount = index_->forwardingTermStructure(); - else if (!discountCurve_.empty()) - discount = discountCurve_; - else - discount = forecastCurve_; - + Handle discount = + discountCurve_.empty() ? index_->forwardingTermStructure() : discountCurve_; NPV_ = amount_ * discount->discount(valueDate_); } void ForwardRateAgreement::calculateForwardRate() const { - if (useIndexedCoupon_ && index_) + if (useIndexedCoupon_) forwardRate_ = InterestRate(index_->fixing(fixingDate()), index_->dayCounter(), Simple, Once); - else if (!useIndexedCoupon_ && index_) + else // par coupon approximation forwardRate_ = InterestRate((index_->forwardingTermStructure()->discount(valueDate_) / index_->forwardingTermStructure()->discount(maturityDate_) - 1.0) / index_->dayCounter().yearFraction(valueDate_, maturityDate_), - index_->dayCounter(), Simple, Once); - else // calculating forward rate using the forecast curve - forwardRate_ = -/* InterestRate((discountCurve_->discount(valueDate_) / - discountCurve_->discount(maturityDate_) - - 1.0) / - discountCurve_->dayCounter().yearFraction(valueDate_, maturityDate_), - discountCurve_->dayCounter(), Simple, Once); */ - InterestRate((forecastCurve_->discount(valueDate_) / - forecastCurve_->discount(maturityDate_) - - 1.0) / - forecastCurve_->dayCounter().yearFraction(valueDate_, maturityDate_), - forecastCurve_->dayCounter(), Simple, Once); + index_->dayCounter(), Simple, Once); } void ForwardRateAgreement::calculateAmount() const { calculateForwardRate(); Integer sign = fraType_ == Position::Long? 1 : -1; - Rate F = forwardRate_.rate(); Rate K = strikeForwardRate_.rate(); Time T = forwardRate_.dayCounter().yearFraction(valueDate_, maturityDate_); - amount_ = notionalAmount_ * sign * (F - K) * T / (1.0 + F * T); } diff --git a/ql/instruments/forwardrateagreement.hpp b/ql/instruments/forwardrateagreement.hpp index cb5a9458245..0d3522a73cc 100644 --- a/ql/instruments/forwardrateagreement.hpp +++ b/ql/instruments/forwardrateagreement.hpp @@ -91,24 +91,6 @@ namespace QuantLib { Handle discountCurve = Handle(), bool useIndexedCoupon = true); - /*! When using this constructor, the forward rate will be - forecast directly from the passed term structure. Lacking - an index, we need to pass the number of fixing days and - the business day convention explicitly to calculate the - relevant dates. - */ - ForwardRateAgreement( - const Date& valueDate, - const Date& maturityDate, - Position::Type type, - Rate strikeForwardRate, - Real notionalAmount, - //Handle discountCurve, - Handle forecastCurve, - Natural fixingDays, - BusinessDayConvention businessDayConvention, - Handle discountCurve = Handle()); - //! \name Calculations //@{ //! A FRA expires/settles on the value date @@ -149,10 +131,6 @@ namespace QuantLib { //! maturityDate of the underlying index; not the date the FRA is settled. Date maturityDate_; Handle discountCurve_; - //! the number of fixingDays for fixingDate calculation without the index - Natural fixingDays_; - //! forecasting curve for fixings calculation - Handle forecastCurve_; private: void calculateForwardRate() const; @@ -160,7 +138,6 @@ namespace QuantLib { mutable Real amount_; }; - inline const Calendar& ForwardRateAgreement::calendar() const { return calendar_; } inline BusinessDayConvention ForwardRateAgreement::businessDayConvention() const { diff --git a/ql/termstructures/yield/ratehelpers.cpp b/ql/termstructures/yield/ratehelpers.cpp index 907a431267c..2a7cb9308db 100644 --- a/ql/termstructures/yield/ratehelpers.cpp +++ b/ql/termstructures/yield/ratehelpers.cpp @@ -623,12 +623,8 @@ namespace QuantLib { earliestDate_ = iborIndex_->fixingCalendar().advance( spotDate, *periodToStart_, iborIndex_->businessDayConvention(), iborIndex_->endOfMonth()); - // maturity date is calculated from spot date -/* maturityDate_ = iborIndex_->fixingCalendar().advance( - spotDate, *periodToStart_ + iborIndex_->tenor(), iborIndex_->businessDayConvention(), - iborIndex_->endOfMonth()); */ // maturity date is calculated from earliest date - // coherently with the instrument logic + // coherently with the FRA instrument logic maturityDate_ = iborIndex_->fixingCalendar().advance( earliestDate_, iborIndex_->tenor(), iborIndex_->businessDayConvention(), iborIndex_->endOfMonth()); From 4887a7a5f645a6e95cb302ca2908a7fb96fc99fc Mon Sep 17 00:00:00 2001 From: jakeheke75 Date: Wed, 19 Apr 2023 10:19:13 +0200 Subject: [PATCH 107/292] deprecated constructor in version 1.31 --- ql/instruments/forwardrateagreement.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ql/instruments/forwardrateagreement.hpp b/ql/instruments/forwardrateagreement.hpp index 0d3522a73cc..593acc89ff5 100644 --- a/ql/instruments/forwardrateagreement.hpp +++ b/ql/instruments/forwardrateagreement.hpp @@ -66,7 +66,7 @@ namespace QuantLib { class ForwardRateAgreement: public Instrument { public: /*! \deprecated Use one of the other constructors. - Deprecated in version 1.30. + Deprecated in version 1.31. */ QL_DEPRECATED ForwardRateAgreement( From ec2ad9e77cfb6e77d406707048196859f7f25b53 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Thu, 15 Apr 2021 16:25:45 +0200 Subject: [PATCH 108/292] Set version to 1.31-dev. --- CMakeLists.txt | 6 +++--- configure.ac | 2 +- ql/version.hpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54287716311..0972077efa6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,14 +5,14 @@ cmake_policy(SET CMP0091 NEW) # Version info set(QUANTLIB_VERSION_MAJOR 1) -set(QUANTLIB_VERSION_MINOR 30) +set(QUANTLIB_VERSION_MINOR 31) set(QUANTLIB_VERSION_PATCH 0) set(QUANTLIB_VERSION ${QUANTLIB_VERSION_MAJOR}.${QUANTLIB_VERSION_MINOR}.${QUANTLIB_VERSION_PATCH}) # Project Info set(PACKAGE_NAME "QuantLib") -set(PACKAGE_VERSION "${QUANTLIB_VERSION}") -set(PACKAGE_VERSION_HEX "0x013000f0") +set(PACKAGE_VERSION "${QUANTLIB_VERSION}-dev") +set(PACKAGE_VERSION_HEX "0x01310000") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/lballabio/QuantLib/issues/") diff --git a/configure.ac b/configure.ac index 61cd03f3a66..dcaf78c7d49 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # Process this file with autoconf to produce a configure script. -AC_INIT([QuantLib], [1.30], +AC_INIT([QuantLib], [1.31-dev], [quantlib-dev@lists.sourceforge.net], [QuantLib]) AC_PREREQ(2.62) diff --git a/ql/version.hpp b/ql/version.hpp index 1fae4a02258..5756f21bf66 100644 --- a/ql/version.hpp +++ b/ql/version.hpp @@ -31,10 +31,10 @@ /*! @{ */ //! version string -#define QL_VERSION "1.30" +#define QL_VERSION "1.31-dev" //! version hexadecimal number -#define QL_HEX_VERSION 0x013000f0 +#define QL_HEX_VERSION 0x01310000 /*! @} */ From d2d89f05ec5770bf68289e3a7af421e911ed6536 Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Wed, 19 Apr 2023 10:51:02 +0200 Subject: [PATCH 109/292] Avoid warning on latest Apple clang --- test-suite/tracing.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test-suite/tracing.cpp b/test-suite/tracing.cpp index b2092e70e70..50c1a9d66ee 100644 --- a/test-suite/tracing.cpp +++ b/test-suite/tracing.cpp @@ -36,7 +36,7 @@ namespace { } }; -#if defined(__clang__) && __clang_major__ >= 15 +#if defined(__clang__) && __clang_major__ >= 14 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-but-set-variable" #endif @@ -74,7 +74,7 @@ namespace { } } -#if defined(__clang__) && __clang_major__ >= 15 +#if defined(__clang__) && __clang_major__ >= 14 #pragma clang diagnostic pop #endif From a60789d72ec9fd3f0ddbcc6c8df74180f2d2e9bb Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Wed, 19 Apr 2023 13:03:48 +0200 Subject: [PATCH 110/292] Remove features deprecated in version 1.26 --- cmake/GenerateHeaders.cmake | 4 + ql/cashflows/cpicoupon.cpp | 84 ---------- ql/cashflows/cpicoupon.hpp | 72 -------- ql/cashflows/zeroinflationcashflow.cpp | 17 -- ql/cashflows/zeroinflationcashflow.hpp | 15 -- ql/math/Makefile.am | 2 +- ql/math/all.hpp | 2 - ql/math/curve.hpp | 30 +--- ql/math/lexicographicalview.hpp | 154 +----------------- ql/methods/montecarlo/lsmbasissystem.hpp | 6 - ql/patterns/Makefile.am | 2 +- ql/patterns/all.hpp | 1 - ql/patterns/composite.hpp | 33 +--- ql/patterns/observable.hpp | 45 +---- .../vanilla/mcamericanengine.hpp | 12 -- ql/termstructures/yield/Makefile.am | 2 +- ql/termstructures/yield/all.hpp | 1 - .../yield/drifttermstructure.hpp | 98 +---------- 18 files changed, 21 insertions(+), 559 deletions(-) diff --git a/cmake/GenerateHeaders.cmake b/cmake/GenerateHeaders.cmake index 3e032e53758..c488734ed42 100644 --- a/cmake/GenerateHeaders.cmake +++ b/cmake/GenerateHeaders.cmake @@ -51,6 +51,10 @@ function(generate_dir_headers source_dir binary_dir) list(FILTER children_hpp EXCLUDE REGEX "amortizingfloatingratebond.hpp") list(FILTER children_hpp EXCLUDE REGEX "amortizingcmsratebond.hpp") list(FILTER children_hpp EXCLUDE REGEX "riskybond.hpp") + list(FILTER children_hpp EXCLUDE REGEX "composite.hpp") + list(FILTER children_hpp EXCLUDE REGEX "lexicographicalview.hpp") + list(FILTER children_hpp EXCLUDE REGEX "^curve.hpp") + list(FILTER children_hpp EXCLUDE REGEX "drifttermstructure.hpp") file(GLOB children_dir RELATIVE ${source_dir} "${source_dir}/*") list(FILTER children_dir EXCLUDE REGEX "CMakeFiles") list(FILTER children_dir EXCLUDE REGEX "^\\..*") diff --git a/ql/cashflows/cpicoupon.cpp b/ql/cashflows/cpicoupon.cpp index 5ebcf16cbad..26c607b9c81 100644 --- a/ql/cashflows/cpicoupon.cpp +++ b/ql/cashflows/cpicoupon.cpp @@ -126,32 +126,6 @@ namespace QuantLib { "|baseCPI_| < 1e-16, future divide-by-zero problem"); } - CPICoupon::CPICoupon(Real baseCPI, - const Date& paymentDate, - Real nominal, - const Date& startDate, - const Date& endDate, - Natural fixingDays, - const ext::shared_ptr& zeroIndex, - const Period& observationLag, - CPI::InterpolationType observationInterpolation, - const DayCounter& dayCounter, - Real fixedRate, - Spread spread, - const Date& refPeriodStart, - const Date& refPeriodEnd, - const Date& exCouponDate) - : InflationCoupon(paymentDate, nominal, startDate, endDate, - fixingDays, zeroIndex, observationLag, - dayCounter, refPeriodStart, refPeriodEnd, exCouponDate), - baseCPI_(baseCPI), fixedRate_(fixedRate), spread_(spread), - observationInterpolation_(observationInterpolation) { - - QL_REQUIRE(zeroIndex, "no index provided"); - QL_REQUIRE(std::fabs(baseCPI_) > 1e-16, - "|baseCPI_| < 1e-16, future divide-by-zero problem"); - } - void CPICoupon::accept(AcyclicVisitor& v) { auto* v1 = dynamic_cast*>(&v); @@ -169,34 +143,6 @@ namespace QuantLib { } - Rate CPICoupon::indexFixing(const Date &d) const { - // you may want to modify the interpolation of the index - // this gives you the chance - - Rate I1; - // what interpolation do we use? Index / flat / linear - if (observationInterpolation() == CPI::AsIndex) { - I1 = cpiIndex()->fixing(d); - - } else { - // work out what it should be - std::pair dd = inflationPeriod(d, cpiIndex()->frequency()); - Real indexStart = cpiIndex()->fixing(dd.first); - if (observationInterpolation() == CPI::Linear) { - Real indexEnd = cpiIndex()->fixing(dd.second+Period(1,Days)); - // linear interpolation - I1 = indexStart + (indexEnd - indexStart) * (d - dd.first) - / (Real)( (dd.second+Period(1,Days)) - dd.first); // can't get to next period's value within current period - } else { - // no interpolation, i.e. flat = constant, so use start-of-period value - I1 = indexStart; - } - - } - return I1; - } - - CPICashFlow::CPICashFlow(Real notional, const ext::shared_ptr& index, @@ -218,28 +164,6 @@ namespace QuantLib { "|baseCPI_| < 1e-16, future divide-by-zero problem"); } - CPICashFlow::CPICashFlow(Real notional, - const ext::shared_ptr& index, - const Date& baseDate, - Real baseFixing, - const Date& fixingDate, - const Date& paymentDate, - bool growthOnly, - CPI::InterpolationType interpolation, - const Frequency& frequency) - : IndexedCashFlow(notional, index, baseDate, fixingDate, - paymentDate, growthOnly), - baseFixing_(baseFixing), interpolation_(interpolation), - frequency_(frequency) { - - QL_REQUIRE(std::fabs(baseFixing_)>1e-16, - "|baseFixing|<1e-16, future divide-by-zero error"); - if (interpolation_ != CPI::AsIndex) { - QL_REQUIRE(frequency_ != QuantLib::NoFrequency, - "non-index interpolation w/o frequency"); - } - } - Date CPICashFlow::baseDate() const { Date base = IndexedCashFlow::baseDate(); if (base != Date()) { @@ -336,14 +260,6 @@ namespace QuantLib { return *this; } - CPILeg& CPILeg::withFixingDays(Natural fixingDays) { - return *this; - } - - CPILeg& CPILeg::withFixingDays(const std::vector& fixingDays) { - return *this; - } - CPILeg& CPILeg::withSpreads(Spread spread) { spreads_ = std::vector(1,spread); return *this; diff --git a/ql/cashflows/cpicoupon.hpp b/ql/cashflows/cpicoupon.hpp index cbf1431793c..5613a8b3e3a 100644 --- a/ql/cashflows/cpicoupon.hpp +++ b/ql/cashflows/cpicoupon.hpp @@ -100,26 +100,6 @@ namespace QuantLib { const Date& refPeriodEnd = Date(), const Date& exCouponDate = Date()); - /*! \deprecated Use the other constructor instead. - Deprecated in version 1.26. - */ - QL_DEPRECATED - CPICoupon(Real baseCPI, - const Date& paymentDate, - Real nominal, - const Date& startDate, - const Date& endDate, - Natural fixingDays, - const ext::shared_ptr& index, - const Period& observationLag, - CPI::InterpolationType observationInterpolation, - const DayCounter& dayCounter, - Real fixedRate, // aka gearing - Spread spread = 0.0, - const Date& refPeriodStart = Date(), - const Date& refPeriodEnd = Date(), - const Date& exCouponDate = Date()); - //! \name Inspectors //@{ //! fixed rate that will be inflated by the index ratio @@ -147,18 +127,6 @@ namespace QuantLib { //! how do you observe the index? as-is, flat, linear? CPI::InterpolationType observationInterpolation() const; - /*! \deprecated Use CPI::laggedFixing instead. - Deprecated in version 1.26. - */ - QL_DEPRECATED - Rate indexObservation(const Date& onDate) const; - - /*! \deprecated Renamed to adjustedIndexGrowth. - Deprecated in version 1.26. - */ - QL_DEPRECATED - Rate adjustedFixing() const; - //! index used ext::shared_ptr cpiIndex() const; //@} @@ -175,12 +143,6 @@ namespace QuantLib { Date baseDate_; bool checkPricerImpl(const ext::shared_ptr&) const override; - - /*! \deprecated Use CPI::laggedFixing instead. - Deprecated in version 1.26. - */ - QL_DEPRECATED - Rate indexFixing(const Date &) const; }; @@ -198,20 +160,6 @@ namespace QuantLib { const Date& paymentDate, bool growthOnly = false); - /*! \deprecated Use the other constructor. - Deprecated in version 1.26. - */ - QL_DEPRECATED - CPICashFlow(Real notional, - const ext::shared_ptr& index, - const Date& baseDate, - Real baseFixing, - const Date& fixingDate, - const Date& paymentDate, - bool growthOnly = false, - CPI::InterpolationType interpolation = CPI::AsIndex, - const Frequency& frequency = QuantLib::NoFrequency); - //! value used on base date /*! This does not have to agree with index on that date. */ Real baseFixing() const override; @@ -262,16 +210,6 @@ namespace QuantLib { CPILeg& withPaymentDayCounter(const DayCounter&); CPILeg& withPaymentAdjustment(BusinessDayConvention); CPILeg& withPaymentCalendar(const Calendar&); - /*! \deprecated No-op; do not use. - Deprecated in version 1.26. - */ - QL_DEPRECATED - CPILeg& withFixingDays(Natural fixingDays); - /*! \deprecated No-op; do not use. - Deprecated in version 1.26. - */ - QL_DEPRECATED - CPILeg& withFixingDays(const std::vector& fixingDays); CPILeg& withObservationInterpolation(CPI::InterpolationType); CPILeg& withSubtractInflationNominal(bool); CPILeg& withSpreads(Spread spread); @@ -340,16 +278,6 @@ namespace QuantLib { return observationInterpolation_; } - inline Rate CPICoupon::indexObservation(const Date& onDate) const { - QL_DEPRECATED_DISABLE_WARNING - return indexFixing(onDate); - QL_DEPRECATED_ENABLE_WARNING - } - - inline Rate CPICoupon::adjustedFixing() const { - return adjustedIndexGrowth(); - } - inline ext::shared_ptr CPICoupon::cpiIndex() const { return ext::dynamic_pointer_cast(index()); } diff --git a/ql/cashflows/zeroinflationcashflow.cpp b/ql/cashflows/zeroinflationcashflow.cpp index 0d677b233b1..a79600e36c8 100644 --- a/ql/cashflows/zeroinflationcashflow.cpp +++ b/ql/cashflows/zeroinflationcashflow.cpp @@ -38,23 +38,6 @@ namespace QuantLib { zeroInflationIndex_(index), observationInterpolation_(observationInterpolation), startDate_(startDate), endDate_(endDate), observationLag_(observationLag) {} - ZeroInflationCashFlow::ZeroInflationCashFlow(Real notional, - const ext::shared_ptr& index, - CPI::InterpolationType observationInterpolation, - const Date& startDate, - const Date& endDate, - const Period& observationLag, - const Calendar& calendar, - BusinessDayConvention convention, - const Date& paymentDate, - bool growthOnly) - : IndexedCashFlow(notional, index, - calendar.adjust(startDate - observationLag, convention), - calendar.adjust(endDate - observationLag, convention), - paymentDate, growthOnly), - zeroInflationIndex_(index), observationInterpolation_(observationInterpolation), - startDate_(startDate), endDate_(endDate), observationLag_(observationLag) {} - Real ZeroInflationCashFlow::amount() const { Real I0, I1; diff --git a/ql/cashflows/zeroinflationcashflow.hpp b/ql/cashflows/zeroinflationcashflow.hpp index 6bd8d4296e4..cfb4f6deb88 100644 --- a/ql/cashflows/zeroinflationcashflow.hpp +++ b/ql/cashflows/zeroinflationcashflow.hpp @@ -49,21 +49,6 @@ namespace QuantLib { const Date& paymentDate, bool growthOnly = false); - /*! \deprecated Use the other constructor. - Deprecated in version 1.26. - */ - QL_DEPRECATED - ZeroInflationCashFlow(Real notional, - const ext::shared_ptr& index, - CPI::InterpolationType observationInterpolation, - const Date& startDate, - const Date& endDate, - const Period& observationLag, - const Calendar& calendar, - BusinessDayConvention convention, - const Date& paymentDate, - bool growthOnly = false); - //! \name ZeroInflationCashFlow interface //@{ ext::shared_ptr zeroInflationIndex() const { diff --git a/ql/math/Makefile.am b/ql/math/Makefile.am index b55899427c8..2bf7f61cf6c 100644 --- a/ql/math/Makefile.am +++ b/ql/math/Makefile.am @@ -93,7 +93,7 @@ all.hpp: Makefile.am echo "/* This file is automatically generated; do not edit. */" > ${srcdir}/$@ echo "/* Add the files to be included into Makefile.am instead. */" >> ${srcdir}/$@ echo >> ${srcdir}/$@ - for i in $(filter-out all.hpp initializers.hpp, $(this_include_HEADERS)); do \ + for i in $(filter-out all.hpp curve.hpp initializers.hpp lexicographicalview.hpp, $(this_include_HEADERS)); do \ echo "#include <${subdir}/$$i>" >> ${srcdir}/$@; \ done echo >> ${srcdir}/$@ diff --git a/ql/math/all.hpp b/ql/math/all.hpp index be17d090c8b..e724b24b3ce 100644 --- a/ql/math/all.hpp +++ b/ql/math/all.hpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -17,7 +16,6 @@ #include #include #include -#include #include #include #include diff --git a/ql/math/curve.hpp b/ql/math/curve.hpp index bec736d145f..c1214daa896 100644 --- a/ql/math/curve.hpp +++ b/ql/math/curve.hpp @@ -17,31 +17,5 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -/*! \file curve.hpp - \brief Curve -*/ - -#ifndef quantlib_curve_hpp -#define quantlib_curve_hpp - -#include -#include - -namespace QuantLib { - - /*! \deprecated To be removed as unused. - Copy it in your codebase if you need it. - Deprecated in version 1.26. - */ - class QL_DEPRECATED Curve { - public: - typedef Real argument_type; - typedef Real result_type; - virtual ~Curve() = default; - virtual Real operator()(Real x) const = 0; - }; - -} - - -#endif +// Deprecated in version 1.31 +#pragma message("Warning: this file is empty and will disappear in a future release. Do not include it.") diff --git a/ql/math/lexicographicalview.hpp b/ql/math/lexicographicalview.hpp index 9ed2193ac20..ab0219f6303 100644 --- a/ql/math/lexicographicalview.hpp +++ b/ql/math/lexicographicalview.hpp @@ -17,155 +17,5 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -/*! \file lexicographicalview.hpp - \brief Lexicographical 2-D view of a contiguous set of data. -*/ - -#ifndef quantlib_lexicographical_view_hpp -#define quantlib_lexicographical_view_hpp - -#include -#include - -namespace QuantLib { - - /*! \deprecated To be removed as unused. - Copy it in your codebase if you need it. - Deprecated in version 1.26. - */ - template - class QL_DEPRECATED LexicographicalView { - public: - //! attaches the view with the given dimension to a sequence - LexicographicalView(const RandomAccessIterator& begin, - const RandomAccessIterator& end, Size xSize); - //! iterates over \f$ v_{ij} \f$ with \f$ j \f$ fixed. - typedef RandomAccessIterator x_iterator; - //! iterates backwards over \f$ v_{ij} \f$ with \f$ j \f$ fixed. - typedef boost::reverse_iterator - reverse_x_iterator; - //! iterates over \f$ v_{ij} \f$ with \f$ i \f$ fixed. - typedef step_iterator y_iterator; - //! iterates backwards over \f$ v_{ij} \f$ with \f$ i \f$ fixed. - typedef boost::reverse_iterator reverse_y_iterator; - - //! \name Element access - //@{ - y_iterator operator[](Size i); - //@} - - //! \name Iterator access - //@{ - x_iterator xbegin (Size j); - x_iterator xend (Size j); - reverse_x_iterator rxbegin(Size j); - reverse_x_iterator rxend (Size j); - y_iterator ybegin (Size i); - y_iterator yend (Size i); - reverse_y_iterator rybegin(Size i); - reverse_y_iterator ryend (Size i); - //@} - - //! \name Inspectors - //@{ - //! dimension of the array along x - Size xSize() const; - //! dimension of the array along y - Size ySize() const; - //@} - private: - RandomAccessIterator begin_, end_; - Size xSize_, ySize_; - }; - - - // inline definitions - - QL_DEPRECATED_DISABLE_WARNING - - template - inline - LexicographicalView::LexicographicalView( - const RandomAccessIterator& begin, - const RandomAccessIterator& end, - Size xSize) - : begin_(begin), end_(end), xSize_(xSize), - ySize_((end-begin)/xSize) { - QL_REQUIRE((end_-begin_) % xSize_ == 0, - "The x size of the view is not an exact divisor" - "of the size of the underlying sequence"); - } - - template - inline typename LexicographicalView::x_iterator - LexicographicalView::xbegin(Size j) { - return begin_+j*xSize_; - } - - template - inline typename LexicographicalView::x_iterator - LexicographicalView::xend(Size j) { - return begin_+(j+1)*xSize_; - } - - template - inline - typename LexicographicalView::reverse_x_iterator - LexicographicalView::rxbegin(Size j) { - return reverse_x_iterator(xend(j)); - } - - template - inline - typename LexicographicalView::reverse_x_iterator - LexicographicalView::rxend(Size j) { - return reverse_x_iterator(xbegin(j)); - } - - template - inline typename LexicographicalView::y_iterator - LexicographicalView::ybegin(Size i) { - return y_iterator(begin_+i,xSize_); - } - - template - inline typename LexicographicalView::y_iterator - LexicographicalView::yend(Size i) { - return y_iterator(begin_+i,xSize_)+ySize_; - } - - template - inline - typename LexicographicalView::reverse_y_iterator - LexicographicalView::rybegin(Size i) { - return reverse_y_iterator(yend(i)); - } - - template - inline - typename LexicographicalView::reverse_y_iterator - LexicographicalView::ryend(Size i) { - return reverse_y_iterator(ybegin(i)); - } - - template - inline typename LexicographicalView::y_iterator - LexicographicalView::operator[](Size i) { - return y_iterator(begin_+i,xSize_); - } - - template - inline Size LexicographicalView::xSize() const { - return xSize_; - } - - template - inline Size LexicographicalView::ySize() const { - return ySize_; - } - - QL_DEPRECATED_ENABLE_WARNING -} - - -#endif +// Deprecated in version 1.31 +#pragma message("Warning: this file is empty and will disappear in a future release. Do not include it.") diff --git a/ql/methods/montecarlo/lsmbasissystem.hpp b/ql/methods/montecarlo/lsmbasissystem.hpp index daa2fb697e1..66e5a010cbb 100644 --- a/ql/methods/montecarlo/lsmbasissystem.hpp +++ b/ql/methods/montecarlo/lsmbasissystem.hpp @@ -41,12 +41,6 @@ namespace QuantLib { Legendre, Chebyshev, Chebyshev2nd }; - /*! \deprecated Renamed to PolynomialType. - Deprecated in version 1.26. - */ - QL_DEPRECATED - typedef PolynomialType PolynomType; - static std::vector > pathBasisSystem(Size order, PolynomialType type); diff --git a/ql/patterns/Makefile.am b/ql/patterns/Makefile.am index def3bf6b573..9bbb58170e9 100644 --- a/ql/patterns/Makefile.am +++ b/ql/patterns/Makefile.am @@ -40,7 +40,7 @@ all.hpp: Makefile.am echo "/* This file is automatically generated; do not edit. */" > ${srcdir}/$@ echo "/* Add the files to be included into Makefile.am instead. */" >> ${srcdir}/$@ echo >> ${srcdir}/$@ - for i in $(filter-out all.hpp, $(this_include_HEADERS)); do \ + for i in $(filter-out all.hpp composite.hpp, $(this_include_HEADERS)); do \ echo "#include <${subdir}/$$i>" >> ${srcdir}/$@; \ done echo >> ${srcdir}/$@ diff --git a/ql/patterns/all.hpp b/ql/patterns/all.hpp index ea1a8d50b60..ad22ab7efde 100644 --- a/ql/patterns/all.hpp +++ b/ql/patterns/all.hpp @@ -1,7 +1,6 @@ /* This file is automatically generated; do not edit. */ /* Add the files to be included into Makefile.am instead. */ -#include #include #include #include diff --git a/ql/patterns/composite.hpp b/ql/patterns/composite.hpp index 6c8c07a0430..37227b53931 100644 --- a/ql/patterns/composite.hpp +++ b/ql/patterns/composite.hpp @@ -17,34 +17,5 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -/*! \file composite.hpp - \brief composite pattern -*/ - -#ifndef quantlib_composite_hpp -#define quantlib_composite_hpp - -#include -#include -#include - -namespace QuantLib { - - /*! \deprecated To be removed as unused. - Copy it in your codebase if you need it. - Deprecated in version 1.26. - */ - template - class QL_DEPRECATED Composite : public T { - protected: - std::list > components_; - void add(const ext::shared_ptr& c) { components_.push_back(c); } - typedef typename std::list >::iterator iterator; - typedef typename std::list >::const_iterator - const_iterator; - }; - -} - - -#endif +// Deprecated in version 1.31 +#pragma message("Warning: this file is empty and will disappear in a future release. Do not include it.") diff --git a/ql/patterns/observable.hpp b/ql/patterns/observable.hpp index 69c264d8cc4..c17c6b0a611 100644 --- a/ql/patterns/observable.hpp +++ b/ql/patterns/observable.hpp @@ -99,18 +99,10 @@ namespace QuantLib { //! Object that gets notified when a given observable changes /*! \ingroup patterns */ class Observer { - public: - /*! \deprecated Don't use `set_type`; it's not used in the public interface - anyway. Use `Observer::iterator` if you need to - capture the return value from `registerWith`. - Deprecated in version 1.26. - */ - QL_DEPRECATED // to be moved to private section, not removed + private: typedef boost::unordered_set > set_type; - - QL_DEPRECATED_DISABLE_WARNING + public: typedef set_type::iterator iterator; - QL_DEPRECATED_ENABLE_WARNING // constructors, assignment, destructor Observer() = default; @@ -143,9 +135,7 @@ namespace QuantLib { virtual void deepUpdate(); private: - QL_DEPRECATED_DISABLE_WARNING set_type observables_; - QL_DEPRECATED_ENABLE_WARNING }; @@ -272,17 +262,10 @@ namespace QuantLib { class Observer : public ext::enable_shared_from_this { friend class Observable; friend class ObservableSettings; - public: - /*! \deprecated Don't use `set_type`; it's not used in the public interface - anyway. Use `Observer::iterator` if you need to capture - the return value from `registerWith`. - Deprecated in version 1.26. - */ - QL_DEPRECATED // to be moved to private section, not removed + private: typedef boost::unordered_set > set_type; - QL_DEPRECATED_DISABLE_WARNING + public: typedef set_type::iterator iterator; - QL_DEPRECATED_ENABLE_WARNING // constructors, assignment, destructor Observer() {} @@ -356,9 +339,7 @@ namespace QuantLib { ext::shared_ptr proxy_; mutable std::recursive_mutex mutex_; - QL_DEPRECATED_DISABLE_WARNING set_type observables_; - QL_DEPRECATED_ENABLE_WARNING }; namespace detail { @@ -369,15 +350,10 @@ namespace QuantLib { /*! \ingroup patterns */ class Observable { friend class Observer; - public: - /*! \deprecated Don't use `set_type`; it's not used in the public interface anyway. - Deprecated in version 1.26. - */ - QL_DEPRECATED // to be moved to private section, not removed + private: typedef boost::unordered_set> set_type; - QL_DEPRECATED_DISABLE_WARNING + public: typedef set_type::iterator iterator; - QL_DEPRECATED_ENABLE_WARNING // constructors, assignment, destructor Observable(); @@ -394,13 +370,8 @@ namespace QuantLib { const ext::shared_ptr& proxy, bool disconnect); ext::shared_ptr sig_; - - QL_DEPRECATED_DISABLE_WARNING set_type observers_; - QL_DEPRECATED_ENABLE_WARNING - mutable std::recursive_mutex mutex_; - ObservableSettings& settings_; }; @@ -425,9 +396,7 @@ namespace QuantLib { boost::owner_less > > set_type; - QL_DEPRECATED_DISABLE_WARNING void registerDeferredObservers(const Observable::set_type& observers); - QL_DEPRECATED_ENABLE_WARNING void unregisterDeferredObserver(const ext::shared_ptr& proxy); set_type deferredObservers_; @@ -440,11 +409,9 @@ namespace QuantLib { // inline definitions - QL_DEPRECATED_DISABLE_WARNING inline void ObservableSettings::registerDeferredObservers(const Observable::set_type& observers) { deferredObservers_.insert(observers.begin(), observers.end()); } - QL_DEPRECATED_ENABLE_WARNING inline void ObservableSettings::unregisterDeferredObserver( const ext::shared_ptr& o) { diff --git a/ql/pricingengines/vanilla/mcamericanengine.hpp b/ql/pricingengines/vanilla/mcamericanengine.hpp index 756692c6b07..e00b95bae4b 100644 --- a/ql/pricingengines/vanilla/mcamericanengine.hpp +++ b/ql/pricingengines/vanilla/mcamericanengine.hpp @@ -123,12 +123,6 @@ namespace QuantLib { MakeMCAmericanEngine& withAntitheticVariateCalibration(bool b = true); MakeMCAmericanEngine& withSeedCalibration(BigNatural seed); - /*! \deprecated Renamed to withPolynomialOrder. - Deprecated in version 1.26. - */ - QL_DEPRECATED - MakeMCAmericanEngine& withPolynomOrder(Size polynomialOrder); - // conversion to pricing engine operator ext::shared_ptr() const; private: @@ -284,12 +278,6 @@ namespace QuantLib { return *this; } - template - inline MakeMCAmericanEngine & - MakeMCAmericanEngine::withPolynomOrder(Size polynomialOrder) { - return withPolynomialOrder(polynomialOrder); - } - template inline MakeMCAmericanEngine & MakeMCAmericanEngine::withBasisSystem(LsmBasisSystem::PolynomialType polynomialType) { diff --git a/ql/termstructures/yield/Makefile.am b/ql/termstructures/yield/Makefile.am index 9e94ea78d60..33b9199e84c 100644 --- a/ql/termstructures/yield/Makefile.am +++ b/ql/termstructures/yield/Makefile.am @@ -65,7 +65,7 @@ all.hpp: Makefile.am echo "/* This file is automatically generated; do not edit. */" > ${srcdir}/$@ echo "/* Add the files to be included into Makefile.am instead. */" >> ${srcdir}/$@ echo >> ${srcdir}/$@ - for i in $(filter-out all.hpp, $(this_include_HEADERS)); do \ + for i in $(filter-out all.hpp drifttermstructure.hpp, $(this_include_HEADERS)); do \ echo "#include <${subdir}/$$i>" >> ${srcdir}/$@; \ done echo >> ${srcdir}/$@ diff --git a/ql/termstructures/yield/all.hpp b/ql/termstructures/yield/all.hpp index 3ee87886c21..ff91e8eb11e 100644 --- a/ql/termstructures/yield/all.hpp +++ b/ql/termstructures/yield/all.hpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/ql/termstructures/yield/drifttermstructure.hpp b/ql/termstructures/yield/drifttermstructure.hpp index b297c9c3797..bdedf14bc08 100644 --- a/ql/termstructures/yield/drifttermstructure.hpp +++ b/ql/termstructures/yield/drifttermstructure.hpp @@ -18,99 +18,5 @@ FOR A PARTICULAR PURPOSE. See the license for more details. */ -/*! \file drifttermstructure.hpp - \brief Drift term structure -*/ - -#ifndef quantlib_drift_term_structure_hpp -#define quantlib_drift_term_structure_hpp - -#include -#include -#include - -namespace QuantLib { - - /*! \deprecated To be removed as unused. - Copy it in your codebase if you need it. - Deprecated in version 1.26. - */ - class QL_DEPRECATED DriftTermStructure : public ZeroYieldStructure { - public: - DriftTermStructure(const Handle& riskFreeTS, - Handle dividendTS, - Handle blackVolTS); - //! \name YieldTermStructure interface - //@{ - DayCounter dayCounter() const override; - Calendar calendar() const override; - Natural settlementDays() const override; - const Date& referenceDate() const override; - Date maxDate() const override; - //@} - protected: - //! returns the discount factor as seen from the evaluation date - Rate zeroYieldImpl(Time) const override; - - private: - Handle riskFreeTS_, dividendTS_; - Handle blackVolTS_; - Real underlyingLevel_; - }; - - - // inline definitions - - QL_DEPRECATED_DISABLE_WARNING - - inline DriftTermStructure::DriftTermStructure(const Handle& riskFreeTS, - Handle dividendTS, - Handle blackVolTS) - : ZeroYieldStructure(riskFreeTS->dayCounter()), riskFreeTS_(riskFreeTS), - dividendTS_(std::move(dividendTS)), blackVolTS_(std::move(blackVolTS)) { - registerWith(riskFreeTS_); - registerWith(dividendTS_); - registerWith(blackVolTS_); - } - - inline DayCounter DriftTermStructure::dayCounter() const { - return riskFreeTS_->dayCounter(); - } - - inline Calendar DriftTermStructure::calendar() const { - return riskFreeTS_->calendar(); - } - - inline Natural DriftTermStructure::settlementDays() const { - return riskFreeTS_->settlementDays(); - } - - inline const Date& DriftTermStructure::referenceDate() const { - // warning: here it is assumed that all TS have the same referenceDate - // It should be QL_REQUIREd - return riskFreeTS_->referenceDate(); - } - - inline Date DriftTermStructure::maxDate() const { - return std::min(std::min(dividendTS_->maxDate(), - riskFreeTS_->maxDate()), - blackVolTS_->maxDate()); - } - - inline Rate DriftTermStructure::zeroYieldImpl(Time t) const { - // warning: here it is assumed that - // a) all TS have the same daycount. - // b) all TS have the same referenceDate - // It should be QL_REQUIREd - return riskFreeTS_->zeroRate(t, Continuous, NoFrequency, true).rate() - - dividendTS_->zeroRate(t, Continuous, NoFrequency, true).rate() - - 0.5 * blackVolTS_->blackVol(t, underlyingLevel_, true) - * blackVolTS_->blackVol(t, underlyingLevel_, true); - } - - QL_DEPRECATED_ENABLE_WARNING - -} - - -#endif +// Deprecated in version 1.31 +#pragma message("Warning: this file is empty and will disappear in a future release. Do not include it.") From 334fa970275313e19ada47ae9077206705747abf Mon Sep 17 00:00:00 2001 From: Luigi Ballabio Date: Wed, 19 Apr 2023 13:19:52 +0200 Subject: [PATCH 111/292] Fix access to private type --- ql/patterns/observable.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ql/patterns/observable.hpp b/ql/patterns/observable.hpp index c17c6b0a611..b61922736e9 100644 --- a/ql/patterns/observable.hpp +++ b/ql/patterns/observable.hpp @@ -350,6 +350,7 @@ namespace QuantLib { /*! \ingroup patterns */ class Observable { friend class Observer; + friend class ObservableSettings; private: typedef boost::unordered_set> set_type; public: From d2cf852ce68c69da2730dabd3af915348e9e1638 Mon Sep 17 00:00:00 2001 From: Jonathan Sweemer Date: Wed, 12 Apr 2023 07:54:44 +0000 Subject: [PATCH 112/292] Unsuppress cppcoreguidelines-special-member-functions --- .clang-tidy | 3 ++- ql/cashflows/cashflows.hpp | 4 ++++ .../callablebonds/callablebond.cpp | 2 +- ql/math/array.hpp | 9 ++++---- ql/math/matrix.hpp | 4 ++-- .../operators/ninepointlinearop.hpp | 1 + .../operators/triplebandlinearop.hpp | 1 + .../finitedifferences/tridiagonaloperator.hpp | 1 + ql/patterns/observable.hpp | 4 ++-- ql/patterns/singleton.hpp | 1 + ql/settings.hpp | 2 +- ql/termstructures/interpolatedcurve.hpp | 23 +++++++++++++++++-- .../swaption/sabrswaptionvolatilitycube.hpp | 2 +- ql/time/date.cpp | 2 +- ql/utilities/clone.hpp | 1 + ql/utilities/observablevalue.hpp | 2 +- test-suite/inflationcpibond.cpp | 2 +- test-suite/observable.cpp | 2 +- test-suite/tracing.cpp | 2 +- test-suite/utilities.hpp | 2 +- 20 files changed, 50 insertions(+), 20 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index bbd6dfac185..8692c07263e 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -34,7 +34,6 @@ Checks: > -cppcoreguidelines-pro-type-const-cast, -cppcoreguidelines-pro-type-member-init, -cppcoreguidelines-pro-type-vararg, - -cppcoreguidelines-special-member-functions, misc-*, -misc-confusable-identifiers, -misc-const-correctness, @@ -70,6 +69,8 @@ Checks: > HeaderFilterRegex: '.*' FormatStyle: file CheckOptions: + - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor + value: 1 - key: modernize-use-default-member-init.UseAssignment value: 1 ... diff --git a/ql/cashflows/cashflows.hpp b/ql/cashflows/cashflows.hpp index 0ba2f2d8e1c..22595249671 100644 --- a/ql/cashflows/cashflows.hpp +++ b/ql/cashflows/cashflows.hpp @@ -66,7 +66,11 @@ namespace QuantLib { }; public: CashFlows() = delete; + CashFlows(CashFlows&&) = delete; CashFlows(const CashFlows&) = delete; + CashFlows& operator=(CashFlows&&) = delete; + CashFlows& operator=(const CashFlows&) = delete; + ~CashFlows() = default; //! \name Date functions //@{ diff --git a/ql/experimental/callablebonds/callablebond.cpp b/ql/experimental/callablebonds/callablebond.cpp index abe24dbeb89..9d029fdb286 100644 --- a/ql/experimental/callablebonds/callablebond.cpp +++ b/ql/experimental/callablebonds/callablebond.cpp @@ -157,7 +157,7 @@ namespace QuantLib { namespace { template - class RestoreVal { + class RestoreVal { // NOLINT(cppcoreguidelines-special-member-functions) T orig_; T &ref_; public: diff --git a/ql/math/array.hpp b/ql/math/array.hpp index d3b8135ab45..de5ec1ef459 100644 --- a/ql/math/array.hpp +++ b/ql/math/array.hpp @@ -69,6 +69,7 @@ namespace QuantLib { //! creates the array from an iterable sequence template Array(ForwardIterator begin, ForwardIterator end); + ~Array() = default; Array& operator=(const Array&); Array& operator=(Array&&) noexcept; @@ -614,7 +615,7 @@ namespace QuantLib { return result; } - inline Array operator+(Array&& v1, Array&& v2) { + inline Array operator+(Array&& v1, Array&& v2) { // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) QL_REQUIRE(v1.size() == v2.size(), "arrays with different sizes (" << v1.size() << ", " << v2.size() << ") cannot be added"); @@ -674,7 +675,7 @@ namespace QuantLib { return result; } - inline Array operator-(Array&& v1, Array&& v2) { + inline Array operator-(Array&& v1, Array&& v2) { // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) QL_REQUIRE(v1.size() == v2.size(), "arrays with different sizes (" << v1.size() << ", " << v2.size() << ") cannot be subtracted"); @@ -734,7 +735,7 @@ namespace QuantLib { return result; } - inline Array operator*(Array&& v1, Array&& v2) { + inline Array operator*(Array&& v1, Array&& v2) { // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) QL_REQUIRE(v1.size() == v2.size(), "arrays with different sizes (" << v1.size() << ", " << v2.size() << ") cannot be multiplied"); @@ -794,7 +795,7 @@ namespace QuantLib { return result; } - inline Array operator/(Array&& v1, Array&& v2) { + inline Array operator/(Array&& v1, Array&& v2) { // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) QL_REQUIRE(v1.size() == v2.size(), "arrays with different sizes (" << v1.size() << ", " << v2.size() << ") cannot be divided"); diff --git a/ql/math/matrix.hpp b/ql/math/matrix.hpp index f5364c1e138..030bac4c73d 100644 --- a/ql/math/matrix.hpp +++ b/ql/math/matrix.hpp @@ -554,7 +554,7 @@ namespace QuantLib { return std::move(m1); } - inline Matrix operator+(Matrix&& m1, Matrix&& m2) { + inline Matrix operator+(Matrix&& m1, Matrix&& m2) { // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) QL_REQUIRE(m1.rows() == m2.rows() && m1.columns() == m2.columns(), "matrices with different sizes (" << @@ -610,7 +610,7 @@ namespace QuantLib { return std::move(m1); } - inline Matrix operator-(Matrix&& m1, Matrix&& m2) { + inline Matrix operator-(Matrix&& m1, Matrix&& m2) { // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved) QL_REQUIRE(m1.rows() == m2.rows() && m1.columns() == m2.columns(), "matrices with different sizes (" << diff --git a/ql/methods/finitedifferences/operators/ninepointlinearop.hpp b/ql/methods/finitedifferences/operators/ninepointlinearop.hpp index 24a5ad586f4..8da0ae1bbac 100644 --- a/ql/methods/finitedifferences/operators/ninepointlinearop.hpp +++ b/ql/methods/finitedifferences/operators/ninepointlinearop.hpp @@ -42,6 +42,7 @@ namespace QuantLib { NinePointLinearOp(NinePointLinearOp&& m) noexcept; NinePointLinearOp& operator=(const NinePointLinearOp& m); NinePointLinearOp& operator=(NinePointLinearOp&& m) noexcept; + ~NinePointLinearOp() override = default; Array apply(const Array& r) const override; NinePointLinearOp mult(const Array& u) const; diff --git a/ql/methods/finitedifferences/operators/triplebandlinearop.hpp b/ql/methods/finitedifferences/operators/triplebandlinearop.hpp index 6ca4b9eda09..25def57fcb6 100644 --- a/ql/methods/finitedifferences/operators/triplebandlinearop.hpp +++ b/ql/methods/finitedifferences/operators/triplebandlinearop.hpp @@ -43,6 +43,7 @@ namespace QuantLib { TripleBandLinearOp(TripleBandLinearOp&& m) noexcept; TripleBandLinearOp& operator=(const TripleBandLinearOp& m); TripleBandLinearOp& operator=(TripleBandLinearOp&& m) noexcept; + ~TripleBandLinearOp() override = default; Array apply(const Array& r) const override; Array solve_splitting(const Array& r, Real a, Real b = 1.0) const; diff --git a/ql/methods/finitedifferences/tridiagonaloperator.hpp b/ql/methods/finitedifferences/tridiagonaloperator.hpp index 9e6a7ec3d61..36d44267d1b 100644 --- a/ql/methods/finitedifferences/tridiagonaloperator.hpp +++ b/ql/methods/finitedifferences/tridiagonaloperator.hpp @@ -65,6 +65,7 @@ namespace QuantLib { TridiagonalOperator(TridiagonalOperator&&) noexcept; TridiagonalOperator& operator=(const TridiagonalOperator&); TridiagonalOperator& operator=(TridiagonalOperator&&) noexcept; + ~TridiagonalOperator() = default; //! \name Operator interface //@{ //! apply operator to a given array diff --git a/ql/patterns/observable.hpp b/ql/patterns/observable.hpp index b61922736e9..fff917e8f3d 100644 --- a/ql/patterns/observable.hpp +++ b/ql/patterns/observable.hpp @@ -46,7 +46,7 @@ namespace QuantLib { //! Object that notifies its changes to a set of observers /*! \ingroup patterns */ - class Observable { + class Observable { // NOLINT(cppcoreguidelines-special-member-functions) friend class Observer; friend class ObservableSettings; public: @@ -98,7 +98,7 @@ namespace QuantLib { //! Object that gets notified when a given observable changes /*! \ingroup patterns */ - class Observer { + class Observer { // NOLINT(cppcoreguidelines-special-member-functions) private: typedef boost::unordered_set > set_type; public: diff --git a/ql/patterns/singleton.hpp b/ql/patterns/singleton.hpp index 9f5c567b233..9b1ab56dc5e 100644 --- a/ql/patterns/singleton.hpp +++ b/ql/patterns/singleton.hpp @@ -62,6 +62,7 @@ namespace QuantLib { Singleton(Singleton&&) = delete; Singleton& operator=(const Singleton&) = delete; Singleton& operator=(Singleton&&) = delete; + ~Singleton() = default; //! access to the unique instance static T& instance(); diff --git a/ql/settings.hpp b/ql/settings.hpp index 67686d6063f..00c0ccd604e 100644 --- a/ql/settings.hpp +++ b/ql/settings.hpp @@ -117,7 +117,7 @@ namespace QuantLib { // helper class to temporarily and safely change the settings - class SavedSettings { + class SavedSettings { // NOLINT(cppcoreguidelines-special-member-functions) public: SavedSettings(); ~SavedSettings(); diff --git a/ql/termstructures/interpolatedcurve.hpp b/ql/termstructures/interpolatedcurve.hpp index 6320be0068f..19ab47448ba 100644 --- a/ql/termstructures/interpolatedcurve.hpp +++ b/ql/termstructures/interpolatedcurve.hpp @@ -39,6 +39,9 @@ namespace QuantLib { */ template class InterpolatedCurve { + public: + ~InterpolatedCurve() = default; + protected: //! \name Building //@{ @@ -47,9 +50,9 @@ namespace QuantLib { const Interpolator& i = Interpolator()) : times_(std::move(times)), data_(std::move(data)), interpolator_(i) {} - InterpolatedCurve(const std::vector