/** * Calculates the present value of the 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 ratesProvider the rates provider, used to determine price index values * @param discountingProvider the discount factors provider * @return the present value of the bond trade */ public CurrencyAmount presentValue( ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider) { validate(ratesProvider, discountingProvider); LocalDate settlementDate = settlementDate(trade, ratesProvider.getValuationDate()); CurrencyAmount pvProduct = productPricer.presentValue(trade.getProduct(), ratesProvider, discountingProvider, settlementDate); return presentValueFromProductPresentValue(trade, ratesProvider, discountingProvider, pvProduct); }
/** * 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); }
LocalDate settlementDate = settlementDate(trade, ratesProvider.getValuationDate()); CurrencyAmount pvProduct = productPricer.presentValueWithZSpread( trade.getProduct(), ratesProvider,
/** * Calculates the present value sensitivity of the 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 ratesProvider the rates provider, used to determine price index values * @param discountingProvider the discount factors provider * @return the present value sensitivity of the bond trade */ public PointSensitivities presentValueSensitivity( ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider) { validate(ratesProvider, discountingProvider); LocalDate settlementDate = settlementDate(trade, ratesProvider.getValuationDate()); PointSensitivityBuilder productSensi = productPricer.presentValueSensitivity(trade.getProduct(), ratesProvider, discountingProvider, settlementDate); return presentValueSensitivityFromProductPresentValueSensitivity( trade, ratesProvider, discountingProvider, productSensi).build(); }
/** * Calculates the present value sensitivity of the 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> * Coupon payments of the underlying product are considered based on the settlement date of the trade. * * @param trade the trade * @param ratesProvider the rates provider, used to determine price index values * @param discountingProvider the discount factors provider * @param zSpread the z-spread * @param compoundedRateType the compounded rate type * @param periodsPerYear the number of periods per year * @return the present value sensitivity of the bond trade */ public PointSensitivities presentValueSensitivityWithZSpread( ResolvedCapitalIndexedBondTrade trade, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { validate(ratesProvider, discountingProvider); LocalDate settlementDate = settlementDate(trade, ratesProvider.getValuationDate()); PointSensitivityBuilder productSensi = productPricer.presentValueSensitivityWithZSpread(trade.getProduct(), ratesProvider, discountingProvider, settlementDate, zSpread, compoundedRateType, periodsPerYear); return presentValueSensitivityFromProductPresentValueSensitivity( trade, ratesProvider, discountingProvider, productSensi).build(); }
ResolvedCapitalIndexedBond bond = trade.getProduct(); LocalDate standardSettlementDate = bond.calculateSettlementDateFromValuation(valuationDate, refData); LocalDate tradeSettlementDate = settlementDate(trade, valuationDate); RepoCurveDiscountFactors repoDf = DiscountingCapitalIndexedBondProductPricer.repoCurveDf(bond, discountingProvider); double df = repoDf.discountFactor(standardSettlementDate);
ResolvedCapitalIndexedBond bond = trade.getProduct(); LocalDate standardSettlementDate = bond.calculateSettlementDateFromValuation(valuationDate, refData); LocalDate tradeSettlementDate = settlementDate(trade, valuationDate); RepoCurveDiscountFactors repoDf = DiscountingCapitalIndexedBondProductPricer.repoCurveDf(bond, discountingProvider); double df = repoDf.discountFactor(standardSettlementDate);
ResolvedCapitalIndexedBond bond = trade.getProduct(); LocalDate standardSettlementDate = bond.calculateSettlementDateFromValuation(valuationDate, refData); LocalDate tradeSettlementDate = settlementDate(trade, valuationDate); RepoCurveDiscountFactors repoDf = DiscountingCapitalIndexedBondProductPricer.repoCurveDf(bond, discountingProvider); double df = repoDf.discountFactor(standardSettlementDate);
ResolvedCapitalIndexedBond bond = trade.getProduct(); LocalDate standardSettlementDate = bond.calculateSettlementDateFromValuation(valuationDate, refData); LocalDate tradeSettlementDate = settlementDate(trade, valuationDate); RepoCurveDiscountFactors repoDf = DiscountingCapitalIndexedBondProductPricer.repoCurveDf(bond, discountingProvider); double df = repoDf.discountFactor(standardSettlementDate);