public void test_forecastValue() { double computed = PRICER.forecastValue(PAYMENT_PERIOD, ISSUER_CURVE); double expected = FIXED_RATE * NOTIONAL * YEAR_FRACTION; assertEquals(computed, expected); }
public void test_forecastValue_past() { double computed = PRICER.forecastValue(PAYMENT_PERIOD, ISSUER_CURVE_AFTER); assertEquals(computed, 0d); }
/** * Explains the present value of a single fixed coupon payment period. * <p> * This adds information to the {@link ExplainMapBuilder} to aid understanding of the calculation. * * @param period the period to price * @param discountFactors the discount factor provider * @param builder the builder to populate */ public void explainPresentValue( FixedCouponBondPaymentPeriod period, IssuerCurveDiscountFactors discountFactors, ExplainMapBuilder builder) { Currency currency = period.getCurrency(); LocalDate paymentDate = period.getPaymentDate(); explainBasics(period, builder, currency, paymentDate); if (paymentDate.isBefore(discountFactors.getValuationDate())) { builder.put(ExplainKey.COMPLETED, Boolean.TRUE); builder.put(ExplainKey.FORECAST_VALUE, CurrencyAmount.zero(currency)); builder.put(ExplainKey.PRESENT_VALUE, CurrencyAmount.zero(currency)); } else { builder.put(ExplainKey.DISCOUNT_FACTOR, discountFactors.discountFactor(paymentDate)); builder.put(ExplainKey.FORECAST_VALUE, CurrencyAmount.of(currency, forecastValue(period, discountFactors))); builder.put(ExplainKey.PRESENT_VALUE, CurrencyAmount.of(currency, presentValue(period, discountFactors))); } }
builder.put(ExplainKey.DISCOUNT_FACTOR, discountFactors.getDiscountFactors() .discountFactorWithSpread(paymentDate, zSpread, compoundedRateType, periodsPerYear)); builder.put(ExplainKey.FORECAST_VALUE, CurrencyAmount.of(currency, forecastValue(period, discountFactors))); builder.put(ExplainKey.PRESENT_VALUE, CurrencyAmount.of(currency, presentValueWithSpread(period, discountFactors, zSpread, compoundedRateType, periodsPerYear)));