public virtual void test_resolve_beforeEnd_weekend()
        {
            FxResetCalculation @base = FxResetCalculation.builder().index(EUR_GBP_ECB).referenceCurrency(GBP).fixingDateOffset(MINUS_TWO_DAYS).fixingRelativeTo(FxResetFixingRelativeTo.PERIOD_END).build();
            Optional <FxReset> test  = @base.resolve(REF_DATA).apply(0, SchedulePeriod.of(DATE_2014_03_31, DATE_2014_06_30));

            assertEquals(test, FxReset.of(FxIndexObservation.of(EUR_GBP_ECB, date(2014, 6, 26), REF_DATA), GBP));
        }
Esempio n. 2
0
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 575402001:         // currency
                    this.currency_Renamed = (Currency)newValue;
                    break;

                case -449555555:         // fxReset
                    this.fxReset_Renamed = (FxResetCalculation)newValue;
                    break;

                case -1413853096:         // amount
                    this.amount_Renamed = (ValueSchedule)newValue;
                    break;

                case -511982201:         // initialExchange
                    this.initialExchange_Renamed = (bool?)newValue.Value;
                    break;

                case -2147112388:         // intermediateExchange
                    this.intermediateExchange_Renamed = (bool?)newValue.Value;
                    break;

                case -1048781383:         // finalExchange
                    this.finalExchange_Renamed = (bool?)newValue.Value;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
        public virtual void test_resolve_beforeStart_threeDays()
        {
            FxResetCalculation @base = FxResetCalculation.builder().index(EUR_GBP_ECB).referenceCurrency(GBP).fixingDateOffset(MINUS_THREE_DAYS).build();
            Optional <FxReset> test  = @base.resolve(REF_DATA).apply(0, SchedulePeriod.of(DATE_2014_03_31, DATE_2014_06_30));

            assertEquals(test, FxReset.of(FxIndexObservation.of(EUR_GBP_ECB, date(2014, 3, 26), REF_DATA), GBP));
        }
Esempio n. 4
0
 /// <summary>
 /// Restricted copy constructor. </summary>
 /// <param name="beanToCopy">  the bean to copy from, not null </param>
 internal Builder(NotionalSchedule beanToCopy)
 {
     this.currency_Renamed             = beanToCopy.Currency;
     this.fxReset_Renamed              = beanToCopy.fxReset;
     this.amount_Renamed               = beanToCopy.Amount;
     this.initialExchange_Renamed      = beanToCopy.InitialExchange;
     this.intermediateExchange_Renamed = beanToCopy.IntermediateExchange;
     this.finalExchange_Renamed        = beanToCopy.FinalExchange;
 }
        public virtual void test_builder_defaults()
        {
            FxResetCalculation test = FxResetCalculation.builder().index(EUR_GBP_ECB).referenceCurrency(GBP).build();

            assertEquals(test.Index, EUR_GBP_ECB);
            assertEquals(test.ReferenceCurrency, GBP);
            assertEquals(test.FixingDateOffset, EUR_GBP_ECB.FixingDateOffset);
            assertEquals(test.FixingRelativeTo, FxResetFixingRelativeTo.PERIOD_START);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            FxResetCalculation test = FxResetCalculation.builder().index(EUR_GBP_ECB).referenceCurrency(GBP).fixingDateOffset(MINUS_TWO_DAYS).build();

            coverImmutableBean(test);
            FxResetCalculation test2 = FxResetCalculation.builder().index(EUR_USD_ECB).referenceCurrency(Currency.EUR).fixingDateOffset(MINUS_THREE_DAYS).fixingRelativeTo(FxResetFixingRelativeTo.PERIOD_END).build();

            coverBeanEquals(test, test2);
        }
        public virtual void test_resolve_initial_notional_override()
        {
            FxResetCalculation @base = FxResetCalculation.builder().index(EUR_GBP_ECB).referenceCurrency(GBP).fixingDateOffset(MINUS_TWO_DAYS).initialNotionalValue(100000d).build();
            Optional <FxReset> fxResetFirstPeriod = @base.resolve(REF_DATA).apply(0, SchedulePeriod.of(DATE_2014_03_31, DATE_2014_06_30));

            assertFalse(fxResetFirstPeriod.Present);

            Optional <FxReset> fxResetSecondPeriod = @base.resolve(REF_DATA).apply(1, SchedulePeriod.of(DATE_2014_03_31, DATE_2014_06_30));

            assertTrue(fxResetSecondPeriod.Present);
        }
