/// <summary> /// Make a set of CDSCouponDes. /// </summary> /// <param name="leg"> the schedule of the accrual periods </param> /// <param name="accrualDCC"> the day count used for the accrual </param> /// <returns> a set of CDSCouponDes </returns> public static CdsCouponDes[] makeCoupons(IsdaPremiumLegSchedule leg, Enums.DayCount accrualDCC) { int n = leg.NumPayments; CdsCouponDes[] coupons = new CdsCouponDes[n]; for (int i = 0; i < n; i++) { coupons[i] = new CdsCouponDes(leg.getAccStartDate(i), leg.getAccEndDate(i), leg.getPaymentDate(i), accrualDCC); } return coupons; }
/// <summary> /// Turn a date based description of a CDS accrual period (<seealso cref="CdsCouponDes"/>) into an analytic description /// (<seealso cref="CdsCoupon"/>). This uses ACT/360 for the accrual day count. /// </summary> /// <param name="tradeDate"> The trade date </param> /// <param name="coupon"> A date based description of a CDS accrual period </param> /// <param name="protectionFromStartOfDay"> If true the protection is from the start of day and the effective accrual /// start and end dates are one day less. The exception is the accrual end date which should have one day /// added (if protectionFromStartOfDay = true) in the CDSCouponDes to compensate for this, so the /// accrual end date is just the CDS maturity. /// The effect of having protectionFromStartOfDay = true is to add an extra day of protection. </param> /// <param name="curveDCC"> Day count used on curve (NOTE ISDA uses ACT/365 (fixed) and it is not recommended to change this) </param> public CdsCoupon(DateTime tradeDate, CdsCouponDes coupon, bool protectionFromStartOfDay, Enums.DayCount curveDCC) { DateTime effStart = protectionFromStartOfDay ? coupon.getAccStart().AddDays(1) : coupon.getAccStart(); DateTime effEnd = protectionFromStartOfDay ? coupon.getAccEnd().AddDays(-1) : coupon.getAccEnd(); Actual365 dc = new Actual365(); _effStart = DateTime.Compare(effStart, tradeDate) < 0 ? -dc.YearFraction(effStart, tradeDate) : dc.YearFraction(tradeDate, effStart); _effEnd = dc.YearFraction(tradeDate, effEnd); _paymentTime = dc.YearFraction(tradeDate, coupon.getPaymentDate()); _yearFrac = coupon.getYearFrac(); _ycRatio = _yearFrac / dc.YearFraction(coupon.getAccStart(), coupon.getAccEnd()); }
/// <summary> /// Turn a date based description of a CDS accrual period (<seealso cref="CdsCouponDes"/>) into an analytic description /// (<seealso cref="CdsCoupon"/>). This has protection from start of day and uses ACT/360 for the accrual day count. /// </summary> /// <param name="tradeDate"> The trade date </param> /// <param name="coupon"> A date based description of a CDS accrual period </param> public CdsCoupon(DateTime tradeDate, CdsCouponDes coupon, Boolean protectionFromStartOfDay) : this(tradeDate, coupon, PROTECTION_FROM_START, ACT_360) { }
/// <summary> /// Turn a date based description of a CDS accrual period (<seealso cref="CdsCouponDes"/>) into an analytic description /// (<seealso cref="CdsCoupon"/>). This has protection from start of day and uses ACT/360 for the accrual day count. /// </summary> /// <param name="tradeDate"> The trade date </param> /// <param name="coupon"> A date based description of a CDS accrual period </param> /// <param name="curveDCC"> Day count used on curve (NOTE ISDA uses ACT/365 (fixed) and it is not recommended to change this) </param> public CdsCoupon(DateTime tradeDate, CdsCouponDes coupon, Enums.DayCount curveDCC) : this(tradeDate, coupon, PROTECTION_FROM_START, curveDCC) { }