public override double amount() { if (amount_ != null) return amount_.Value; return nominal() * (rate_.compoundFactor(accrualStartDate_, accrualEndDate_, refPeriodStart_, refPeriodEnd_) - 1.0); }
public override void setupArguments(IPricingEngineArguments args) { base.setupArguments(args); VanillaSwap.Arguments arguments = args as VanillaSwap.Arguments; if (arguments == null) // it's a swap engine... { return; } arguments.type = type_; arguments.nominal = nominal_; List <CashFlow> fixedCoupons = fixedLeg(); arguments.fixedResetDates = new InitializedList <Date>(fixedCoupons.Count); arguments.fixedPayDates = new InitializedList <Date>(fixedCoupons.Count); arguments.fixedCoupons = new InitializedList <double>(fixedCoupons.Count); for (int i = 0; i < fixedCoupons.Count; ++i) { FixedRateCoupon coupon = (FixedRateCoupon)fixedCoupons[i]; arguments.fixedPayDates[i] = coupon.date(); arguments.fixedResetDates[i] = coupon.accrualStartDate(); arguments.fixedCoupons[i] = coupon.amount(); } List <CashFlow> floatingCoupons = floatingLeg(); arguments.floatingResetDates = new InitializedList <Date>(floatingCoupons.Count); arguments.floatingPayDates = new InitializedList <Date>(floatingCoupons.Count); arguments.floatingFixingDates = new InitializedList <Date>(floatingCoupons.Count); arguments.floatingAccrualTimes = new InitializedList <double>(floatingCoupons.Count); arguments.floatingSpreads = new InitializedList <double>(floatingCoupons.Count); arguments.floatingCoupons = new InitializedList <double>(floatingCoupons.Count); for (int i = 0; i < floatingCoupons.Count; ++i) { IborCoupon coupon = (IborCoupon)floatingCoupons[i]; arguments.floatingResetDates[i] = coupon.accrualStartDate(); arguments.floatingPayDates[i] = coupon.date(); arguments.floatingFixingDates[i] = coupon.fixingDate(); arguments.floatingAccrualTimes[i] = coupon.accrualPeriod(); arguments.floatingSpreads[i] = coupon.spread(); try { arguments.floatingCoupons[i] = coupon.amount(); } catch { arguments.floatingCoupons[i] = default(double); } } }