public void test_priceWithZSpread_periodic() { double computed = TRADE_PRICER.priceWithZSpread(FUTURE_TRADE, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); double expected = PRODUCT_PRICER.priceWithZSpread(FUTURE_PRODUCT, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); assertEquals(computed, expected, TOL); }
public void test_priceWithZSpread_continuous() { double computed = TRADE_PRICER.priceWithZSpread(FUTURE_TRADE, PROVIDER, Z_SPREAD, CONTINUOUS, 0); double expected = PRODUCT_PRICER.priceWithZSpread(FUTURE_PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0); assertEquals(computed, expected, TOL); }
/** * Calculates the par spread of the bond future trade with z-spread. * <p> * The par spread is defined in the following way. When the reference price (or market quote) * is increased by the par spread, the present value of the trade is zero. * <p> * The z-spread is a parallel shift applied to continuously compounded rates or periodic compounded rates * of the issuer discounting curve. * <p> * This method calculates based on the difference between the model price and the * last settlement price, or the trade price if traded on the valuation date. * * @param trade the trade * @param discountingProvider the discounting provider * @param lastSettlementPrice the last settlement price used for margining, in decimal form * @param zSpread the z-spread * @param compoundedRateType the compounded rate type * @param periodPerYear the number of periods per year * @return the par spread */ public double parSpreadWithZSpread( ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider, double lastSettlementPrice, double zSpread, CompoundedRateType compoundedRateType, int periodPerYear) { double referencePrice = referencePrice(trade, discountingProvider.getValuationDate(), lastSettlementPrice); return priceWithZSpread(trade, discountingProvider, zSpread, compoundedRateType, periodPerYear) - referencePrice; }
/** * Calculates the present value of the bond future trade with z-spread. * <p> * The present value of the product is the value on the valuation date. * <p> * The z-spread is a parallel shift applied to continuously compounded rates or periodic compounded rates * of the issuer discounting curve. * <p> * This method calculates based on the difference between the model price and the * last settlement price, or the trade price if traded on the valuation date. * * @param trade the trade * @param discountingProvider the discounting provider * @param lastSettlementPrice the last settlement price used for margining, in decimal form * @param zSpread the z-spread * @param compoundedRateType the compounded rate type * @param periodPerYear the number of periods per year * @return the present value */ public CurrencyAmount presentValueWithZSpread( ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider, double lastSettlementPrice, double zSpread, CompoundedRateType compoundedRateType, int periodPerYear) { double price = priceWithZSpread(trade, discountingProvider, zSpread, compoundedRateType, periodPerYear); double referencePrice = referencePrice(trade, discountingProvider.getValuationDate(), lastSettlementPrice); return presentValue(trade, price, referencePrice); }
/** * Calculates the currency exposure of the bond future trade 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> * This method calculates based on the difference between the model price and the * last settlement price, or the trade price if traded on the valuation date. * * @param trade the trade * @param discountingProvider the discounting provider * @param lastSettlementPrice the last settlement price used for margining, in decimal form * @param zSpread the z-spread * @param compoundedRateType the compounded rate type * @param periodPerYear the number of periods per year * @return the currency exposure of the bond future trade */ public MultiCurrencyAmount currencyExposureWithZSpread( ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider, double lastSettlementPrice, double zSpread, CompoundedRateType compoundedRateType, int periodPerYear) { double price = priceWithZSpread(trade, discountingProvider, zSpread, compoundedRateType, periodPerYear); double referencePrice = referencePrice(trade, discountingProvider.getValuationDate(), lastSettlementPrice); return MultiCurrencyAmount.of(presentValue(trade, price, referencePrice)); }