/** * Calculates the yield for settlement at a given settlement date using curves with z-spread. * <p> * The z-spread is a parallel shift applied to continuously compounded rates or * periodic compounded rates of the issuer discounting curve. * <p> * The z-spread is applied only on the legal entity curve, not on the repo curve. * * @param bill the bill * @param provider the discounting provider * @param settlementDate the settlement date * @param zSpread the z-spread * @param compoundedRateType the compounded rate type * @param periodsPerYear the number of periods per year * @return the yield */ public double yieldFromCurvesWithZSpread( ResolvedBill bill, LegalEntityDiscountingProvider provider, LocalDate settlementDate, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { double price = priceFromCurvesWithZSpread(bill, provider, settlementDate, zSpread, compoundedRateType, periodsPerYear); return bill.yieldFromPrice(price, settlementDate); }
public void price_zspread_settle_date_after_maturity_error() { assertThrows( () -> PRICER.priceFromCurvesWithZSpread(BILL, PROVIDER, MATURITY_DATE, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0), IllegalArgumentException.class); }
public void price_zspread_settle_date_before_valuation_error() { assertThrows( () -> PRICER.priceFromCurvesWithZSpread(BILL, PROVIDER, VAL_DATE.minusDays(1), Z_SPREAD, CompoundedRateType.CONTINUOUS, 0), IllegalArgumentException.class); }
public void yieldFromCurves_zspread() { LocalDate settlementDate = VAL_DATE.plusDays(1); double yieldComputed = PRICER.yieldFromCurvesWithZSpread(BILL, PROVIDER, settlementDate, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0); double priceExpected = PRICER.priceFromCurvesWithZSpread(BILL, PROVIDER, settlementDate, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0); double yieldExpected = BILL.yieldFromPrice(priceExpected, settlementDate); assertEquals(yieldComputed, yieldExpected, TOLERANCE_PRICE); }
public void priceFromCurves_zspread() { LocalDate settlementDate = VAL_DATE.plusDays(1); double priceComputed = PRICER.priceFromCurvesWithZSpread(BILL, PROVIDER, settlementDate, Z_SPREAD, CompoundedRateType.CONTINUOUS, 0); double dfMaturity = DSC_FACTORS_ISSUER.discountFactor(MATURITY_DATE); double dfSettle = DSC_FACTORS_REPO.discountFactor(settlementDate); double priceExpected = dfMaturity * Math.exp(-Z_SPREAD * DSC_FACTORS_ISSUER.relativeYearFraction(MATURITY_DATE)) / dfSettle; assertEquals(priceComputed, priceExpected, TOLERANCE_PRICE); }