public SwaptionVolatilityDiscrete(List<Period> optionTenors, List<Period> swapTenors, int settlementDays, Calendar cal, BusinessDayConvention bdc, DayCounter dc) : base(settlementDays, cal, bdc, dc) { nOptionTenors_ = optionTenors.Count; optionTenors_ = optionTenors; optionDates_ = new InitializedList<Date>(nOptionTenors_); optionTimes_ = new InitializedList<double>(nOptionTenors_); optionDatesAsReal_ = new InitializedList<double>(nOptionTenors_); nSwapTenors_ = swapTenors.Count; swapTenors_ = swapTenors; swapLengths_ = new InitializedList<double>(nSwapTenors_); checkOptionTenors(); initializeOptionDatesAndTimes(); checkSwapTenors(); initializeSwapLengths(); optionInterpolator_ = new LinearInterpolation(optionTimes_, optionTimes_.Count, optionDatesAsReal_); optionInterpolator_.update(); optionInterpolator_.enableExtrapolation(); evaluationDate_ = Settings.evaluationDate(); Settings.registerWith(update); }
public override void update() { for (int i = 0; i < size_; ++i) { Utils.QL_REQUIRE(yBegin_[i] > 0.0, () => "invalid value (" + yBegin_[i] + ") at index " + i); logY_[i] = Math.Log(yBegin_[i]); } interpolation_.update(); }
/* In case a pricing engine is not used, this method must be overridden to perform the actual * calculations and set any needed results. * In case a pricing engine is used, the default implementation can be used. */ protected override void performCalculations() { // check if date recalculation could be avoided here if (moving_) { initializeOptionDatesAndTimes(); initializeSwapLengths(); optionInterpolator_.update(); } }
public override void update() { for (int i = 0; i < size_; ++i) { if (!(yBegin_[i] > 0.0)) { throw new ArgumentException("invalid value (" + yBegin_[i] + ") at index " + i); } logY_[i] = System.Math.Log(yBegin_[i]); } interpolation_.update(); }
public SwaptionVolatilityDiscrete(List<Period> optionTenors, List<Period> swapTenors, Date referenceDate, Calendar cal, BusinessDayConvention bdc, DayCounter dc) : base(referenceDate, cal, bdc, dc) { nOptionTenors_ = optionTenors.Count; optionTenors_ = optionTenors; optionDates_ = new InitializedList<Date>(nOptionTenors_); optionTimes_ = new InitializedList<double>(nOptionTenors_); optionDatesAsReal_ = new InitializedList<double>(nOptionTenors_); nSwapTenors_ = swapTenors.Count; swapTenors_ = swapTenors; swapLengths_ = new InitializedList<double>(nSwapTenors_); checkOptionTenors(); initializeOptionDatesAndTimes(); checkSwapTenors(); initializeSwapLengths(); optionInterpolator_ = new LinearInterpolation(optionTimes_, optionTimes_.Count, optionDatesAsReal_); optionInterpolator_.update(); optionInterpolator_.enableExtrapolation(); }
public void setInterpolation <Interpolator>(Interpolator i) where Interpolator : IInterpolationFactory, new () { varianceCurve_ = i.interpolate(times_, times_.Count, variances_); varianceCurve_.update(); notifyObservers(); }