Beispiel #1
0
        public virtual void test_createTrade_withFee()
        {
            TenorCdsTemplate  base1      = TenorCdsTemplate.of(TENOR_10Y, CONV1);
            TenorCdsTemplate  base2      = TenorCdsTemplate.of(AccrualStart.NEXT_DAY, TENOR_2Y, CONV2);
            LocalDate         tradeDate  = LocalDate.of(2015, 5, 5);
            AdjustablePayment payment1   = AdjustablePayment.of(EUR, NOTIONAL_2M, CONV1.SettlementDateOffset.adjust(tradeDate, REF_DATA));
            AdjustablePayment payment2   = AdjustablePayment.of(USD, NOTIONAL_2M, CONV2.SettlementDateOffset.adjust(tradeDate, REF_DATA));
            LocalDate         startDate1 = date(2015, 3, 20);
            LocalDate         endDate1   = date(2025, 6, 20);
            LocalDate         startDate2 = date(2015, 5, 6);
            LocalDate         endDate2   = date(2017, 6, 20);
            CdsTrade          test1      = base1.createTrade(LEGAL_ENTITY, tradeDate, BUY, NOTIONAL_2M, 0.05d, payment1, REF_DATA);
            CdsTrade          test2      = base2.createTrade(LEGAL_ENTITY, tradeDate, BUY, NOTIONAL_2M, 0.05d, payment2, REF_DATA);
            Cds expected1         = Cds.of(BUY, LEGAL_ENTITY, CONV1.Currency, NOTIONAL_2M, startDate1, endDate1, Frequency.P3M, CONV1.SettlementDateOffset.Calendar, 0.05d);
            PeriodicSchedule sch1 = expected1.PaymentSchedule;

            expected1 = expected1.toBuilder().paymentSchedule(sch1.toBuilder().startDateBusinessDayAdjustment(sch1.BusinessDayAdjustment).rollConvention(RollConventions.DAY_20).build()).build();
            Cds expected2         = Cds.of(BUY, LEGAL_ENTITY, CONV2.Currency, NOTIONAL_2M, startDate2, endDate2, Frequency.P3M, CONV2.SettlementDateOffset.Calendar, 0.05d);
            PeriodicSchedule sch2 = expected2.PaymentSchedule;

            expected2 = expected2.toBuilder().paymentSchedule(sch2.toBuilder().startDateBusinessDayAdjustment(sch2.BusinessDayAdjustment).rollConvention(RollConventions.DAY_20).build()).build();
            assertEquals(test1.Info.TradeDate, tradeDate);
            assertEquals(test1.UpfrontFee, payment1);
            assertEquals(test1.Product, expected1);
            assertEquals(test2.Info.TradeDate, tradeDate);
            assertEquals(test2.UpfrontFee, payment2);
            assertEquals(test2.Product, expected2);
        }
Beispiel #2
0
        private AdjustablePayment parsePremium(XmlElement swaptionEl, FpmlDocument document, TradeInfoBuilder tradeInfoBuilder)
        {
            XmlElement     premiumEl       = swaptionEl.getChild("premium");
            PayReceive     payReceive      = document.parsePayerReceiver(premiumEl, tradeInfoBuilder);
            XmlElement     paymentAmountEl = premiumEl.getChild("paymentAmount");
            CurrencyAmount ccyAmount       = document.parseCurrencyAmount(paymentAmountEl);

            ccyAmount = payReceive.Pay ? ccyAmount.negated() : ccyAmount;
            AdjustableDate paymentDate = premiumEl.findChild("paymentDate").map(el => document.parseAdjustableDate(el)).get();

            return(AdjustablePayment.of(ccyAmount, paymentDate));
        }
