/// <summary>
        /// Creates a trade representing the CDS at the node.
        /// <para>
        /// This uses the observed market data to build the CDS 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 CdsCalibrationTrade 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);

            if (quoteConvention.Equals(CdsQuoteConvention.PAR_SPREAD))
            {
                return(CdsCalibrationTrade.of(template.createTrade(legalEntityId, valuationDate, buySell, notional, quoteValue, refData), quote));
            }
            double coupon = FixedRate.Value;     // always success

            return(CdsCalibrationTrade.of(template.createTrade(legalEntityId, valuationDate, buySell, notional, coupon, refData), quote));
        }