Class DsfTradeCalculationFunction<T extends SecuritizedProductPortfolioItem<Dsf> & Resolvable<ResolvedDsfTrade>>
 java.lang.Object

 com.opengamma.strata.measure.dsf.DsfTradeCalculationFunction<T>

 Type Parameters:
T
 the trade or position type
 All Implemented Interfaces:
CalculationFunction<T>
public class DsfTradeCalculationFunction<T extends SecuritizedProductPortfolioItem<Dsf> & Resolvable<ResolvedDsfTrade>> extends Object implements CalculationFunction<T>
Perform calculations on a singleDsfTrade
orDsfPosition
for each of a set of scenarios.This uses the standard discounting calculation method. An instance of
RatesMarketDataLookup
must be specified. The supported builtin measures are: Present value
 PV01 calibrated sum
 PV01 calibrated bucketed
 PV01 market quote sum
 PV01 market quote bucketed
 Unit price
 Currency exposure
 Resolved trade
The "natural" currency is the currency of the swap leg that is received.
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 (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.


Field Summary
Fields Modifier and Type Field Description static DsfTradeCalculationFunction<DsfPosition>
POSITION
The position instancestatic DsfTradeCalculationFunction<DsfTrade>
TRADE
The trade instance

Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<Measure,Result<?>>
calculate(T target, Set<Measure> measures, CalculationParameters parameters, ScenarioMarketData scenarioMarketData, ReferenceData refData)
Calculates values of multiple measures for the target using multiple sets of market data.Optional<String>
identifier(T target)
Returns an identifier that should uniquely identify the specified target.Currency
naturalCurrency(T target, ReferenceData refData)
Returns the "natural" currency for the specified target.FunctionRequirements
requirements(T target, Set<Measure> measures, CalculationParameters parameters, ReferenceData refData)
Determines the market data required by this function to perform its calculations.Set<Measure>
supportedMeasures()
Returns the set of measures that the function can calculate.Class<T>
targetType()
Gets the target type that this function applies to.



Field Detail

TRADE
public static final DsfTradeCalculationFunction<DsfTrade> TRADE
The trade instance

POSITION
public static final DsfTradeCalculationFunction<DsfPosition> POSITION
The position instance


Method Detail

targetType
public Class<T> targetType()
Description copied from interface:CalculationFunction
Gets the target type that this function applies to.The target type will typically be a concrete class.
 Specified by:
targetType
in interfaceCalculationFunction<T extends SecuritizedProductPortfolioItem<Dsf> & Resolvable<ResolvedDsfTrade>>
 Returns:
 the target type

supportedMeasures
public Set<Measure> supportedMeasures()
Description copied from interface:CalculationFunction
Returns the set of measures that the function can calculate. Specified by:
supportedMeasures
in interfaceCalculationFunction<T extends SecuritizedProductPortfolioItem<Dsf> & Resolvable<ResolvedDsfTrade>>
 Returns:
 the readonly set of measures that the function can calculate

identifier
public Optional<String> identifier(T target)
Description copied from interface:CalculationFunction
Returns an identifier that should uniquely identify the specified target.This identifier is used in error messages to identify the target. This should normally be overridden to provide a suitable identifier. For example, if the target is a trade, there will typically be a trade identifier available.
This method must not throw an exception.
 Specified by:
identifier
in interfaceCalculationFunction<T extends SecuritizedProductPortfolioItem<Dsf> & Resolvable<ResolvedDsfTrade>>
 Parameters:
target
 the target of the calculation Returns:
 the identifier of the target, empty if no suitable identifier available

naturalCurrency
public Currency naturalCurrency(T target, ReferenceData refData)
Description copied from interface:CalculationFunction
Returns the "natural" currency for the specified target.This is the currency to which currency amounts are converted if the "natural" reporting currency is requested using
ReportingCurrency.NATURAL
. Most targets have a "natural" currency, for example the currency of a FRA or the base currency of an FX forward.It is required that all functions that return a currencyconvertible measure must choose a "natural" currency for each trade. The choice must be consistent not random, given the same trade the same currency must be returned. This might involve picking, the first leg or base currency from a currency pair. An exception must only be thrown if the function handles no currencyconvertible measures.
 Specified by:
naturalCurrency
in interfaceCalculationFunction<T extends SecuritizedProductPortfolioItem<Dsf> & Resolvable<ResolvedDsfTrade>>
 Parameters:
target
 the target of the calculationrefData
 the reference data to be used in the calculation Returns:
 the "natural" currency of the target

requirements
public FunctionRequirements requirements(T target, Set<Measure> measures, CalculationParameters parameters, ReferenceData refData)
Description copied from interface:CalculationFunction
Determines the market data required by this function to perform its calculations.Any market data needed by the
calculate
method should be specified.The set of measures may include measures that are not supported by this function.
 Specified by:
requirements
in interfaceCalculationFunction<T extends SecuritizedProductPortfolioItem<Dsf> & Resolvable<ResolvedDsfTrade>>
 Parameters:
target
 the target of the calculationmeasures
 the set of measures to be calculatedparameters
 the parameters that affect how the calculation is performedrefData
 the reference data to be used in the calculation Returns:
 the requirements specifying the market data the function needs to perform calculations

calculate
public Map<Measure,Result<?>> calculate(T target, Set<Measure> measures, CalculationParameters parameters, ScenarioMarketData scenarioMarketData, ReferenceData refData)
Description copied from interface:CalculationFunction
Calculates values of multiple measures for the target using multiple sets of market data.The set of measures must only contain measures that the function supports, as returned by
CalculationFunction.supportedMeasures()
. The market data must provide at least the set of data requested byCalculationFunction.requirements(CalculationTarget, Set, CalculationParameters, ReferenceData)
.The result of this method will often be an instance of
ScenarioArray
, which handles the common case where there is one calculated value for each scenario. However, it is also possible for the function to calculate an aggregated result, such as the maximum or minimum value across all scenarios, in which case the result would not implementScenarioArray
. Specified by:
calculate
in interfaceCalculationFunction<T extends SecuritizedProductPortfolioItem<Dsf> & Resolvable<ResolvedDsfTrade>>
 Parameters:
target
 the target of the calculationmeasures
 the set of measures to calculateparameters
 the parameters that affect how the calculation is performedscenarioMarketData
 the multiscenario market data to be used in the calculationrefData
 the reference data to be used in the calculation Returns:
 the readonly map of calculated values, keyed by their measure

