public virtual void test_enum_SampleNamed_externals() { ExtendedEnum <SampleNamed> test = ExtendedEnum.of(typeof(SampleNamed)); assertEquals(test.externalNameGroups(), ImmutableSet.of("Foo", "Bar")); assertThrowsIllegalArg(() => test.externalNames("Rubbish")); ExternalEnumNames <SampleNamed> fooExternals = test.externalNames("Foo"); assertEquals(fooExternals.lookup("Foo1"), SampleNameds.STANDARD); assertEquals(fooExternals.lookup("Foo1", typeof(SampleNamed)), SampleNameds.STANDARD); assertEquals(fooExternals.lookup("Foo1", typeof(SampleNamed)), SampleNameds.STANDARD); assertEquals(fooExternals.externalNames(), ImmutableMap.of("Foo1", "Standard")); assertThrowsIllegalArg(() => fooExternals.lookup("Rubbish")); assertThrowsIllegalArg(() => fooExternals.lookup(null)); assertThrowsIllegalArg(() => fooExternals.lookup("Other", typeof(MoreSampleNameds))); assertEquals(fooExternals.ToString(), "ExternalEnumNames[SampleNamed:Foo]"); ExternalEnumNames <SampleNamed> barExternals = test.externalNames("Bar"); assertEquals(barExternals.lookup("Foo1"), MoreSampleNameds.MORE); assertEquals(barExternals.lookup("Foo2"), SampleNameds.STANDARD); assertEquals(barExternals.reverseLookup(MoreSampleNameds.MORE), "Foo1"); assertEquals(barExternals.reverseLookup(SampleNameds.STANDARD), "Foo2"); assertThrowsIllegalArg(() => barExternals.reverseLookup(OtherSampleNameds.OTHER)); assertEquals(barExternals.externalNames(), ImmutableMap.of("Foo1", "More", "Foo2", "Standard")); assertEquals(barExternals.ToString(), "ExternalEnumNames[SampleNamed:Bar]"); }
public virtual void test_of() { FixedCouponBondPaymentPeriod test = FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(DETACHMENT_DATE).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build(); assertEquals(test.Currency, USD); assertEquals(test.UnadjustedStartDate, START); assertEquals(test.StartDate, START_ADJUSTED); assertEquals(test.UnadjustedEndDate, END); assertEquals(test.EndDate, END_ADJUSTED); assertEquals(test.PaymentDate, END_ADJUSTED); assertEquals(test.DetachmentDate, DETACHMENT_DATE); assertEquals(test.FixedRate, FIXED_RATE); assertEquals(test.Notional, NOTIONAL); assertEquals(test.YearFraction, YEAR_FRACTION); assertEquals(test.hasExCouponPeriod(), true); // the object is not changed assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(2))), test); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(test.Currency, USD); assertEquals(test.UnadjustedStartDate, START); assertEquals(test.StartDate, START_ADJUSTED); assertEquals(test.UnadjustedEndDate, END); assertEquals(test.EndDate, END_ADJUSTED); assertEquals(test.PaymentDate, END_ADJUSTED); assertEquals(test.DetachmentDate, DETACHMENT_DATE); assertEquals(test.FixedRate, FIXED_RATE); assertEquals(test.Notional, NOTIONAL); assertEquals(test.YearFraction, YEAR_FRACTION); assertEquals(test.hasExCouponPeriod(), true); }
//------------------------------------------------------------------------- public virtual void test_collectIndices() { InflationRateCalculation test = InflationRateCalculation.builder().index(GB_HICP).lag(Period.ofMonths(3)).indexCalculationMethod(MONTHLY).build(); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GB_HICP)); }
//------------------------------------------------------------------------- public virtual void test_collectIndices() { OvernightCompoundedRateComputation test = OvernightCompoundedRateComputation.of(USD_FED_FUND, date(2016, 2, 24), date(2016, 3, 24), REF_DATA); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(USD_FED_FUND)); }
public virtual void test_collectIndices() { ResolvedSwapLeg test = ResolvedSwapLeg.builder().type(IBOR).payReceive(RECEIVE).paymentPeriods(RPP1).paymentEvents(NOTIONAL_EXCHANGE).build(); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M)); }
//------------------------------------------------------------------------- public virtual void test_collectIndices() { IborInterpolatedRateComputation test = IborInterpolatedRateComputation.of(GBP_LIBOR_1M, GBP_LIBOR_3M, FIXING_DATE, REF_DATA); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_1M, GBP_LIBOR_3M)); }
//------------------------------------------------------------------------- public virtual void test_collectIndices_simple() { KnownAmountRateComputation test = KnownAmountRateComputation.of(GBP_P1000); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of()); }
public virtual void test_of_oneLeg() { ResolvedCms test = ResolvedCms.of(CMS_LEG); assertEquals(test.CmsLeg, CMS_LEG); assertFalse(test.PayLeg.Present); assertEquals(test.allPaymentCurrencies(), ImmutableSet.of(CMS_LEG.Currency)); }
//------------------------------------------------------------------------- public virtual void test_collectIndices() { IborRateComputation test = IborRateComputation.of(GBP_LIBOR_3M, date(2014, 6, 30), REF_DATA); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M)); }
//------------------------------------------------------------------------- public virtual void test_collectIndices() { InflationEndMonthRateComputation test = InflationEndMonthRateComputation.of(GB_HICP, START_INDEX, END_MONTH); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GB_HICP)); }
public virtual void test_collectIndices_fxReset() { RatePaymentPeriod test = RatePaymentPeriod.builder().paymentDate(DATE_2014_10_01).accrualPeriods(RAP2).dayCount(ACT_365F).currency(GBP).notional(1000d).fxReset(FX_RESET_USD).compoundingMethod(CompoundingMethod.STRAIGHT).build(); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M, GBP_USD_WM)); }
//------------------------------------------------------------------------- public virtual void test_collectIndices() { InflationInterpolatedRateComputation test = InflationInterpolatedRateComputation.of(GB_HICP, START_MONTH_FIRST, END_MONTH_FIRST, WEIGHT); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GB_HICP)); }
//------------------------------------------------------------------------- public virtual void test_collectIndices() { FixedRateCalculation test = FixedRateCalculation.builder().dayCount(ACT_365F).rate(ValueSchedule.of(0.025d)).build(); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of()); }
//------------------------------------------------------------------------- public virtual void test_collectIndices_simple() { KnownAmountSwapPaymentPeriod test = KnownAmountSwapPaymentPeriod.builder().payment(PAYMENT_2014_10_03).startDate(DATE_2014_03_30).unadjustedStartDate(DATE_2014_03_30).endDate(DATE_2014_10_01).unadjustedEndDate(DATE_2014_09_30).build(); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of()); }
//------------------------------------------------------------------------- public virtual void test_collectIndices() { FixedRateComputation test = FixedRateComputation.of(0.05); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of()); }
//------------------------------------------------------------------------- public virtual void test_of_twoLegs() { ResolvedCms test = sut(); assertEquals(test.CmsLeg, CMS_LEG); assertEquals(test.PayLeg.get(), PAY_LEG); assertEquals(test.allPaymentCurrencies(), ImmutableSet.of(CMS_LEG.Currency)); }
//------------------------------------------------------------------------- public virtual void test_collectIndices() { OvernightRateCalculation test = OvernightRateCalculation.builder().dayCount(ACT_365F).index(GBP_SONIA).build(); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GBP_SONIA)); }
//------------------------------------------------------------------------- public virtual void test_collectIndices() { IborAveragedRateComputation test = IborAveragedRateComputation.of(FIXINGS); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M)); }
public virtual void test_collectIndices_stubCalcsTwoStubs_interpolated() { IborRateCalculation test = IborRateCalculation.builder().dayCount(ACT_365F).index(GBP_LIBOR_1M).fixingDateOffset(MINUS_TWO_DAYS).initialStub(IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_1W, GBP_LIBOR_1M)).finalStub(IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_3M, GBP_LIBOR_1M)).build(); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_1M, GBP_LIBOR_1W, GBP_LIBOR_3M)); }
//------------------------------------------------------------------------- public virtual void test_collectIndices_simple() { IborRateCalculation test = IborRateCalculation.builder().dayCount(ACT_365F).index(GBP_LIBOR_1M).fixingDateOffset(MINUS_TWO_DAYS).build(); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_1M)); }
public virtual void test_collectIndices_fxReset() { SchedulePeriod sched = SchedulePeriod.of(DATE_2014_03_30, DATE_2014_09_30); KnownAmountNotionalSwapPaymentPeriod test = KnownAmountNotionalSwapPaymentPeriod.of(PAYMENT_2014_10_03, sched, USD_P50000, FX_RESET); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(FX_RESET.Index)); }
//------------------------------------------------------------------------- public virtual void test_fxIndexRates() { LocalDateDoubleTimeSeries ts = LocalDateDoubleTimeSeries.of(VAL_DATE, 0.62d); ImmutableRatesProvider test = ImmutableRatesProvider.builder(VAL_DATE).fxRateProvider(FX_MATRIX).discountCurve(GBP, DISCOUNT_CURVE_GBP).discountCurve(USD, DISCOUNT_CURVE_USD).timeSeries(GBP_USD_WM, ts).build(); assertEquals(test.fxIndexRates(GBP_USD_WM).Index, GBP_USD_WM); assertEquals(test.fxIndexRates(GBP_USD_WM).Fixings, ts); assertEquals(test.TimeSeriesIndices, ImmutableSet.of(GBP_USD_WM)); }
//------------------------------------------------------------------------- public virtual void test_builder() { BondFutureOptionSecurity test = sut(); assertEquals(test.Info, INFO); assertEquals(test.SecurityId, PRODUCT.SecurityId); assertEquals(test.Currency, PRODUCT.Currency); assertEquals(test.UnderlyingIds, ImmutableSet.of(PRODUCT.UnderlyingFuture.SecurityId)); }
//------------------------------------------------------------------------- public virtual void test_builder() { OvernightFutureSecurity test = sut(); assertEquals(test.Info, INFO); assertEquals(test.SecurityId, PRODUCT.SecurityId); assertEquals(test.Currency, PRODUCT.Currency); assertEquals(test.UnderlyingIds, ImmutableSet.of()); }
//------------------------------------------------------------------------- public virtual void test_collectIndices() { KnownAmountSwapLeg test = KnownAmountSwapLeg.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(DaysAdjustment.ofBusinessDays(2, GBLO)).build()).amount(ValueSchedule.of(123d)).currency(GBP).build(); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of()); assertEquals(test.allIndices(), ImmutableSet.of()); }
public virtual void test_builder() { ResolvedSwap test = ResolvedSwap.builder().legs(LEG1).build(); assertEquals(test.Legs, ImmutableSet.of(LEG1)); assertEquals(test.CrossCurrency, false); assertEquals(test.allPaymentCurrencies(), ImmutableSet.of(GBP)); assertEquals(test.allIndices(), ImmutableSet.of(GBP_LIBOR_3M)); }
public virtual void test_collectIndices_fxReset() { RatePeriodSwapLeg test = RatePeriodSwapLeg.builder().type(IBOR).payReceive(RECEIVE).paymentPeriods(RPP1_FXRESET).build(); ImmutableSet.Builder <Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M, GBP_USD_WM)); assertEquals(test.allCurrencies(), ImmutableSet.of(GBP, USD)); }
public virtual void test_of_singleCurrency() { ResolvedSwap test = ResolvedSwap.of(LEG1); assertEquals(test.Legs, ImmutableSet.of(LEG1)); assertEquals(test.CrossCurrency, false); assertEquals(test.allPaymentCurrencies(), ImmutableSet.of(GBP)); assertEquals(test.allIndices(), ImmutableSet.of(GBP_LIBOR_3M)); }
public virtual void test_of_twoLegs() { ResolvedIborCapFloor test = ResolvedIborCapFloor.of(CAPFLOOR_LEG, PAY_LEG); assertEquals(test.CapFloorLeg, CAPFLOOR_LEG); assertEquals(test.PayLeg.get(), PAY_LEG); assertEquals(test.allPaymentCurrencies(), ImmutableSet.of(EUR)); assertEquals(test.allIndices(), ImmutableSet.of(EUR_EURIBOR_3M)); }
//------------------------------------------------------------------------- public virtual void test_priceIndexValues() { LocalDateDoubleTimeSeries ts = LocalDateDoubleTimeSeries.of(VAL_DATE, 0.62d); ImmutableRatesProvider test = ImmutableRatesProvider.builder(VAL_DATE).priceIndexCurve(GB_RPI, GBPRI_CURVE).timeSeries(GB_RPI, ts).build(); assertEquals(test.priceIndexValues(GB_RPI).Index, GB_RPI); assertEquals(test.priceIndexValues(GB_RPI).Fixings, ts); assertEquals(test.PriceIndices, ImmutableSet.of(GB_RPI)); assertEquals(test.TimeSeriesIndices, ImmutableSet.of(GB_RPI)); }