Example #1
0
        //-------------------------------------------------------------------------
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableValidator private void validate()
        private void validate()
        {
            ArgChecker.inOrderOrEqual(deliveryDate, underlyingSwap.StartDate, "deliveryDate", "startDate");
            ArgChecker.isFalse(underlyingSwap.CrossCurrency, "underlying swap must not be cross currency");
            foreach (ResolvedSwapLeg swapLeg in underlyingSwap.Legs)
            {
                if (swapLeg.Type.Equals(SwapLegType.FIXED))
                {
                    ArgChecker.isTrue(swapLeg.PayReceive.Receive, "underlying must be receiver swap");
                }
                foreach (SwapPaymentEvent @event in swapLeg.PaymentEvents)
                {
                    ArgChecker.isTrue(@event is NotionalExchange, "PaymentEvent must be NotionalExchange");
                    NotionalExchange notioanlEvent = (NotionalExchange)@event;
                    ArgChecker.isTrue(Math.Abs(notioanlEvent.PaymentAmount.Amount) == 1d, "notional of underlying swap must be unity");
                }
                foreach (SwapPaymentPeriod period in swapLeg.PaymentPeriods)
                {
                    ArgChecker.isTrue(period is NotionalPaymentPeriod, "PaymentPeriod must be NotionalPaymentPeriod");
                    NotionalPaymentPeriod notioanlPeriod = (NotionalPaymentPeriod)period;
                    ArgChecker.isTrue(Math.Abs(notioanlPeriod.NotionalAmount.Amount) == 1d, "notional of underlying swap must be unity");
                }
            }
            ArgChecker.inOrderOrEqual(lastTradeDate, deliveryDate, "lastTradeDate", "deliveryDate");
        }
Example #2
0
        // create notional exchange events when no FxReset
        private static ImmutableList <SwapPaymentEvent> createStandardEvents(IList <NotionalPaymentPeriod> payPeriods, LocalDate initialExchangePaymentDate, bool initialExchange, bool intermediateExchange, bool finalExchange)
        {
            NotionalPaymentPeriod firstPeriod = payPeriods[0];

            ImmutableList.Builder <SwapPaymentEvent> events = ImmutableList.builder();
            if (initialExchange)
            {
                events.add(NotionalExchange.of(firstPeriod.NotionalAmount.negated(), initialExchangePaymentDate));
            }
            if (intermediateExchange)
            {
                for (int i = 0; i < payPeriods.Count - 1; i++)
                {
                    NotionalPaymentPeriod period1 = payPeriods[i];
                    NotionalPaymentPeriod period2 = payPeriods[i + 1];
                    if (period1.NotionalAmount.Amount != period2.NotionalAmount.Amount)
                    {
                        events.add(NotionalExchange.of(period1.NotionalAmount.minus(period2.NotionalAmount), period1.PaymentDate));
                    }
                }
            }
            if (finalExchange)
            {
                NotionalPaymentPeriod lastPeriod = payPeriods[payPeriods.Count - 1];
                events.add(NotionalExchange.of(lastPeriod.NotionalAmount, lastPeriod.PaymentDate));
            }
            return(events.build());
        }
Example #3
0
        // find the notional
        private CurrencyAmount buildLegNotional(ResolvedSwapLeg leg)
        {
            // check for NotionalPaymentPeriod
            SwapPaymentPeriod firstPaymentPeriod = leg.PaymentPeriods.get(0);

            if (firstPaymentPeriod is NotionalPaymentPeriod)
            {
                NotionalPaymentPeriod pp = (NotionalPaymentPeriod)firstPaymentPeriod;
                return(pp.NotionalAmount.positive());
            }
            return(NOT_FOUND);
        }
Example #4
0
        // create notional exchange events when FxReset specified
        private static ImmutableList <SwapPaymentEvent> createFxResetEvents(IList <NotionalPaymentPeriod> payPeriods, LocalDate initialExchangeDate, bool initialExchange, bool intermediateExchange, bool finalExchange)
        {
            ImmutableList.Builder <SwapPaymentEvent> events = ImmutableList.builder();
            for (int i = 0; i < payPeriods.Count; i++)
            {
                NotionalPaymentPeriod period           = payPeriods[i];
                LocalDate             startPaymentDate = (i == 0 ? initialExchangeDate : payPeriods[i - 1].PaymentDate);

                bool includeStartPayment = i == 0 ? initialExchange : intermediateExchange;
                bool includeEndPayment   = i == payPeriods.Count - 1 ? finalExchange : intermediateExchange;

                if (period.FxResetObservation.Present)
                {
                    FxIndexObservation observation = period.FxResetObservation.get();

                    // notional out at start of period
                    if (includeStartPayment)
                    {
                        events.add(FxResetNotionalExchange.of(period.NotionalAmount.negated(), startPaymentDate, observation));
                    }

                    // notional in at end of period
                    if (includeEndPayment)
                    {
                        events.add(FxResetNotionalExchange.of(period.NotionalAmount, period.PaymentDate, observation));
                    }
                }
                else
                {
                    // handle weird swap where only some periods have FX reset

                    // notional out at start of period
                    if (includeStartPayment)
                    {
                        events.add(NotionalExchange.of(CurrencyAmount.of(period.Currency, -period.NotionalAmount.Amount), startPaymentDate));
                    }
                    // notional in at end of period
                    if (includeEndPayment)
                    {
                        events.add(NotionalExchange.of(CurrencyAmount.of(period.Currency, period.NotionalAmount.Amount), period.PaymentDate));
                    }
                }
            }
            return(events.build());
        }