@Override public Double apply(final Double z) { return dirtyPriceFromCurvesWithZSpread( bond, provider, refData, z, compoundedRateType, periodsPerYear) - dirtyPrice; } };
public void test_zSpreadFromCurvesAndPV_periodic() { double dirtyPrice = PRICER.dirtyPriceFromCurvesWithZSpread( PRODUCT, PROVIDER, REF_DATA, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); double computed = PRICER.zSpreadFromCurvesAndDirtyPrice( PRODUCT, PROVIDER, REF_DATA, dirtyPrice, PERIODIC, PERIOD_PER_YEAR); assertEquals(computed, Z_SPREAD, TOL); }
public void test_zSpreadFromCurvesAndPV_continuous() { double dirtyPrice = PRICER.dirtyPriceFromCurvesWithZSpread( PRODUCT, PROVIDER, REF_DATA, Z_SPREAD, CONTINUOUS, 0); double computed = PRICER.zSpreadFromCurvesAndDirtyPrice( PRODUCT, PROVIDER, REF_DATA, dirtyPrice, CONTINUOUS, 0); assertEquals(computed, Z_SPREAD, TOL); }
/** * Calculates the dirty price of the fixed coupon bond with z-spread. * <p> * The z-spread is a parallel shift applied to continuously compounded rates or periodic * compounded rates of the discounting curve. * <p> * The fixed coupon bond is represented as {@link Security} where standard ID of the bond is stored. * * @param bond the product * @param provider the discounting provider * @param refData the reference data used to calculate the settlement date * @param zSpread the z-spread * @param compoundedRateType the compounded rate type * @param periodsPerYear the number of periods per year * @return the dirty price of the fixed coupon bond security */ public double dirtyPriceFromCurvesWithZSpread( ResolvedFixedCouponBond bond, LegalEntityDiscountingProvider provider, ReferenceData refData, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear) { LocalDate settlementDate = bond.getSettlementDateOffset().adjust(provider.getValuationDate(), refData); return dirtyPriceFromCurvesWithZSpread(bond, provider, zSpread, compoundedRateType, periodsPerYear, settlementDate); }
for (int i = 0; i < size; ++i) { ResolvedFixedCouponBond bond = basket.get(i); double dirtyPrice = bondPricer.dirtyPriceFromCurvesWithZSpread( bond, discountingProvider, zSpread, compoundedRateType, periodPerYear, future.getLastDeliveryDate()); priceBonds[i] = bondPricer.cleanPriceFromDirtyPrice(
for (int i = 0; i < size; i++) { ResolvedFixedCouponBond bond = basket.get(i); double dirtyPrice = bondPricer.dirtyPriceFromCurvesWithZSpread( bond, discountingProvider, zSpread, compoundedRateType, periodPerYear, future.getLastDeliveryDate()); priceBonds[i] = bondPricer.cleanPriceFromDirtyPrice(
public void test_dirtyPriceFromCurvesWithZSpread_continuous() { double computed = PRICER.dirtyPriceFromCurvesWithZSpread( PRODUCT, PROVIDER, REF_DATA, Z_SPREAD, CONTINUOUS, 0); CurrencyAmount pv = PRICER.presentValueWithZSpread(PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0); LocalDate settlement = DATE_OFFSET.adjust(VAL_DATE, REF_DATA); double df = DSC_FACTORS_REPO.discountFactor(settlement); assertEquals(computed, pv.getAmount() / df / NOTIONAL); }
public void test_dirtyPriceFromCurvesWithZSpread_periodic() { double computed = PRICER.dirtyPriceFromCurvesWithZSpread( PRODUCT, PROVIDER, REF_DATA, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); CurrencyAmount pv = PRICER.presentValueWithZSpread( PRODUCT, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); LocalDate settlement = DATE_OFFSET.adjust(VAL_DATE, REF_DATA); double df = DSC_FACTORS_REPO.discountFactor(settlement); assertEquals(computed, pv.getAmount() / df / NOTIONAL); }
public void test_priceWithZSpread_continuous() { double computed = FUTURE_PRICER.priceWithZSpread(FUTURE_PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0); double dirtyPrice = BOND_PRICER.dirtyPriceFromCurvesWithZSpread( BOND, PROVIDER, Z_SPREAD, CONTINUOUS, 0, FUTURE_PRODUCT.getLastDeliveryDate()); double expected = BOND_PRICER.cleanPriceFromDirtyPrice( BOND, FUTURE_PRODUCT.getLastDeliveryDate(), dirtyPrice) / CONVERSION_FACTOR[0]; assertEquals(computed, expected, TOL); }
public void test_priceWithZSpread_periodic() { double computed = FUTURE_PRICER.priceWithZSpread(FUTURE_PRODUCT, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); double dirtyPrice = BOND_PRICER.dirtyPriceFromCurvesWithZSpread( BOND, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR, FUTURE_PRODUCT.getLastDeliveryDate()); double expected = BOND_PRICER.cleanPriceFromDirtyPrice( BOND, FUTURE_PRODUCT.getLastDeliveryDate(), dirtyPrice) / CONVERSION_FACTOR[0]; assertEquals(computed, expected, TOL); }
public void test_dirtyPriceSensitivityWithZspread_periodic() { PointSensitivityBuilder point = PRICER.dirtyPriceSensitivityWithZspread( PRODUCT, PROVIDER, REF_DATA, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point.build()); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(PROVIDER, p -> CurrencyAmount.of(EUR, PRICER .dirtyPriceFromCurvesWithZSpread(PRODUCT, p, REF_DATA, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR))); assertTrue(computed.equalWithTolerance(expected, NOTIONAL * EPS)); }
public void test_dirtyPriceSensitivityWithZspread_continuous() { PointSensitivityBuilder point = PRICER.dirtyPriceSensitivityWithZspread(PRODUCT, PROVIDER, REF_DATA, Z_SPREAD, CONTINUOUS, 0); CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point.build()); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(PROVIDER, p -> CurrencyAmount.of( EUR, PRICER.dirtyPriceFromCurvesWithZSpread(PRODUCT, p, REF_DATA, Z_SPREAD, CONTINUOUS, 0))); assertTrue(computed.equalWithTolerance(expected, NOTIONAL * EPS)); }
public void test_presentValueFromCleanPriceWithZSpread_periodic_noExcoupon_coherency() { double priceDirty = PRODUCT_PRICER.dirtyPriceFromCurvesWithZSpread( PRODUCT_NO_EXCOUPON, PROVIDER, REF_DATA, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); LocalDate standardSettlementDate = PRODUCT.getSettlementDateOffset().adjust(PROVIDER.getValuationDate(), REF_DATA); double priceCleanComputed = PRODUCT_PRICER.cleanPriceFromDirtyPrice(PRODUCT, standardSettlementDate, priceDirty); CurrencyAmount pvCleanPrice = TRADE_PRICER.presentValueFromCleanPriceWithZSpread( TRADE_NO_EXCOUPON, PROVIDER, REF_DATA, priceCleanComputed, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); CurrencyAmount pvCurves = TRADE_PRICER.presentValueWithZSpread( TRADE_NO_EXCOUPON, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); assertEquals(pvCleanPrice.getAmount(), pvCurves.getAmount(), NOTIONAL * TOL); }
public void test_presentValueFromCleanPriceWithZSpread_periodic_coherency() { double priceDirty = PRODUCT_PRICER.dirtyPriceFromCurvesWithZSpread( PRODUCT, PROVIDER, REF_DATA, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); LocalDate standardSettlementDate = PRODUCT.getSettlementDateOffset().adjust(PROVIDER.getValuationDate(), REF_DATA); double priceCleanComputed = PRODUCT_PRICER.cleanPriceFromDirtyPrice(PRODUCT, standardSettlementDate, priceDirty); CurrencyAmount pvCleanPrice = TRADE_PRICER.presentValueFromCleanPriceWithZSpread( TRADE, PROVIDER, REF_DATA, priceCleanComputed, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); CurrencyAmount pvCurves = TRADE_PRICER .presentValueWithZSpread(TRADE, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); assertEquals(pvCleanPrice.getAmount(), pvCurves.getAmount(), NOTIONAL * TOL); }
public void test_presentValueFromCleanPriceWithZSpread_continuous_coherency() { double priceDirty = PRODUCT_PRICER .dirtyPriceFromCurvesWithZSpread(PRODUCT, PROVIDER, REF_DATA, Z_SPREAD, CONTINUOUS, 0); LocalDate standardSettlementDate = PRODUCT.getSettlementDateOffset().adjust(PROVIDER.getValuationDate(), REF_DATA); double priceCleanComputed = PRODUCT_PRICER.cleanPriceFromDirtyPrice(PRODUCT, standardSettlementDate, priceDirty); CurrencyAmount pvCleanPrice = TRADE_PRICER.presentValueFromCleanPriceWithZSpread( TRADE, PROVIDER, REF_DATA, priceCleanComputed, Z_SPREAD, CONTINUOUS, 0); CurrencyAmount pvCurves = TRADE_PRICER.presentValueWithZSpread(TRADE, PROVIDER, Z_SPREAD, CONTINUOUS, 0); assertEquals(pvCleanPrice.getAmount(), pvCurves.getAmount(), NOTIONAL * TOL); }
public void test_presentValueFromCleanPriceWithZSpread_continuous_noExcoupon_coherency() { double priceDirty = PRODUCT_PRICER.dirtyPriceFromCurvesWithZSpread( PRODUCT_NO_EXCOUPON, PROVIDER, REF_DATA, Z_SPREAD, CONTINUOUS, 0); LocalDate standardSettlementDate = PRODUCT.getSettlementDateOffset().adjust(PROVIDER.getValuationDate(), REF_DATA); double priceCleanComputed = PRODUCT_PRICER.cleanPriceFromDirtyPrice(PRODUCT, standardSettlementDate, priceDirty); CurrencyAmount pvCleanPrice = TRADE_PRICER.presentValueFromCleanPriceWithZSpread( TRADE_NO_EXCOUPON, PROVIDER, REF_DATA, priceCleanComputed, Z_SPREAD, CONTINUOUS, 0); CurrencyAmount pvCurves = TRADE_PRICER .presentValueWithZSpread(TRADE_NO_EXCOUPON, PROVIDER, Z_SPREAD, CONTINUOUS, 0); assertEquals(pvCleanPrice.getAmount(), pvCurves.getAmount(), NOTIONAL * TOL); }