示例#1
0
        // creates and resolves the underlying swap
        private static ResolvedSwap createUnderlyingSwap(LocalDate fixingDate)
        {
            FixedIborSwapConvention conv = EUR_EURIBOR_1100_5Y.Template.Convention;
            LocalDate effectiveDate      = conv.calculateSpotDateFromTradeDate(fixingDate, REF_DATA);
            LocalDate maturityDate       = effectiveDate.plus(EUR_EURIBOR_1100_5Y.Template.Tenor);
            Swap      swap = conv.toTrade(fixingDate, effectiveDate, maturityDate, BuySell.BUY, 1d, 1d).Product;

            return(swap.resolve(REF_DATA));
        }
        //-------------------------------------------------------------------------
        public virtual void test_resolve()
        {
            Swaption         @base = sut();
            ResolvedSwaption test  = @base.resolve(REF_DATA);

            assertEquals(test.Expiry, ADJUSTMENT.adjust(EXPIRY_DATE, REF_DATA).atTime(EXPIRY_TIME).atZone(ZONE));
            assertEquals(test.LongShort, LONG);
            assertEquals(test.SwaptionSettlement, PHYSICAL_SETTLE);
            assertEquals(test.Underlying, SWAP.resolve(REF_DATA));
        }
        public virtual void test_builder_notUnitNotional()
        {
            SwapLeg fixedLeg10 = RateCalculationSwapLeg.builder().payReceive(RECEIVE).accrualSchedule(PeriodicSchedule.builder().startDate(LocalDate.of(2014, 9, 12)).endDate(LocalDate.of(2016, 9, 12)).frequency(P6M).businessDayAdjustment(BDA_MF).stubConvention(StubConvention.SHORT_INITIAL).build()).paymentSchedule(PaymentSchedule.builder().paymentFrequency(P6M).paymentDateOffset(DaysAdjustment.NONE).build()).notionalSchedule(NotionalSchedule.of(USD, 10d)).calculation(FixedRateCalculation.builder().dayCount(THIRTY_U_360).rate(ValueSchedule.of(0.015)).build()).build();
            SwapLeg iborLeg500 = RateCalculationSwapLeg.builder().payReceive(PAY).accrualSchedule(PeriodicSchedule.builder().startDate(LocalDate.of(2014, 9, 12)).endDate(LocalDate.of(2016, 9, 12)).frequency(P1M).businessDayAdjustment(BDA_MF).stubConvention(StubConvention.SHORT_INITIAL).build()).paymentSchedule(PaymentSchedule.builder().paymentFrequency(P3M).paymentDateOffset(DaysAdjustment.NONE).build()).notionalSchedule(NotionalSchedule.builder().currency(USD).amount(ValueSchedule.of(500d)).finalExchange(true).initialExchange(true).build()).calculation(IborRateCalculation.builder().index(INDEX).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, SAT_SUN, BDA_P)).build()).build();
            Swap    swap1      = Swap.of(fixedLeg10, SWAP.getLeg(PAY).get());
            Swap    swap2      = Swap.of(SWAP.getLeg(RECEIVE).get(), iborLeg500);

            assertThrowsIllegalArg(() => ResolvedDsf.builder().securityId(PRODUCT.SecurityId).notional(NOTIONAL).deliveryDate(DELIVERY_DATE).lastTradeDate(LAST_TRADE_DATE).underlyingSwap(swap1.resolve(REF_DATA)).build());
            assertThrowsIllegalArg(() => ResolvedDsf.builder().securityId(PRODUCT.SecurityId).notional(NOTIONAL).deliveryDate(DELIVERY_DATE).lastTradeDate(LAST_TRADE_DATE).underlyingSwap(swap2.resolve(REF_DATA)).build());
        }