public void test_ofIborInterpolatedRate() { IborRateStubCalculation test = IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_1M, GBP_LIBOR_3M); assertEquals(test.getFixedRate(), OptionalDouble.empty()); assertEquals(test.getIndex(), Optional.of(GBP_LIBOR_1M)); assertEquals(test.getIndexInterpolated(), Optional.of(GBP_LIBOR_3M)); assertEquals(test.isFixedRate(), false); assertEquals(test.isKnownAmount(), false); assertEquals(test.isFloatingRate(), true); assertEquals(test.isInterpolated(), true); }
public void test_ofFixedRate() { IborRateStubCalculation test = IborRateStubCalculation.ofFixedRate(0.025d); assertEquals(test.getFixedRate(), OptionalDouble.of(0.025d)); assertEquals(test.getIndex(), Optional.empty()); assertEquals(test.getIndexInterpolated(), Optional.empty()); assertEquals(test.isFixedRate(), true); assertEquals(test.isKnownAmount(), false); assertEquals(test.isFloatingRate(), false); assertEquals(test.isInterpolated(), false); }
public void test_ofIborRate() { IborRateStubCalculation test = IborRateStubCalculation.ofIborRate(GBP_LIBOR_3M); assertEquals(test.getFixedRate(), OptionalDouble.empty()); assertEquals(test.getIndex(), Optional.of(GBP_LIBOR_3M)); assertEquals(test.getIndexInterpolated(), Optional.empty()); assertEquals(test.isFixedRate(), false); assertEquals(test.isKnownAmount(), false); assertEquals(test.isFloatingRate(), true); assertEquals(test.isInterpolated(), false); }
void collectIndices(ImmutableSet.Builder<Index> builder) { getIndex().ifPresent(idx -> builder.add(idx)); getIndexInterpolated().ifPresent(idx -> builder.add(idx)); }
void collectCurrencies(ImmutableSet.Builder<Currency> builder) { getKnownAmount().ifPresent(amt -> builder.add(amt.getCurrency())); getIndex().ifPresent(idx -> builder.add(idx.getCurrency())); getIndexInterpolated().ifPresent(idx -> builder.add(idx.getCurrency())); }
public void test_ofKnownAmount() { IborRateStubCalculation test = IborRateStubCalculation.ofKnownAmount(GBP_P1000); assertEquals(test.getFixedRate(), OptionalDouble.empty()); assertEquals(test.getKnownAmount(), Optional.of(GBP_P1000)); assertEquals(test.getIndex(), Optional.empty()); assertEquals(test.getIndexInterpolated(), Optional.empty()); assertEquals(test.isFixedRate(), false); assertEquals(test.isKnownAmount(), true); assertEquals(test.isFloatingRate(), false); assertEquals(test.isInterpolated(), false); }
Optional<IborIndex> stubIndex2Opt = findValue(row, leg, interpolatedField).map(s -> IborIndex.of(s)); if (stubRateOpt.isPresent() && !stubAmountOpt.isPresent() && !stubIndexOpt.isPresent() && !stubIndex2Opt.isPresent()) { return Optional.of(IborRateStubCalculation.ofFixedRate(stubRateOpt.get())); return Optional.of(IborRateStubCalculation.ofKnownAmount(CurrencyAmount.of(currency, stubAmountOpt.get()))); return Optional.of(IborRateStubCalculation.ofIborInterpolatedRate(stubIndexOpt.get(), stubIndex2Opt.get())); } else { return Optional.of(IborRateStubCalculation.ofIborRate(stubIndexOpt.get()));
public void test_ofIborInterpolatedRate_invalid_interpolatedSameIndex() { assertThrowsIllegalArg(() -> IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_3M, GBP_LIBOR_3M)); }
public void coverage() { IborRateStubCalculation test = IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_1M, GBP_LIBOR_3M); coverImmutableBean(test); IborRateStubCalculation test2 = IborRateStubCalculation.ofFixedRate(0.028d); coverBeanEquals(test, test2); IborRateStubCalculation test3 = IborRateStubCalculation.ofKnownAmount(GBP_P1000); coverBeanEquals(test, test3); }
/** * Creates the {@code RateComputation} for the stub. * * @param fixingDate the fixing date * @param defaultIndex the default index to use if the stub has no rules * @param refData the reference data * @return the rate observation */ RateComputation createRateComputation(LocalDate fixingDate, IborIndex defaultIndex, ReferenceData refData) { if (isInterpolated()) { return IborInterpolatedRateComputation.of(index, indexInterpolated, fixingDate, refData); } else if (isFloatingRate()) { return IborRateComputation.of(index, fixingDate, refData); } else if (isFixedRate()) { return FixedRateComputation.of(fixedRate); } else if (isKnownAmount()) { return KnownAmountRateComputation.of(knownAmount); } else { return IborRateComputation.of(defaultIndex, fixingDate, refData); } }
public void test_of_null() { assertThrowsIllegalArg(() -> IborRateStubCalculation.ofIborRate(null)); assertThrowsIllegalArg(() -> IborRateStubCalculation.ofIborInterpolatedRate(null, GBP_LIBOR_3M)); assertThrowsIllegalArg(() -> IborRateStubCalculation.ofIborInterpolatedRate(GBP_LIBOR_3M, null)); assertThrowsIllegalArg(() -> IborRateStubCalculation.ofIborInterpolatedRate(null, null)); }
.fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, EUTA)) .spread(ValueSchedule.of(0.001)) .initialStub(IborRateStubCalculation.ofFixedRate(0.05125)) .finalStub(IborRateStubCalculation.ofIborRate(EUR_EURIBOR_3M)) .build()) .build();
public void test_serialization() { IborRateStubCalculation test = IborRateStubCalculation.ofIborRate(GBP_LIBOR_3M); assertSerialization(test); }
public void test_createRateComputation_fixedRate() { IborRateStubCalculation test = IborRateStubCalculation.ofFixedRate(0.025d); assertEquals(test.createRateComputation(DATE, GBP_LIBOR_3M, REF_DATA), FixedRateComputation.of(0.025d)); }
public void test_createRateComputation_knownAmount() { IborRateStubCalculation test = IborRateStubCalculation.ofKnownAmount(GBP_P1000); assertEquals(test.createRateComputation(DATE, GBP_LIBOR_3M, REF_DATA), KnownAmountRateComputation.of(GBP_P1000)); }
if (firstRate != null && firstRegularRate == null && (initialStub == null || IborRateStubCalculation.NONE.equals(initialStub))) { return FixedRateComputation.of(firstRate); return firstNonNull(initialStub, IborRateStubCalculation.NONE).createRateComputation(fixingDate, index, refData); return firstNonNull(finalStub, IborRateStubCalculation.NONE).createRateComputation(fixingDate, index, refData);
.build()) .firstRegularRate(0.028d) .initialStub(IborRateStubCalculation.ofFixedRate(0.030d)) .build();
public void test_createRateComputation_NONE() { IborRateStubCalculation test = IborRateStubCalculation.NONE; assertEquals(test.createRateComputation(DATE, GBP_LIBOR_3M, REF_DATA), IborRateComputation.of(GBP_LIBOR_3M, DATE, REF_DATA)); }
private IborRateStubCalculation parseStubCalculation(XmlElement baseEl, FpmlDocument document) { Optional<XmlElement> rateOptEl = baseEl.findChild("stubRate"); if (rateOptEl.isPresent()) { return IborRateStubCalculation.ofFixedRate(document.parseDecimal(rateOptEl.get())); return IborRateStubCalculation.ofKnownAmount(document.parseCurrencyAmount(amountOptEl.get())); document.validateNotPresent(indexEl, "capRateSchedule"); document.validateNotPresent(indexEl, "floorRateSchedule"); return IborRateStubCalculation.ofIborRate((IborIndex) document.parseIndex(indexEl)); } else if (indicesEls.size() == 2) { XmlElement index1El = indicesEls.get(0); document.validateNotPresent(index2El, "capRateSchedule"); document.validateNotPresent(index2El, "floorRateSchedule"); return IborRateStubCalculation.ofIborInterpolatedRate( (IborIndex) document.parseIndex(index1El), (IborIndex) document.parseIndex(index2El));
public 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)); }