/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(ResolvedBondFutureOptionTrade beanToCopy) { this.info = beanToCopy.getInfo(); this.product = beanToCopy.getProduct(); this.quantity = beanToCopy.getQuantity(); this.tradedPrice = beanToCopy.tradedPrice; }
@Override public ResolvedBondFutureOptionTrade build() { return new ResolvedBondFutureOptionTrade( info, product, quantity, tradedPrice); }
/** * Calculates the present value sensitivity of the bond future option trade. * <p> * The present value sensitivity of the trade is the sensitivity of the present value to * the underlying curves. * * @param trade the trade * @param discountingProvider the discounting provider * @param volatilities the volatilities * @return the present value curve sensitivity of the trade */ public PointSensitivities presentValueSensitivityRates( ResolvedBondFutureOptionTrade trade, LegalEntityDiscountingProvider discountingProvider, BondFutureVolatilities volatilities) { ResolvedBondFutureOption product = trade.getProduct(); PointSensitivities priceSensi = productPricer.priceSensitivity(product, discountingProvider, volatilities); PointSensitivities marginIndexSensi = productPricer.marginIndexSensitivity(product, priceSensi); return marginIndexSensi.multipliedBy(trade.getQuantity()); }
/** * Calculates the reference price for the trade. * <p> * If the valuation date equals the trade date, then the reference price is the trade price. * Otherwise, the reference price is the last settlement price used for margining. * * @param trade the trade * @param valuationDate the date for which the reference price should be calculated * @param lastSettlementPrice the last settlement price used for margining, in decimal form * @return the reference price, in decimal form */ private double referencePrice(ResolvedBondFutureOptionTrade trade, LocalDate valuationDate, double lastSettlementPrice) { ArgChecker.notNull(valuationDate, "valuationDate"); return trade.getTradedPrice() .filter(tp -> tp.getTradeDate().equals(valuationDate)) .map(tp -> tp.getPrice()) .orElse(lastSettlementPrice); }
/** * 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_resolve() { ResolvedBondFutureOptionTrade expected = ResolvedBondFutureOptionTrade.builder() .info(POSITION_INFO) .product(PRODUCT.resolve(REF_DATA)) .quantity(QUANTITY) .build(); assertEquals(sut().resolve(REF_DATA), expected); }
/** * Computes the present value sensitivity to the Black volatility used in the pricing * based on the price of the underlying future. * <p> * The result is a single sensitivity to the volatility used. * The volatility is associated with the expiry/delay/strike/future price key combination. * * @param futureOptionTrade the trade * @param discountingProvider the discounting provider * @param volatilities the volatilities * @param futurePrice the price of the underlying future * @return the price sensitivity */ public BondFutureOptionSensitivity presentValueSensitivityModelParamsVolatility( ResolvedBondFutureOptionTrade futureOptionTrade, LegalEntityDiscountingProvider discountingProvider, BlackBondFutureVolatilities volatilities, double futurePrice) { ResolvedBondFutureOption product = futureOptionTrade.getProduct(); BondFutureOptionSensitivity priceSensitivity = productPricer.priceSensitivityModelParamsVolatility(product, discountingProvider, volatilities, futurePrice); double factor = productPricer.marginIndex(product, 1) * futureOptionTrade.getQuantity(); return priceSensitivity.multipliedBy(factor); }
public void test_presentValue_from_prices_date() { double currentPrice = 0.0325; double lastClosingPrice = 0.03; LocalDate valuationDate1 = LocalDate.of(2014, 3, 30); // before trade date CurrencyAmount computed1 = OPTION_TRADE_PRICER.presentValue(OPTION_TRADE, valuationDate1, currentPrice, lastClosingPrice); double expected2 = NOTIONAL * QUANTITY * (currentPrice - lastClosingPrice); assertEquals(computed1.getCurrency(), Currency.EUR); assertEquals(computed1.getAmount(), expected2, TOL * NOTIONAL * QUANTITY); LocalDate valuationDate2 = LocalDate.of(2014, 3, 31); // equal to trade date CurrencyAmount computed2 = OPTION_TRADE_PRICER.presentValue(OPTION_TRADE, valuationDate2, currentPrice, lastClosingPrice); double expected = NOTIONAL * QUANTITY * (currentPrice - OPTION_TRADE.getTradedPrice().get().getPrice()); assertEquals(computed2.getCurrency(), Currency.EUR); assertEquals(computed2.getAmount(), expected, TOL * NOTIONAL * QUANTITY); }
/** * 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_resolve() { ResolvedBondFutureOptionTrade expected = ResolvedBondFutureOptionTrade.builder() .info(TRADE_INFO) .product(OPTION_PRODUCT.resolve(REF_DATA)) .quantity(QUANTITY) .tradedPrice(TradedPrice.of(TRADE_INFO.getTradeDate().get(), PRICE)) .build(); assertEquals(sut().resolve(REF_DATA), expected); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 3237038: // info return ((ResolvedBondFutureOptionTrade) bean).getInfo(); case -309474065: // product return ((ResolvedBondFutureOptionTrade) bean).getProduct(); case -1285004149: // quantity return ((ResolvedBondFutureOptionTrade) bean).getQuantity(); case -1873824343: // tradedPrice return ((ResolvedBondFutureOptionTrade) bean).tradedPrice; } return super.propertyGet(bean, propertyName, quiet); }
/** * Calculates the present value of the bond future option trade from the current option price. * <p> * The present value of the product is the value on the valuation date. * The current price is specified, not calculated. * <p> * This method calculates based on the difference between the specified current price and the * last settlement price, or the trade price if traded on the valuation date. * * @param trade the trade * @param valuationDate the valuation date; required to asses if the trade or last closing price should be used * @param currentOptionPrice the option price on the valuation date * @param lastOptionSettlementPrice the last settlement price used for margining for the option, in decimal form * @return the present value */ public CurrencyAmount presentValue( ResolvedBondFutureOptionTrade trade, LocalDate valuationDate, double currentOptionPrice, double lastOptionSettlementPrice) { ResolvedBondFutureOption option = trade.getProduct(); double referencePrice = referencePrice(trade, valuationDate, lastOptionSettlementPrice); double priceIndex = productPricer.marginIndex(option, currentOptionPrice); double referenceIndex = productPricer.marginIndex(option, referencePrice); double pv = (priceIndex - referenceIndex) * trade.getQuantity(); return CurrencyAmount.of(option.getUnderlyingFuture().getCurrency(), pv); }
public void test_getters() { ResolvedBondFutureOptionTrade test = sut(); BondFutureOptionTrade base = BondFutureOptionTradeTest.sut(); assertEquals(test.getTradedPrice().get(), TradedPrice.of(base.getInfo().getTradeDate().get(), base.getPrice())); }
/** * Computes the present value sensitivity to the Black volatility used in the pricing. * <p> * The result is a single sensitivity to the volatility used. * The volatility is associated with the expiry/delay/strike/future price key combination. * <p> * This calculates the underlying future price using the future pricer. * * @param futureOptionTrade the trade * @param discountingProvider the discounting provider * @param volatilities the volatilities * @return the price sensitivity */ public BondFutureOptionSensitivity presentValueSensitivityModelParamsVolatility( ResolvedBondFutureOptionTrade futureOptionTrade, LegalEntityDiscountingProvider discountingProvider, BlackBondFutureVolatilities volatilities) { ResolvedBondFuture future = futureOptionTrade.getProduct().getUnderlyingFuture(); double futurePrice = productPricer.getFuturePricer().price(future, discountingProvider); return presentValueSensitivityModelParamsVolatility(futureOptionTrade, discountingProvider, volatilities, futurePrice); }
@Override public ResolvedBondFutureOptionTrade resolve(ReferenceData refData) { ResolvedBondFutureOption resolved = product.resolve(refData); return new ResolvedBondFutureOptionTrade(info, resolved, getQuantity(), null); }
@Override public ResolvedBondFutureOptionTrade resolve(ReferenceData refData) { if (!info.getTradeDate().isPresent()) { throw new IllegalArgumentException("Trade date on TradeInfo must be present"); } ResolvedBondFutureOption resolved = getProduct().resolve(refData); TradedPrice tradedPrice = TradedPrice.of(info.getTradeDate().get(), price); return new ResolvedBondFutureOptionTrade(info, resolved, quantity, tradedPrice); }