public void test_presentValue_aftermaturity() { CurrencyAmount pvComputed = PRICER.presentValue(BILL_PAST, PROVIDER); assertEquals(pvComputed.getCurrency(), EUR); assertEquals(pvComputed.getAmount(), 0.0d, TOLERANCE_PV); } public void test_presentValue_zspread() {
public void presentValueSensitivity() { PointSensitivities sensiComputed = PRICER.presentValueSensitivity(BILL, PROVIDER); PointSensitivities sensiExpected = IssuerCurveDiscountFactors.of(DSC_FACTORS_ISSUER, GROUP_ISSUER) .zeroRatePointSensitivity(MATURITY_DATE) .multipliedBy(NOTIONAL.getAmount()).build(); assertTrue(sensiComputed.equalWithTolerance(sensiExpected, TOLERANCE_PV)); CurrencyParameterSensitivities paramSensiComputed = PROVIDER.parameterSensitivity(sensiComputed); CurrencyParameterSensitivities paramSensiExpected = FD_CALC.sensitivity(PROVIDER, p -> PRICER.presentValue(BILL, p)); assertTrue(paramSensiComputed.equalWithTolerance(paramSensiExpected, EPS * NOTIONAL_AMOUNT)); }
public void test_presentValue() { CurrencyAmount pvComputed = PRICER.presentValue(BILL, PROVIDER); double pvExpected = DSC_FACTORS_ISSUER.discountFactor(MATURITY_DATE) * NOTIONAL.getAmount(); assertEquals(pvComputed.getCurrency(), EUR); assertEquals(pvComputed.getAmount(), pvExpected, TOLERANCE_PV); }
public void test_presentValue_settle_on_val() { CurrencyAmount pvComputed = PRICER_TRADE.presentValue(BILL_TRADE_SETTLE_ON_VAL, PROVIDER); CurrencyAmount pvExpected = PRICER_PRODUCT.presentValue(BILL_PRODUCT.resolve(REF_DATA), PROVIDER) .plus(-PRICE * NOTIONAL_AMOUNT) .multipliedBy(QUANTITY); assertEquals(pvComputed.getCurrency(), EUR); assertEquals(pvComputed.getAmount(), pvExpected.getAmount(), TOLERANCE_PV); MultiCurrencyAmount ceComputed = PRICER_TRADE.currencyExposure(BILL_TRADE_SETTLE_ON_VAL, PROVIDER); assertEquals(ceComputed.getCurrencies().size(), 1); assertTrue(ceComputed.contains(EUR)); assertEquals(ceComputed.getAmount(EUR).getAmount(), pvExpected.getAmount(), TOLERANCE_PV); CurrencyAmount cashComputed = PRICER_TRADE.currentCash(BILL_TRADE_SETTLE_ON_VAL, VAL_DATE); assertEquals(cashComputed.getCurrency(), EUR); assertEquals(cashComputed.getAmount(), -PRICE * NOTIONAL_AMOUNT * QUANTITY, TOLERANCE_PV); }
public void test_presentValue_settle_before_val() { CurrencyAmount pvComputed = PRICER_TRADE.presentValue(BILL_TRADE_SETTLE_BEFORE_VAL, PROVIDER); CurrencyAmount pvExpected = PRICER_PRODUCT.presentValue(BILL_PRODUCT.resolve(REF_DATA), PROVIDER) .multipliedBy(QUANTITY); assertEquals(pvComputed.getCurrency(), EUR); assertEquals(pvComputed.getAmount(), pvExpected.getAmount(), TOLERANCE_PV); MultiCurrencyAmount ceComputed = PRICER_TRADE.currencyExposure(BILL_TRADE_SETTLE_BEFORE_VAL, PROVIDER); assertEquals(ceComputed.getCurrencies().size(), 1); assertTrue(ceComputed.contains(EUR)); assertEquals(ceComputed.getAmount(EUR).getAmount(), pvExpected.getAmount(), TOLERANCE_PV); CurrencyAmount cashComputed = PRICER_TRADE.currentCash(BILL_TRADE_SETTLE_BEFORE_VAL, VAL_DATE); assertEquals(cashComputed.getCurrency(), EUR); assertEquals(cashComputed.getAmount(), 0, TOLERANCE_PV); }
public void test_presentValue_settle_after_val() { CurrencyAmount pvComputed = PRICER_TRADE.presentValue(BILL_TRADE_SETTLE_AFTER_VAL, PROVIDER); CurrencyAmount pvExpected = PRICER_PRODUCT.presentValue(BILL_PRODUCT.resolve(REF_DATA), PROVIDER) .multipliedBy(QUANTITY) .plus(PRICER_PAYMENT.presentValue(BILL_TRADE_SETTLE_AFTER_VAL.getSettlement().get(), PROVIDER.repoCurveDiscountFactors(BILL_PRODUCT.getSecurityId(), BILL_PRODUCT.getLegalEntityId(), BILL_PRODUCT.getCurrency()) .getDiscountFactors())); assertEquals(pvComputed.getCurrency(), EUR); assertEquals(pvComputed.getAmount(), pvExpected.getAmount(), TOLERANCE_PV); MultiCurrencyAmount ceComputed = PRICER_TRADE.currencyExposure(BILL_TRADE_SETTLE_AFTER_VAL, PROVIDER); assertEquals(ceComputed.getCurrencies().size(), 1); assertTrue(ceComputed.contains(EUR)); assertEquals(ceComputed.getAmount(EUR).getAmount(), pvExpected.getAmount(), TOLERANCE_PV); CurrencyAmount cashComputed = PRICER_TRADE.currentCash(BILL_TRADE_SETTLE_AFTER_VAL, VAL_DATE); assertEquals(cashComputed.getCurrency(), EUR); assertEquals(cashComputed.getAmount(), 0, TOLERANCE_PV); }
/** * Calculates the present value of a bill trade. * <p> * If the settlement details are provided, the present value is the sum of the underlying product's present value * multiplied by the quantity and the present value of the settlement payment if still due at the valuation date. * If not it is the underlying product's present value multiplied by the quantity. * * @param trade the trade * @param provider the discounting provider * @return the present value */ public CurrencyAmount presentValue(ResolvedBillTrade trade, LegalEntityDiscountingProvider provider) { if (provider.getValuationDate().isAfter(trade.getProduct().getNotional().getDate())) { return CurrencyAmount.of(trade.getProduct().getCurrency(), 0.0d); } CurrencyAmount pvProduct = productPricer.presentValue(trade.getProduct(), provider) .multipliedBy(trade.getQuantity()); if (trade.getSettlement().isPresent()) { RepoCurveDiscountFactors repoDf = DiscountingBillProductPricer.repoCurveDf(trade.getProduct(), provider); CurrencyAmount pvSettle = paymentPricer.presentValue(trade.getSettlement().get(), repoDf.getDiscountFactors()); return pvProduct.plus(pvSettle); } return pvProduct; }