private CurrencyAmount presentValuePayment(ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider) { RepoCurveDiscountFactors repoDf = DiscountingFixedCouponBondProductPricer.repoCurveDf(trade.getProduct(), provider); Payment upfrontPayment = upfrontPayment(trade); return paymentPricer.presentValue(upfrontPayment, repoDf.getDiscountFactors()); }
public void test_upfrontPayment() { Payment payment = TRADE_PRICER.upfrontPayment(TRADE); assertEquals(payment.getCurrency(), EUR); assertEquals(payment.getAmount(), -NOTIONAL * QUANTITY * DIRTY_PRICE, TOL); assertEquals(payment.getDate(), SETTLEMENT); }
private PointSensitivityBuilder presentValueSensitivityPayment( ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider) { RepoCurveDiscountFactors repoDf = DiscountingFixedCouponBondProductPricer.repoCurveDf(trade.getProduct(), provider); Payment upfrontPayment = upfrontPayment(trade); PointSensitivityBuilder pt = paymentPricer.presentValueSensitivity( upfrontPayment, repoDf.getDiscountFactors()); if (pt instanceof ZeroRateSensitivity) { return RepoCurveZeroRateSensitivity.of((ZeroRateSensitivity) pt, repoDf.getRepoGroup()); } return pt; // NoPointSensitivity }
public void test_upfrontPayment_position() { Payment payment = TRADE_PRICER.upfrontPayment(POSITION); assertEquals(payment.getCurrency(), EUR); assertEquals(payment.getAmount(), 0, TOL); assertEquals(payment.getDate(), POSITION.getProduct().getStartDate()); }
/** * Calculates the current cash of the fixed coupon bond trade. * * @param trade the trade * @param valuationDate the valuation date * @return the current cash amount */ public CurrencyAmount currentCash(ResolvedFixedCouponBondTrade trade, LocalDate valuationDate) { Payment upfrontPayment = upfrontPayment(trade); Currency currency = upfrontPayment.getCurrency(); // assumes single currency is involved in trade CurrencyAmount currentCash = CurrencyAmount.zero(currency); if (upfrontPayment.getDate().equals(valuationDate)) { currentCash = currentCash.plus(upfrontPayment.getValue()); } if (trade.getSettlement().isPresent()) { LocalDate settlementDate = trade.getSettlement().get().getSettlementDate(); ResolvedFixedCouponBond product = trade.getProduct(); if (!settlementDate.isAfter(valuationDate)) { double cashCoupon = product.hasExCouponPeriod() ? 0d : currentCashCouponPayment(product, valuationDate); Payment payment = product.getNominalPayment(); double cashNominal = payment.getDate().isEqual(valuationDate) ? payment.getAmount() : 0d; currentCash = currentCash.plus(CurrencyAmount.of(currency, (cashCoupon + cashNominal) * trade.getQuantity())); } } return currentCash; }