/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(ResolvedIborFutureOptionTrade beanToCopy) { this.info = beanToCopy.getInfo(); this.product = beanToCopy.getProduct(); this.quantity = beanToCopy.getQuantity(); this.tradedPrice = beanToCopy.tradedPrice; }
@Override public ResolvedIborFutureOptionTrade build() { return new ResolvedIborFutureOptionTrade( info, product, quantity, tradedPrice); }
public void test_builder() { ResolvedIborFutureOptionTrade test = sut(); assertEquals(test.getInfo(), TRADE_INFO); assertEquals(test.getProduct(), PRODUCT); assertEquals(test.getQuantity(), QUANTITY); assertEquals(test.getTradedPrice(), Optional.of(TradedPrice.of(TRADE_DATE, PRICE))); }
/** * Calculates the present value sensitivity of the Ibor 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 ratesProvider the rates provider * @param volatilities the volatilities * @return the present value curve sensitivity of the trade */ public PointSensitivities presentValueSensitivityRates( ResolvedIborFutureOptionTrade trade, RatesProvider ratesProvider, NormalIborFutureOptionVolatilities volatilities) { ResolvedIborFutureOption product = trade.getProduct(); PointSensitivities priceSensi = futureOptionPricer.priceSensitivityRatesStickyStrike(product, ratesProvider, volatilities); PointSensitivities marginIndexSensi = futureOptionPricer.marginIndexSensitivity(product, priceSensi); return marginIndexSensi.multipliedBy(trade.getQuantity()); }
/** * Calculates the price of the Ibor future option trade. * <p> * The price of the trade is the price on the valuation date. * The price is calculated using the volatility model. * * @param trade the trade * @param ratesProvider the rates provider * @param volatilities the volatilities * @return the price of the product, in decimal form */ public double price( ResolvedIborFutureOptionTrade trade, RatesProvider ratesProvider, NormalIborFutureOptionVolatilities volatilities) { return futureOptionPricer.price(trade.getProduct(), ratesProvider, volatilities); }
/** * 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(ResolvedIborFutureOptionTrade trade, LocalDate valuationDate, double lastSettlementPrice) { ArgChecker.notNull(valuationDate, "valuationDate"); return trade.getTradedPrice() .filter(tp -> tp.getTradeDate().equals(valuationDate)) .map(tp -> tp.getPrice()) .orElse(lastSettlementPrice); }
public void test_resolve() { ResolvedIborFutureOptionTrade expected = ResolvedIborFutureOptionTrade.builder() .info(POSITION_INFO) .product(PRODUCT.resolve(REF_DATA)) .quantity(QUANTITY) .build(); assertEquals(sut().resolve(REF_DATA), expected); }
public void test_resolve() { IborFutureOptionTrade test = sut(); ResolvedIborFutureOptionTrade resolved = test.resolve(REF_DATA); assertEquals(resolved.getInfo(), TRADE_INFO); assertEquals(resolved.getProduct(), PRODUCT.resolve(REF_DATA)); assertEquals(resolved.getQuantity(), QUANTITY); assertEquals(resolved.getTradedPrice(), Optional.of(TradedPrice.of(TRADE_DATE, PRICE))); }
/** * Computes the present value sensitivity to the normal 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 ratesProvider the rates provider * @param volatilities the volatilities * @param futurePrice the price of the underlying future, in decimal form * @return the price sensitivity */ public IborFutureOptionSensitivity presentValueSensitivityModelParamsVolatility( ResolvedIborFutureOptionTrade futureOptionTrade, RatesProvider ratesProvider, NormalIborFutureOptionVolatilities volatilities, double futurePrice) { ResolvedIborFutureOption product = futureOptionTrade.getProduct(); IborFutureOptionSensitivity priceSensitivity = futureOptionPricer.priceSensitivityModelParamsVolatility(product, ratesProvider, volatilities, futurePrice); double factor = futureOptionPricer.marginIndex(product, 1) * futureOptionTrade.getQuantity(); return priceSensitivity.multipliedBy(factor); }
/** * Calculates the present value of the Ibor 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 ratesProvider the rates provider * @param volatilities the volatilities * @param futurePrice the price of the underlying future, in decimal form * @param lastOptionSettlementPrice the last settlement price used for margining for the option, in decimal form * @return the present value */ public CurrencyAmount presentValue( ResolvedIborFutureOptionTrade trade, RatesProvider ratesProvider, NormalIborFutureOptionVolatilities volatilities, double futurePrice, double lastOptionSettlementPrice) { double optionPrice = futureOptionPricer.price(trade.getProduct(), ratesProvider, volatilities, futurePrice); return presentValue(trade, ratesProvider.getValuationDate(), optionPrice, lastOptionSettlementPrice); }
static ResolvedIborFutureOptionTrade sut() { return ResolvedIborFutureOptionTrade.builder() .info(TRADE_INFO) .product(PRODUCT) .quantity(QUANTITY) .tradedPrice(TradedPrice.of(TRADE_DATE, PRICE)) .build(); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 3237038: // info return ((ResolvedIborFutureOptionTrade) bean).getInfo(); case -309474065: // product return ((ResolvedIborFutureOptionTrade) bean).getProduct(); case -1285004149: // quantity return ((ResolvedIborFutureOptionTrade) bean).getQuantity(); case -1873824343: // tradedPrice return ((ResolvedIborFutureOptionTrade) bean).tradedPrice; } return super.propertyGet(bean, propertyName, quiet); }
/** * Calculates the present value of the Ibor 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 current price for the option, in decimal form * @param lastOptionSettlementPrice the last settlement price used for margining for the option, in decimal form * @return the present value */ public CurrencyAmount presentValue( ResolvedIborFutureOptionTrade trade, LocalDate valuationDate, double currentOptionPrice, double lastOptionSettlementPrice) { ResolvedIborFutureOption option = trade.getProduct(); double referencePrice = referencePrice(trade, valuationDate, lastOptionSettlementPrice); double priceIndex = futureOptionPricer.marginIndex(option, currentOptionPrice); double referenceIndex = futureOptionPricer.marginIndex(option, referencePrice); double pv = (priceIndex - referenceIndex) * trade.getQuantity(); return CurrencyAmount.of(option.getUnderlyingFuture().getCurrency(), pv); }
/** * Computes the present value sensitivity to the normal 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 ratesProvider the rates provider * @param volatilities the volatilities * @return the price sensitivity */ public IborFutureOptionSensitivity presentValueSensitivityModelParamsVolatility( ResolvedIborFutureOptionTrade futureOptionTrade, RatesProvider ratesProvider, NormalIborFutureOptionVolatilities volatilities) { ResolvedIborFuture future = futureOptionTrade.getProduct().getUnderlyingFuture(); double futurePrice = futureOptionPricer.getFuturePricer().price(future, ratesProvider); return presentValueSensitivityModelParamsVolatility(futureOptionTrade, ratesProvider, volatilities, futurePrice); }
static ResolvedIborFutureOptionTrade sut2() { return ResolvedIborFutureOptionTrade.builder() .info(TRADE_INFO2) .product(PRODUCT2) .quantity(QUANTITY2) .tradedPrice(TradedPrice.of(TRADE_DATE, PRICE2)) .build(); }
@Override public ResolvedIborFutureOptionTrade resolve(ReferenceData refData) { ResolvedIborFutureOption resolved = product.resolve(refData); return new ResolvedIborFutureOptionTrade(info, resolved, getQuantity(), null); }
@Override public ResolvedIborFutureOptionTrade resolve(ReferenceData refData) { if (!info.getTradeDate().isPresent()) { throw new IllegalArgumentException("Trade date on TradeInfo must be present"); } ResolvedIborFutureOption resolved = getProduct().resolve(refData); TradedPrice tradedPrice = TradedPrice.of(info.getTradeDate().get(), price); return new ResolvedIborFutureOptionTrade(info, resolved, quantity, tradedPrice); }