/** * Calculates the present value sensitivity of the bond product. * <p> * The present value sensitivity of the product is the sensitivity of the present value to * the underlying curves. * * @param bond the product * @param ratesProvider the rates provider, used to determine price index values * @param discountingProvider the discount factors provider * @return the present value curve sensitivity of the product */ public PointSensitivityBuilder presentValueSensitivity( ResolvedCapitalIndexedBond bond, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider) { validate(ratesProvider, discountingProvider); return presentValueSensitivity( bond, ratesProvider, discountingProvider, ratesProvider.getValuationDate()); }
/** * Calculates the dirty price of the bond security. * <p> * The bond is represented as {@link Security} where standard ID of the bond is stored. * <p> * Strata uses <i>decimal prices</i> for bonds. For example, a price of 99.32% is represented in Strata by 0.9932. * * @param bond the product * @param ratesProvider the rates provider, used to determine price index values * @param discountingProvider the discount factors provider * @param refData the reference data used to calculate the settlement date * @return the dirty price of the bond security */ public double dirtyNominalPriceFromCurves( ResolvedCapitalIndexedBond bond, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, ReferenceData refData) { validate(ratesProvider, discountingProvider); LocalDate settlementDate = bond.calculateSettlementDateFromValuation(ratesProvider.getValuationDate(), refData); return dirtyNominalPriceFromCurves(bond, ratesProvider, discountingProvider, settlementDate); }
/** * Calculates the dirty price sensitivity of the bond security. * <p> * The dirty price sensitivity of the security is the sensitivity of the dirty price value to * the underlying curves. * * @param bond the product * @param ratesProvider the rates provider, used to determine price index values * @param discountingProvider the discount factors provider * @param refData the reference data used to calculate the settlement date * @return the dirty price curve sensitivity of the security */ public PointSensitivityBuilder dirtyNominalPriceSensitivity( ResolvedCapitalIndexedBond bond, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, ReferenceData refData) { validate(ratesProvider, discountingProvider); LocalDate settlementDate = bond.calculateSettlementDateFromValuation(ratesProvider.getValuationDate(), refData); return dirtyNominalPriceSensitivity(bond, ratesProvider, discountingProvider, settlementDate); }
int periodsPerYear) { validate(ratesProvider, discountingProvider); LocalDate settlementDate = bond.calculateSettlementDateFromValuation(ratesProvider.getValuationDate(), refData); final Function<Double, Double> residual = new Function<Double, Double>() {
int periodsPerYear) { validate(ratesProvider, discountingProvider); LocalDate settlementDate = bond.calculateSettlementDateFromValuation(ratesProvider.getValuationDate(), refData); final Function<Double, Double> residual = new Function<Double, Double>() {
/** * Computes the conventional real yield from the curves. * <p> * The yield is in the bill yield convention. * * @param bond the product * @param ratesProvider the rates provider, used to determine price index values * @param discountingProvider the discount factors provider * @param refData the reference data used to calculate the settlement date * @return the yield of the product */ public double realYieldFromCurves( ResolvedCapitalIndexedBond bond, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, ReferenceData refData) { validate(ratesProvider, discountingProvider); LocalDate settlementDate = bond.calculateSettlementDateFromValuation(ratesProvider.getValuationDate(), refData); double dirtyPrice; if (bond.getYieldConvention().equals(CapitalIndexedBondYieldConvention.GB_IL_FLOAT)) { dirtyPrice = dirtyNominalPriceFromCurves(bond, ratesProvider, discountingProvider, settlementDate); } else { double dirtyNominalPrice = dirtyNominalPriceFromCurves(bond, ratesProvider, discountingProvider, settlementDate); dirtyPrice = realPriceFromNominalPrice(bond, ratesProvider, settlementDate, dirtyNominalPrice); } return realYieldFromDirtyPrice(bond, ratesProvider, settlementDate, dirtyPrice); }
CurrencyAmount presentValue( ResolvedCapitalIndexedBond bond, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, LocalDate referenceDate) { IssuerCurveDiscountFactors issuerDf = issuerCurveDf(bond, discountingProvider); double pvNominal = periodPricer.presentValue(bond.getNominalPayment(), ratesProvider, issuerDf); double pvCoupon = 0d; for (CapitalIndexedBondPaymentPeriod period : bond.getPeriodicPayments()) { if ((bond.hasExCouponPeriod() && period.getDetachmentDate().isAfter(referenceDate)) || (!bond.hasExCouponPeriod() && period.getPaymentDate().isAfter(referenceDate))) { pvCoupon += periodPricer.presentValue(period, ratesProvider, issuerDf); } } return CurrencyAmount.of(bond.getCurrency(), pvCoupon + pvNominal); }
CurrencyAmount presentValueWithZSpread( ResolvedCapitalIndexedBond bond, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, LocalDate referenceDate, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { IssuerCurveDiscountFactors issuerDf = issuerCurveDf(bond, discountingProvider); double pvNominal = periodPricer.presentValueWithZSpread( bond.getNominalPayment(), ratesProvider, issuerDf, zSpread, compoundedRateType, periodsPerYear); double pvCoupon = 0d; for (CapitalIndexedBondPaymentPeriod period : bond.getPeriodicPayments()) { if ((bond.hasExCouponPeriod() && period.getDetachmentDate().isAfter(referenceDate)) || (!bond.hasExCouponPeriod() && period.getPaymentDate().isAfter(referenceDate))) { pvCoupon += periodPricer.presentValueWithZSpread( period, ratesProvider, issuerDf, zSpread, compoundedRateType, periodsPerYear); } } return CurrencyAmount.of(bond.getCurrency(), pvCoupon + pvNominal); }
PointSensitivityBuilder presentValueSensitivityWithZSpread( ResolvedCapitalIndexedBond bond, RatesProvider ratesProvider, LegalEntityDiscountingProvider discountingProvider, LocalDate referenceDate, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { IssuerCurveDiscountFactors issuerDf = issuerCurveDf(bond, discountingProvider); PointSensitivityBuilder pointNominal = periodPricer.presentValueSensitivityWithZSpread( bond.getNominalPayment(), ratesProvider, issuerDf, zSpread, compoundedRateType, periodsPerYear); PointSensitivityBuilder pointCoupon = PointSensitivityBuilder.none(); for (CapitalIndexedBondPaymentPeriod period : bond.getPeriodicPayments()) { if ((bond.hasExCouponPeriod() && period.getDetachmentDate().isAfter(referenceDate)) || (!bond.hasExCouponPeriod() && period.getPaymentDate().isAfter(referenceDate))) { pointCoupon = pointCoupon.combinedWith(periodPricer.presentValueSensitivityWithZSpread( period, ratesProvider, issuerDf, zSpread, compoundedRateType, periodsPerYear)); } } return pointNominal.combinedWith(pointCoupon); }
int periodsPerYear) { validate(ratesProvider, discountingProvider); LocalDate settlementDate = bond.calculateSettlementDateFromValuation(ratesProvider.getValuationDate(), refData); return dirtyNominalPriceFromCurvesWithZSpread( int periodsPerYear) { validate(ratesProvider, discountingProvider); LocalDate settlementDate = bond.calculateSettlementDateFromValuation(ratesProvider.getValuationDate(), refData); return dirtyNominalPriceSensitivityWithZSpread(