/** * Calculates the zero rate point sensitivity with z-spread at the specified date specifying * the currency of the sensitivity. * <p> * This returns a sensitivity instance referring to the zero rate sensitivity of the * points that were queried in the market data. * The sensitivity refers to the result of {@link #discountFactorWithSpread(LocalDate, double, CompoundedRateType, int)}. * <p> * The z-spread is a parallel shift applied to continuously compounded rates or periodic * compounded rates of the discounting curve. * <p> * This method allows the currency of the sensitivity to differ from the currency of the market data. * * @param date the date to discount to * @param sensitivityCurrency the currency of the sensitivity * @param zSpread the z-spread * @param compoundedRateType the compounded rate type * @param periodsPerYear the number of periods per year * @return the point sensitivity of the zero rate * @throws RuntimeException if the result cannot be calculated */ public default ZeroRateSensitivity zeroRatePointSensitivityWithSpread( LocalDate date, Currency sensitivityCurrency, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { double yearFraction = relativeYearFraction(date); return zeroRatePointSensitivityWithSpread(yearFraction, sensitivityCurrency, zSpread, compoundedRateType, periodsPerYear); }
/** * Calculates the zero rate point sensitivity with z-spread at the specified date. * <p> * This returns a sensitivity instance referring to the zero rate sensitivity of the * points that were queried in the market data. * The sensitivity refers to the result of {@link #discountFactorWithSpread(LocalDate, double, CompoundedRateType, int)}. * <p> * The z-spread is a parallel shift applied to continuously compounded rates or periodic * compounded rates of the discounting curve. * * @param date the date to discount to * @param zSpread the z-spread * @param compoundedRateType the compounded rate type * @param periodsPerYear the number of periods per year * @return the point sensitivity of the zero rate * @throws RuntimeException if the result cannot be calculated */ public default ZeroRateSensitivity zeroRatePointSensitivityWithSpread( LocalDate date, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { double yearFraction = relativeYearFraction(date); return zeroRatePointSensitivityWithSpread(yearFraction, zSpread, compoundedRateType, periodsPerYear); }
/** * Calculates the zero rate point sensitivity with z-spread at the specified year fraction. * <p> * This returns a sensitivity instance referring to the zero rate sensitivity of the * points that were queried in the market data. * The sensitivity refers to the result of {@link #discountFactorWithSpread(LocalDate, double, CompoundedRateType, int)}. * <p> * The z-spread is a parallel shift applied to continuously compounded rates or periodic * compounded rates of the discounting curve. * <p> * The year fraction must be based on {@code #relativeYearFraction(LocalDate)}. * * @param yearFraction the year fraction * @param zSpread the z-spread * @param compoundedRateType the compounded rate type * @param periodsPerYear the number of periods per year * @return the point sensitivity of the zero rate * @throws RuntimeException if the result cannot be calculated */ public default ZeroRateSensitivity zeroRatePointSensitivityWithSpread( double yearFraction, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { return zeroRatePointSensitivityWithSpread(yearFraction, getCurrency(), zSpread, compoundedRateType, periodsPerYear); }
public void test_presentValueSensitivityWithSpread() { PointSensitivityBuilder computed = PRICER.presentValueSensitivityWithSpread( PAYMENT_PERIOD, ISSUER_CURVE, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); PointSensitivityBuilder expected = IssuerCurveZeroRateSensitivity.of( DSC_FACTORS.zeroRatePointSensitivityWithSpread(END_ADJUSTED, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR) .multipliedBy(FIXED_RATE * NOTIONAL * YEAR_FRACTION), GROUP); assertEquals(computed, expected); }
discountFactors.zeroRatePointSensitivityWithSpread(payment.getDate(), zSpread, compoundedRateType, periodsPerYear); return sensi.multipliedBy(payment.getAmount());
public void presentValueSensitivity_zspread() { PointSensitivities sensiComputed = PRICER.presentValueSensitivityWithZSpread(BILL, PROVIDER, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0); PointSensitivities sensiExpected = IssuerCurveZeroRateSensitivity.of( DSC_FACTORS_ISSUER.zeroRatePointSensitivityWithSpread(MATURITY_DATE, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0), GROUP_ISSUER) .multipliedBy(NOTIONAL.getAmount()) .build(); assertTrue(sensiComputed.equalWithTolerance(sensiExpected, TOLERANCE_PV)); CurrencyParameterSensitivities paramSensiComputed = PROVIDER.parameterSensitivity(sensiComputed); CurrencyParameterSensitivities paramSensiExpected = FD_CALC.sensitivity( PROVIDER, p -> PRICER.presentValueWithZSpread(BILL, p, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0)); assertTrue(paramSensiComputed.equalWithTolerance(paramSensiExpected, EPS * NOTIONAL_AMOUNT)); }
return PointSensitivityBuilder.none(); ZeroRateSensitivity zeroSensi = discountFactors.getDiscountFactors().zeroRatePointSensitivityWithSpread( period.getPaymentDate(), zSpread, compoundedRateType, periodsPerYear); IssuerCurveZeroRateSensitivity dscSensi =
double dfEndBar = bill.getNotional().getAmount(); ZeroRateSensitivity zeroSensMaturity = issuerDf.getDiscountFactors() .zeroRatePointSensitivityWithSpread(bill.getNotional().getDate(), zSpread, compoundedRateType, periodsPerYear); IssuerCurveZeroRateSensitivity dscSensMaturity = IssuerCurveZeroRateSensitivity.of(zeroSensMaturity, issuerDf.getLegalEntityGroup())
.discountFactorWithSpread(period.getPaymentDate(), zSpread, compoundedRateType, periodsPerYear); ZeroRateSensitivity zeroSensi = issuerDiscountFactors.getDiscountFactors() .zeroRatePointSensitivityWithSpread(period.getPaymentDate(), zSpread, compoundedRateType, periodsPerYear); IssuerCurveZeroRateSensitivity dfSensi = IssuerCurveZeroRateSensitivity.of(zeroSensi, issuerDiscountFactors.getLegalEntityGroup());