Esempio n. 1
0
        /// <summary>
        /// Create a pay leg.
        /// <para>
        /// The pay leg created is periodic fixed rate payments without compounding.
        /// The Ibor index is used to specify the payment frequency.
        ///
        /// </para>
        /// </summary>
        /// <param name="index">  the Ibor index </param>
        /// <param name="startDate">  the start date </param>
        /// <param name="endDate">  the end date </param>
        /// <param name="fixedRate">  the fixed rate </param>
        /// <param name="notional">  the notional </param>
        /// <param name="payRec">  pay or receive </param>
        /// <returns> the instance </returns>
        public static SwapLeg createFixedPayLegUnresolved(IborIndex index, LocalDate startDate, LocalDate endDate, double fixedRate, double notional, PayReceive payRec)
        {
            Frequency        frequency   = Frequency.of(index.Tenor.Period);
            PeriodicSchedule accSchedule = PeriodicSchedule.of(startDate, endDate, frequency, BUSINESS_ADJ, StubConvention.NONE, RollConventions.NONE);

            return(RateCalculationSwapLeg.builder().payReceive(payRec).accrualSchedule(accSchedule).calculation(FixedRateCalculation.of(fixedRate, ACT_360)).paymentSchedule(PaymentSchedule.builder().paymentFrequency(frequency).paymentDateOffset(DaysAdjustment.NONE).build()).notionalSchedule(NotionalSchedule.of(CurrencyAmount.of(EUR, notional))).build());
        }
Esempio n. 2
0
        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 knownAmountLeg = KnownAmountSwapLeg.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()).amount(ValueSchedule.of(0.015)).currency(USD).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);
            Swap    swap3          = Swap.of(knownAmountLeg, SWAP.getLeg(PAY).get());

            assertThrowsIllegalArg(() => Dsf.builder().securityId(SECURITY_ID).notional(NOTIONAL).deliveryDate(DELIVERY_DATE).lastTradeDate(LAST_TRADE_DATE).underlyingSwap(swap1).build());
            assertThrowsIllegalArg(() => Dsf.builder().securityId(SECURITY_ID).notional(NOTIONAL).deliveryDate(DELIVERY_DATE).lastTradeDate(LAST_TRADE_DATE).underlyingSwap(swap2).build());
            // should succeed normally (no notional to validate on known amount leg)
            Dsf.builder().securityId(SECURITY_ID).notional(NOTIONAL).deliveryDate(DELIVERY_DATE).lastTradeDate(LAST_TRADE_DATE).underlyingSwap(swap3).build();
        }