> ## 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.

# Collateral algorithms

> What the Bilateral CSA and Unilateral (Bank) CSA algorithms compute, with the exposure combination, collateral call, and collateralized exposure formulas, and the holding-period look-back.

A collateral algorithm computes, for each netting set, time point, and scenario, the collateral balance that the CSA requires. The collateralized exposure measures subtract this balance from the netted mark-to-future (MtF) value. Netting Set Analytics provides two algorithms: `Bilateral CSA` and `Unilateral (Bank) CSA`. A cube builds one folder of collateral measures per algorithm that it wires, named `Collateralized Exposures - <algorithm name>`. The PFE cube wires `Bilateral CSA`.

Understanding [exposure concepts](../../introduction/exposure-concepts) (specifically the CSA parameters and the holding period) is a prerequisite for this page.

## Which parameters do the algorithms use?

Both algorithms read the CSA parameters of the netting set from the `NettingAgreements` table. See the [data model](../database/database-model#nettingagreements) for the field definitions.

| Symbol | Parameter |
| - | - |
| $h$ | Counterparty holding period, in days |
| $\theta_b$, $\theta_c$ | Bank and counterparty threshold |
| $m_b$, $m_c$ | Bank and counterparty minimum transfer amount |
| $A_b$, $A_c$ | Bank and counterparty independent amount constant |
| $k_b$, $k_c$ | Bank and counterparty independent amount scale factor |
| $F_b$, $F_c$ | Bank and counterparty independent amount floor |
| $I(T, s)$ | Supplementary independent amount at time point $T$ in scenario $s$, from the `IndependentAmounts` table |

Both algorithms use the counterparty holding period $h$.

## How is the collateral balance looked up in time?

For each reporting time point $T$, the algorithm values the netting set at the holding-period date $T - h$:

1. If $T - h$ is before the as-of date, the balance equals the initial collateral of the netting agreement, converted with the FX rate at $T$. The exposure formulas below are not applied.
2. If $T - h$ is a date of the simulation grid, the algorithm uses the MtF value of the netting set at that date.
3. If $T - h$ falls between two grid dates, the algorithm linearly interpolates the MtF value between the two nearest reporting dates.

The algorithms evaluate reporting time points only. Time points that exist only for collateral evaluation serve as interpolation inputs.

## How are currencies converted?

The CSA parameters are expressed in the CSA parameter currency. For each scenario $s$, the algorithm divides the MtF value at $T - h$ by the FX rate at $T - h$ to express it in that currency, and multiplies the resulting collateral by the FX rate at $T$ to return to the cube base currency. FX rates for dates between two grid dates are linearly interpolated.

In the formulas below, $R(s)$ is the netting set MtF value at $T - h$ in the CSA parameter currency, and $N(s) = \max(R(s), 0)$ is its positive part:

$R(s) = \frac{\text{MtF}(T - h, s)}{\text{FX}(T - h, s)}, \qquad N(s) = \max\bigl(R(s),\, 0\bigr)$

The independent amounts $A_b$ and $A_c$ count as zero when $R(s) = 0$.

## What is the total exposure under the Bilateral CSA algorithm?

The bilateral algorithm combines the counterparty-side and bank-side independent amount terms with the MtF value:

$M_c(s) = \max\bigl(k_c \cdot N(s) + A_c + I(T, s),\; F_c\bigr)$

$M_b(s) = \min\bigl(k_b \cdot \min(R(s), 0) + A_b,\; F_b\bigr)$

$E(s) = R(s) + M_c(s) + M_b(s)$

## What is the total exposure under the Unilateral (Bank) CSA algorithm?

The unilateral algorithm uses only the counterparty parameters and the positive part of the MtF value:

$M_c(s) = \max\bigl(\max(k_c \cdot N(s),\, 0) + A_c + I(T, s),\; F_c\bigr)$

$E(s) = N(s) + M_c(s)$

## How is the collateral call determined?

The collateral call $C(s)$ turns the total exposure $E(s)$ into a collateral amount, in the CSA parameter currency. A call is made only when the exposure exceeds the threshold by at least the minimum transfer amount.

For the Bilateral CSA algorithm, the counterparty side is tested first, then the bank side:

$C(s) = \begin{cases} E(s) - \theta_c & \text{if } E(s) > \theta_c + m_c \\ E(s) - \theta_b & \text{if } E(s) < \theta_b + m_b \\ 0 & \text{otherwise} \end{cases}$

For the Unilateral (Bank) CSA algorithm, only the counterparty threshold and minimum transfer amount apply:

$C(s) = \begin{cases} E(s) - \theta_c & \text{if } E(s) > \theta_c + m_c \\ 0 & \text{otherwise} \end{cases}$

The collateral balance in the cube base currency is $C(s) \cdot \text{FX}(T, s)$.

## How is collateralized exposure computed?

Both algorithms subtract the collateral balance $C^{\text{base}}(T, s)$ from the netting set MtF value $\text{MtF}(T, s)$ at time point $T$ and take the positive part for the bank side and the negative part for the counterparty side:

$E^{\text{coll}}_{\text{bank}}(T, s) = \max\bigl(\text{MtF}(T, s) - C^{\text{base}}(T, s),\; 0\bigr)$

$E^{\text{coll}}_{\text{cpty}}(T, s) = \min\bigl(\text{MtF}(T, s) - C^{\text{base}}(T, s),\; 0\bigr)$

## Related pages

* [Exposure measures](./exposure-measures)
* [Services](../services)
* [Configuration](../../reference/configuration)
* [Public API](../../reference/public-api)
