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

# Dynamic bucketing

> Interpolates sensitivities to a new set of pillars to allow comparisons across different coordinate sets.

## Overview

The sensitivities can be expressed as plots, curves, surfaces or cubes (0 to 3 dimensions).
They come with a set of pillars that define the coordinates of the sensitivity values.
Those coordinates can be unique per sensitivity.
To allow sensitivities comparison, Atoti Market Risk proposes the dynamic bucketing feature.
This feature interpolates the sensitivity to a new set of pillars (coordinates).

## Input - Output

The input coordinates are defined by the following hierarchies:

* [Tenor Dates](../cube/dimensions/risk), [Tenors](/cube/dimensions/risk)
* [Maturity Dates](/cube/dimensions/risk), [Maturities](/cube/dimensions/risk)
* [Moneyness](/cube/dimensions/risk)

and it will be output to those hierarchies:

* [DynamicTenors](/cube/dimensions/dynamicbucketing)
* [DynamicMaturities](/cube/dimensions/dynamicbucketing)
* [DynamicMoneyness](/cube/dimensions/dynamicbucketing)

The feature will recompute the input values at the input coordinates to match the output coordinates.

In case of multiple hierarchy for the same axis, the coordinate is defined by taking the hierarchies in the definition order until finding one with a value different from the default value.

## Computation

The input axis and the output axis are converted in number of days from the asOfDate. This is done by calling the [Maturity converter](/calculations/date-conversion) service.
The values are distributed axis by axis across the dynamic plots.

For an input value between two plots we have

$\left\{ \begin{array}{cl} p_{n}\le p_i \le p_{n+1} \\ V_{p_{n}}\Leftarrow V_{p_i}\cdot \frac{p_{n+1}-p_i}{p_{n+1}-p_n}\\ V_{p_{n+1}}\Leftarrow V_{p_i}\cdot \frac{p_i-p_n}{p_{n+1}-p_n}\end{array} \right.$

with:

* $p_{n}$: The lower output pillar.
* $p_{n+1}$: The upper output pillar.
* $p_i$: The input pillar, between the output pillars.
* $V{p_{n}}$: The value at the lower pillar, the resulting value is the sum of all contributions of all intervals.
* $V_{p_{n+1}}$: The value at the upper pillar, the resulting value is the sum of all contributions of all intervals.
* $V_{p_i}$: The input value at the input pillar.

## Sample

Here you can see how the input value are distributed to the output values. The columns are the input pillars, the lines are the output pillars.

| Dynamic Tenor | Output value |    0.25Y |    0.5Y |        1Y |       2Y |       3Y |       5Y |      10Y |      15Y |     20Y |
| :-----------: | -----------: | -------: | ------: | --------: | -------: | -------: | -------: | -------: | -------: | ------: |
| *Input Value* |              | -1287.39 | 1165.62 | -2,171.47 | 13032.82 | -3996.96 | 29499.60 | 42184.16 | 40837.54 | 3390.73 |
|    N/A (0Y)   |      -643.70 |  -643.70 |         |           |          |          |          |          |          |         |
|      0.5Y     |       521.92 |  -643.70 | 1165.62 |           |          |          |          |          |          |         |
|       1Y      |     -2171.47 |          |         |  -2171.47 |          |          |          |          |          |         |
|       2Y      |     88737.31 |          |         |           | 13032.82 | -3854.21 | 26338.93 | 30131.54 | 21877.25 | 1210.98 |
|      30Y      |     36210.58 |          |         |           |          |  -142.75 |  3160.67 | 12052.62 | 18960.29 | 2179.76 |

### Setup

See [Creating dynamic maturities](/dev/dev-tools/dynamic-maturities-add).
