double price( ResolvedBondFutureOption futureOption, LegalEntityDiscountingProvider discountingProvider, BondFutureVolatilities volatilities) { ArgChecker.isTrue(volatilities instanceof BlackBondFutureVolatilities, "Provider must be of type BlackVolatilityBondFutureProvider"); return price(futureOption, discountingProvider, (BlackBondFutureVolatilities) volatilities); }
public void test_priceSensitivityBlackVolatility() { BondFutureOptionSensitivity sensi = OPTION_PRICER.priceSensitivityModelParamsVolatility( FUTURE_OPTION_PRODUCT, RATE_PROVIDER, VOLS); testPriceSensitivityBlackVolatility( VOLS.parameterSensitivity(sensi), (p) -> OPTION_PRICER.price(FUTURE_OPTION_PRODUCT, RATE_PROVIDER, (p))); }
public void test_priceSensitivity() { PointSensitivities point = OPTION_PRICER.priceSensitivityRatesStickyStrike( FUTURE_OPTION_PRODUCT, RATE_PROVIDER, VOLS); CurrencyParameterSensitivities computed = RATE_PROVIDER.parameterSensitivity(point); CurrencyParameterSensitivities expected = FD_CAL.sensitivity(RATE_PROVIDER, (p) -> CurrencyAmount.of(EUR, OPTION_PRICER.price(FUTURE_OPTION_PRODUCT, (p), VOLS))); double futurePrice = FUTURE_PRICER.price(FUTURE_OPTION_PRODUCT.getUnderlyingFuture(), RATE_PROVIDER); double strike = FUTURE_OPTION_PRODUCT.getStrikePrice(); double expiryTime = ACT_365F.relativeYearFraction(VAL_DATE, FUTURE_OPTION_PRODUCT.getExpiryDate()); double logMoneyness = Math.log(strike / futurePrice); double logMoneynessUp = Math.log(strike / (futurePrice + EPS)); double logMoneynessDw = Math.log(strike / (futurePrice - EPS)); double vol = SURFACE.zValue(expiryTime, logMoneyness); double volUp = SURFACE.zValue(expiryTime, logMoneynessUp); double volDw = SURFACE.zValue(expiryTime, logMoneynessDw); double volSensi = 0.5 * (volUp - volDw) / EPS; double vega = BlackFormulaRepository.vega(futurePrice, strike, expiryTime, vol); CurrencyParameterSensitivities sensiVol = RATE_PROVIDER.parameterSensitivity( FUTURE_PRICER.priceSensitivity(FUTURE_OPTION_PRODUCT.getUnderlyingFuture(), RATE_PROVIDER)).multipliedBy( -vega * volSensi); expected = expected.combinedWith(sensiVol); assertTrue(computed.equalWithTolerance(expected, 30d * EPS)); }
/** * Calculates the price of the bond future option trade. * <p> * The price of the trade is the price on the valuation date. * * @param trade the trade * @param discountingProvider the discounting provider * @param volatilities the volatilities * @return the price of the product, in decimal form */ public double price( ResolvedBondFutureOptionTrade trade, LegalEntityDiscountingProvider discountingProvider, BondFutureVolatilities volatilities) { return productPricer.price(trade.getProduct(), discountingProvider, volatilities); }
public void test_priceSensitivityBlackVolatility_from_future_price() { double futurePrice = 1.1d; BondFutureOptionSensitivity sensi = OPTION_PRICER.priceSensitivityModelParamsVolatility( FUTURE_OPTION_PRODUCT, RATE_PROVIDER, VOLS, futurePrice); testPriceSensitivityBlackVolatility( VOLS.parameterSensitivity(sensi), (p) -> OPTION_PRICER.price(FUTURE_OPTION_PRODUCT, RATE_PROVIDER, (p), futurePrice)); }
/** * Calculates the price of the bond future option product. * <p> * The price of the option is the price on the valuation date. * <p> * This calculates the underlying future price using the future pricer. * <p> * Strata uses <i>decimal prices</i> for bond futures. This is coherent with the pricing of {@link BondFuture}. * For example, a price of 1.32% is represented in Strata by 0.0132. * * @param futureOption the option product * @param discountingProvider the discounting provider * @param volatilities the volatilities * @return the price of the product, in decimal form */ public double price( ResolvedBondFutureOption futureOption, LegalEntityDiscountingProvider discountingProvider, BlackBondFutureVolatilities volatilities) { double futurePrice = futurePrice(futureOption, discountingProvider); return price(futureOption, discountingProvider, volatilities, futurePrice); }
public void regression_price() { double price = OPTION_PRICER.price(FUTURE_OPTION_PRODUCT, RATE_PROVIDER, VOLS); assertEquals(price, 0.08916005173932573, TOL); // 2.x } }
public void test_price_from_generic_provider() { BondFutureVolatilities vols = BlackBondFutureExpiryLogMoneynessVolatilities.of(VAL_DATE_TIME, SURFACE); double computed = OPTION_PRICER.price(FUTURE_OPTION_PRODUCT, RATE_PROVIDER, vols); double expected = OPTION_PRICER.price(FUTURE_OPTION_PRODUCT, RATE_PROVIDER, VOLS); assertEquals(computed, expected, TOL); }
/** * Calculates the present value of the bond future option trade from the underlying future price. * <p> * The present value of the product is the value on the valuation date. * The current price is calculated using the volatility model with a known future price. * <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 volatilities the volatilities * @param futurePrice the price of the underlying future * @param lastOptionSettlementPrice the last settlement price used for margining for the option, in decimal form * @return the present value */ public CurrencyAmount presentValue( ResolvedBondFutureOptionTrade trade, LegalEntityDiscountingProvider discountingProvider, BlackBondFutureVolatilities volatilities, double futurePrice, double lastOptionSettlementPrice) { double optionPrice = productPricer.price(trade.getProduct(), discountingProvider, volatilities, futurePrice); return presentValue(trade, discountingProvider.getValuationDate(), optionPrice, lastOptionSettlementPrice); }
public void test_presentValue_from_future_price() { double futurePrice = 0.975d; CurrencyAmount computed = OPTION_TRADE_PRICER.presentValue(OPTION_TRADE, RATE_PROVIDER, VOLS, futurePrice, REFERENCE_PRICE); double expected = NOTIONAL * QUANTITY * (OPTION_PRODUCT_PRICER.price(OPTION_PRODUCT, RATE_PROVIDER, VOLS, futurePrice) - REFERENCE_PRICE); assertEquals(computed.getCurrency(), Currency.EUR); assertEquals(computed.getAmount(), expected, TOL * NOTIONAL * QUANTITY); }
public void test_presentValue() { CurrencyAmount computed = OPTION_TRADE_PRICER.presentValue(OPTION_TRADE, RATE_PROVIDER, VOLS, REFERENCE_PRICE); double expected = (OPTION_PRODUCT_PRICER.price(OPTION_PRODUCT, RATE_PROVIDER, VOLS) - REFERENCE_PRICE) * NOTIONAL * QUANTITY; assertEquals(computed.getCurrency(), Currency.EUR); assertEquals(computed.getAmount(), expected, TOL * NOTIONAL * QUANTITY); }
public void test_price_from_future_price() { double futurePrice = 1.1d; double computed = OPTION_PRICER.price(FUTURE_OPTION_PRODUCT, RATE_PROVIDER, VOLS, futurePrice); double strike = FUTURE_OPTION_PRODUCT.getStrikePrice(); double expiryTime = ACT_365F.relativeYearFraction(VAL_DATE, FUTURE_OPTION_PRODUCT.getExpiryDate()); double logMoneyness = Math.log(strike / futurePrice); double vol = SURFACE.zValue(expiryTime, logMoneyness); double expected = BlackFormulaRepository.price(futurePrice, strike, expiryTime, vol, true); assertEquals(computed, expected, TOL); }
public void test_price() { double computed = OPTION_PRICER.price(FUTURE_OPTION_PRODUCT, RATE_PROVIDER, VOLS); double futurePrice = FUTURE_PRICER.price(FUTURE_OPTION_PRODUCT.getUnderlyingFuture(), RATE_PROVIDER); double strike = FUTURE_OPTION_PRODUCT.getStrikePrice(); double expiryTime = ACT_365F.relativeYearFraction(VAL_DATE, FUTURE_OPTION_PRODUCT.getExpiryDate()); double logMoneyness = Math.log(strike / futurePrice); double vol = SURFACE.zValue(expiryTime, logMoneyness); double expected = BlackFormulaRepository.price(futurePrice, strike, expiryTime, vol, true); assertEquals(computed, expected, TOL); }