Ejemplo n.º 1
0
 public virtual void test_tryParseTenor()
 {
     assertEquals(LoaderUtils.tryParseTenor("P2D"), Tenor.ofDays(2));
     assertEquals(LoaderUtils.tryParseTenor("2D"), Tenor.ofDays(2));
     assertEquals(LoaderUtils.tryParseTenor("2X"), null);
     assertEquals(LoaderUtils.tryParseTenor("2"), null);
     assertEquals(LoaderUtils.tryParseTenor(""), null);
     assertEquals(LoaderUtils.tryParseTenor(null), null);
 }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "stubIbor") public void test_stub_ibor(FixedIborSwapConvention convention, com.opengamma.strata.basics.date.Tenor tenor)
        public virtual void test_stub_ibor(FixedIborSwapConvention convention, Tenor tenor)
        {
            LocalDate    tradeDate    = LocalDate.of(2015, 10, 20);
            SwapTrade    swap         = convention.createTrade(tradeDate, tenor, BuySell.BUY, 1, 0.01, REF_DATA);
            ResolvedSwap swapResolved = swap.Product.resolve(REF_DATA);
            LocalDate    endDate      = swapResolved.getLeg(PayReceive.PAY).get().EndDate;

            assertTrue(endDate.isAfter(tradeDate.plus(tenor).minusMonths(1)));
            assertTrue(endDate.isBefore(tradeDate.plus(tenor).plusMonths(1)));
        }
        //-------------------------------------------------------------------------
        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);
        }
Ejemplo n.º 4
0
 public virtual void test_parseTenor()
 {
     assertEquals(LoaderUtils.parseTenor("P2D"), Tenor.ofDays(2));
     assertEquals(LoaderUtils.parseTenor("2D"), Tenor.ofDays(2));
     assertThrowsIllegalArg(() => LoaderUtils.parseTenor("2"));
 }
        //-------------------------------------------------------------------------
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @DataProvider(name = "stubOn") public static Object[][] data_stub_on()
        public static object[][] data_stub_on()
        {
            return(new object[][]
            {
                new object[] { OvernightIborSwapConventions.USD_FED_FUND_AA_LIBOR_3M, Tenor.TENOR_4M },
                new object[] { OvernightIborSwapConventions.GBP_SONIA_OIS_1Y_LIBOR_3M, Tenor.of(Period.ofMonths(13)) }
            });
        }