private CurrencyAmount presentValueFromProductPresentValue( ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider, CurrencyAmount productPresentValue) { CurrencyAmount pvProduct = productPresentValue.multipliedBy(trade.getQuantity()); CurrencyAmount pvPayment = presentValuePayment(trade, provider); return pvProduct.plus(pvPayment); }
private CurrencyAmount presentValueFromProductPresentValue( ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, CurrencyAmount productPresentValue) { CurrencyAmount pvProduct = productPresentValue.multipliedBy(trade.getQuantity()); CurrencyAmount pvPayment = presentValueSettlement(trade, ratesProvider, discountingProvider); return pvProduct.plus(pvPayment); }
public void test_plus_double() { CurrencyAmount test = CCY_AMOUNT.plus(AMT2); assertEquals(test, CurrencyAmount.of(CCY1, AMT1 + AMT2)); }
public void test_plus_CurrencyAmount_null() { assertThrowsIllegalArg(() -> CCY_AMOUNT.plus(null)); }
public void test_plus_CurrencyAmount() { CurrencyAmount ccyAmount = CurrencyAmount.of(CCY1, AMT2); CurrencyAmount test = CCY_AMOUNT.plus(ccyAmount); assertEquals(test, CurrencyAmount.of(CCY1, AMT1 + AMT2)); }
CurrencyAmount presentValue( ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, LocalDate referenceDate) { IssuerCurveDiscountFactors issuerDf = issuerCurveDf(bond, provider); CurrencyAmount pvNominal = nominalPricer.presentValue(bond.getNominalPayment(), issuerDf.getDiscountFactors()); CurrencyAmount pvCoupon = presentValueCoupon(bond, issuerDf, referenceDate); return pvNominal.plus(pvCoupon); }
public void test_presentValue() { MultiCurrencyAmount computed1 = PRICER.presentValue(CAP_ONE_LEG, RATES, VOLS); MultiCurrencyAmount computed2 = PRICER.presentValue(CAP_TWO_LEGS, RATES, VOLS); CurrencyAmount cap = PRICER_CAP_LEG.presentValue(CAP_LEG, RATES, VOLS); CurrencyAmount pay = PRICER_PAY_LEG.presentValue(PAY_LEG, RATES); assertEquals(computed1, MultiCurrencyAmount.of(cap)); assertEquals(computed2, MultiCurrencyAmount.of(cap.plus(pay))); }
public void test_presentValue() { MultiCurrencyAmount computed1 = PRICER.presentValue(CAP_ONE_LEG, RATES, VOLS); MultiCurrencyAmount computed2 = PRICER.presentValue(CAP_TWO_LEGS, RATES, VOLS); CurrencyAmount cap = PRICER_CAP_LEG.presentValue(CAP_LEG, RATES, VOLS); CurrencyAmount pay = PRICER_PAY_LEG.presentValue(PAY_LEG, RATES); assertEquals(computed1, MultiCurrencyAmount.of(cap)); assertEquals(computed2, MultiCurrencyAmount.of(cap.plus(pay))); }
public void test_presentValue() { MultiCurrencyAmount computed1 = PRICER.presentValue(CAP_ONE_LEG, RATES, VOLS); MultiCurrencyAmount computed2 = PRICER.presentValue(CAP_TWO_LEGS, RATES, VOLS); CurrencyAmount cap = PRICER_CAP_LEG.presentValue(CAP_LEG, RATES, VOLS); CurrencyAmount pay = PRICER_PAY_LEG.presentValue(PAY_LEG, RATES); assertEquals(computed1, MultiCurrencyAmount.of(cap)); assertEquals(computed2, MultiCurrencyAmount.of(cap.plus(pay))); }
public void test_convertedTo_rateProvider_conversionSize2() { FxRateProvider provider = (ccy1, ccy2) -> { if (ccy1.equals(ccy2)) { return 1d; } if (ccy1.equals(CCY1) && ccy2.equals(CCY2)) { return 2.5d; } throw new IllegalArgumentException(); }; MultiCurrencyAmount test = MultiCurrencyAmount.of(CA1, CA2); assertEquals(test.convertedTo(CCY2, provider), CA2.plus(CurrencyAmount.of(CCY2, AMT1 * 2.5d))); }
public void coverage() { KnownAmountRateComputation test = KnownAmountRateComputation.of(GBP_P1000); coverImmutableBean(test); KnownAmountRateComputation test2 = KnownAmountRateComputation.of(GBP_P1000.plus(100)); coverBeanEquals(test, test2); }
public void test_presentValue_noExcoupon() { CurrencyAmount computed = PRICER.presentValue(PRODUCT_NO_EXCOUPON, PROVIDER); CurrencyAmount expected = PRICER_NOMINAL.presentValue(PRODUCT.getNominalPayment(), DSC_FACTORS_ISSUER); int size = PRODUCT.getPeriodicPayments().size(); double pvcCupon = 0d; for (int i = 2; i < size; ++i) { FixedCouponBondPaymentPeriod payment = PRODUCT.getPeriodicPayments().get(i); pvcCupon += PRICER_COUPON.presentValue(payment, IssuerCurveDiscountFactors.of(DSC_FACTORS_ISSUER, GROUP_ISSUER)); } expected = expected.plus(pvcCupon); assertEquals(computed.getCurrency(), EUR); assertEquals(computed.getAmount(), expected.getAmount(), NOTIONAL * TOL); }
public void test_presentValue_noExcoupon() { CurrencyAmount computedTrade = TRADE_PRICER.presentValue(TRADE_NO_EXCOUPON, PROVIDER); CurrencyAmount computedProduct = PRODUCT_PRICER.presentValue(PRODUCT_NO_EXCOUPON, PROVIDER, SETTLEMENT); CurrencyAmount pvPayment = PRICER_NOMINAL.presentValue(UPFRONT_PAYMENT, ZeroRateDiscountFactors.of(EUR, VAL_DATE, CURVE_REPO)); assertEquals(computedTrade.getAmount(), computedProduct.multipliedBy(QUANTITY).plus(pvPayment).getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_presentValue() { CurrencyAmount computedTrade = TRADE_PRICER.presentValue(TRADE, PROVIDER); CurrencyAmount computedProduct = PRODUCT_PRICER.presentValue(PRODUCT, PROVIDER, SETTLEMENT); CurrencyAmount pvPayment = PRICER_NOMINAL.presentValue(UPFRONT_PAYMENT, ZeroRateDiscountFactors.of(EUR, VAL_DATE, CURVE_REPO)); assertEquals(computedTrade.getAmount(), computedProduct.multipliedBy(QUANTITY).plus(pvPayment).getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_presentValueWithZSpread_periodic() { CurrencyAmount computedTrade = TRADE_PRICER.presentValueWithZSpread(TRADE, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); CurrencyAmount computedProduct = PRODUCT_PRICER.presentValueWithZSpread( PRODUCT, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR, SETTLEMENT); CurrencyAmount pvPayment = PRICER_NOMINAL.presentValue(UPFRONT_PAYMENT, ZeroRateDiscountFactors.of(EUR, VAL_DATE, CURVE_REPO)); assertEquals(computedTrade.getAmount(), computedProduct.multipliedBy(QUANTITY).plus(pvPayment).getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_presentValueWithZSpread_continuous_noExcoupon() { CurrencyAmount computedTrade = TRADE_PRICER.presentValueWithZSpread(TRADE_NO_EXCOUPON, PROVIDER, Z_SPREAD, CONTINUOUS, 0); CurrencyAmount computedProduct = PRODUCT_PRICER.presentValueWithZSpread( PRODUCT_NO_EXCOUPON, PROVIDER, Z_SPREAD, CONTINUOUS, 0, SETTLEMENT); CurrencyAmount pvPayment = PRICER_NOMINAL.presentValue(UPFRONT_PAYMENT, ZeroRateDiscountFactors.of(EUR, VAL_DATE, CURVE_REPO)); assertEquals(computedTrade.getAmount(), computedProduct.multipliedBy(QUANTITY).plus(pvPayment).getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_presentValueWithZSpread_periodic_noExcoupon() { CurrencyAmount computedTrade = TRADE_PRICER.presentValueWithZSpread( TRADE_NO_EXCOUPON, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); CurrencyAmount computedProduct = PRODUCT_PRICER.presentValueWithZSpread( PRODUCT_NO_EXCOUPON, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR, SETTLEMENT); CurrencyAmount pvPayment = PRICER_NOMINAL.presentValue(UPFRONT_PAYMENT, ZeroRateDiscountFactors.of(EUR, VAL_DATE, CURVE_REPO)); assertEquals(computedTrade.getAmount(), computedProduct.multipliedBy(QUANTITY).plus(pvPayment).getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_presentValueWithZSpread_continuous() { CurrencyAmount computedTrade = TRADE_PRICER.presentValueWithZSpread( TRADE, PROVIDER, Z_SPREAD, CONTINUOUS, 0); CurrencyAmount computedProduct = PRODUCT_PRICER.presentValueWithZSpread(PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0, SETTLEMENT); CurrencyAmount pvPayment = PRICER_NOMINAL.presentValue(UPFRONT_PAYMENT, ZeroRateDiscountFactors.of(EUR, VAL_DATE, CURVE_REPO)); assertEquals(computedTrade.getAmount(), computedProduct.multipliedBy(QUANTITY).plus(pvPayment).getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_presentValue() { CurrencyAmount computed = PRICER.presentValue(TRADE, RATES_PROVIDER, PriceType.CLEAN, REF_DATA); CurrencyAmount expected = PRICER_PRODUCT.presentValue(PRODUCT, RATES_PROVIDER, VALUATION_DATE, PriceType.CLEAN, REF_DATA) .plus(PRICER_PAYMENT.presentValue(UPFRONT, YIELD_CRVE.toDiscountFactors())); CurrencyAmount computedMf = PRICER_MF.presentValue(TRADE_NO_SETTLE_DATE, RATES_PROVIDER, PriceType.CLEAN, REF_DATA); CurrencyAmount expectedMf = PRICER_PRODUCT_MF.presentValue(PRODUCT, RATES_PROVIDER, VALUATION_DATE, PriceType.CLEAN, REF_DATA); assertEquals(computed.getAmount(), expected.getAmount(), TOL); assertEquals(computedMf.getAmount(), expectedMf.getAmount(), TOL); }
public void test_presentValue() { CurrencyAmount computed = PRICER.presentValue(TRADE, RATES_PROVIDER, PriceType.CLEAN, REF_DATA); CurrencyAmount expected = PRICER_PRODUCT.presentValue(PRODUCT, RATES_PROVIDER, VALUATION_DATE, PriceType.CLEAN, REF_DATA) .plus(PRICER_PAYMENT.presentValue(UPFRONT, YIELD_CRVE.toDiscountFactors())); CurrencyAmount computedMf = PRICER_MF.presentValue(TRADE_NO_SETTLE_DATE, RATES_PROVIDER, PriceType.CLEAN, REF_DATA); CurrencyAmount expectedMf = PRICER_PRODUCT_MF.presentValue(PRODUCT, RATES_PROVIDER, VALUATION_DATE, PriceType.CLEAN, REF_DATA); assertEquals(computed.getAmount(), expected.getAmount(), TOL); assertEquals(computedMf.getAmount(), expectedMf.getAmount(), TOL); }