com.opengamma.strata.measure.fx.FxSwapTradeCalculations Maven / Gradle / Ivy
/*
* Copyright (C) 2016 - present by OpenGamma Inc. and the OpenGamma group of companies
*
* Please see distribution for license.
*/
package com.opengamma.strata.measure.fx;
import com.opengamma.strata.basics.currency.MultiCurrencyAmount;
import com.opengamma.strata.data.scenario.DoubleScenarioArray;
import com.opengamma.strata.data.scenario.MultiCurrencyScenarioArray;
import com.opengamma.strata.data.scenario.ScenarioArray;
import com.opengamma.strata.data.scenario.ScenarioMarketData;
import com.opengamma.strata.market.param.CurrencyParameterSensitivities;
import com.opengamma.strata.measure.rate.RatesMarketDataLookup;
import com.opengamma.strata.pricer.fx.DiscountingFxSwapTradePricer;
import com.opengamma.strata.pricer.rate.RatesProvider;
import com.opengamma.strata.product.fx.FxSwapTrade;
import com.opengamma.strata.product.fx.ResolvedFxSwapTrade;
/**
* Calculates pricing and risk measures for FX swap trades.
*
* This provides a high-level entry point for FX swap pricing and risk measures.
*
* Each method takes a {@link ResolvedFxSwapTrade}, whereas application code will
* typically work with {@link FxSwapTrade}. Call
* {@link FxSwapTrade#resolve(com.opengamma.strata.basics.ReferenceData) FxSwapTrade::resolve(ReferenceData)}
* to convert {@code FxSwapTrade} to {@code ResolvedFxSwapTrade}.
*/
public class FxSwapTradeCalculations {
/**
* Default implementation.
*/
public static final FxSwapTradeCalculations DEFAULT = new FxSwapTradeCalculations(
DiscountingFxSwapTradePricer.DEFAULT);
/**
* Pricer for {@link ResolvedFxSwapTrade}.
*/
private final FxSwapMeasureCalculations calc;
/**
* Creates an instance.
*
* In most cases, applications should use the {@link #DEFAULT} instance.
*
* @param tradePricer the pricer for {@link ResolvedFxSwapTrade}
*/
public FxSwapTradeCalculations(
DiscountingFxSwapTradePricer tradePricer) {
this.calc = new FxSwapMeasureCalculations(tradePricer);
}
//-------------------------------------------------------------------------
/**
* Calculates present value across one or more scenarios.
*
* @param trade the trade
* @param lookup the lookup used to query the market data
* @param marketData the market data
* @return the present value, one entry per scenario
*/
public MultiCurrencyScenarioArray presentValue(
ResolvedFxSwapTrade trade,
RatesMarketDataLookup lookup,
ScenarioMarketData marketData) {
return calc.presentValue(trade, lookup.marketDataView(marketData));
}
/**
* Calculates present value for a single set of market data.
*
* @param trade the trade
* @param ratesProvider the market data
* @return the present value
*/
public MultiCurrencyAmount presentValue(
ResolvedFxSwapTrade trade,
RatesProvider ratesProvider) {
return calc.presentValue(trade, ratesProvider);
}
//-------------------------------------------------------------------------
/**
* Calculates present value sensitivity across one or more scenarios.
*
* This is the sensitivity of
* {@linkplain #presentValue(ResolvedFxSwapTrade, RatesMarketDataLookup, ScenarioMarketData) present value}
* to a one basis point shift in the calibrated curves.
* The result is the sum of the sensitivities of all affected curves.
*
* @param trade the trade
* @param lookup the lookup used to query the market data
* @param marketData the market data
* @return the present value sensitivity, one entry per scenario
*/
public MultiCurrencyScenarioArray pv01CalibratedSum(
ResolvedFxSwapTrade trade,
RatesMarketDataLookup lookup,
ScenarioMarketData marketData) {
return calc.pv01CalibratedSum(trade, lookup.marketDataView(marketData));
}
/**
* Calculates present value sensitivity for a single set of market data.
*
* This is the sensitivity of
* {@linkplain #presentValue(ResolvedFxSwapTrade, RatesMarketDataLookup, ScenarioMarketData) present value}
* to a one basis point shift in the calibrated curves.
* The result is the sum of the sensitivities of all affected curves.
*
* @param trade the trade
* @param ratesProvider the market data
* @return the present value sensitivity
*/
public MultiCurrencyAmount pv01CalibratedSum(
ResolvedFxSwapTrade trade,
RatesProvider ratesProvider) {
return calc.pv01CalibratedSum(trade, ratesProvider);
}
//-------------------------------------------------------------------------
/**
* Calculates present value sensitivity across one or more scenarios.
*
* This is the sensitivity of
* {@linkplain #presentValue(ResolvedFxSwapTrade, RatesMarketDataLookup, ScenarioMarketData) present value}
* to a one basis point shift in the calibrated curves.
* The result is provided for each affected curve and currency, bucketed by curve node.
*
* @param trade the trade
* @param lookup the lookup used to query the market data
* @param marketData the market data
* @return the present value sensitivity, one entry per scenario
*/
public ScenarioArray pv01CalibratedBucketed(
ResolvedFxSwapTrade trade,
RatesMarketDataLookup lookup,
ScenarioMarketData marketData) {
return calc.pv01CalibratedBucketed(trade, lookup.marketDataView(marketData));
}
/**
* Calculates present value sensitivity for a single set of market data.
*
* This is the sensitivity of
* {@linkplain #presentValue(ResolvedFxSwapTrade, RatesMarketDataLookup, ScenarioMarketData) present value}
* to a one basis point shift in the calibrated curves.
* The result is provided for each affected curve and currency, bucketed by curve node.
*
* @param trade the trade
* @param ratesProvider the market data
* @return the present value sensitivity
*/
public CurrencyParameterSensitivities pv01CalibratedBucketed(
ResolvedFxSwapTrade trade,
RatesProvider ratesProvider) {
return calc.pv01CalibratedBucketed(trade, ratesProvider);
}
//-------------------------------------------------------------------------
/**
* Calculates present value sensitivity across one or more scenarios.
*
* This is the sensitivity of
* {@linkplain #presentValue(ResolvedFxSwapTrade, RatesMarketDataLookup, ScenarioMarketData) present value}
* to a one basis point shift in the market quotes used to calibrate the curves.
* The result is the sum of the sensitivities of all affected curves.
*
* @param trade the trade
* @param lookup the lookup used to query the market data
* @param marketData the market data
* @return the present value sensitivity, one entry per scenario
*/
public MultiCurrencyScenarioArray pv01MarketQuoteSum(
ResolvedFxSwapTrade trade,
RatesMarketDataLookup lookup,
ScenarioMarketData marketData) {
return calc.pv01MarketQuoteSum(trade, lookup.marketDataView(marketData));
}
/**
* Calculates present value sensitivity for a single set of market data.
*
* This is the sensitivity of
* {@linkplain #presentValue(ResolvedFxSwapTrade, RatesMarketDataLookup, ScenarioMarketData) present value}
* to a one basis point shift in the market quotes used to calibrate the curves.
* The result is the sum of the sensitivities of all affected curves.
*
* @param trade the trade
* @param ratesProvider the market data
* @return the present value sensitivity
*/
public MultiCurrencyAmount pv01MarketQuoteSum(
ResolvedFxSwapTrade trade,
RatesProvider ratesProvider) {
return calc.pv01MarketQuoteSum(trade, ratesProvider);
}
//-------------------------------------------------------------------------
/**
* Calculates present value sensitivity across one or more scenarios.
*
* This is the sensitivity of
* {@linkplain #presentValue(ResolvedFxSwapTrade, RatesMarketDataLookup, ScenarioMarketData) present value}
* to a one basis point shift in the market quotes used to calibrate the curves.
* The result is provided for each affected curve and currency, bucketed by curve node.
*
* @param trade the trade
* @param lookup the lookup used to query the market data
* @param marketData the market data
* @return the present value sensitivity, one entry per scenario
*/
public ScenarioArray pv01MarketQuoteBucketed(
ResolvedFxSwapTrade trade,
RatesMarketDataLookup lookup,
ScenarioMarketData marketData) {
return calc.pv01MarketQuoteBucketed(trade, lookup.marketDataView(marketData));
}
/**
* Calculates present value sensitivity for a single set of market data.
*
* This is the sensitivity of
* {@linkplain #presentValue(ResolvedFxSwapTrade, RatesMarketDataLookup, ScenarioMarketData) present value}
* to a one basis point shift in the market quotes used to calibrate the curves.
* The result is provided for each affected curve and currency, bucketed by curve node.
*
* @param trade the trade
* @param ratesProvider the market data
* @return the present value sensitivity
*/
public CurrencyParameterSensitivities pv01MarketQuoteBucketed(
ResolvedFxSwapTrade trade,
RatesProvider ratesProvider) {
return calc.pv01MarketQuoteBucketed(trade, ratesProvider);
}
//-------------------------------------------------------------------------
/**
* Calculates par spread across one or more scenarios.
*
* @param trade the trade
* @param lookup the lookup used to query the market data
* @param marketData the market data
* @return the par spread, one entry per scenario
*/
public DoubleScenarioArray parSpread(
ResolvedFxSwapTrade trade,
RatesMarketDataLookup lookup,
ScenarioMarketData marketData) {
return calc.parSpread(trade, lookup.marketDataView(marketData));
}
/**
* Calculates par spread for a single set of market data.
*
* @param trade the trade
* @param ratesProvider the market data
* @return the par spread
*/
public double parSpread(
ResolvedFxSwapTrade trade,
RatesProvider ratesProvider) {
return calc.parSpread(trade, ratesProvider);
}
//-------------------------------------------------------------------------
/**
* Calculates currency exposure across one or more scenarios.
*
* The currency risk, expressed as the equivalent amount in each currency.
*
* @param trade the trade
* @param lookup the lookup used to query the market data
* @param marketData the market data
* @return the currency exposure, one entry per scenario
*/
public MultiCurrencyScenarioArray currencyExposure(
ResolvedFxSwapTrade trade,
RatesMarketDataLookup lookup,
ScenarioMarketData marketData) {
return calc.currencyExposure(trade, lookup.marketDataView(marketData));
}
/**
* Calculates currency exposure for a single set of market data.
*
* The currency risk, expressed as the equivalent amount in each currency.
*
* @param trade the trade
* @param ratesProvider the market data
* @return the currency exposure
*/
public MultiCurrencyAmount currencyExposure(
ResolvedFxSwapTrade trade,
RatesProvider ratesProvider) {
return calc.currencyExposure(trade, ratesProvider);
}
//-------------------------------------------------------------------------
/**
* Calculates current cash across one or more scenarios.
*
* The sum of all cash flows paid on the valuation date.
*
* @param trade the trade
* @param lookup the lookup used to query the market data
* @param marketData the market data
* @return the current cash, one entry per scenario
*/
public MultiCurrencyScenarioArray currentCash(
ResolvedFxSwapTrade trade,
RatesMarketDataLookup lookup,
ScenarioMarketData marketData) {
return calc.currentCash(trade, lookup.marketDataView(marketData));
}
/**
* Calculates current cash for a single set of market data.
*
* The sum of all cash flows paid on the valuation date.
*
* @param trade the trade
* @param ratesProvider the market data
* @return the current cash
*/
public MultiCurrencyAmount currentCash(
ResolvedFxSwapTrade trade,
RatesProvider ratesProvider) {
return calc.currentCash(trade, ratesProvider);
}
}