public override void addTimesTo(List<double> times) { Swaption.Arguments args=new Swaption.Arguments(); swaption_.setupArguments(args); List<double> swaptionTimes = new DiscretizedSwaption(args, termStructure_.link.referenceDate(), termStructure_.link.dayCounter()).mandatoryTimes(); /*times.insert(times.end(), swaptionTimes.begin(), swaptionTimes.end());*/ for(int i=0;i<swaptionTimes.Count;i++) times.Insert(times.Count, swaptionTimes[i]); }
public DiscretizedSwaption(Swaption.Arguments args, Date referenceDate, DayCounter dayCounter) : base(new DiscretizedSwap(args, referenceDate, dayCounter), args.exercise.type(), new List<double>()) { arguments_=args; exerciseTimes_ = new InitializedList<double>(arguments_.exercise.dates().Count); for (int i = 0; i < exerciseTimes_.Count; ++i) exerciseTimes_[i] = dayCounter.yearFraction(referenceDate, arguments_.exercise.date(i)); // Date adjustments can get time vectors out of synch. // Here, we try and collapse similar dates which could cause // a mispricing. for (int i=0; i<arguments_.exercise.dates().Count; i++) { Date exerciseDate = arguments_.exercise.date(i); for (int j = 0; j < arguments_.fixedPayDates.Count; j++) { if (withinNextWeek(exerciseDate, arguments_.fixedPayDates[j]) // coupons in the future are dealt with below && arguments_.fixedResetDates[j] < referenceDate) arguments_.fixedPayDates[j] = exerciseDate; } for (int j = 0; j < arguments_.fixedResetDates.Count; j++) { if (withinPreviousWeek(exerciseDate, arguments_.fixedResetDates[j])) arguments_.fixedResetDates[j] = exerciseDate; } for (int j = 0; j < arguments_.floatingResetDates.Count; j++) { if (withinPreviousWeek(exerciseDate, arguments_.floatingResetDates[j])) arguments_.floatingResetDates[j] = exerciseDate; } } double lastFixedPayment = dayCounter.yearFraction(referenceDate, arguments_.fixedPayDates.Last() ); double lastFloatingPayment = dayCounter.yearFraction(referenceDate, arguments_.floatingPayDates.Last()); lastPayment_ = Math.Max(lastFixedPayment,lastFloatingPayment); underlying_ = new DiscretizedSwap(arguments_, referenceDate, dayCounter); }