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

# Data model

> The framework database tables (MarkToFuture, SimulationDates, NettingAgreements, IndependentAmounts, FxScenarios), their fields, and joins.

The netting-set analytics framework defines a set of database tables that hold the exposure simulation data. These tables are specific to the framework and extend the universal common tables shared across all solutions.

For the other universal common tables (CounterpartyAttributes, OrganizationAttributes, and others), see the [common data model](../../../../common/developer-guide/database/database-model). This page documents the framework-specific tables and `TradeAttributes` in full, with base fields and framework-added fields listed together and the framework additions marked.

## What tables does the framework define?

The following tables are defined by the netting-set analytics framework.

| Table | Key fields | Description |
| - | - | - |
| [`MarkToFuture`](#marktofuture) | `AsOfDate`, `TradeId`, `TimePoint` | The facts table. Holds the MtF scenario vector for each trade at each future time point. |
| [`SimulationDates`](#simulationdates) | `AsOfDate`, `TimePoint` | The set of valid future simulation dates for a given as-of date, and whether each date is used for reporting, collateral evaluation, or both. |
| [`NettingAgreements`](#nettingagreements) | `AsOfDate`, `NettingSetId` | CSA and ISDA netting parameters for each netting set. |
| [`IndependentAmounts`](#independentamounts) | `AsOfDate`, `TradeId`, `NettingSetId` | Per-trade independent amount obligations for trades subject to initial margin. |
| [`FxScenarios`](#fxscenarios) | `AsOfDate`, `FromCCY`, `ToCCY`, `TimePoint` | FX rate scenario vectors used during collateral evaluation to convert exposure values between currencies. |

## What are the field definitions?

### MarkToFuture

The facts table. Each row holds the MtF simulation vector for one trade at one future time point.

| Field | Type | Key | Notes |
| - | - | - | - |
| `AsOfDate` | `LocalDate` | Yes | Business date of the record. |
| `TradeId` | `String` | Yes | Unique trade identifier. |
| `TimePoint` | `LocalDate` | Yes | Future simulation date. |
| `MarkToFutureVector` | `double[]` | No | MtF scenario values. The vector length equals the `scenariosCount` value configured on the consuming cube. A blank value loads as a vector of zeros. |

All non-blank vectors must use the same length. The vector length is set at startup and must match the consuming cube's scenarios count configuration.

A blank vector field loads as a vector of `scenariosCount` zeros. Every blank row shares that one vector, so it takes no vector storage. Leave the field blank for any all-zero vector, such as the time points after a trade's maturity date.

> [!NOTE]
>
> Keep the rows of a matured trade with a blank vector rather than removing them. The collateral balance at a time point depends on the exposure one holding period earlier, so removing those rows changes the collateral results.

The table is partitioned on `AsOfDate` and `TradeId`. To change this partitioning in the PFE cube, see [Partitioning and aggregate providers](../../../../solutions/counterparty-credit-risk/pfe/developer-guide/partitioning).

### SimulationDates

Defines the set of future time points available in the simulation grid for a given as-of date. Time points can be designated as reporting dates, collateral evaluation dates, or both, using the `ReportingOrCollateral` field.

| Field | Type | Key | Notes |
| - | - | - | - |
| `AsOfDate` | `LocalDate` | Yes | Business date. |
| `TimePoint` | `LocalDate` | Yes | A future simulation date in the grid. |
| `ReportingOrCollateral` | `ReportingOrCollateral` | No | Whether the date is used for reporting (`R`), collateral evaluation (`C`), or both. See [Enums](../../reference/enums). |

### NettingAgreements

Holds the ISDA and CSA parameters for each netting set. These parameters drive netting aggregation and collateral balance calculation.

| Field | Type | Key | Default | Notes |
| - | - | - | - | - |
| `AsOfDate` | `LocalDate` | Yes | | Business date. |
| `NettingSetId` | `String` | Yes | `N/A` | Unique netting set identifier. The value `N/A` is the system default for trades without an agreement. |
| `NettingSetName` | `String` | No | | Human-readable name. |
| `InitialCollateral` | `Double` | No | | Initial collateral balance, used when the holding-period look-back date is before the business date. |
| `BankThreshold` | `Double` | No | | Exposure threshold below which the bank does not call collateral. |
| `BankMinimumTransferAmount` | `Double` | No | | Smallest collateral transfer the bank will request. |
| `BankHoldingPeriod` | `Integer` | No | `20` | Margin period of risk for the bank side, in days. |
| `BankIndependentAmountConstant` | `Double` | No | | Fixed independent amount posted by the bank. |
| `BankIndependentAmountScaleFactor` | `Double` | No | | Scale factor applied to the bank independent amount. |
| `BankIndependentAmountFloor` | `Double` | No | | Floor on the bank independent amount. |
| `CounterpartyThreshold` | `Double` | No | | Exposure threshold below which the counterparty does not call collateral. |
| `CounterpartyMinimumTransferAmount` | `Double` | No | | Smallest collateral transfer the counterparty will request. |
| `CounterpartyHoldingPeriod` | `Integer` | No | `20` | Margin period of risk for the counterparty side, in days. |
| `CptyIndependentAmountConstant` | `Double` | No | | Fixed independent amount posted by the counterparty. |
| `CptyIndependentAmountScaleFactor` | `Double` | No | | Scale factor applied to the counterparty independent amount. |
| `CptyIndependentAmountFloor` | `Double` | No | | Floor on the counterparty independent amount. |
| `HaircutScaleFactor` | `Double` | No | `1.0` | Haircut multiplier applied to exposure values. |
| `CSAParamCurrency` | `String` | No | `USD` | Currency of the CSA threshold and MTA parameters. |

### IndependentAmounts

Holds per-trade independent amount obligations. Trades subject to initial margin requirements have one or more rows in this table, one per netting-set membership.

| Field | Type | Key | Notes |
| - | - | - | - |
| `AsOfDate` | `LocalDate` | Yes | Business date. |
| `TradeId` | `String` | Yes | Trade identifier. |
| `NettingSetId` | `String` | Yes | Netting set to which this independent amount belongs. |
| `IndependentAmount` | `Double` | No | The independent amount value. |
| `IndependentAmountMaturity` | `LocalDate` | No | Maturity date of the independent amount obligation. |
| `IndependentAmountCurrency` | `String` | No | Currency of the independent amount. |

### FxScenarios

Holds FX rate scenario vectors used during collateral evaluation to convert between the CSA parameter currency and the base currency of the cube.

| Field | Type | Key | Notes |
| - | - | - | - |
| `AsOfDate` | `LocalDate` | Yes | Business date. |
| `FromCCY` | `String` | Yes | Source currency. |
| `ToCCY` | `String` | Yes | Target currency. |
| `TimePoint` | `LocalDate` | Yes | Future simulation date. |
| `ScenariosVector` | `double[]` | No | FX rate vector across scenarios. The vector length must match `scenariosCount`. |

### TradeAttributes

`TradeAttributes` is a universal common table that the framework extends. Rows in the Customization column marked with `✓` are added by the framework; the rest are base fields from the common layer.

| Field | Type | Key | Customization | Notes |
| - | - | - | - | - |
| `AsOfDate` | `LocalDate` | Yes | | Business date of the record. |
| `TradeId` | `String` | Yes | | Unique trade identifier. |
| `Trader` | `String` | No | | Name of the trader responsible for the trade. |
| `Sales` | `String` | No | | Name of the sales person associated with the trade. |
| `TradeDate` | `LocalDate` | No | | Date the trade was booked. |
| `TradeMaturityDate` | `LocalDate` | No | | Maturity date of the trade. |
| `CounterpartyId` | `String` | No | | Foreign key to `CounterpartyAttributes`. |
| `OrganizationUnitId` | `String` | No | | Foreign key to `OrganizationAttributes`. |
| `BookId` | `String` | No | | Foreign key to `BookAttributes`. Inherited from the common `TradeAttributes` table. |
| `LegalEntityId` | `String` | No | ✓ | Legal entity of the trade's booking entity. |
| `Notional` | `Double` | No | ✓ | Trade notional. |
| `NotionalCurrency` | `String` | No | ✓ | Currency of the notional. |
| `AssetClass` | `String` | No | ✓ | Asset class of the instrument. |
| `InstrumentType` | `String` | No | ✓ | Instrument type. |
| `InstrumentSubType` | `String` | No | ✓ | Instrument subtype. |
| `NettingSetId` | `String` | No | ✓ | Foreign key to `NettingAgreements`. Defaults to `N/A`. |
| `BreakDate` | `LocalDate` | No | ✓ | Optional trade termination date for break-date-aware exposure aggregation. Nullable. |

The framework adds the fields marked in the Customization column.

For the full common reference, see [TradeAttributes](../../../../common/reference/tables#tradeattributes) and the [common data model](../../../../common/developer-guide/database/database-model).

> The framework also adds a `Counterparty` object field to `CounterpartyAttributes`.

## How are the tables joined?

| From table | To table | Join fields |
| - | - | - |
| `MarkToFuture` | `TradeAttributes` | `AsOfDate`, `TradeId` |
| `MarkToFuture` | `SimulationDates` | `AsOfDate`, `TimePoint` |
| `TradeAttributes` | `NettingAgreements` | `AsOfDate`, `NettingSetId` |
| `TradeAttributes` | `IndependentAmounts` | `AsOfDate`, `TradeId`, `NettingSetId` |

`FxScenarios` is not joined to other tables via a database reference. The collateral algorithms read it at query time using direct key lookups on `AsOfDate`, `FromCCY`, `ToCCY`, and `TimePoint`.

## Related pages

* [Common data model](../../../../common/developer-guide/database/database-model)
* [How to customize the data model](../../../../common/developer-guide/database/customizing-data-model)
* [Dimensions](../cube/dimensions)
