diff --git a/modules/measure/src/main/java/com/opengamma/strata/measure/fxopt/FxCollarMeasureCalculations.java b/modules/measure/src/main/java/com/opengamma/strata/measure/fxopt/FxCollarMeasureCalculations.java index 400eecdd56..8913279a6b 100644 --- a/modules/measure/src/main/java/com/opengamma/strata/measure/fxopt/FxCollarMeasureCalculations.java +++ b/modules/measure/src/main/java/com/opengamma/strata/measure/fxopt/FxCollarMeasureCalculations.java @@ -1,9 +1,12 @@ +/* + * Copyright (C) 2016 - present by OpenGamma Inc. and the OpenGamma group of companies + * + * Please see distribution for license. + */ package com.opengamma.strata.measure.fxopt; import static com.opengamma.strata.measure.fxopt.FxCalculationUtils.checkBlackVolatilities; -import java.time.LocalDate; - import com.opengamma.strata.basics.currency.CurrencyAmount; import com.opengamma.strata.basics.currency.CurrencyPair; import com.opengamma.strata.basics.currency.MultiCurrencyAmount; @@ -20,6 +23,7 @@ import com.opengamma.strata.pricer.rate.RatesProvider; import com.opengamma.strata.pricer.sensitivity.MarketQuoteSensitivityCalculator; import com.opengamma.strata.product.fxopt.ResolvedFxCollarTrade; +import java.time.LocalDate; /** * Multi-scenario measure calculations for FX collar trades. @@ -61,6 +65,7 @@ MultiCurrencyScenarioArray presentValue( ResolvedFxCollarTrade trade, RatesScenarioMarketData ratesMarketData, FxOptionScenarioMarketData optionMarketData) { + CurrencyPair currencyPair = trade.getProduct().getOption1().getCurrencyPair(); return MultiCurrencyScenarioArray.of( ratesMarketData.getScenarioCount(), @@ -75,6 +80,7 @@ MultiCurrencyAmount presentValue( ResolvedFxCollarTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities) { + return tradePricer.presentValue(trade, ratesProvider, checkBlackVolatilities(volatilities)); } @@ -108,6 +114,7 @@ ScenarioArray pv01RatesCalibratedBucketed( ResolvedFxCollarTrade trade, RatesScenarioMarketData ratesMarketData, FxOptionScenarioMarketData optionMarketData) { + CurrencyPair currencyPair = trade.getProduct().getOption1().getCurrencyPair(); return ScenarioArray.of( ratesMarketData.getScenarioCount(), @@ -181,6 +188,7 @@ private CurrencyParameterSensitivities pointSensitivity( ResolvedFxCollarTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities) { + PointSensitivities pointSens = tradePricer.presentValueSensitivityRatesStickyStrike( trade, ratesProvider, checkBlackVolatilities(volatilities)); return ratesProvider.parameterSensitivity(pointSens); @@ -207,10 +215,10 @@ CurrencyParameterSensitivities vegaMarketQuoteBucketed( RatesProvider ratesProvider, FxOptionVolatilities volatilities) { - BlackFxOptionVolatilities blackVols = checkBlackVolatilities(volatilities); - PointSensitivities pointSens = - tradePricer.presentValueSensitivityModelParamsVolatility(trade, ratesProvider, blackVols); - return blackVols.parameterSensitivity(pointSens); + BlackFxOptionVolatilities blackVols = checkBlackVolatilities(volatilities); + PointSensitivities pointSens = + tradePricer.presentValueSensitivityModelParamsVolatility(trade, ratesProvider, blackVols); + return blackVols.parameterSensitivity(pointSens); } // calculates currency exposure for all scenarios @@ -233,7 +241,8 @@ MultiCurrencyAmount currencyExposure( ResolvedFxCollarTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities) { - return tradePricer.currencyExposure(trade, ratesProvider, checkBlackVolatilities(volatilities)); + + return tradePricer.currencyExposure(trade, ratesProvider, checkBlackVolatilities(volatilities)); } // calculates current cash for all scenarios @@ -253,6 +262,7 @@ CurrencyScenarioArray currentCash( CurrencyAmount currentCash( ResolvedFxCollarTrade trade, LocalDate valuationDate) { - return tradePricer.currentCash(trade, valuationDate); + + return tradePricer.currentCash(trade, valuationDate); } } diff --git a/modules/measure/src/main/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculationFunction.java b/modules/measure/src/main/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculationFunction.java index af05226ebd..a226f7ca40 100644 --- a/modules/measure/src/main/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculationFunction.java +++ b/modules/measure/src/main/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculationFunction.java @@ -5,11 +5,6 @@ */ package com.opengamma.strata.measure.fxopt; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.Set; - import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.opengamma.strata.basics.ReferenceData; @@ -28,7 +23,32 @@ import com.opengamma.strata.product.fxopt.FxCollar; import com.opengamma.strata.product.fxopt.FxCollarTrade; import com.opengamma.strata.product.fxopt.ResolvedFxCollarTrade; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +/** + * Perform calculations on an FX collar trade for each of a set of scenarios. + *

+ * This uses Black FX option volatilities, which must be specified using {@link FxOptionMarketDataLookup}. + * An instance of {@link RatesMarketDataLookup} must also be specified. + *

+ * The supported built-in measures are: + *

+ *

+ * The "natural" currency is the market convention base currency of the underlying FX. + */ public class FxCollarTradeCalculationFunction implements CalculationFunction { /** diff --git a/modules/measure/src/main/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculations.java b/modules/measure/src/main/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculations.java index ce21d194d5..e5a71e6f6f 100644 --- a/modules/measure/src/main/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculations.java +++ b/modules/measure/src/main/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculations.java @@ -1,3 +1,8 @@ +/* + * Copyright (C) 2016 - present by OpenGamma Inc. and the OpenGamma group of companies + * + * Please see distribution for license. + */ package com.opengamma.strata.measure.fxopt; import com.opengamma.strata.basics.currency.CurrencyAmount; @@ -13,6 +18,19 @@ import com.opengamma.strata.pricer.rate.RatesProvider; import com.opengamma.strata.product.fxopt.ResolvedFxCollarTrade; +/** + * Calculates pricing and risk measures for FX collar trades. + *

+ * This provides a high-level entry point for FX collar pricing and risk measures. + * Pricing is performed using the Black method. + *

+ * Each method takes a {@link ResolvedFxCollarTrade}, whereas application code will + * typically work with {@link com.opengamma.strata.product.fxopt.FxCollarTrade} + * . Call + * {@link com.opengamma.strata.product.fxopt.FxCollarTrade + * #resolve(com.opengamma.strata.basics.ReferenceData) FxVanillaOptionTrade::resolve(ReferenceData)} + * to convert {@code FxVanillaOptionTrade} to {@code ResolvedFxVanillaOptionTrade}. + */ public class FxCollarTradeCalculations { /** @@ -52,6 +70,7 @@ public MultiCurrencyScenarioArray presentValue( RatesMarketDataLookup ratesLookup, FxOptionMarketDataLookup fxLookup, ScenarioMarketData marketData) { + return calc.presentValue( trade, ratesLookup.marketDataView(marketData), @@ -70,6 +89,7 @@ public MultiCurrencyAmount presentValue( ResolvedFxCollarTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities) { + return calc.presentValue(trade, ratesProvider, volatilities); } @@ -90,6 +110,7 @@ public MultiCurrencyScenarioArray pv01RatesCalibratedSum( RatesMarketDataLookup ratesLookup, FxOptionMarketDataLookup fxLookup, ScenarioMarketData marketData) { + return calc.pv01RatesCalibratedSum( trade, ratesLookup.marketDataView(marketData), @@ -111,6 +132,7 @@ public MultiCurrencyAmount pv01RatesCalibratedSum( ResolvedFxCollarTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities) { + return calc.pv01RatesCalibratedSum(trade, ratesProvider, volatilities); } @@ -131,6 +153,7 @@ public ScenarioArray pv01RatesCalibratedBucketed RatesMarketDataLookup ratesLookup, FxOptionMarketDataLookup fxLookup, ScenarioMarketData marketData) { + return calc.pv01RatesCalibratedBucketed( trade, ratesLookup.marketDataView(marketData), @@ -152,6 +175,7 @@ public CurrencyParameterSensitivities pv01RatesCalibratedBucketed( ResolvedFxCollarTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities) { + return calc.pv01RatesCalibratedBucketed(trade, ratesProvider, volatilities); } @@ -173,6 +197,7 @@ public MultiCurrencyScenarioArray pv01RatesMarketQuoteSum( RatesMarketDataLookup ratesLookup, FxOptionMarketDataLookup fxLookup, ScenarioMarketData marketData) { + return calc.pv01RatesMarketQuoteSum( trade, ratesLookup.marketDataView(marketData), @@ -195,6 +220,7 @@ public MultiCurrencyAmount pv01RatesMarketQuoteSum( ResolvedFxCollarTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities) { + return calc.pv01RatesMarketQuoteSum(trade, ratesProvider, volatilities); } @@ -216,6 +242,7 @@ public ScenarioArray pv01RatesMarketQuoteBuckete RatesMarketDataLookup ratesLookup, FxOptionMarketDataLookup fxLookup, ScenarioMarketData marketData) { + return calc.pv01RatesMarketQuoteBucketed( trade, ratesLookup.marketDataView(marketData), @@ -238,6 +265,7 @@ public CurrencyParameterSensitivities pv01RatesMarketQuoteBucketed( ResolvedFxCollarTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities) { + return calc.pv01RatesMarketQuoteBucketed(trade, ratesProvider, volatilities); } @@ -258,6 +286,7 @@ public ScenarioArray vegaMarketQuoteBucketed( RatesMarketDataLookup ratesLookup, FxOptionMarketDataLookup fxLookup, ScenarioMarketData marketData) { + return calc.vegaMarketQuoteBucketed( trade, ratesLookup.marketDataView(marketData), @@ -279,6 +308,7 @@ public CurrencyParameterSensitivities vegaMarketQuoteBucketed( ResolvedFxCollarTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities) { + return calc.vegaMarketQuoteBucketed(trade, ratesProvider, volatilities); } @@ -298,6 +328,7 @@ public MultiCurrencyScenarioArray currencyExposure( RatesMarketDataLookup ratesLookup, FxOptionMarketDataLookup fxLookup, ScenarioMarketData marketData) { + return calc.currencyExposure( trade, ratesLookup.marketDataView(marketData), @@ -318,6 +349,7 @@ public MultiCurrencyAmount currencyExposure( ResolvedFxCollarTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities) { + return calc.currencyExposure(trade, ratesProvider, volatilities); } @@ -329,6 +361,7 @@ public MultiCurrencyAmount currencyExposure( * @param trade the trade * @param ratesLookup the lookup used to query the market data * @param marketData the market data + * @param fxLookup the market data lookup * @return the current cash, one entry per scenario */ public CurrencyScenarioArray currentCash( @@ -336,6 +369,7 @@ public CurrencyScenarioArray currentCash( RatesMarketDataLookup ratesLookup, FxOptionMarketDataLookup fxLookup, ScenarioMarketData marketData) { + return calc.currentCash( trade, ratesLookup.marketDataView(marketData), @@ -354,6 +388,7 @@ public CurrencyScenarioArray currentCash( public CurrencyAmount currentCash( ResolvedFxCollarTrade trade, RatesProvider ratesProvider) { + return calc.currentCash(trade, ratesProvider.getValuationDate()); } } diff --git a/modules/measure/src/test/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculationFunctionTest.java b/modules/measure/src/test/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculationFunctionTest.java index 8a99965092..bf07cd44c1 100644 --- a/modules/measure/src/test/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculationFunctionTest.java +++ b/modules/measure/src/test/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculationFunctionTest.java @@ -1,3 +1,8 @@ +/* + * Copyright (C) 2016 - present by OpenGamma Inc. and the OpenGamma group of companies + * + * Please see distribution for license. + */ package com.opengamma.strata.measure.fxopt; import static com.opengamma.strata.basics.currency.Currency.EUR; diff --git a/modules/measure/src/test/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculationsTest.java b/modules/measure/src/test/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculationsTest.java index 343cf7da66..bf77d211c0 100644 --- a/modules/measure/src/test/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculationsTest.java +++ b/modules/measure/src/test/java/com/opengamma/strata/measure/fxopt/FxCollarTradeCalculationsTest.java @@ -1,3 +1,8 @@ +/* + * Copyright (C) 2016 - present by OpenGamma Inc. and the OpenGamma group of companies + * + * Please see distribution for license. + */ package com.opengamma.strata.measure.fxopt; import static org.assertj.core.api.Assertions.assertThat; diff --git a/modules/pricer/src/test/java/com/opengamma/strata/pricer/fxopt/DiscountingFxCollarProductPricerTest.java b/modules/pricer/src/test/java/com/opengamma/strata/pricer/fxopt/DiscountingFxCollarProductPricerTest.java index 2f8263e122..605659b303 100644 --- a/modules/pricer/src/test/java/com/opengamma/strata/pricer/fxopt/DiscountingFxCollarProductPricerTest.java +++ b/modules/pricer/src/test/java/com/opengamma/strata/pricer/fxopt/DiscountingFxCollarProductPricerTest.java @@ -1,3 +1,8 @@ +/* + * 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 static com.opengamma.strata.basics.currency.Currency.EUR; @@ -34,7 +39,6 @@ */ public class DiscountingFxCollarProductPricerTest { - private static final ZoneId ZONE = ZoneId.of("Z"); private static final ZonedDateTime EXPIRY = ZonedDateTime.of(2014, 5, 9, 13, 10, 0, 0, ZONE); private static final LocalDate VAL_DATE = RatesProviderDataSets.VAL_DATE_2014_01_22; @@ -55,7 +59,6 @@ public class DiscountingFxCollarProductPricerTest { private static final BlackFxOptionSmileVolatilities VOLS_AFTER = FxVolatilitySmileDataSet.createVolatilitySmileProvider6(VAL_DATETIME_AFTER); - private static final CurrencyPair CURRENCY_PAIR = CurrencyPair.of(EUR, USD); private static final double NOTIONAL = 1.0e6; private static final LocalDate PAYMENT_DATE = LocalDate.of(2014, 5, 13); diff --git a/modules/pricer/src/test/java/com/opengamma/strata/pricer/fxopt/DiscountingFxCollarTradePricerTest.java b/modules/pricer/src/test/java/com/opengamma/strata/pricer/fxopt/DiscountingFxCollarTradePricerTest.java index ba13d5b377..ba2227fd38 100644 --- a/modules/pricer/src/test/java/com/opengamma/strata/pricer/fxopt/DiscountingFxCollarTradePricerTest.java +++ b/modules/pricer/src/test/java/com/opengamma/strata/pricer/fxopt/DiscountingFxCollarTradePricerTest.java @@ -1,3 +1,8 @@ +/* + * 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 static com.opengamma.strata.basics.currency.Currency.EUR;