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_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 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); }
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_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 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_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); }
/** * Calculates the currency exposure of the bond future trade. * <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 currency exposure of the bond future trade */ public MultiCurrencyAmount currencyExposure( ResolvedBondFutureTrade trade, LegalEntityDiscountingProvider discountingProvider, double lastSettlementPrice) { double price = price(trade, discountingProvider); double referencePrice = referencePrice(trade, discountingProvider.getValuationDate(), lastSettlementPrice); return MultiCurrencyAmount.of(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)); }