Esempio n. 8
0
 private NotionalSchedule(Currency currency, FxResetCalculation fxReset, ValueSchedule amount, bool initialExchange, bool intermediateExchange, bool finalExchange)
 {
     JodaBeanUtils.notNull(currency, "currency");
     JodaBeanUtils.notNull(amount, "amount");
     this.currency             = currency;
     this.fxReset              = fxReset;
     this.amount               = amount;
     this.initialExchange      = initialExchange;
     this.intermediateExchange = intermediateExchange;
     this.finalExchange        = finalExchange;
     validate();
 }
        public virtual void test_builder_FxResetSetsFlags()
        {
            FxResetCalculation fxReset = FxResetCalculation.builder().referenceCurrency(GBP).index(GBP_USD_WM).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)).build();
            NotionalSchedule   test    = NotionalSchedule.builder().currency(USD).amount(ValueSchedule.of(2000d)).intermediateExchange(true).finalExchange(true).fxReset(fxReset).build();

            assertEquals(test.Currency, USD);
            assertEquals(test.Amount, ValueSchedule.of(2000d));
            assertEquals(test.FxReset, fxReset);
            assertEquals(test.InitialExchange, false);
            assertEquals(test.IntermediateExchange, true);
            assertEquals(test.FinalExchange, true);
        }
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         FxResetCalculation other = (FxResetCalculation)obj;
         return(JodaBeanUtils.equal(index, other.index) && JodaBeanUtils.equal(referenceCurrency, other.referenceCurrency) && JodaBeanUtils.equal(fixingRelativeTo, other.fixingRelativeTo) && JodaBeanUtils.equal(fixingDateOffset, other.fixingDateOffset) && JodaBeanUtils.equal(initialNotionalValue, other.initialNotionalValue));
     }
     return(false);
 }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            NotionalSchedule test = NotionalSchedule.of(GBP, 1000d);

            coverImmutableBean(test);
            NotionalSchedule test2 = NotionalSchedule.builder().currency(USD).amount(ValueSchedule.of(2000d)).fxReset(FxResetCalculation.builder().referenceCurrency(GBP).index(GBP_USD_WM).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)).build()).initialExchange(true).intermediateExchange(true).finalExchange(true).build();

            coverBeanEquals(test, test2);
        }