Beispiel #3
0
        public virtual void test_createTrade_withFee()
        {
            DatesCdsTemplate  @base     = DatesCdsTemplate.of(START, END, CONV1);
            LocalDate         tradeDate = LocalDate.of(2015, 5, 5);
            AdjustablePayment payment   = AdjustablePayment.of(EUR, NOTIONAL_2M, CONV1.SettlementDateOffset.adjust(tradeDate, REF_DATA));
            CdsTrade          test      = @base.createTrade(LEGAL_ENTITY, tradeDate, BUY, NOTIONAL_2M, 0.05d, payment, REF_DATA);
            Cds expected          = Cds.of(BUY, LEGAL_ENTITY, CONV1.Currency, NOTIONAL_2M, START, END, Frequency.P3M, CONV1.SettlementDateOffset.Calendar, 0.05d);
            PeriodicSchedule sch1 = expected.PaymentSchedule;

            expected = expected.toBuilder().paymentSchedule(sch1.toBuilder().startDateBusinessDayAdjustment(sch1.BusinessDayAdjustment).rollConvention(RollConventions.DAY_20).build()).build();
            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.UpfrontFee, payment);
            assertEquals(test.Product, expected);
        }
        //-------------------------------------------------------------------------
        public virtual void test_toTrade()
        {
            LocalDate tradeDate          = LocalDate.of(2015, 12, 21); // 19, 20 weekend
            LocalDate startDate          = LocalDate.of(2015, 12, 20);
            LocalDate endDate            = LocalDate.of(2020, 12, 20);
            LocalDate settlementDate     = LocalDate.of(2015, 12, 24);
            TradeInfo info               = TradeInfo.builder().tradeDate(tradeDate).settlementDate(settlementDate).build();
            Tenor     tenor              = Tenor.TENOR_5Y;
            ImmutableCdsConvention @base = ImmutableCdsConvention.of(NAME, GBP, ACT_360, P3M, BUSI_ADJ_STD, SETTLE_DAY_ADJ_STD);
            Cds      product             = Cds.builder().legalEntityId(LEGAL_ENTITY).paymentSchedule(PeriodicSchedule.builder().startDate(startDate).endDate(endDate).frequency(P3M).businessDayAdjustment(BUSI_ADJ_STD).startDateBusinessDayAdjustment(BUSI_ADJ_STD).endDateBusinessDayAdjustment(BusinessDayAdjustment.NONE).stubConvention(StubConvention.SMART_INITIAL).rollConvention(RollConventions.DAY_20).build()).buySell(BUY).currency(GBP).dayCount(ACT_360).notional(NOTIONAL).fixedRate(COUPON).paymentOnDefault(PaymentOnDefault.ACCRUED_PREMIUM).protectionStart(ProtectionStartOfDay.BEGINNING).stepinDateOffset(STEPIN_DAY_ADJ).settlementDateOffset(SETTLE_DAY_ADJ_STD).build();
            CdsTrade expected            = CdsTrade.builder().info(info).product(product).build();
            CdsTrade test1               = @base.createTrade(LEGAL_ENTITY, tradeDate, tenor, BUY, NOTIONAL, COUPON, REF_DATA);

            assertEquals(test1, expected);
            CdsTrade test2 = @base.createTrade(LEGAL_ENTITY, tradeDate, startDate, tenor, BUY, NOTIONAL, COUPON, REF_DATA);

            assertEquals(test2, expected);
            CdsTrade test3 = @base.createTrade(LEGAL_ENTITY, tradeDate, startDate, endDate, BUY, NOTIONAL, COUPON, REF_DATA);

            assertEquals(test3, expected);
            CdsTrade test4 = @base.toTrade(LEGAL_ENTITY, info, startDate, endDate, BUY, NOTIONAL, COUPON);

            assertEquals(test4, expected);

            AdjustablePayment upfront        = AdjustablePayment.of(CurrencyAmount.of(GBP, 0.1 * NOTIONAL), settlementDate);
            CdsTrade          expectedWithUf = CdsTrade.builder().info(info).product(product).upfrontFee(upfront).build();
            CdsTrade          test5          = @base.createTrade(LEGAL_ENTITY, tradeDate, tenor, BUY, NOTIONAL, COUPON, upfront, REF_DATA);

            assertEquals(test5, expectedWithUf);
            CdsTrade test6 = @base.createTrade(LEGAL_ENTITY, tradeDate, startDate, tenor, BUY, NOTIONAL, COUPON, upfront, REF_DATA);

            assertEquals(test6, expectedWithUf);
            CdsTrade test7 = @base.createTrade(LEGAL_ENTITY, tradeDate, startDate, endDate, BUY, NOTIONAL, COUPON, upfront, REF_DATA);

            assertEquals(test7, expectedWithUf);
            CdsTrade test8 = @base.toTrade(LEGAL_ENTITY, info, startDate, endDate, BUY, NOTIONAL, COUPON, upfront);

            assertEquals(test8, expectedWithUf);
        }
 public virtual void test_positive_notional()
 {
     assertThrows(() => Bill.builder().dayCount(DAY_COUNT).legalEntityId(LEGAL_ENTITY).notional(AdjustablePayment.of(CurrencyAmount.of(CCY, -10), MATURITY_DATE_ADJ)).securityId(SECURITY_ID).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build());
 }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            BillSecurity test1 = BillSecurity.builder().dayCount(DAY_COUNT).info(INFO).legalEntityId(LEGAL_ENTITY).notional(NOTIONAL).settlementDateOffset(SETTLE).yieldConvention(YIELD_CONVENTION).build();

            coverImmutableBean(test1);
            BillSecurity test2 = BillSecurity.builder().dayCount(DayCounts.ACT_365F).info(SecurityInfo.of(SecurityId.of("OG-Test", "ID2"), PRICE_INFO)).legalEntityId(LegalEntityId.of("OG-Ticker", "LE2")).notional(AdjustablePayment.of(CurrencyAmount.of(CCY, 10), MATURITY_DATE_ADJ)).settlementDateOffset(DaysAdjustment.ofBusinessDays(2, EUTA, BUSINESS_ADJUST)).yieldConvention(BillYieldConvention.INTEREST_AT_MATURITY).build();

            coverBeanEquals(test1, test2);
        }
        internal static FxVanillaOptionTrade sut2()
        {
            AdjustablePayment premium = AdjustablePayment.of(CurrencyAmount.of(EUR, NOTIONAL * 0.01), date(2014, 11, 13));

            return(FxVanillaOptionTrade.builder().product(PRODUCT2).premium(premium).build());
        }
 internal static SwaptionTrade sut2()
 {
     return(SwaptionTrade.builder().premium(AdjustablePayment.of(CurrencyAmount.of(Currency.USD, -3050000d), LocalDate.of(2014, 3, 17))).product(SwaptionTest.sut2()).build());
 }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            FxSingleBarrierOptionTrade test1 = sut();
            FxSingleBarrierOptionTrade test2 = FxSingleBarrierOptionTrade.builder().product(FxSingleBarrierOption.of(VANILLA_OPTION, BARRIER)).premium(AdjustablePayment.of(CurrencyAmount.of(EUR, NOTIONAL * 0.01), date(2014, 11, 13))).build();

            coverImmutableBean(test1);
            coverBeanEquals(test1, test2);
        }