public void test_currentCash_exCoupon() { CurrencyAmount computed = PRICER.currentCash(PRODUCT_EX_COUPON, RATES_PROVIDER, VALUATION); assertEquals(computed.getAmount(), 0d); }
public void test_currentCash_onPayment_exCoupon() { CurrencyAmount computed = PRICER.currentCash(PRODUCT_EX_COUPON, RATES_PROVIDER_ON_PAY, VALUATION_ON_PAY); assertEquals(computed.getAmount(), 0d); }
public void test_currentCash() { CurrencyAmount computed = PRICER.currentCash(PRODUCT, RATES_PROVIDER, VALUATION); assertEquals(computed.getAmount(), 0d); }
public void test_currentCash() { CurrencyAmount computed = PRICER.currentCash(TRADE_SETTLED, RATES_PROVIDER_ON_PAY); CurrencyAmount expected = PRODUCT_PRICER.currentCash(RPRODUCT, RATES_PROVIDER_ON_PAY, SETTLEMENT_BEFORE); assertEquals(computed.getAmount(), expected.getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_currentCash_position() { CurrencyAmount computed = PRICER.currentCash(POSITION, RATES_PROVIDER_ON_PAY); CurrencyAmount expected = PRODUCT_PRICER.currentCash(RPRODUCT, RATES_PROVIDER_ON_PAY, PAYMENT); assertEquals(computed.getAmount(), expected.getAmount(), NOTIONAL * QUANTITY * TOL); }
public void test_currentCash_onPayment() { CurrencyAmount computed = PRICER.currentCash(PRODUCT, RATES_PROVIDER_ON_PAY, VALUATION_ON_PAY.minusDays(7)); double expected = PERIOD_PRICER.forecastValue(PRODUCT.getPeriodicPayments().get(15), RATES_PROVIDER_ON_PAY); assertEquals(computed.getAmount(), expected); }
/** * Calculates the current cash of the bond trade. * * @param trade the trade * @param ratesProvider the rates provider, used to determine price index values * @return the current cash */ public CurrencyAmount currentCash( ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider) { LocalDate valuationDate = ratesProvider.getValuationDate(); LocalDate settlementDate = settlementDate(trade, valuationDate); CurrencyAmount cashProduct = productPricer.currentCash(trade.getProduct(), ratesProvider, settlementDate); if (!trade.getSettlement().isPresent()) { return cashProduct; } BondPaymentPeriod settlePeriod = trade.getSettlement().get().getPayment(); double cashSettle = settlePeriod.getPaymentDate().isEqual(valuationDate) ? netAmount(trade, ratesProvider).getAmount() : 0d; return cashProduct.plus(cashSettle); }