public void test_of() { IborRateComputation test = IborRateComputation.of(USD_LIBOR_3M, date(2016, 2, 18), REF_DATA); IborIndexObservation obs = IborIndexObservation.of(USD_LIBOR_3M, date(2016, 2, 18), REF_DATA); IborRateComputation expected = IborRateComputation.of(obs); assertEquals(test, expected); assertEquals(test.getCurrency(), USD); assertEquals(test.getIndex(), obs.getIndex()); assertEquals(test.getFixingDate(), obs.getFixingDate()); assertEquals(test.getEffectiveDate(), obs.getEffectiveDate()); assertEquals(test.getMaturityDate(), obs.getMaturityDate()); assertEquals(test.getYearFraction(), obs.getYearFraction()); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 122345516: // observation return ((IborRateComputation) bean).getObservation(); } return super.propertyGet(bean, propertyName, quiet); }
/** * Creates an instance from the underlying index observation. * * @param underlyingObservation the underlying index observation * @return the rate computation */ public static IborRateComputation of(IborIndexObservation underlyingObservation) { return new IborRateComputation(underlyingObservation); }
/** * Gets the fixing date-time of the index. * * @return the fixing date-time */ public ZonedDateTime getFixingDateTime() { return iborRate.getIndex().calculateFixingDateTime(iborRate.getFixingDate()); }
@Override public double rate( IborRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider) { IborIndexRates rates = provider.iborIndexRates(computation.getIndex()); return rates.rate(computation.getObservation()); }
public 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)); }
/** * Gets the last date of trading, which is the same as the fixing date. * <p> * This is typically 2 business days before the IMM date (3rd Wednesday of the month). * By including this method, it allows for the possibility of a future where the fixing date * and last trade date differ. * * @return the last trade date */ public LocalDate getLastTradeDate() { return iborRate.getFixingDate(); }
@Override public ResolvedIborFuture resolve(ReferenceData refData) { IborRateComputation iborRate = IborRateComputation.of(index, lastTradeDate, refData); return new ResolvedIborFuture(securityId, currency, notional, accrualFactor, iborRate, rounding); }
/** * Gets the Ibor index that the future is based on. * * @return the Ibor index */ public IborIndex getIndex() { return iborRate.getIndex(); }
/** * Gets the fixing date of the index. * * @return the fixing date */ public LocalDate getFixingDate() { return iborRate.getFixingDate(); }
private RateComputation createRateComputation(ReferenceData refData) { LocalDate fixingDate = fixingDateOffset.adjust(startDate, refData); if (indexInterpolated != null) { return IborInterpolatedRateComputation.of(index, indexInterpolated, fixingDate, refData); } else { return IborRateComputation.of(index, fixingDate, refData); } }
ExplainMap explainObs = explain.get(ExplainKey.OBSERVATIONS).get().get(0); IborRateComputation floatingRate = (IborRateComputation) fraExp.getFloatingRate(); assertEquals(explainObs.get(ExplainKey.INDEX).get(), floatingRate.getIndex()); assertEquals(explainObs.get(ExplainKey.FIXING_DATE).get(), floatingRate.getFixingDate()); assertEquals(explainObs.get(ExplainKey.INDEX_VALUE).get(), FORWARD_RATE, TOLERANCE); assertEquals(explainObs.get(ExplainKey.FROM_FIXING_SERIES).isPresent(), false);
@Override public PointSensitivityBuilder rateSensitivity( IborRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider) { IborIndexRates rates = provider.iborIndexRates(computation.getIndex()); return rates.ratePointSensitivity(computation.getObservation()); }
/** * Gets the Ibor index. * * @return the ibor index */ public IborIndex getIndex() { return iborRate.getIndex(); }
private LocalDate calculateLastFixingDate(LocalDate valuationDate, ReferenceData refData) { SwapTrade trade = template.createTrade(valuationDate, BuySell.BUY, 1, 1, refData); SwapLeg iborLeg = trade.getProduct().getLegs(SwapLegType.IBOR).get(0); ResolvedSwapLeg iborLegExpanded = iborLeg.resolve(refData); List<SwapPaymentPeriod> periods = iborLegExpanded.getPaymentPeriods(); int nbPeriods = periods.size(); RatePaymentPeriod lastPeriod = (RatePaymentPeriod) periods.get(nbPeriods - 1); List<RateAccrualPeriod> accruals = lastPeriod.getAccrualPeriods(); int nbAccruals = accruals.size(); IborRateComputation ibor = (IborRateComputation) accruals.get(nbAccruals - 1).getRateComputation(); return ibor.getFixingDate(); }
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)); }
double rate = obsFunc.rate(observation, period.getStartDate(), period.getEndDate(), provider); if (i == j) { fixingDate = observation.getFixingDate(); index = observation.getIndex(); when(obsFuncUp.rate(observation, period.getStartDate(), period.getEndDate(), provNew)).thenReturn(rate + eps); when(obsFuncDown.rate(observation, period.getStartDate(), period.getEndDate(), provNew))
/** * Calculates the price sensitivity of the Ibor future product. * <p> * The price sensitivity of the product is the sensitivity of the price to the underlying curves. * * @param future the future * @param ratesProvider the rates provider * @return the price curve sensitivity of the product */ public PointSensitivities priceSensitivity(ResolvedIborFuture future, RatesProvider ratesProvider) { IborRateSensitivity sensi = IborRateSensitivity.of(future.getIborRate().getObservation(), -1d); // The sensitivity should be to no currency or currency XXX. To avoid useless conversion, the dimension-less // price sensitivity is reported in the future currency. return PointSensitivities.of(sensi); }
@Override public double explainRate( IborRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider, ExplainMapBuilder builder) { IborIndexRates rates = provider.iborIndexRates(computation.getIndex()); double rate = rates.explainRate(computation.getObservation(), builder, child -> {}); builder.put(ExplainKey.COMBINED_RATE, rate); return rate; }
@Override public void collectIndices(ImmutableSet.Builder<Index> builder) { builder.add(getIndex()); }