diff --git a/ql/cashflows/cpicoupon.cpp b/ql/cashflows/cpicoupon.cpp index 4a33ef1fc0f..8b978d8e661 100644 --- a/ql/cashflows/cpicoupon.cpp +++ b/ql/cashflows/cpicoupon.cpp @@ -42,7 +42,7 @@ namespace QuantLib { const Date& refPeriodStart, const Date& refPeriodEnd, const Date& exCouponDate) - : CPICoupon(baseCPI, Null(), paymentDate, nominal, startDate, endDate, + : CPICoupon(baseCPI, Date(), paymentDate, nominal, startDate, endDate, index, observationLag, observationInterpolation, dayCounter, fixedRate, refPeriodStart, refPeriodEnd, exCouponDate) {} @@ -84,7 +84,7 @@ namespace QuantLib { observationInterpolation_(observationInterpolation), baseDate_(baseDate) { QL_REQUIRE(index_, "no index provided"); - QL_REQUIRE(baseCPI_ != Null() || baseDate != Null(), + QL_REQUIRE(baseCPI_ != Null() || baseDate != Date(), "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"); @@ -150,7 +150,7 @@ namespace QuantLib { interpolation_(interpolation), frequency_(index ? index->frequency() : NoFrequency) { QL_REQUIRE(index, "no index provided"); QL_REQUIRE( - baseFixing_ != Null() || baseDate != Null(), + baseFixing_ != Null() || baseDate != Date(), "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"); @@ -182,7 +182,7 @@ namespace QuantLib { const Period& observationLag) : schedule_(std::move(schedule)), index_(std::move(index)), baseCPI_(baseCPI), observationLag_(observationLag), paymentDayCounter_(Thirty360(Thirty360::BondBasis)), - paymentCalendar_(schedule_.calendar()), baseDate_(Null()) {} + paymentCalendar_(schedule_.calendar()) {} CPILeg& CPILeg::withObservationInterpolation(CPI::InterpolationType interp) { @@ -283,7 +283,7 @@ namespace QuantLib { if (n>0) { QL_REQUIRE(!fixedRates_.empty(), "no fixedRates given"); - if (baseDate_ == Null() && baseCPI_ == Null()) { + if (baseDate_ == Date() && baseCPI_ == Null()) { baseDate = schedule_.date(0) - observationLag_; } diff --git a/ql/cashflows/cpicoupon.hpp b/ql/cashflows/cpicoupon.hpp index 0267ece0669..7b9d418b738 100644 --- a/ql/cashflows/cpicoupon.hpp +++ b/ql/cashflows/cpicoupon.hpp @@ -250,7 +250,7 @@ namespace QuantLib { Calendar exCouponCalendar_; BusinessDayConvention exCouponAdjustment_ = Following; bool exCouponEndOfMonth_ = false; - Date baseDate_ = Null(); + Date baseDate_ = Date(); }; diff --git a/ql/cashflows/timebasket.cpp b/ql/cashflows/timebasket.cpp index c2bd4446241..4df46a0e83b 100644 --- a/ql/cashflows/timebasket.cpp +++ b/ql/cashflows/timebasket.cpp @@ -47,7 +47,7 @@ namespace QuantLib { for (auto j : *this) { Date date = j.first; Real value = j.second; - Date pDate = Null(), nDate = Null(); + Date pDate = Date(), nDate = Date(); auto bi = std::lower_bound(sbuckets.begin(), sbuckets.end(), date); @@ -60,7 +60,7 @@ namespace QuantLib { if (bi != sbuckets.begin() && bi != sbuckets.end()) nDate = *(bi-1); - if (pDate == date || nDate == Null()) { + if (pDate == date || nDate == Date()) { result[pDate] += value; } else { Real pDays = Real(pDate-date); diff --git a/ql/experimental/credit/defaultevent.cpp b/ql/experimental/credit/defaultevent.cpp index 9ced640409f..307a4d7363c 100644 --- a/ql/experimental/credit/defaultevent.cpp +++ b/ql/experimental/credit/defaultevent.cpp @@ -97,7 +97,7 @@ namespace QuantLib { : bondsCurrency_(std::move(curr)), defaultDate_(creditEventDate), eventType_(atomicEvType), bondsSeniority_(bondsSen), defSettlement_(settleDate, recoveryRates.empty() ? makeIsdaConvMap() : recoveryRates) { - if(settleDate != Null()) {// has settled + if (settleDate != Date()) {// has settled QL_REQUIRE(settleDate >= creditEventDate, "Settlement date should be after default date."); QL_REQUIRE(recoveryRates.find(bondsSen) != recoveryRates.end(), @@ -114,7 +114,7 @@ namespace QuantLib { Real recoveryRate) : bondsCurrency_(std::move(curr)), defaultDate_(creditEventDate), eventType_(atomicEvType), bondsSeniority_(bondsSen), defSettlement_(settleDate, bondsSen, recoveryRate) { - if(settleDate != Null()) { + if (settleDate != Date()) { QL_REQUIRE(settleDate >= creditEventDate, "Settlement date should be after default date."); } diff --git a/ql/experimental/credit/defaultevent.hpp b/ql/experimental/credit/defaultevent.hpp index 8b907609394..58fbf8cacab 100644 --- a/ql/experimental/credit/defaultevent.hpp +++ b/ql/experimental/credit/defaultevent.hpp @@ -96,7 +96,7 @@ namespace QuantLib { Currency curr, Seniority bondsSen, // Settlement information: - const Date& settleDate = Null(), + const Date& settleDate = Date(), const std::map& recoveryRates = rate_map()); /*! Use NoSeniority to settle to all seniorities with that recovery. In that case the event is assumed to have @@ -114,7 +114,7 @@ namespace QuantLib { bool isRestructuring() const { return eventType_.isRestructuring(); } bool isDefault() const { return !isRestructuring();} bool hasSettled() const { - return defSettlement_.date() != Null(); + return defSettlement_.date() != Date(); } const DefaultSettlement& settlement() const { return defSettlement_; diff --git a/ql/experimental/exoticoptions/partialtimebarrieroption.cpp b/ql/experimental/exoticoptions/partialtimebarrieroption.cpp index 8c7b2728ca2..23eaa84d009 100644 --- a/ql/experimental/exoticoptions/partialtimebarrieroption.cpp +++ b/ql/experimental/exoticoptions/partialtimebarrieroption.cpp @@ -51,8 +51,7 @@ namespace QuantLib { PartialTimeBarrierOption::arguments::arguments() : barrierType(PartialBarrier::Type(-1)), barrierRange(PartialBarrier::Range(-1)), - barrier(Null()), rebate(Null()), - coverEventDate(Null()) {} + barrier(Null()), rebate(Null()) {} void PartialTimeBarrierOption::arguments::validate() const { OneAssetOption::arguments::validate(); @@ -78,7 +77,7 @@ namespace QuantLib { QL_REQUIRE(barrier != Null(), "no barrier given"); QL_REQUIRE(rebate != Null(), "no rebate given"); - QL_REQUIRE(coverEventDate != Null(), "no cover event date given"); + QL_REQUIRE(coverEventDate != Date(), "no cover event date given"); QL_REQUIRE(coverEventDate < exercise->lastDate(), "cover event date equal or later than exercise date"); } diff --git a/ql/instruments/bond.cpp b/ql/instruments/bond.cpp index 1b3c505c3e8..a40ceecba56 100644 --- a/ql/instruments/bond.cpp +++ b/ql/instruments/bond.cpp @@ -149,7 +149,7 @@ namespace QuantLib { } Date Bond::maturityDate() const { - if (maturityDate_!=Null()) + if (maturityDate_ != Date()) return maturityDate_; else return BondFunctions::maturityDate(*this); diff --git a/ql/instruments/creditdefaultswap.cpp b/ql/instruments/creditdefaultswap.cpp index 1441057e229..6286752754c 100644 --- a/ql/instruments/creditdefaultswap.cpp +++ b/ql/instruments/creditdefaultswap.cpp @@ -53,7 +53,7 @@ namespace QuantLib { : side_(side), notional_(notional), upfront_(ext::nullopt), runningSpread_(spread), settlesAccrual_(settlesAccrual), paysAtDefaultTime_(paysAtDefaultTime), claim_(std::move(claim)), - protectionStart_(protectionStart == Null() ? schedule[0] : protectionStart), + protectionStart_(protectionStart == Date() ? schedule[0] : protectionStart), tradeDate_(tradeDate), cashSettlementDays_(cashSettlementDays) { init(schedule, convention, dayCounter, lastPeriodDayCounter, rebatesAccrual); @@ -78,7 +78,7 @@ namespace QuantLib { : side_(side), notional_(notional), upfront_(upfront), runningSpread_(runningSpread), settlesAccrual_(settlesAccrual), paysAtDefaultTime_(paysAtDefaultTime), claim_(std::move(claim)), - protectionStart_(protectionStart == Null() ? schedule[0] : protectionStart), + protectionStart_(protectionStart == Date() ? schedule[0] : protectionStart), tradeDate_(tradeDate), cashSettlementDays_(cashSettlementDays) { init(schedule, convention, dayCounter, lastPeriodDayCounter, rebatesAccrual, upfrontDate); @@ -460,10 +460,8 @@ namespace QuantLib { QL_REQUIRE(!leg.empty(), "coupons not set"); QL_REQUIRE(upfrontPayment, "upfront payment not set"); QL_REQUIRE(claim, "claim not set"); - QL_REQUIRE(protectionStart != Null(), - "protection start date not set"); - QL_REQUIRE(maturity != Null(), - "maturity date not set"); + QL_REQUIRE(protectionStart != Date(), "protection start date not set"); + QL_REQUIRE(maturity != Date(), "maturity date not set"); } void CreditDefaultSwap::results::reset() { @@ -494,7 +492,7 @@ namespace QuantLib { if (rule == DateGeneration::CDS2015 && (anchorDate == Date(20, Dec, anchorDate.year()) || anchorDate == Date(20, Jun, anchorDate.year()))) { if (tenor.length() == 0) { - return Null(); + return Date(); } else { anchorDate -= 3 * Months; } diff --git a/ql/instruments/creditdefaultswap.hpp b/ql/instruments/creditdefaultswap.hpp index 6180e3dcb46..fba1e740b47 100644 --- a/ql/instruments/creditdefaultswap.hpp +++ b/ql/instruments/creditdefaultswap.hpp @@ -347,7 +347,7 @@ namespace QuantLib { /*! Return the CDS maturity date given the CDS trade date, \p tradeDate, the CDS \p tenor and a CDS \p rule. - A \c Null() is returned when a \p rule of \c CDS2015 and a \p tenor length of zero fail to yield a valid + A null date is returned when a \p rule of \c CDS2015 and a \p tenor length of zero fail to yield a valid CDS maturity date. \warning An exception will be thrown if the \p rule is not \c CDS2015, \c CDS or \c OldCDS. diff --git a/ql/instruments/forwardvanillaoption.hpp b/ql/instruments/forwardvanillaoption.hpp index 88393f57f08..b61042c1af7 100644 --- a/ql/instruments/forwardvanillaoption.hpp +++ b/ql/instruments/forwardvanillaoption.hpp @@ -36,8 +36,7 @@ namespace QuantLib { template class ForwardOptionArguments : public ArgumentsType { public: - ForwardOptionArguments() : moneyness(Null()), - resetDate(Null()) {} + ForwardOptionArguments() : moneyness(Null()) {} void validate() const override; Real moneyness; Date resetDate; @@ -72,7 +71,7 @@ namespace QuantLib { QL_REQUIRE(moneyness != Null(), "null moneyness given"); QL_REQUIRE(moneyness > 0.0, "negative or zero moneyness given"); - QL_REQUIRE(resetDate != Null(), "null reset date given"); + QL_REQUIRE(resetDate != Date(), "null reset date given"); QL_REQUIRE(resetDate >= Settings::instance().evaluationDate(), "reset date in the past"); QL_REQUIRE(this->exercise->lastDate() > resetDate, diff --git a/ql/instruments/makecds.cpp b/ql/instruments/makecds.cpp index 75a69e17c86..5e8573e4dae 100644 --- a/ql/instruments/makecds.cpp +++ b/ql/instruments/makecds.cpp @@ -46,7 +46,7 @@ namespace QuantLib { MakeCreditDefaultSwap::operator ext::shared_ptr() const { - Date tradeDate = (tradeDate_ != Null()) ? tradeDate_ : Settings::instance().evaluationDate(); + Date tradeDate = (tradeDate_ != Date()) ? tradeDate_ : Settings::instance().evaluationDate(); Date upfrontDate = WeekendsOnly().advance(tradeDate, cashSettlementDays_, Days); Date protectionStart; diff --git a/ql/instruments/makeswaption.cpp b/ql/instruments/makeswaption.cpp index 9b044d5153c..dadcdc46fb1 100644 --- a/ql/instruments/makeswaption.cpp +++ b/ql/instruments/makeswaption.cpp @@ -36,7 +36,7 @@ namespace QuantLib { Rate strike) : swapIndex_(std::move(swapIndex)), delivery_(Settlement::Physical), settlementMethod_(Settlement::PhysicalOTC), optionTenor_(optionTenor), - optionConvention_(ModifiedFollowing), fixingDate_(Null()), strike_(strike), + optionConvention_(ModifiedFollowing), strike_(strike), underlyingType_(Swap::Payer), nominal_(1.0) {} MakeSwaption::MakeSwaption(ext::shared_ptr swapIndex, @@ -58,10 +58,10 @@ namespace QuantLib { // if the evaluation date is not a business day // then move to the next business day refDate = fixingCalendar.adjust(refDate); - if (fixingDate_ == Null()) + if (fixingDate_ == Date()) fixingDate_ = fixingCalendar.advance(refDate, optionTenor_, optionConvention_); - if (exerciseDate_ == Null()) { + if (exerciseDate_ == Date()) { exercise_ = ext::shared_ptr(new EuropeanExercise(fixingDate_)); } else { diff --git a/ql/instruments/simplechooseroption.hpp b/ql/instruments/simplechooseroption.hpp index f3091b3ee4e..e33bb34f297 100644 --- a/ql/instruments/simplechooseroption.hpp +++ b/ql/instruments/simplechooseroption.hpp @@ -50,7 +50,7 @@ namespace QuantLib { //! Extra %arguments for single chooser option class SimpleChooserOption::arguments : public OneAssetOption::arguments { public: - arguments() : choosingDate(Null()) {} + arguments() = default; void validate() const override; Date choosingDate; }; diff --git a/ql/legacy/libormarketmodels/lfmcovarparam.hpp b/ql/legacy/libormarketmodels/lfmcovarparam.hpp index 2367d26ccfd..f2f534e2a43 100644 --- a/ql/legacy/libormarketmodels/lfmcovarparam.hpp +++ b/ql/legacy/libormarketmodels/lfmcovarparam.hpp @@ -45,9 +45,9 @@ namespace QuantLib { Size size() const { return size_; } Size factors() const { return factors_; } - virtual Matrix diffusion(Time t, const Array& x = Null()) const = 0; - virtual Matrix covariance(Time t, const Array& x = Null()) const; - virtual Matrix integratedCovariance(Time t, const Array& x = Null()) const; + virtual Matrix diffusion(Time t, const Array& x = {}) const = 0; + virtual Matrix covariance(Time t, const Array& x = {}) const; + virtual Matrix integratedCovariance(Time t, const Array& x = {}) const; protected: const Size size_; diff --git a/ql/legacy/libormarketmodels/lfmcovarproxy.hpp b/ql/legacy/libormarketmodels/lfmcovarproxy.hpp index c4c6fd67d36..fc7438898bd 100644 --- a/ql/legacy/libormarketmodels/lfmcovarproxy.hpp +++ b/ql/legacy/libormarketmodels/lfmcovarproxy.hpp @@ -40,12 +40,11 @@ namespace QuantLib { ext::shared_ptr volatilityModel() const; ext::shared_ptr correlationModel() const; - Matrix diffusion(Time t, const Array& x = Null()) const override; - Matrix covariance(Time t, const Array& x = Null()) const override; + Matrix diffusion(Time t, const Array& x = {}) const override; + Matrix covariance(Time t, const Array& x = {}) const override; using LfmCovarianceParameterization::integratedCovariance; - virtual Real integratedCovariance( - Size i, Size j, Time t, const Array& x = Null()) const; + virtual Real integratedCovariance(Size i, Size j, Time t, const Array& x = {}) const; protected: const ext::shared_ptr volaModel_; diff --git a/ql/legacy/libormarketmodels/lfmhullwhiteparam.hpp b/ql/legacy/libormarketmodels/lfmhullwhiteparam.hpp index d874ad55483..2256d4d11f8 100644 --- a/ql/legacy/libormarketmodels/lfmhullwhiteparam.hpp +++ b/ql/legacy/libormarketmodels/lfmhullwhiteparam.hpp @@ -45,9 +45,9 @@ namespace QuantLib { const ext::shared_ptr & capletVol, const Matrix& correlation = Matrix(), Size factors = 1); - Matrix diffusion(Time t, const Array& x = Null()) const override; - Matrix covariance(Time t, const Array& x = Null()) const override; - Matrix integratedCovariance(Time t, const Array& x = Null()) const override; + Matrix diffusion(Time t, const Array& x = {}) const override; + Matrix covariance(Time t, const Array& x = {}) const override; + Matrix integratedCovariance(Time t, const Array& x = {}) const override; protected: Size nextIndexReset(Time t) const; diff --git a/ql/legacy/libormarketmodels/lmconstwrappercorrmodel.hpp b/ql/legacy/libormarketmodels/lmconstwrappercorrmodel.hpp index 44a10999bc9..02a7244bedd 100644 --- a/ql/legacy/libormarketmodels/lmconstwrappercorrmodel.hpp +++ b/ql/legacy/libormarketmodels/lmconstwrappercorrmodel.hpp @@ -38,13 +38,13 @@ namespace QuantLib { Size factors() const override { return corrModel_->factors(); } - Matrix correlation(Time t, const Array& x = Null()) const override { + Matrix correlation(Time t, const Array& x = {}) const override { return corrModel_->correlation(t, x); } - Matrix pseudoSqrt(Time t, const Array& x = Null()) const override { + Matrix pseudoSqrt(Time t, const Array& x = {}) const override { return corrModel_->pseudoSqrt(t, x); } - Real correlation(Size i, Size j, Time t, const Array& x = Null()) const override { + Real correlation(Size i, Size j, Time t, const Array& x = {}) const override { return corrModel_->correlation(i, j, t, x); } bool isTimeIndependent() const override { return corrModel_->isTimeIndependent(); } diff --git a/ql/legacy/libormarketmodels/lmconstwrappervolmodel.hpp b/ql/legacy/libormarketmodels/lmconstwrappervolmodel.hpp index 11c747d01e6..6280d769093 100644 --- a/ql/legacy/libormarketmodels/lmconstwrappervolmodel.hpp +++ b/ql/legacy/libormarketmodels/lmconstwrappervolmodel.hpp @@ -37,15 +37,14 @@ namespace QuantLib { volaModel_(volaModel) { } - Array volatility(Time t, const Array& x = Null()) const override { + Array volatility(Time t, const Array& x = {}) const override { return volaModel_->volatility(t, x); } Volatility volatility( - Size i, Time t, const Array& x = Null()) { + Size i, Time t, const Array& x = {}) { return volaModel_->volatility(i, t, x); } - Real - integratedVariance(Size i, Size j, Time u, const Array& x = Null()) const override { + Real integratedVariance(Size i, Size j, Time u, const Array& x = {}) const override { return volaModel_->integratedVariance(i, j, u, x); } diff --git a/ql/legacy/libormarketmodels/lmcorrmodel.hpp b/ql/legacy/libormarketmodels/lmcorrmodel.hpp index 209ddc0840c..26973e31aa9 100644 --- a/ql/legacy/libormarketmodels/lmcorrmodel.hpp +++ b/ql/legacy/libormarketmodels/lmcorrmodel.hpp @@ -43,9 +43,9 @@ namespace QuantLib { std::vector& params(); void setParams(const std::vector & arguments); - virtual Matrix correlation(Time t, const Array& x = Null()) const = 0; - virtual Matrix pseudoSqrt(Time t, const Array& x = Null()) const; - virtual Real correlation(Size i, Size j, Time t, const Array& x = Null()) const; + virtual Matrix correlation(Time t, const Array& x = {}) const = 0; + virtual Matrix pseudoSqrt(Time t, const Array& x = {}) const; + virtual Real correlation(Size i, Size j, Time t, const Array& x = {}) const; virtual bool isTimeIndependent() const; protected: diff --git a/ql/legacy/libormarketmodels/lmexpcorrmodel.hpp b/ql/legacy/libormarketmodels/lmexpcorrmodel.hpp index bfd259c1fa1..3706f3859d8 100644 --- a/ql/legacy/libormarketmodels/lmexpcorrmodel.hpp +++ b/ql/legacy/libormarketmodels/lmexpcorrmodel.hpp @@ -46,8 +46,8 @@ namespace QuantLib { public: LmExponentialCorrelationModel(Size size, Real rho); - Matrix correlation(Time t, const Array& x = Null()) const override; - Matrix pseudoSqrt(Time t, const Array& x = Null()) const override; + Matrix correlation(Time t, const Array& x = {}) const override; + Matrix pseudoSqrt(Time t, const Array& x = {}) const override; Real correlation(Size i, Size j, Time t, const Array& x) const override; bool isTimeIndependent() const override; diff --git a/ql/legacy/libormarketmodels/lmextlinexpvolmodel.hpp b/ql/legacy/libormarketmodels/lmextlinexpvolmodel.hpp index 61f653afd43..70eac4ab44a 100644 --- a/ql/legacy/libormarketmodels/lmextlinexpvolmodel.hpp +++ b/ql/legacy/libormarketmodels/lmextlinexpvolmodel.hpp @@ -49,11 +49,10 @@ namespace QuantLib { LmExtLinearExponentialVolModel(const std::vector