FX
This post-processor converts a scalar value from a source currency to a display currency. If the input value is a double array, only the first entry of the array is taken in account, the output value is always a double.
import com.activeviam.accelerator.common.postprocessor.fxconversion.impl.FX;
// ...
injectAll(ICustomParametersAware.class, (pivot, properties, ppPluginKey) -> (location, cache) -> List.of());
injectAll(IFXRatesAware.class, new FxRates("EUR"));
// ...
CopperMeasure fx = FX.measure(
Copper.sum("MtM native"),
getAsOfDateLevel(),
getCurrencyLevel(),
getDisplayCurrencyLevel())
.withFormatter("DOUBLE[#,##0.00;-#,##0.00]")
.as("MtM")
.publish(context);;
The post-processor uses two beans :
ICustomParameters
: (optional) provides extra leaves to theIFXRates
method calls (see Bean services for post-processors).IFXRates
provides the FX rate service used by the post-processor to retrieve the FX rate itself.
If the display currency level is not set, the post-processor will use the IReferenceCurrency
context value to retrieve it.
Here are the parameters of the measure
function:
Parameters | Type | Mandatory | Usage |
---|---|---|---|
underlyingMeasure | CopperMeasure | X | The value expressed in the source currency. |
asOfDateLevel | LevelIdentifier | X | The date level of the exchange rate to retrieve. |
currencyLevel | LevelIdentifier | X | The source currency level. |
referenceCcyLvl | LevelIdentifier | The destination currency level, if not set, the post-processor will use the IReferenceCurrency context value. |
|
dateInfo | IDateShift | Date shift used to retrieve, for instance, the previous day rate. | |
preferredCurrency | String | Fallback display currency when no referenceCcyLvl and no IReferenceCurrency context values are set. |
Real time handling
To handle continuous query updates, a continuous query handler is added. By default, the following continuous query handlers STORED,STORE_TICK[FXRates]
are added to the ones from the underlying metric, which means that the metric is updated on any location change and on any FXRates
store updates.
You can change this default setup using the following functions:
Function | Description |
---|---|
withContinuousQueryHandlers(String... handlers) |
Completely changes the used handlers. |
withStoreTick(String storeName) |
Changes the store triggering the updates. |
addContinuousQueryHandlers(String... handlers) |
Adds another set of handlers instead of the default ones. |