All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.opengamma.strata.pricer.fxopt.BlackFxVanillaOptionTradePricer Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2015 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.strata.pricer.fxopt;

import java.time.LocalDate;

import com.opengamma.strata.basics.currency.CurrencyAmount;
import com.opengamma.strata.basics.currency.FxRate;
import com.opengamma.strata.basics.currency.MultiCurrencyAmount;
import com.opengamma.strata.basics.currency.Payment;
import com.opengamma.strata.collect.ArgChecker;
import com.opengamma.strata.market.sensitivity.PointSensitivities;
import com.opengamma.strata.pricer.DiscountingPaymentPricer;
import com.opengamma.strata.pricer.rate.RatesProvider;
import com.opengamma.strata.product.fxopt.FxVanillaOptionTrade;
import com.opengamma.strata.product.fxopt.ResolvedFxSingleBarrierOption;
import com.opengamma.strata.product.fxopt.ResolvedFxVanillaOption;
import com.opengamma.strata.product.fxopt.ResolvedFxVanillaOptionTrade;

/**
 * Pricer for FX vanilla option trades with a lognormal model.
 * 

* This function provides the ability to price an {@link FxVanillaOptionTrade}. */ public class BlackFxVanillaOptionTradePricer { /** * Default implementation. */ public static final BlackFxVanillaOptionTradePricer DEFAULT = new BlackFxVanillaOptionTradePricer( BlackFxVanillaOptionProductPricer.DEFAULT, DiscountingPaymentPricer.DEFAULT); /** * Pricer for {@link ResolvedFxSingleBarrierOption}. */ private final BlackFxVanillaOptionProductPricer productPricer; /** * Pricer for {@link Payment}. */ private final DiscountingPaymentPricer paymentPricer; /** * Creates an instance. * * @param productPricer the pricer for {@link ResolvedFxVanillaOption} * @param paymentPricer the pricer for {@link Payment} */ public BlackFxVanillaOptionTradePricer( BlackFxVanillaOptionProductPricer productPricer, DiscountingPaymentPricer paymentPricer) { this.productPricer = ArgChecker.notNull(productPricer, "productPricer"); this.paymentPricer = ArgChecker.notNull(paymentPricer, "paymentPricer"); } //------------------------------------------------------------------------- /** * Calculates the present value of the FX vanilla option trade. *

* The present value of the trade is the value on the valuation date. * * @param trade the option trade * @param ratesProvider the rates provider * @param volatilities the Black volatility provider * @return the present value of the trade */ public MultiCurrencyAmount presentValue( ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, BlackFxOptionVolatilities volatilities) { ResolvedFxVanillaOption product = trade.getProduct(); CurrencyAmount pvProduct = productPricer.presentValue(product, ratesProvider, volatilities); Payment premium = trade.getPremium(); CurrencyAmount pvPremium = paymentPricer.presentValue(premium, ratesProvider); return MultiCurrencyAmount.of(pvProduct).plus(pvPremium); } //------------------------------------------------------------------------- /** * Calculates the present value sensitivity of the FX vanilla option trade. *

* The present value sensitivity of the trade is the sensitivity of the present value to * the underlying curves. *

* The volatility is fixed in this sensitivity computation. * * @param trade the option trade * @param ratesProvider the rates provider * @param volatilities the Black volatility provider * @return the present value curve sensitivity of the trade */ public PointSensitivities presentValueSensitivityRatesStickyStrike( ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, BlackFxOptionVolatilities volatilities) { ResolvedFxVanillaOption product = trade.getProduct(); PointSensitivities pvcsProduct = productPricer.presentValueSensitivityRatesStickyStrike(product, ratesProvider, volatilities); Payment premium = trade.getPremium(); PointSensitivities pvcsPremium = paymentPricer.presentValueSensitivity(premium, ratesProvider).build(); return pvcsProduct.combinedWith(pvcsPremium); } //------------------------------------------------------------------------- /** * Computes the present value sensitivity to the black volatility used in the pricing. *

* The result is a single sensitivity to the volatility used. * * @param trade the option trade * @param ratesProvider the rates provider * @param volatilities the Black volatility provider * @return the present value sensitivity */ public PointSensitivities presentValueSensitivityModelParamsVolatility( ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, BlackFxOptionVolatilities volatilities) { ResolvedFxVanillaOption product = trade.getProduct(); return productPricer.presentValueSensitivityModelParamsVolatility(product, ratesProvider, volatilities).build(); } //------------------------------------------------------------------------- /** * Calculates the currency exposure of the FX vanilla option trade. * * @param trade the option trade * @param ratesProvider the rates provider * @param volatilities the Black volatility provider * @return the currency exposure */ public MultiCurrencyAmount currencyExposure( ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, BlackFxOptionVolatilities volatilities) { Payment premium = trade.getPremium(); CurrencyAmount pvPremium = paymentPricer.presentValue(premium, ratesProvider); ResolvedFxVanillaOption product = trade.getProduct(); return productPricer.currencyExposure(product, ratesProvider, volatilities).plus(pvPremium); } //------------------------------------------------------------------------- /** * Calculates the current of the FX vanilla option trade. * * @param trade the option trade * @param valuationDate the valuation date * @return the current cash amount */ public CurrencyAmount currentCash(ResolvedFxVanillaOptionTrade trade, LocalDate valuationDate) { Payment premium = trade.getPremium(); if (premium.getDate().equals(valuationDate)) { return CurrencyAmount.of(premium.getCurrency(), premium.getAmount()); } return CurrencyAmount.of(premium.getCurrency(), 0d); } //------------------------------------------------------------------------- /** * Calculates the forward exchange rate. * * @param trade the option trade * @param ratesProvider the rates provider * @return the forward rate */ public FxRate forwardFxRate(ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider) { ResolvedFxVanillaOption product = trade.getProduct(); return productPricer.forwardFxRate(product, ratesProvider); } //------------------------------------------------------------------------- /** * Calculates the implied Black volatility of the foreign exchange vanilla option trade. * * @param trade the option trade * @param ratesProvider the rates provider * @param volatilities the Black volatility provider * @return the implied volatility of the product * @throws IllegalArgumentException if the option has expired */ public double impliedVolatility( ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, BlackFxOptionVolatilities volatilities) { ResolvedFxVanillaOption option = trade.getProduct(); return productPricer.impliedVolatility(option, ratesProvider, volatilities); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy