Exemplo n.º 1
0
        internal static Dsf sut2()
        {
            SwapLeg iborLeg = 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(1d)).finalExchange(true).initialExchange(true).build()).calculation(IborRateCalculation.builder().index(INDEX).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, SAT_SUN, BDA_P)).build()).build();
            Swap    swap2   = Swap.of(SWAP.getLeg(RECEIVE).get(), iborLeg);

            return(Dsf.builder().securityId(SECURITY_ID2).notional(20000L).deliveryDate(LocalDate.of(2014, 9, 5)).lastTradeDate(LocalDate.of(2014, 9, 2)).underlyingSwap(swap2).build());
        }
        // swap USD standard conventions- TODO: replace by a template when available
        private static Swap swapUsd(LocalDate start, LocalDate end, PayReceive payReceive, NotionalSchedule notional, double fixedRate)
        {
            SwapLeg fixedLeg = CurveGammaCalculatorTest.fixedLeg(start, end, Frequency.P6M, payReceive, notional, fixedRate, StubConvention.SHORT_INITIAL);
            SwapLeg iborLeg  = CurveGammaCalculatorTest.iborLeg(start, end, USD_LIBOR_3M, (payReceive == PAY) ? RECEIVE : PAY, notional, StubConvention.SHORT_INITIAL);

            return(Swap.of(fixedLeg, iborLeg));
        }
Exemplo n.º 3
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_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());
        }
Exemplo n.º 5
0
        //-------------------------------------------------------------------------
        public Trade parseTrade(FpmlDocument document, XmlElement tradeEl)
        {
            // supported elements:
            //  'swaption'
            //  'swaption/buyerPartyReference'
            //  'swaption/sellerPartyReference'
            //  'swaption/premium/payerPartyReference'
            //  'swaption/premium/receiverPartyReference'
            //  'swaption/premium/paymentAmount'
            //  'swaption/premium/paymentDate'
            //  'swaption/europeanExercise'
            //  'swaption/europeanExercise/expirationDate'
            //  'swaption/europeanExercise/expirationDate/adjustableDate'
            //  'swaption/europeanExercise/expirationDate/adjustableDate/unadjustedDate'
            //  'swaption/europeanExercise/expirationDate/adjustableDate/dateAdjustments'
            //  'swaption/europeanExercise/expirationTime
            //  'swaption/swap'
            // ignored elements:
            //  'Product.model?'
            //  'swaption/calculationAgent'
            //  'swaption/assetClass'
            //  'swaption/primaryAssestClass'
            //  'swaption/productId'
            //  'swaption/productType'
            //  'swaption/secondaryAssetClass'
            //  'swaption/sellerAccountReference'
            //  'swaption/sellerPartyReference'
            //  'swaption/swaptionAdjustedDates'
            //  'swaption/swaptionStraddle'
            TradeInfoBuilder tradeInfoBuilder = document.parseTradeInfo(tradeEl);

            XmlElement swaptionEl         = tradeEl.getChild("swaption");
            XmlElement europeanExerciseEl = swaptionEl.getChild("europeanExercise");
            XmlElement expirationTimeEl   = europeanExerciseEl.getChild("expirationTime");

            // Parse the premium, expiry date, expiry time and expiry zone, longShort and swaption settlement.
            AdjustablePayment  premium            = parsePremium(swaptionEl, document, tradeInfoBuilder);
            AdjustableDate     expiryDate         = parseExpiryDate(europeanExerciseEl, document);
            LocalTime          expiryTime         = parseExpiryTime(expirationTimeEl, document);
            ZoneId             expiryZone         = parseExpiryZone(expirationTimeEl, document);
            LongShort          longShort          = parseLongShort(swaptionEl, document, tradeInfoBuilder);
            SwaptionSettlement swaptionSettlement = parseSettlement(swaptionEl, document);

            //Re use the Swap FpML parser to parse the underlying swap on this swaption.
            SwapFpmlParserPlugin swapParser = SwapFpmlParserPlugin.INSTANCE;
            Swap swap = swapParser.parseSwap(document, swaptionEl, tradeInfoBuilder);

            Swaption swaption = Swaption.builder().expiryDate(expiryDate).expiryZone(expiryZone).expiryTime(expiryTime).longShort(longShort).swaptionSettlement(swaptionSettlement).underlying(swap).build();

            return(SwaptionTrade.builder().info(tradeInfoBuilder.build()).product(swaption).premium(premium).build());
        }
        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(() => DsfSecurity.builder().info(INFO).notional(NOTIONAL).lastTradeDate(LAST_TRADE_DATE).underlyingSwap(swap1).build());
            assertThrowsIllegalArg(() => DsfSecurity.builder().info(INFO).notional(NOTIONAL).lastTradeDate(LAST_TRADE_DATE).underlyingSwap(swap2).build());
            // should succeed normally (no notional to validate on known amount leg)
            DsfSecurity.builder().info(INFO).notional(NOTIONAL).lastTradeDate(LAST_TRADE_DATE).underlyingSwap(swap3).build();
        }