FXRate

This post-processor provides the current FX exchange rate related to the current location.

import com.activeviam.accelerator.common.postprocessor.fxconversion.impl.FXRate;

// ...
injectAll(ICustomParametersAware.class, (pivot, properties, ppPluginKey) -> (location, cache) -> List.of());
injectAll(IFXRatesAware.class, new FxRates("EUR"));

// ...
CopperMeasure fx = FXRate.measure(
                getAsOfDateLevel(),
                getCurrencyLevel(),
                getDisplayCurrencyLevel())
        .withFormatter("DOUBLE[#,##0.00;-#,##0.00]")
        .withinFolder("FX Rate")
        .as("Delta FX Rate")
        .publish(context);

The post-processor uses two beans:

  • ICustomParameters (optional) provides extra leaves to the IFXRates 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
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 set. By default, the continuous query handlers are set to STORED,STORE_TICK[FXRates], 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.