Esempio n. 12
0
 /// <summary>
 /// Sets the FX reset definition, optional.
 /// <para>
 /// This property is used when the defined amount of the notional is specified in
 /// a currency other than the currency of the swap leg. When this occurs, the notional
 /// amount has to be converted using an FX rate to the swap leg currency. This conversion
 /// occurs at each payment period boundary and usually corresponds to an actual
 /// exchange of money between the counterparties.
 /// </para>
 /// <para>
 /// When building the notional schedule, if an {@code FxResetCalculation} is present,
 /// then at least one of the notional exchange flags should be set to true. If all notional
 /// exchange flags are false then an IllegalArgumentException is thrown.
 /// </para>
 /// </summary>
 /// <param name="fxReset">  the new value </param>
 /// <returns> this, for chaining, not null </returns>
 public Builder fxReset(FxResetCalculation fxReset)
 {
     this.fxReset_Renamed = fxReset;
     return(this);
 }
        //-------------------------------------------------------------------------
        public virtual void test_resolve_oneAccrualPerPayment_fxReset()
        {
            // test case
            RateCalculationSwapLeg test = RateCalculationSwapLeg.builder().payReceive(PAY).accrualSchedule(PeriodicSchedule.builder().startDate(DATE_01_05).endDate(DATE_04_05).frequency(P1M).businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, GBLO)).build()).paymentSchedule(PaymentSchedule.builder().paymentFrequency(P1M).paymentDateOffset(PLUS_TWO_DAYS).build()).notionalSchedule(NotionalSchedule.builder().currency(GBP).amount(ValueSchedule.of(1000d)).fxReset(FxResetCalculation.builder().referenceCurrency(EUR).index(EUR_GBP_ECB).fixingDateOffset(MINUS_TWO_DAYS).build()).initialExchange(true).intermediateExchange(true).finalExchange(true).build()).calculation(FixedRateCalculation.builder().dayCount(ACT_365F).rate(ValueSchedule.of(0.025d)).build()).build();
            // expected
            RatePaymentPeriod       rpp1 = RatePaymentPeriod.builder().paymentDate(DATE_02_07).accrualPeriods(RateAccrualPeriod.builder().startDate(DATE_01_06).endDate(DATE_02_05).unadjustedStartDate(DATE_01_05).yearFraction(ACT_365F.yearFraction(DATE_01_06, DATE_02_05)).rateComputation(FixedRateComputation.of(0.025d)).build()).dayCount(ACT_365F).currency(GBP).notional(-1000d).fxReset(FxReset.of(FxIndexObservation.of(EUR_GBP_ECB, DATE_01_02, REF_DATA), EUR)).build();
            RatePaymentPeriod       rpp2 = RatePaymentPeriod.builder().paymentDate(DATE_03_07).accrualPeriods(RateAccrualPeriod.builder().startDate(DATE_02_05).endDate(DATE_03_05).yearFraction(ACT_365F.yearFraction(DATE_02_05, DATE_03_05)).rateComputation(FixedRateComputation.of(0.025d)).build()).dayCount(ACT_365F).currency(GBP).notional(-1000d).fxReset(FxReset.of(FxIndexObservation.of(EUR_GBP_ECB, DATE_02_03, REF_DATA), EUR)).build();
            RatePaymentPeriod       rpp3 = RatePaymentPeriod.builder().paymentDate(DATE_04_09).accrualPeriods(RateAccrualPeriod.builder().startDate(DATE_03_05).endDate(DATE_04_07).unadjustedEndDate(DATE_04_05).yearFraction(ACT_365F.yearFraction(DATE_03_05, DATE_04_07)).rateComputation(FixedRateComputation.of(0.025d)).build()).dayCount(ACT_365F).currency(GBP).notional(-1000d).fxReset(FxReset.of(FxIndexObservation.of(EUR_GBP_ECB, DATE_03_03, REF_DATA), EUR)).build();
            FxResetNotionalExchange ne1a = FxResetNotionalExchange.of(CurrencyAmount.of(EUR, 1000d), DATE_01_06, FxIndexObservation.of(EUR_GBP_ECB, DATE_01_02, REF_DATA));
            FxResetNotionalExchange ne1b = FxResetNotionalExchange.of(CurrencyAmount.of(EUR, -1000d), DATE_02_07, FxIndexObservation.of(EUR_GBP_ECB, DATE_01_02, REF_DATA));
            FxResetNotionalExchange ne2a = FxResetNotionalExchange.of(CurrencyAmount.of(EUR, 1000d), DATE_02_07, FxIndexObservation.of(EUR_GBP_ECB, DATE_02_03, REF_DATA));
            FxResetNotionalExchange ne2b = FxResetNotionalExchange.of(CurrencyAmount.of(EUR, -1000d), DATE_03_07, FxIndexObservation.of(EUR_GBP_ECB, DATE_02_03, REF_DATA));
            FxResetNotionalExchange ne3a = FxResetNotionalExchange.of(CurrencyAmount.of(EUR, 1000d), DATE_03_07, FxIndexObservation.of(EUR_GBP_ECB, DATE_03_03, REF_DATA));
            FxResetNotionalExchange ne3b = FxResetNotionalExchange.of(CurrencyAmount.of(EUR, -1000d), DATE_04_09, FxIndexObservation.of(EUR_GBP_ECB, DATE_03_03, REF_DATA));

            // assertion
            assertEquals(test.resolve(REF_DATA), ResolvedSwapLeg.builder().type(FIXED).payReceive(PAY).paymentPeriods(rpp1, rpp2, rpp3).paymentEvents(ne1a, ne1b, ne2a, ne2b, ne3a, ne3b).build());
        }
 public virtual void test_invalidCurrency()
 {
     assertThrowsIllegalArg(() => FxResetCalculation.builder().index(EUR_USD_ECB).referenceCurrency(GBP).fixingDateOffset(MINUS_TWO_DAYS).build());
 }
        public virtual void test_serialization()
        {
            FxResetCalculation test = FxResetCalculation.builder().index(EUR_GBP_ECB).referenceCurrency(GBP).fixingDateOffset(MINUS_TWO_DAYS).build();

            assertSerialization(test);
        }
 public virtual void test_builder_invalidCurrencyFxReset()
 {
     assertThrowsIllegalArg(() => NotionalSchedule.builder().currency(USD).amount(ValueSchedule.of(2000d)).fxReset(FxResetCalculation.builder().referenceCurrency(USD).index(GBP_USD_WM).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)).build()).build());
     assertThrowsIllegalArg(() => NotionalSchedule.builder().currency(EUR).amount(ValueSchedule.of(2000d)).fxReset(FxResetCalculation.builder().referenceCurrency(USD).index(GBP_USD_WM).fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)).build()).build());
 }
        public virtual void test_collectIndices_fxReset()
        {
            RateCalculationSwapLeg test = RateCalculationSwapLeg.builder().payReceive(PAY).accrualSchedule(PeriodicSchedule.builder().startDate(DATE_01_05).endDate(DATE_04_05).frequency(P1M).businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, GBLO)).build()).paymentSchedule(PaymentSchedule.builder().paymentFrequency(P1M).paymentDateOffset(PLUS_TWO_DAYS).build()).notionalSchedule(NotionalSchedule.builder().currency(GBP).amount(ValueSchedule.of(1000d)).finalExchange(true).fxReset(FxResetCalculation.builder().referenceCurrency(EUR).index(EUR_GBP_ECB).fixingDateOffset(MINUS_TWO_DAYS).build()).build()).calculation(IborRateCalculation.builder().dayCount(DayCounts.ACT_365F).index(GBP_LIBOR_3M).fixingDateOffset(MINUS_TWO_DAYS).build()).build();

            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M, EUR_GBP_ECB));
            assertEquals(test.allIndices(), ImmutableSet.of(GBP_LIBOR_3M, EUR_GBP_ECB));
            assertEquals(test.allCurrencies(), ImmutableSet.of(GBP, EUR));
        }