コード例 #1
0
        //-------------------------------------------------------------------------
        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);
        }
コード例 #2
0
 private CdsIndexTrade(TradeInfo info, CdsIndex product, AdjustablePayment upfrontFee)
 {
     JodaBeanUtils.notNull(info, "info");
     JodaBeanUtils.notNull(product, "product");
     this.info       = info;
     this.product    = product;
     this.upfrontFee = upfrontFee;
 }
コード例 #3
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            CdsIndexTrade test1 = sut();

            coverImmutableBean(test1);
            CdsIndex      product = CdsIndex.of(BUY, INDEX_ID, LEGAL_ENTITIES, USD, 1.e9, START_DATE, END_DATE, P6M, SAT_SUN, 0.067);
            CdsIndexTrade test2   = CdsIndexTrade.builder().product(product).info(TradeInfo.empty()).build();

            coverBeanEquals(test1, test2);
        }
コード例 #4
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            ResolvedCdsIndexTrade test1 = ResolvedCdsIndexTrade.builder().product(PRODUCT).upfrontFee(UPFRONT).info(TRADE_INFO).build();

            coverImmutableBean(test1);
            ResolvedCdsIndex      product = CdsIndex.of(BUY, INDEX_ID, LEGAL_ENTITIES, USD, 1.e9, START_DATE, END_DATE, P6M, SAT_SUN, 0.067).resolve(REF_DATA);
            ResolvedCdsIndexTrade test2   = ResolvedCdsIndexTrade.builder().product(product).info(TradeInfo.empty()).build();

            coverBeanEquals(test1, test2);
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(CdsIndexTrade trade, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            CdsIndex   product       = trade.Product;
            StandardId legalEntityId = product.CdsIndexId;
            Currency   currency      = product.Currency;

            // use lookup to build requirements
            CreditRatesMarketDataLookup lookup = parameters.getParameter(typeof(CreditRatesMarketDataLookup));

            return(lookup.requirements(legalEntityId, currency));
        }
コード例 #6
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 3237038:         // info
                    this.info_Renamed = (TradeInfo)newValue;
                    break;

                case -309474065:         // product
                    this.product_Renamed = (CdsIndex)newValue;
                    break;

                case 963468344:         // upfrontFee
                    this.upfrontFee_Renamed = (AdjustablePayment)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
コード例 #7
0
        public virtual void test_of()
        {
            BusinessDayAdjustment bussAdj  = BusinessDayAdjustment.of(FOLLOWING, SAT_SUN);
            PeriodicSchedule      expected = PeriodicSchedule.builder().startDate(START_DATE).endDate(END_DATE).businessDayAdjustment(bussAdj).startDateBusinessDayAdjustment(BusinessDayAdjustment.NONE).endDateBusinessDayAdjustment(BusinessDayAdjustment.NONE).frequency(P3M).rollConvention(RollConventions.NONE).stubConvention(SMART_INITIAL).build();

            assertEquals(PRODUCT.PaymentSchedule, expected);
            assertEquals(PRODUCT.BuySell, BUY);
            assertEquals(PRODUCT.Currency, USD);
            assertEquals(PRODUCT.DayCount, ACT_360);
            assertEquals(PRODUCT.FixedRate, COUPON);
            assertEquals(PRODUCT.CdsIndexId, INDEX_ID);
            assertEquals(PRODUCT.LegalEntityIds, LEGAL_ENTITIES);
            assertEquals(PRODUCT.Notional, NOTIONAL);
            assertEquals(PRODUCT.PaymentOnDefault, ACCRUED_PREMIUM);
            assertEquals(PRODUCT.ProtectionStart, BEGINNING);
            assertEquals(PRODUCT.SettlementDateOffset, SETTLE_DAY_ADJ);
            assertEquals(PRODUCT.StepinDateOffset, STEPIN_DAY_ADJ);
            CdsIndex test = CdsIndex.of(BUY, INDEX_ID, LEGAL_ENTITIES, USD, NOTIONAL, START_DATE, END_DATE, P3M, SAT_SUN, COUPON);

            assertEquals(test, PRODUCT);
        }
コード例 #8
0
        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));
        }
コード例 #9
0
 /// <summary>
 /// Sets the CDS index product that was agreed when the trade occurred.
 /// <para>
 /// The product captures the contracted financial details of the trade.
 /// </para>
 /// </summary>
 /// <param name="product">  the new value, not null </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder product(CdsIndex product)
 {
     JodaBeanUtils.notNull(product, "product");
     this.product_Renamed = product;
     return(this);
 }
コード例 #10
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(CdsIndexTrade beanToCopy)
 {
     this.info_Renamed       = beanToCopy.Info;
     this.product_Renamed    = beanToCopy.Product;
     this.upfrontFee_Renamed = beanToCopy.upfrontFee;
 }
コード例 #11
0
        /// <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));
        }