diff --git a/ql/termstructures/volatility/swaption/swaptionvolcube.cpp b/ql/termstructures/volatility/swaption/swaptionvolcube.cpp index fefda9d4c88..69df03aefdf 100644 --- a/ql/termstructures/volatility/swaption/swaptionvolcube.cpp +++ b/ql/termstructures/volatility/swaption/swaptionvolcube.cpp @@ -76,8 +76,6 @@ namespace QuantLib { swapIndexBase_->tenor() << ")"); registerWithVolatilitySpread(); - registerWith(Settings::instance().evaluationDate()); - evaluationDate_ = Settings::instance().evaluationDate(); } void SwaptionVolatilityCube::registerWithVolatilitySpread() diff --git a/ql/termstructures/volatility/swaption/swaptionvoldiscrete.cpp b/ql/termstructures/volatility/swaption/swaptionvoldiscrete.cpp index 67f0d2b47bc..4b7fe1d3ea5 100644 --- a/ql/termstructures/volatility/swaption/swaptionvoldiscrete.cpp +++ b/ql/termstructures/volatility/swaption/swaptionvoldiscrete.cpp @@ -37,6 +37,8 @@ namespace QuantLib { optionDates_(nOptionTenors_), optionTimes_(nOptionTenors_), optionDatesAsReal_(nOptionTenors_), + optionInterpolatorTimes_(nOptionTenors_ + 1), + optionInterpolatorDatesAsReal_(nOptionTenors_ + 1), nSwapTenors_(swapTenors.size()), swapTenors_(swapTenors), swapLengths_(nSwapTenors_) { @@ -47,14 +49,12 @@ namespace QuantLib { checkSwapTenors(); initializeSwapLengths(); - optionInterpolator_= LinearInterpolation(optionTimes_.begin(), - optionTimes_.end(), - optionDatesAsReal_.begin()); + optionInterpolator_= LinearInterpolation(optionInterpolatorTimes_.begin(), + optionInterpolatorTimes_.end(), + optionInterpolatorDatesAsReal_.begin()); optionInterpolator_.update(); optionInterpolator_.enableExtrapolation(); - - registerWith(Settings::instance().evaluationDate()); - evaluationDate_ = Settings::instance().evaluationDate(); + cachedReferenceDate_ = referenceDate(); } SwaptionVolatilityDiscrete::SwaptionVolatilityDiscrete( @@ -70,6 +70,8 @@ namespace QuantLib { optionDates_(nOptionTenors_), optionTimes_(nOptionTenors_), optionDatesAsReal_(nOptionTenors_), + optionInterpolatorTimes_(nOptionTenors_ + 1), + optionInterpolatorDatesAsReal_(nOptionTenors_ + 1), nSwapTenors_(swapTenors.size()), swapTenors_(swapTenors), swapLengths_(nSwapTenors_) { @@ -80,9 +82,9 @@ namespace QuantLib { checkSwapTenors(); initializeSwapLengths(); - optionInterpolator_= LinearInterpolation(optionTimes_.begin(), - optionTimes_.end(), - optionDatesAsReal_.begin()); + optionInterpolator_= LinearInterpolation(optionInterpolatorTimes_.begin(), + optionInterpolatorTimes_.end(), + optionInterpolatorDatesAsReal_.begin()); optionInterpolator_.update(); optionInterpolator_.enableExtrapolation(); } @@ -100,6 +102,8 @@ namespace QuantLib { optionDates_(optionDates), optionTimes_(nOptionTenors_), optionDatesAsReal_(nOptionTenors_), + optionInterpolatorTimes_(nOptionTenors_ + 1), + optionInterpolatorDatesAsReal_(nOptionTenors_ + 1), nSwapTenors_(swapTenors.size()), swapTenors_(swapTenors), swapLengths_(nSwapTenors_) { @@ -110,9 +114,9 @@ namespace QuantLib { checkSwapTenors(); initializeSwapLengths(); - optionInterpolator_= LinearInterpolation(optionTimes_.begin(), - optionTimes_.end(), - optionDatesAsReal_.begin()); + optionInterpolator_= LinearInterpolation(optionInterpolatorTimes_.begin(), + optionInterpolatorTimes_.end(), + optionInterpolatorDatesAsReal_.begin()); optionInterpolator_.update(); optionInterpolator_.enableExtrapolation(); } @@ -152,17 +156,20 @@ namespace QuantLib { } void SwaptionVolatilityDiscrete::initializeOptionDatesAndTimes() const { + optionInterpolatorDatesAsReal_[0] = static_cast(referenceDate().serialNumber()); for (Size i=0; i(optionDates_[i].serialNumber()); } initializeOptionTimes(); } void SwaptionVolatilityDiscrete::initializeOptionTimes() const { - for (Size i=0; i optionTenors_; mutable std::vector optionDates_; mutable std::vector