/**
  * Make a set of CDSs with a common trade date and maturities dates the given periods after the
  * next IMM date (after the trade-date). The accrual start date will be the previous IMM date
  * (before the trade date). <b>Note</b> it payment interval is changed from the default of 3M,
  * this will produce a (possibly incorrect) non-standard first coupon.
  *
  * @param tradeDate the trade date
  * @param tenors the tenors (lengths) of the CDSs
  * @param makeEffBusDay is the accrual start day business-day adjusted.
  * @return an array of CDS analytic descriptions
  */
 public CdsAnalytic[] makeImmCds(LocalDate tradeDate, Period[] tenors, boolean makeEffBusDay) {
   LocalDate effectiveDate =
       makeEffBusDay
           ? _businessdayAdjustmentConvention.adjust(
               ImmDateLogic.getPrevIMMDate(tradeDate), _calendar)
           : ImmDateLogic.getPrevIMMDate(tradeDate);
   return makeImmCds(tradeDate, effectiveDate, tenors);
 }
 /**
  * Set up a strip of on-the-run indexes represented as a single name CDSs (i.e. by CdsAnalytic).
  * The index roll dates (when new indices are issued) are 20 Mar & Sep, and the index is defined
  * to have a maturity that is its nominal tenor plus 3M on issuance, so a 5Y index on the
  * 6-Feb-2014 will have a maturity of 20-Dec-2018 (5Y3M on the issue date of 20-Sep-2013). The
  * accrual start date will be the previous IMM date (before the trade date), business-day
  * adjusted. <b>Note</b> it payment interval is changed from the default of 3M, this will produce
  * a (possibly incorrect) non-standard first coupon.
  *
  * @param tradeDate the trade date
  * @param tenors the nominal lengths of the indexes
  * @return an array of CDS analytic descriptions
  */
 public CdsAnalytic[] makeCdx(LocalDate tradeDate, Period[] tenors) {
   ArgChecker.notNull(tradeDate, "tradeDate");
   ArgChecker.noNulls(tenors, "tenors");
   LocalDate effectiveDate =
       _businessdayAdjustmentConvention.adjust(ImmDateLogic.getPrevIMMDate(tradeDate), _calendar);
   LocalDate mid = ImmDateLogic.getNextIndexRollDate(tradeDate).minusMonths(3);
   LocalDate[] maturities = ImmDateLogic.getIMMDateSet(mid, tenors);
   return makeCds(tradeDate, effectiveDate, maturities);
 }
 /**
  * Set up an on-the-run index represented as a single name CDS (i.e. by CdsAnalytic). The index
  * roll dates (when new indices are issued) are 20 Mar & Sep, and the index is defined to have a
  * maturity that is its nominal tenor plus 3M on issuance, so a 5Y index on the 6-Feb-2014 will
  * have a maturity of 20-Dec-2018 (5Y3M on the issue date of 20-Sep-2013). The accrual start date
  * will be the previous IMM date (before the trade date), business-day adjusted. <b>Note</b> it
  * payment interval is changed from the default of 3M, this will produce a (possibly incorrect)
  * non-standard first coupon.
  *
  * @param tradeDate the trade date
  * @param tenor the nominal length of the index
  * @return a CDS analytic description
  */
 public CdsAnalytic makeCdx(LocalDate tradeDate, Period tenor) {
   ArgChecker.notNull(tradeDate, "tradeDate");
   ArgChecker.notNull(tenor, "tenor");
   LocalDate effectiveDate =
       _businessdayAdjustmentConvention.adjust(ImmDateLogic.getPrevIMMDate(tradeDate), _calendar);
   LocalDate roll = ImmDateLogic.getNextIndexRollDate(tradeDate);
   LocalDate maturity = roll.plus(tenor).minusMonths(3);
   return makeCds(tradeDate, effectiveDate, maturity);
 }
 /**
  * Make a CDS represented as a MultiCdsAnalytic instance. Note, this is mainly for testing, since
  * if you want only a single CDS should use a method that returns a {@link CdsAnalytic}.
  *
  * @param tradeDate the trade date
  * @param maturityReferanceDate a reference date that maturities are measured from. For standard
  *     CDSSs, this is the next IMM date after the trade date, so the actually maturities will be
  *     some fixed periods after this.
  * @param termMatIndex the maturities are fixed integer multiples of the payment interval, so 2Y
  *     tenor with a 3M payment interval, this would be 8
  * @return a a CDS represented as a MultiCdsAnalytic
  */
 public MultiCdsAnalytic makeMultiCds(
     LocalDate tradeDate, LocalDate maturityReferanceDate, int termMatIndex) {
   int[] maturityIndexes = new int[termMatIndex + 1];
   for (int i = 0; i <= termMatIndex; i++) {
     maturityIndexes[i] = i;
   }
   LocalDate accStartDate =
       _businessdayAdjustmentConvention.adjust(ImmDateLogic.getPrevIMMDate(tradeDate), _calendar);
   return makeMultiCds(tradeDate, accStartDate, maturityReferanceDate, maturityIndexes);
 }
 /**
  * Make a CDS with a maturity date the given period on from the next IMM date after the
  * trade-date. The accrual start date will be the previous IMM date (before the trade date).
  * <b>Note</b> it payment interval is changed from the default of 3M, this will produce a
  * (possibly incorrect) non-standard first coupon.
  *
  * @param tradeDate the trade date
  * @param tenor the tenor (length) of the CDS
  * @param makeEffBusDay is the accrual start day business-day adjusted.
  * @return a CDS analytic description
  */
 public CdsAnalytic makeImmCds(LocalDate tradeDate, Period tenor, boolean makeEffBusDay) {
   ArgChecker.notNull(tradeDate, "tradeDate");
   ArgChecker.notNull(tenor, "tenor");
   LocalDate effectiveDate =
       makeEffBusDay
           ? _businessdayAdjustmentConvention.adjust(
               ImmDateLogic.getPrevIMMDate(tradeDate), _calendar)
           : ImmDateLogic.getPrevIMMDate(tradeDate);
   LocalDate nextIMM = ImmDateLogic.getNextIMMDate(tradeDate);
   LocalDate maturity = nextIMM.plus(tenor);
   return makeCds(tradeDate, effectiveDate, maturity);
 }
 /**
  * A forward starting CDS starts on some date after today (the trade date). The stepin date and
  * cash settlement date are taken from the forward start date (1 day and 3 working days by
  * default).
  *
  * @param tradeDate the trade date (i.e. today)
  * @param forwardStartDate the forward start date
  * @param maturity the maturity of the CDS
  * @return a CDS analytic description for a forward starting CDS
  */
 public CdsAnalytic makeForwardStartingCds(
     LocalDate tradeDate, LocalDate forwardStartDate, LocalDate maturity) {
   ArgChecker.isFalse(
       forwardStartDate.isBefore(tradeDate),
       "forwardStartDate of {} is before trade date of {}",
       forwardStartDate,
       tradeDate);
   LocalDate stepinDate = forwardStartDate.plusDays(_stepIn);
   LocalDate valueDate = addWorkDays(forwardStartDate, _cashSettle, _calendar);
   LocalDate accStartDate =
       _businessdayAdjustmentConvention.adjust(
           ImmDateLogic.getPrevIMMDate(forwardStartDate), _calendar);
   return makeCds(tradeDate, stepinDate, valueDate, accStartDate, maturity);
 }
 /**
  * Make a set of standard CDS represented as a MultiCdsAnalytic instance.
  *
  * @param tradeDate the trade date
  * @param tenors the tenors (length) of the CDS
  * @return a set of CDS represented as a MultiCdsAnalytic
  */
 public MultiCdsAnalytic makeMultiImmCds(LocalDate tradeDate, Period[] tenors) {
   LocalDate accStartDate =
       _businessdayAdjustmentConvention.adjust(ImmDateLogic.getPrevIMMDate(tradeDate), _calendar);
   return makeMultiImmCds(tradeDate, accStartDate, tenors);
 }