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)); }
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)); }
public virtual void test_of() { FxReset test = FxReset.of(FxIndexObservation.of(EUR_GBP_ECB, DATE_2014_06_30, REF_DATA), GBP); assertEquals(test.Index, EUR_GBP_ECB); assertEquals(test.ReferenceCurrency, GBP); }
/// <summary> /// Restricted copy constructor. </summary> /// <param name="beanToCopy"> the bean to copy from, not null </param> internal Builder(RatePaymentPeriod beanToCopy) { this.paymentDate_Renamed = beanToCopy.PaymentDate; this.accrualPeriods_Renamed = beanToCopy.AccrualPeriods; this.dayCount_Renamed = beanToCopy.DayCount; this.currency_Renamed = beanToCopy.Currency; this.fxReset_Renamed = beanToCopy.fxReset; this.notional_Renamed = beanToCopy.Notional; this.compoundingMethod_Renamed = beanToCopy.CompoundingMethod; }
// build the FxReset private Optional <FxReset> buildFxReset(int periodIndex, SchedulePeriod period, DateAdjuster fixingDateAdjuster, System.Func <LocalDate, FxIndexObservation> obsFn) { if (periodIndex == 0 && initialNotionalValue != null) { //if first notional is fixed then no FxReset is applied return(null); } LocalDate fixingDate = fixingDateAdjuster.adjust(fixingRelativeTo.selectBaseDate(period)); return(FxReset.of(obsFn(fixingDate), referenceCurrency)); }
//------------------------------------------------------------------------- public virtual void coverage() { FxReset test = FxReset.of(FxIndexObservation.of(EUR_GBP_ECB, DATE_2014_06_30, REF_DATA), GBP); coverImmutableBean(test); FxReset test2 = FxReset.of(FxIndexObservation.of(EUR_USD_ECB, date(2014, 1, 15), REF_DATA), USD); coverBeanEquals(test, test2); FxReset test3 = FxReset.of(FxIndexObservation.of(EUR_USD_ECB, date(2014, 1, 15), REF_DATA), EUR); coverBeanEquals(test2, test3); }
//----------------------------------------------------------------------- public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj != null && obj.GetType() == this.GetType()) { FxReset other = (FxReset)obj; return(JodaBeanUtils.equal(observation, other.observation) && JodaBeanUtils.equal(referenceCurrency, other.referenceCurrency)); } return(false); }
/// <summary> /// Creates an instance. </summary> /// <param name="paymentDate"> the value of the property, not null </param> /// <param name="accrualPeriods"> the value of the property, not empty </param> /// <param name="dayCount"> the value of the property, not null </param> /// <param name="currency"> the value of the property, not null </param> /// <param name="fxReset"> the value of the property </param> /// <param name="notional"> the value of the property </param> /// <param name="compoundingMethod"> the value of the property, not null </param> internal RatePaymentPeriod(LocalDate paymentDate, IList <RateAccrualPeriod> accrualPeriods, DayCount dayCount, Currency currency, FxReset fxReset, double notional, CompoundingMethod compoundingMethod) { JodaBeanUtils.notNull(paymentDate, "paymentDate"); JodaBeanUtils.notEmpty(accrualPeriods, "accrualPeriods"); JodaBeanUtils.notNull(dayCount, "dayCount"); JodaBeanUtils.notNull(currency, "currency"); JodaBeanUtils.notNull(compoundingMethod, "compoundingMethod"); this.paymentDate = paymentDate; this.accrualPeriods = ImmutableList.copyOf(accrualPeriods); this.dayCount = dayCount; this.currency = currency; this.fxReset = fxReset; this.notional = notional; this.compoundingMethod = compoundingMethod; validate(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public Builder set(String propertyName, Object newValue) public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case -1540873516: // paymentDate this.paymentDate_Renamed = (LocalDate)newValue; break; case -92208605: // accrualPeriods this.accrualPeriods_Renamed = (IList <RateAccrualPeriod>)newValue; break; case 1905311443: // dayCount this.dayCount_Renamed = (DayCount)newValue; break; case 575402001: // currency this.currency_Renamed = (Currency)newValue; break; case -449555555: // fxReset this.fxReset_Renamed = (FxReset)newValue; break; case 1585636160: // notional this.notional_Renamed = (double?)newValue.Value; break; case -1376171496: // compoundingMethod this.compoundingMethod_Renamed = (CompoundingMethod)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
/// <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. /// </para> /// <para> /// The FX reset definition must be valid. It must have a reference currency that is /// different to that of this period, and the currency of this period must be /// one of those defined by the FX reset index. /// </para> /// </summary> /// <param name="fxReset"> the new value </param> /// <returns> this, for chaining, not null </returns> public Builder fxReset(FxReset fxReset) { this.fxReset_Renamed = fxReset; return(this); }
public void collectIndices(ImmutableSet.Builder <Index> builder) { accrualPeriods.ForEach(accrual => accrual.RateComputation.collectIndices(builder)); FxReset.ifPresent(fxReset => builder.add(fxReset.Index)); }
//------------------------------------------------------------------------- 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_serialization() { FxReset test = FxReset.of(FxIndexObservation.of(EUR_GBP_ECB, DATE_2014_06_30, REF_DATA), GBP); assertSerialization(test); }
public virtual void test_invalidCurrency() { assertThrowsIllegalArg(() => FxReset.meta().builder().set(FxReset.meta().observation(), FxIndexObservation.of(EUR_USD_ECB, DATE_2014_06_30, REF_DATA)).set(FxReset.meta().referenceCurrency(), GBP).build()); assertThrowsIllegalArg(() => FxReset.of(FxIndexObservation.of(EUR_USD_ECB, DATE_2014_06_30, REF_DATA), GBP)); }