![JAR search and dependency download from the Maven repository](/logo.png)
com.opengamma.strata.measure.dsf.DsfTradeCalculations 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.dsf;
import com.opengamma.strata.basics.currency.CurrencyAmount;
import com.opengamma.strata.basics.currency.MultiCurrencyAmount;
import com.opengamma.strata.data.scenario.CurrencyScenarioArray;
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.dsf.DiscountingDsfTradePricer;
import com.opengamma.strata.pricer.rate.RatesProvider;
import com.opengamma.strata.product.dsf.DsfTrade;
import com.opengamma.strata.product.dsf.ResolvedDsfTrade;
/**
* Calculates pricing and risk measures for Deliverable Swap Future (DSF) trades.
*
* This provides a high-level entry point for DSF pricing and risk measures.
*
* Each method takes a {@link ResolvedDsfTrade}, whereas application code will
* typically work with {@link DsfTrade}. Call
* {@link DsfTrade#resolve(com.opengamma.strata.basics.ReferenceData) DsfTrade::resolve(ReferenceData)}
* to convert {@code DsfTrade} to {@code ResolvedDsfTrade}.
*
*
Price
* The price of a DSF is based on the present value (NPV) of the underlying swap on the delivery date.
* For example, a price of 100.182 represents a present value of $100,182.00, if the notional is $100,000.
* This price can also be viewed as a percentage present value - {@code (100 + percentPv)}, or 0.182% in this example.
*
* Strata uses decimal prices for DSFs in the trade model, pricers and market data.
* The decimal price is based on the decimal multiplier equivalent to the implied percentage.
* Thus the market price of 100.182 is represented in Strata by 1.00182.
*/
public class DsfTradeCalculations {
/**
* Default implementation.
*/
public static final DsfTradeCalculations DEFAULT = new DsfTradeCalculations(
DiscountingDsfTradePricer.DEFAULT);
/**
* Pricer for {@link ResolvedDsfTrade}.
*/
private final DsfMeasureCalculations calc;
/**
* Creates an instance.
*
* In most cases, applications should use the {@link #DEFAULT} instance.
*
* @param tradePricer the pricer for {@link ResolvedDsfTrade}
*/
public DsfTradeCalculations(
DiscountingDsfTradePricer tradePricer) {
this.calc = new DsfMeasureCalculations(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 CurrencyScenarioArray presentValue(
ResolvedDsfTrade 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 CurrencyAmount presentValue(
ResolvedDsfTrade trade,
RatesProvider ratesProvider) {
return calc.presentValue(trade, ratesProvider);
}
//-------------------------------------------------------------------------
/**
* Calculates present value sensitivity across one or more scenarios.
*
* This is the sensitivity of
* {@linkplain #presentValue(ResolvedDsfTrade, 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(
ResolvedDsfTrade 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(ResolvedDsfTrade, 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(
ResolvedDsfTrade trade,
RatesProvider ratesProvider) {
return calc.pv01CalibratedSum(trade, ratesProvider);
}
//-------------------------------------------------------------------------
/**
* Calculates present value sensitivity across one or more scenarios.
*
* This is the sensitivity of
* {@linkplain #presentValue(ResolvedDsfTrade, 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(
ResolvedDsfTrade 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(ResolvedDsfTrade, 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(
ResolvedDsfTrade trade,
RatesProvider ratesProvider) {
return calc.pv01CalibratedBucketed(trade, ratesProvider);
}
//-------------------------------------------------------------------------
/**
* Calculates present value sensitivity across one or more scenarios.
*
* This is the sensitivity of
* {@linkplain #presentValue(ResolvedDsfTrade, 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(
ResolvedDsfTrade 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(ResolvedDsfTrade, 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(
ResolvedDsfTrade trade,
RatesProvider ratesProvider) {
return calc.pv01MarketQuoteSum(trade, ratesProvider);
}
//-------------------------------------------------------------------------
/**
* Calculates present value sensitivity across one or more scenarios.
*
* This is the sensitivity of
* {@linkplain #presentValue(ResolvedDsfTrade, 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(
ResolvedDsfTrade 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(ResolvedDsfTrade, 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(
ResolvedDsfTrade trade,
RatesProvider ratesProvider) {
return calc.pv01MarketQuoteBucketed(trade, ratesProvider);
}
//-------------------------------------------------------------------------
/**
* Calculates unit price across one or more scenarios.
*
* This is the price of a single unit of the security.
*
* Strata uses decimal prices for DSFs in the trade model, pricers and market data.
* The decimal price is based on the decimal multiplier equivalent to the implied percentage.
* Thus the market price of 100.182 is represented in Strata by 1.00182.
*
* @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 DoubleScenarioArray unitPrice(
ResolvedDsfTrade trade,
RatesMarketDataLookup lookup,
ScenarioMarketData marketData) {
return calc.unitPrice(trade, lookup.marketDataView(marketData));
}
/**
* Calculates unit price for a single set of market data.
*
* This is the price of a single unit of the security.
*
* Strata uses decimal prices for DSFs in the trade model, pricers and market data.
* The decimal price is based on the decimal multiplier equivalent to the implied percentage.
* Thus the market price of 100.182 is represented in Strata by 1.00182.
*
* @param trade the trade
* @param ratesProvider the market data
* @return the present value
*/
public double unitPrice(
ResolvedDsfTrade trade,
RatesProvider ratesProvider) {
return calc.unitPrice(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(
ResolvedDsfTrade 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(
ResolvedDsfTrade trade,
RatesProvider ratesProvider) {
return calc.currencyExposure(trade, ratesProvider);
}
}