> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Exchange rate and market data API

> Guide to FX risk factor translation in Atoti Market Risk, covering the IRiskFactorFXPairTranslator interface, the RiskFactor hierarchy plugin, and the FX spot market data post-processor

## Relation between RiskFactor and currency pair

The `IRiskFactorFXPairTranslator` interface converts a risk factor into a currency pair and back.

It provides the following functions:

* `riskFactorToFxPair`: Conversion of a risk factor into a currency pair.
* `fxPairToRiskFactor`: Conversion of a currency pair into a risk factor.
* `isFxRiskFactor`: Specifies whether a risk factor is an FX risk factor and can be converted into a currency pair.

This interface has two implementations:

* `RiskFactorFXPairTranslator`: This translator assumes that **RiskFactor=ccy1/ccy2**.
* `LegacyRiskFactorFXPairTranslator`: This translator makes the same transformation as `RiskFactorFXPairTranslator` and also makes **\[ccy]\_FX Equivalent=EUR/ccy** according to the sample dataset.

This service can be injected into any plugin with the interface `IRiskFactorFXPairTranslatorAware`.
It is used by the Delta FX market data post-processor, the RiskFactor hierarchy, and the FX Shift service.

The `LegacyRiskFactorFXPairTranslator` bean is created on the configuration class `RiskFactorFXPairTranslatorConfig`.

## The RiskFactor hierarchy plugin

The `HierarchyWithFxRiskFactors` hierarchy plugin adds the FX Risk Factors in the `Risk Factors` hierarchy.
This hierarchy plugin is a fact one level hierarchy based on the cube retrieval, which adds all possible FX Risk Factors to the members based on the available currencies and the currency-pair-to-risk-factor translator.

## The FX Market Data post-processor

Atoti Market Risk uses a specific post-processor to compute the FX Delta market data: `FxSpotMarketDataPostProcessor`. It will try to use the risk factor as a currency pair.

| Risk Factor | Risk CCy | Base Ccy | Counter Ccy |
| - | - | - | - |
| USD/CAD | \* | USD | CAD |
| CAD\_FX Equivalent | \* | EUR | CAD |
