//-------------------------------------------------------------------------
        public virtual void coverage()
        {
            coverImmutableBean(PRODUCT);
            CdsIndex other = CdsIndex.builder().buySell(SELL).cdsIndexId(StandardId.of("OG", "AA-INDEX")).legalEntityIds(ImmutableList.of(StandardId.of("OG", "ABC1"), StandardId.of("OG", "ABC2"))).currency(JPY).notional(1d).paymentSchedule(PeriodicSchedule.of(LocalDate.of(2014, 1, 4), LocalDate.of(2020, 11, 20), P6M, BusinessDayAdjustment.of(BusinessDayConventions.FOLLOWING, JPTO), StubConvention.SHORT_FINAL, RollConventions.NONE)).fixedRate(0.01).dayCount(ACT_365F).paymentOnDefault(PaymentOnDefault.NONE).protectionStart(ProtectionStartOfDay.NONE).settlementDateOffset(DaysAdjustment.NONE).stepinDateOffset(DaysAdjustment.NONE).build();

            coverBeanEquals(PRODUCT, other);
        }
        public virtual void test_builder()
        {
            LocalDate        startDate = LocalDate.of(2014, 12, 20);
            LocalDate        endDate   = LocalDate.of(2020, 10, 20);
            PeriodicSchedule sch       = PeriodicSchedule.of(startDate, endDate, P3M, BusinessDayAdjustment.NONE, SHORT_INITIAL, RollConventions.NONE);
            CdsIndex         test      = CdsIndex.builder().paymentSchedule(sch).buySell(SELL).currency(JPY).dayCount(ACT_365F).fixedRate(COUPON).cdsIndexId(INDEX_ID).legalEntityIds(LEGAL_ENTITIES).notional(NOTIONAL).paymentOnDefault(PaymentOnDefault.NONE).protectionStart(ProtectionStartOfDay.NONE).settlementDateOffset(SETTLE_DAY_ADJ).stepinDateOffset(STEPIN_DAY_ADJ).build();

            assertEquals(test.PaymentSchedule, sch);
            assertEquals(test.BuySell, SELL);
            assertEquals(test.Currency, JPY);
            assertEquals(test.DayCount, ACT_365F);
            assertEquals(test.FixedRate, COUPON);
            assertEquals(test.CdsIndexId, INDEX_ID);
            assertEquals(test.LegalEntityIds, LEGAL_ENTITIES);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.PaymentOnDefault, PaymentOnDefault.NONE);
            assertEquals(test.ProtectionStart, ProtectionStartOfDay.NONE);
            assertEquals(test.SettlementDateOffset, SETTLE_DAY_ADJ);
            assertEquals(test.StepinDateOffset, STEPIN_DAY_ADJ);
            assertEquals(test.CrossCurrency, false);
            assertEquals(test.allPaymentCurrencies(), ImmutableSet.of(JPY));
            assertEquals(test.allCurrencies(), ImmutableSet.of(JPY));
        }
        /// <summary>
        /// Creates a trade representing the CDS index at the node.
        /// <para>
        /// This uses the observed market data to build the CDS index trade that the node represents.
        /// The resulting trade is not resolved.
        /// The notional of the trade is taken from the 'quantity' variable.
        /// The quantity is signed and will affect whether the trade is Buy or Sell.
        /// The valuation date is defined by the market data.
        ///
        /// </para>
        /// </summary>
        /// <param name="quantity">  the quantity or notional of the trade </param>
        /// <param name="marketData">  the market data required to build a trade for the instrument, including the valuation date </param>
        /// <param name="refData">  the reference data, used to resolve the trade dates </param>
        /// <returns> a trade representing the instrument at the node </returns>
        public CdsIndexCalibrationTrade trade(double quantity, MarketData marketData, ReferenceData refData)
        {
            BuySell   buySell       = quantity > 0 ? BuySell.BUY : BuySell.SELL;
            LocalDate valuationDate = marketData.ValuationDate;
            double    quoteValue    = marketData.getValue(observableId);
            CdsQuote  quote         = CdsQuote.of(quoteConvention, quoteValue);
            double    notional      = Math.Abs(quantity);
            CdsTrade  cdsTrade      = null;

            if (quoteConvention.Equals(CdsQuoteConvention.PAR_SPREAD))
            {
                cdsTrade = template.createTrade(cdsIndexId, valuationDate, buySell, notional, quoteValue, refData);
            }
            else
            {
                double coupon = FixedRate.Value;   // always success
                cdsTrade = template.createTrade(cdsIndexId, valuationDate, buySell, notional, coupon, refData);
            }
            Cds           cdsProduct = cdsTrade.Product;
            CdsIndexTrade cdsIndex   = CdsIndexTrade.builder().info(cdsTrade.Info).product(CdsIndex.builder().buySell(cdsProduct.BuySell).currency(cdsProduct.Currency).notional(cdsProduct.Notional).cdsIndexId(cdsIndexId).legalEntityIds(legalEntityIds).dayCount(cdsProduct.DayCount).paymentSchedule(cdsProduct.PaymentSchedule).fixedRate(cdsProduct.FixedRate).paymentOnDefault(cdsProduct.PaymentOnDefault).protectionStart(cdsProduct.ProtectionStart).settlementDateOffset(cdsProduct.SettlementDateOffset).stepinDateOffset(cdsProduct.StepinDateOffset).build()).build();

            return(CdsIndexCalibrationTrade.of(cdsIndex, quote));
        }