/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(ResolvedFixedCouponBondTrade beanToCopy) { this.info = beanToCopy.getInfo(); this.product = beanToCopy.getProduct(); this.quantity = beanToCopy.getQuantity(); this.settlement = beanToCopy.settlement; }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 3237038: // info return ((ResolvedFixedCouponBondTrade) bean).getInfo(); case -309474065: // product return ((ResolvedFixedCouponBondTrade) bean).getProduct(); case -1285004149: // quantity return ((ResolvedFixedCouponBondTrade) bean).getQuantity(); case 73828649: // settlement return ((ResolvedFixedCouponBondTrade) bean).settlement; } return super.propertyGet(bean, propertyName, quiet); }
private CurrencyAmount presentValuePayment(ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider) { RepoCurveDiscountFactors repoDf = DiscountingFixedCouponBondProductPricer.repoCurveDf(trade.getProduct(), provider); Payment upfrontPayment = upfrontPayment(trade); return paymentPricer.presentValue(upfrontPayment, repoDf.getDiscountFactors()); }
/** * Calculates the present value of the fixed coupon bond trade. * <p> * The present value of the trade is the value on the valuation date. * The result is expressed using the payment currency of the bond. * <p> * Coupon payments of the underlying product are considered based on the settlement date of the trade. * * @param trade the trade * @param provider the discounting provider * @return the present value of the fixed coupon bond trade */ public CurrencyAmount presentValue(ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider) { LocalDate settlementDate = settlementDate(trade, provider.getValuationDate()); CurrencyAmount pvProduct = productPricer.presentValue(trade.getProduct(), provider, settlementDate); return presentValueFromProductPresentValue(trade, provider, pvProduct); }
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 }
/** * Calculates the present value of the fixed coupon bond trade with z-spread. * <p> * The present value of the trade is the value on the valuation date. * The result is expressed using the payment currency of the bond. * <p> * The z-spread is a parallel shift applied to continuously compounded rates or periodic * compounded rates of the discounting curve. * <p> * Coupon payments of the underlying product are considered based on the settlement date of the trade. * * @param trade the trade * @param provider the discounting provider * @param zSpread the z-spread * @param compoundedRateType the compounded rate type * @param periodsPerYear the number of periods per year * @return the present value of the fixed coupon bond trade */ public CurrencyAmount presentValueWithZSpread( ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { LocalDate settlementDate = settlementDate(trade, provider.getValuationDate()); CurrencyAmount pvProduct = productPricer.presentValueWithZSpread( trade.getProduct(), provider, zSpread, compoundedRateType, periodsPerYear, settlementDate); return presentValueFromProductPresentValue(trade, provider, pvProduct); }
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 present value sensitivity of the fixed coupon bond trade. * <p> * The present value sensitivity of the trade is the sensitivity of the present value to * the underlying curves. * <p> * Coupon payments of the underlying product are considered based on the settlement date of the trade. * * @param trade the trade * @param provider the discounting provider * @return the present value curve sensitivity of the trade */ public PointSensitivities presentValueSensitivity( ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider) { LocalDate settlementDate = settlementDate(trade, provider.getValuationDate()); PointSensitivityBuilder sensiProduct = productPricer.presentValueSensitivity( trade.getProduct(), provider, settlementDate); return presentValueSensitivityFromProductPresentValueSensitivity(trade, provider, sensiProduct).build(); }
@Override public Payment upfrontPayment(ResolvedFixedCouponBondTrade trade) { return Payment.of(CurrencyAmount.zero(trade.getProduct().getCurrency()), SETTLEMENT); } };
/** * Calculates the present value sensitivity of the fixed coupon bond trade with z-spread. * <p> * The present value sensitivity of the trade is the sensitivity of the present value to * the underlying curves. * <p> * The z-spread is a parallel shift applied to continuously compounded rates or periodic * compounded rates of the discounting curve. * <p> * Coupon payments of the underlying product are considered based on the settlement date of the trade. * * @param trade the trade * @param provider the discounting provider * @param zSpread the z-spread * @param compoundedRateType the compounded rate type * @param periodsPerYear the number of periods per year * @return the present value curve sensitivity of the trade */ public PointSensitivities presentValueSensitivityWithZSpread( ResolvedFixedCouponBondTrade trade, LegalEntityDiscountingProvider provider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { LocalDate settlementDate = settlementDate(trade, provider.getValuationDate()); PointSensitivityBuilder sensiProduct = productPricer.presentValueSensitivityWithZSpread( trade.getProduct(), provider, zSpread, compoundedRateType, periodsPerYear, settlementDate); return presentValueSensitivityFromProductPresentValueSensitivity(trade, provider, sensiProduct).build(); }
/** * Calculates the payment that was made for the trade. * <p> * This is the payment that was made on the settlement date, based on the quantity and clean price. * * @param trade the trade * @return the payment that was made */ public Payment upfrontPayment(ResolvedFixedCouponBondTrade trade) { ResolvedFixedCouponBond product = trade.getProduct(); Currency currency = product.getCurrency(); if (!trade.getSettlement().isPresent()) { return Payment.of(CurrencyAmount.zero(currency), product.getStartDate()); // date doesn't matter as it is zero } // payment is based on the dirty price ResolvedFixedCouponBondSettlement settlement = trade.getSettlement().get(); LocalDate settlementDate = settlement.getSettlementDate(); double cleanPrice = settlement.getPrice(); double dirtyPrice = productPricer.dirtyPriceFromCleanPrice(product, settlementDate, cleanPrice); // calculate payment double quantity = trade.getQuantity(); double notional = product.getNotional(); return Payment.of(CurrencyAmount.of(currency, -quantity * notional * dirtyPrice), settlementDate); }
/** * 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; }
double cleanPrice) { ResolvedFixedCouponBond product = trade.getProduct(); LocalDate standardSettlementDate = standardSettlementDate(product, provider, refData); LocalDate tradeSettlementDate = settlementDate(trade, provider.getValuationDate());
int periodsPerYear) { ResolvedFixedCouponBond product = trade.getProduct(); LocalDate standardSettlementDate = standardSettlementDate(product, provider, refData); LocalDate tradeSettlementDate = settlementDate(trade, provider.getValuationDate());