/** * Calculates the present value of the bond future trade. * <p> * The present value of the product is the value on the valuation date. * <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 * @return the present value */ public CurrencyAmount presentValue( ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider, double lastSettlementPrice) { double price = price(trade, discountingProvider); double referencePrice = referencePrice(trade, discountingProvider.getValuationDate(), lastSettlementPrice); return presentValue(trade, price, 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); }
public void test_currencyExposure() { MultiCurrencyAmount ceComputed = TRADE_PRICER.currencyExposure(FUTURE_TRADE, PROVIDER, SETTLE_PRICE); CurrencyAmount pv = TRADE_PRICER.presentValue(FUTURE_TRADE, PROVIDER, SETTLE_PRICE); assertEquals(ceComputed, MultiCurrencyAmount.of(pv)); }
/** * Calculates the par spread of the bond future trade. * <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> * 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 * @return the par spread */ public double parSpread( ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider, double lastSettlementPrice) { double referencePrice = referencePrice(trade, discountingProvider.getValuationDate(), lastSettlementPrice); return price(trade, discountingProvider) - referencePrice; }
public void test_presentValueSensitivity() { PointSensitivities point = TRADE_PRICER.presentValueSensitivity(FUTURE_TRADE, PROVIDER); CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(PROVIDER, (p) -> TRADE_PRICER.presentValue(FUTURE_TRADE, (p), SETTLE_PRICE)); assertTrue(computed.equalWithTolerance(expected, 10.0 * EPS * NOTIONAL * QUANTITY)); }
/** * 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; }
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); }
public void presentValue() { // March CurrencyAmount pvMar = TRADE_PRICER.presentValue(FUTURE_TRADE_MAR, LED_PROVIDER, REF_PRICE_MAR * ONE_PERCENT); assertEquals(pvMar.getAmount(), -419282.03701224923, TOL * NOTIONAL); // June CurrencyAmount pvJun = TRADE_PRICER.presentValue(FUTURE_TRADE_JUN, LED_PROVIDER, REF_PRICE_JUN * ONE_PERCENT); assertEquals(pvJun.getAmount(), -479725.4768240452, TOL * NOTIONAL); // September CurrencyAmount pvSep = TRADE_PRICER.presentValue(FUTURE_TRADE_SEP, LED_PROVIDER, REF_PRICE_SEP * ONE_PERCENT); assertEquals(pvSep.getAmount(), -525477.8611646593, TOL * NOTIONAL); }
public void test_parSpreadSensitivityWithZSpread_continuous() { PointSensitivities point = TRADE_PRICER.parSpreadSensitivityWithZSpread( FUTURE_TRADE, PROVIDER, Z_SPREAD, CONTINUOUS, 0); CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(PROVIDER, (p) -> CurrencyAmount.of( USD, TRADE_PRICER.parSpreadWithZSpread(FUTURE_TRADE, (p), SETTLE_PRICE, Z_SPREAD, CONTINUOUS, 0))); assertTrue(computed.equalWithTolerance(expected, 10.0 * EPS * NOTIONAL * QUANTITY)); }
public void test_currencyExposureWithZSpread() { MultiCurrencyAmount ceComputed = TRADE_PRICER.currencyExposureWithZSpread( FUTURE_TRADE, PROVIDER, SETTLE_PRICE, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); CurrencyAmount pv = TRADE_PRICER.presentValueWithZSpread( FUTURE_TRADE, PROVIDER, SETTLE_PRICE, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); assertEquals(ceComputed, MultiCurrencyAmount.of(pv)); }
public void test_price() { double computed = TRADE_PRICER.price(FUTURE_TRADE, PROVIDER); double expected = PRODUCT_PRICER.price(FUTURE_PRODUCT, PROVIDER); assertEquals(computed, expected, TOL); }
public void test_parSpreadSensitivity() { PointSensitivities point = TRADE_PRICER.parSpreadSensitivity(FUTURE_TRADE, PROVIDER); CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point); CurrencyParameterSensitivities expected = FD_CAL.sensitivity( PROVIDER, (p) -> CurrencyAmount.of(USD, TRADE_PRICER.parSpread(FUTURE_TRADE, (p), SETTLE_PRICE))); assertTrue(computed.equalWithTolerance(expected, 10.0 * EPS * NOTIONAL * QUANTITY)); }
public void test_parSpreadWithZSpread_continuous() { double computed = TRADE_PRICER.parSpreadWithZSpread(FUTURE_TRADE, PROVIDER, SETTLE_PRICE, Z_SPREAD, CONTINUOUS, 0); double expected = PRODUCT_PRICER.priceWithZSpread(FUTURE_PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0) - SETTLE_PRICE; assertEquals(computed, expected, TOL); }
public void parSpread() { // March double psMar = TRADE_PRICER.parSpread(FUTURE_TRADE_MAR, LED_PROVIDER, REF_PRICE_MAR * ONE_PERCENT) * HUNDRED; assertEquals(psMar, -0.4192820370122474, TOL * HUNDRED); // June double psJun = TRADE_PRICER.parSpread(FUTURE_TRADE_JUN, LED_PROVIDER, REF_PRICE_JUN * ONE_PERCENT) * HUNDRED; assertEquals(psJun, -0.47972547682404443, TOL * HUNDRED); // September double psSep = TRADE_PRICER.parSpread(FUTURE_TRADE_SEP, LED_PROVIDER, REF_PRICE_SEP * ONE_PERCENT) * HUNDRED; assertEquals(psSep, -0.5254778611646582, TOL * HUNDRED); }
public void parSpreadSensitivity() { TRADE_PRICER.parSpreadSensitivity(FUTURE_TRADE_MAR, LED_PROVIDER).multipliedBy(HUNDRED * ONE_BASIS_POINT); CurrencyParameterSensitivities sensiMar = LED_PROVIDER.parameterSensitivity(pointMar); double[] sensiIssuerMar = new double[] {-4.795692708445902E-6, -2.0781215861310126E-5, -7.730767169573405E-5, TRADE_PRICER.parSpreadSensitivity(FUTURE_TRADE_JUN, LED_PROVIDER).multipliedBy(HUNDRED * ONE_BASIS_POINT); CurrencyParameterSensitivities sensiJun = LED_PROVIDER.parameterSensitivity(pointJun); double[] sensiIssuerJun = new double[] {-1.1453989553600325E-5, -2.348926498286566E-5, -1.0106640809190963E-4, TRADE_PRICER.parSpreadSensitivity(FUTURE_TRADE_SEP, LED_PROVIDER).multipliedBy(HUNDRED * ONE_BASIS_POINT); CurrencyParameterSensitivities sensiSep = LED_PROVIDER.parameterSensitivity(pointSep); double[] sensiIssuerSep = new double[] {-6.287268294968501E-6, -2.7244672992830814E-5, -1.0135221390528455E-4,
public void presentValueSensitivity() { TRADE_PRICER.presentValueSensitivity(FUTURE_TRADE_MAR, LED_PROVIDER).multipliedBy(ONE_BASIS_POINT); CurrencyParameterSensitivities sensiMar = LED_PROVIDER.parameterSensitivity(pointMar); double[] sensiIssuerMar = new double[] {-4.795692708445902, -20.78121586131013, -77.30767169573404, TRADE_PRICER.presentValueSensitivity(FUTURE_TRADE_JUN, LED_PROVIDER).multipliedBy(ONE_BASIS_POINT); CurrencyParameterSensitivities sensiJun = LED_PROVIDER.parameterSensitivity(pointJun); double[] sensiIssuerJun = new double[] {-11.453989553600326, -23.489264982865656, -101.06640809190962, TRADE_PRICER.presentValueSensitivity(FUTURE_TRADE_SEP, LED_PROVIDER).multipliedBy(ONE_BASIS_POINT); CurrencyParameterSensitivities sensiSep = LED_PROVIDER.parameterSensitivity(pointSep); double[] sensiIssuerSep = new double[] {-6.287268294968501, -27.244672992830814, -101.35221390528456,
public void regression() { CurrencyAmount pv = TRADE_PRICER.presentValue(FUTURE_TRADE, PROVIDER, SETTLE_PRICE); assertEquals(pv.getAmount(), -2937800.66334416, EPS * NOTIONAL * QUANTITY); PointSensitivities pvPoint = TRADE_PRICER.presentValueSensitivity(FUTURE_TRADE, PROVIDER); CurrencyParameterSensitivities test = PROVIDER.parameterSensitivity(pvPoint); DoubleArray expectedIssuer = DoubleArray.of( -48626.82968419264, -513532.4556150143, -1768520.182827613, -1.262340715772077E8, -5.208162480624767E8, 0); DoubleArray actualIssuer = test.getSensitivity(METADATA_ISSUER.getCurveName(), USD).getSensitivity(); assertTrue(actualIssuer.equalWithTolerance(expectedIssuer, TOL * NOTIONAL * QUANTITY)); DoubleArray expectedRepo = DoubleArray.of(1.8204636592806276E7, 2.5799948548745323E7, 0.0, 0.0, 0.0, 0.0); DoubleArray actualRepo = test.getSensitivity(METADATA_REPO.getCurveName(), USD).getSensitivity(); assertTrue(actualRepo.equalWithTolerance(expectedRepo, TOL * NOTIONAL * QUANTITY)); }
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_presentValue() { CurrencyAmount computed = TRADE_PRICER.presentValue(FUTURE_TRADE, PROVIDER, SETTLE_PRICE); double expected = (PRODUCT_PRICER.price(FUTURE_PRODUCT, PROVIDER) - SETTLE_PRICE) * NOTIONAL * QUANTITY; assertEquals(computed.getCurrency(), USD); assertEquals(computed.getAmount(), expected, TOL * NOTIONAL * QUANTITY); }
public void test_parSpreadSensitivityWithZSpread_periodic() { PointSensitivities point = TRADE_PRICER.parSpreadSensitivityWithZSpread( FUTURE_TRADE, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(PROVIDER, (p) -> CurrencyAmount.of(USD, TRADE_PRICER.parSpreadWithZSpread(FUTURE_TRADE, (p), SETTLE_PRICE, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR))); assertTrue(computed.equalWithTolerance(expected, 10.0 * EPS * NOTIONAL * QUANTITY)); }