T - the type of target handled by this functionpublic interface CalculationFunction<T extends CalculationTarget>
Implementations of this interface provide the ability to calculate one or more measures
for a target (trade) using one or more sets of market data (scenarios).
The methods of the function allow the CalculationRunner to correctly invoke the function:
targetType()
- the target type that the function applies to
supportedMeasures()
- the set of measures that can be calculated
naturalCurrency(CalculationTarget, ReferenceData)
- the "natural" currency of the target
requirements(CalculationTarget, Set, CalculationParameters, ReferenceData)
- the market data requirements for performing the calculation
calculate(CalculationTarget, Set, CalculationParameters, ScenarioMarketData, ReferenceData)
- perform the calculation
If any of the calculated values contain any currency amounts and implement ScenarioFxConvertible
the calculation runner will automatically convert the amounts into the reporting currency.
| Modifier and Type | Method and Description |
|---|---|
Map<Measure,Result<?>> |
calculate(T target,
Set<Measure> measures,
CalculationParameters parameters,
ScenarioMarketData marketData,
ReferenceData refData)
Calculates values of multiple measures for the target using multiple sets of market data.
|
default 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.
|
Class<T> targetType()
The target type will typically be a concrete class.
Set<Measure> supportedMeasures()
default Optional<String> identifier(T 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.
target - the target of the calculationCurrency naturalCurrency(T target, ReferenceData refData)
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 currency-convertible 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 currency-convertible measures.
target - the target of the calculationrefData - the reference data to be used in the calculationIllegalStateException - if the function calculates no currency-convertible measuresFunctionRequirements requirements(T target, Set<Measure> measures, CalculationParameters parameters, ReferenceData refData)
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.
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 calculationMap<Measure,Result<?>> calculate(T target, Set<Measure> measures, CalculationParameters parameters, ScenarioMarketData marketData, ReferenceData refData)
The set of measures must only contain measures that the function supports,
as returned by supportedMeasures(). The market data must provide at least the
set of data requested by 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 implement ScenarioArray.
target - the target of the calculationmeasures - the set of measures to calculateparameters - the parameters that affect how the calculation is performedmarketData - the multi-scenario market data to be used in the calculationrefData - the reference data to be used in the calculationCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.