public void regression_withZSpread_continuous() { CurrencyAmount pv = TRADE_PRICER.presentValueWithZSpread( FUTURE_TRADE, PROVIDER, SETTLE_PRICE, Z_SPREAD, CONTINUOUS, 0); assertEquals(pv.getAmount(), -7728642.649169521, 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_presentValueWithZSpread_continuous() { CurrencyAmount computed = TRADE_PRICER.presentValueWithZSpread( FUTURE_TRADE, PROVIDER, SETTLE_PRICE, Z_SPREAD, CONTINUOUS, 0); double expected = (PRODUCT_PRICER.priceWithZSpread(FUTURE_PRODUCT, PROVIDER, Z_SPREAD, CONTINUOUS, 0) - SETTLE_PRICE) * NOTIONAL * QUANTITY; assertEquals(computed.getCurrency(), USD); assertEquals(computed.getAmount(), expected, TOL * NOTIONAL * QUANTITY); }
public void test_presentValueWithZSpread_periodic() { CurrencyAmount computed = TRADE_PRICER.presentValueWithZSpread( FUTURE_TRADE, PROVIDER, SETTLE_PRICE, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); double expected = NOTIONAL * QUANTITY * (PRODUCT_PRICER.priceWithZSpread(FUTURE_PRODUCT, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR) - SETTLE_PRICE); assertEquals(computed.getCurrency(), USD); assertEquals(computed.getAmount(), expected, TOL * NOTIONAL * QUANTITY); }
public void test_presentValueSensitivityWithZSpread_periodic() { PointSensitivities point = TRADE_PRICER.presentValueSensitivityWithZSpread( FUTURE_TRADE, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(PROVIDER, (p) -> TRADE_PRICER.presentValueWithZSpread(FUTURE_TRADE, (p), SETTLE_PRICE, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR)); assertTrue(computed.equalWithTolerance(expected, 10.0 * EPS * NOTIONAL * QUANTITY)); }
public void test_presentValueSensitivityWithZSpread_continuous() { PointSensitivities point = TRADE_PRICER.presentValueSensitivityWithZSpread( FUTURE_TRADE, PROVIDER, Z_SPREAD, CONTINUOUS, 0); CurrencyParameterSensitivities computed = PROVIDER.parameterSensitivity(point); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(PROVIDER, (p) -> TRADE_PRICER.presentValueWithZSpread(FUTURE_TRADE, (p), SETTLE_PRICE, Z_SPREAD, CONTINUOUS, 0)); assertTrue(computed.equalWithTolerance(expected, 10.0 * EPS * NOTIONAL * QUANTITY)); }
public void regression_withZSpread_periodic() { CurrencyAmount pv = TRADE_PRICER.presentValueWithZSpread( FUTURE_TRADE, PROVIDER, SETTLE_PRICE, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); assertEquals(pv.getAmount(), -7710148.864076961, EPS * NOTIONAL * QUANTITY); PointSensitivities pvPoint = TRADE_PRICER.presentValueSensitivityWithZSpread( FUTURE_TRADE, PROVIDER, Z_SPREAD, PERIODIC, PERIOD_PER_YEAR); CurrencyParameterSensitivities test = PROVIDER.parameterSensitivity(pvPoint); DoubleArray expectedIssuer = DoubleArray.of( -48374.31671055041, -510470.43789512076, -1748988.1122760356, -1.2199872917663E8, -5.0289585725762194E8, 0); DoubleArray actualIssuer = test.getSensitivity(METADATA_ISSUER.getCurveName(), USD).getSensitivity(); assertTrue(actualIssuer.equalWithTolerance(expectedIssuer, TOL * NOTIONAL * QUANTITY)); DoubleArray expectedRepo = DoubleArray.of(1.7625865116887797E7, 2.497970288088735E7, 0.0, 0.0, 0.0, 0.0); DoubleArray actualRepo = test.getSensitivity(METADATA_REPO.getCurveName(), USD).getSensitivity(); assertTrue(actualRepo.equalWithTolerance(expectedRepo, TOL * NOTIONAL * QUANTITY)); }