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

# Public API

> The framework's public level and measure interfaces in the api/cube packages, with their accessors and the types they return.

The netting-set analytics framework exposes its public API through the `api/cube/` and `api/cube/measures/` packages. These interfaces allow consuming cubes and downstream code to access levels and measures by type-safe references without depending on internal strings.

## What interfaces are exposed?

| Interface | Accessed via | Purpose |
| - | - | - |
| `INettingSetAnalyticsLevels` | Extended by consuming cube level interfaces | Central levels API grouping all framework-level identifiers |
| `ISpecificLevels` | `INettingSetAnalyticsLevels.specific()` | Framework-specific level identifiers (time point, master agreement, CSA, collateral algorithm, independent amount levels) |
| `IExposureMeasures` | Base interface | Base interface for any measure family that provides exposure vectors |
| `IExposureVectorMeasures` | `IExposureMeasures.exposureVectorsMeasures()` | Exposure vectors by side (bank and counterparty) |
| `IExposureMetrics` | `IExposureAndMetricsMeasures.exposureMetrics()` | Scalar exposure metrics (PFE, EE, ENE, ES, scenario index and name) |
| `IGrossMeasures` | Base interface for gross measure families | Combines base gross exposure, exposure vectors, and inframarginal exposure |
| `IBaseGrossExposureMeasures` | `IGrossMeasures.baseGrossExposureMeasures()` | Initial MtM, MtF sum, cumulative cashflow, and their scenario-level variants |
| `INettedMeasures` | Base interface for netted measure families | Combines exposure vectors and inframarginal exposure for the netted family |
| `ICollateralizedMeasures` | Base interface for collateralized measure families | Groups the independent amount measures and the collateralized exposure measures |
| `IIndependentAmountMeasures` | `ICollateralizedMeasures.independentAmountMeasures()` | Independent amount measure |
| `ICsaParametersMeasures` | Exposed by consuming cubes' measures facades | Typed accessors for the built-in CSA parameters and the `Netted` flag of the master agreement, plus configured additional parameters by name |
| `ICollateralizedExposureMeasures` | `ICollateralizedMeasures.exposureMeasures()` | Exposure vectors, inframarginal vectors, and tech collateral measures, evaluated with the selected algorithm |
| `ITechCollateralMeasures` | `ICollateralizedExposureMeasures.techCollateralMeasures()` | Selected algorithm, collateral balance vector, scenario-level balance, raw data points, and collateralized MtM |
| `IInframarginalExposureMeasures` | Base interface | Inframarginal exposure vector accessor |
| `IInframarginalExposureAndMetricsMeasures` | Extends `IInframarginalExposureMeasures` | Adds inframarginal exposure metrics and incremental contributions |
| `IExposureAndMetricsMeasures` | Extends `IExposureMeasures` | Adds exposure metrics to the exposure vector accessor |
| `INettingTechMeasures` | Exposed by consuming cubes' measures facades | Netting technical measures: `hasNettingAgreement()`, `csaParameters()` (the assembled CSA parameters) and `countAtEveryTimePoint()` (the hidden helper of the incremental contributions: the trade's contributor count at every time point of its master agreement, including those after it matures) |
| `ICubeTechMeasures` | Exposed by consuming cubes' measures facades | General technical measures: `confidenceLevelFromHierarchy()` and `tradesCount()` |

## Accessor reference

### `INettingSetAnalyticsLevels`

The central levels API. It groups all framework-level identifiers and delegates to the universal common level APIs. Consuming cubes extend `INettingSetAnalyticsLevels` to add their own cube-specific levels. For example, `IPfeCubeLevels extends INettingSetAnalyticsLevels`.

| Accessor | Returns | Notes |
| - | - | - |
| `dates()` | `IAsOfDateLevels` | As-of date levels |
| `confidenceLevels()` | `IConfidenceLevelLevels` | Confidence level simulation dimension |
| `trades()` | `ITradeAttributesLevels` | Trade descriptor levels |
| `scenarios()` | `IScenariosLevels` | Scenario index and name levels |
| `counterparties()` | `ICounterpartiesLevels` | Counterparty hierarchy levels |
| `fx()` | `IFxLevels` | Display currency level |
| `marketDataSet()` | `IMarketDataSetLevels` | Market data set |
| `specific()` | `ISpecificLevels` | Framework-specific level identifiers |

### `ISpecificLevels`

Provides the framework-specific level identifiers for dimensions unique to the netting-set analytics framework.

| Accessor | Returns | Notes |
| - | - | - |
| `timePoint()` | `LevelIdentifier` | Simulation Dates > Time Point |
| `isIncludedInBreakDate()` | `LevelIdentifier` | Is Included In Break Date > Included In Break Date |
| `independentAmountCurrency()` | `LevelIdentifier` | Collateral > Independent Amount Currency |
| `independentAmountMaturity()` | `LevelIdentifier` | Collateral > Independent Amount Maturity |
| `collateralAlgorithm()` | `LevelIdentifier` | Collateral Algorithm > Collateral Algorithm |
| `mtfCurrency()` | `LevelIdentifier` | Currency > Currency |
| `masterAgreement()` | `LevelIdentifier` | Netting > Master Agreement ID. The level at which exposures are netted. |
| `masterAgreementName()` | `LevelIdentifier` | Netting > Master Agreement Name |
| `masterAgreementType()` | `LevelIdentifier` | Netting > Master Agreement Type |
| `netted()` | `LevelIdentifier` | Netting > Netted |
| `csaId()` | `LevelIdentifier` | NettingAnalyticsTradeAttributes > CSA ID. The level of everything that deals with collateral. |
| `breakDate()` | `LevelIdentifier` | NettingAnalyticsTradeAttributes > Break Date |

### `IExposureMeasures`

Base interface for any measure family that provides exposure vectors.

| Accessor | Returns | Description |
| - | - | - |
| `exposureVectorsMeasures()` | `IExposureVectorMeasures` | Access to exposure vectors by side |

### `IExposureVectorMeasures`

Provides access to exposure vectors by side.

| Accessor | Returns | Description |
| - | - | - |
| `getExposureVectors(Side side)` | `NamedCopperMeasure` | Exposure vector for the given side |
| `getExposureVectorsScenarioLevel(Side side)` | `NamedCopperMeasure` | Scenario-level exposure vector for the given side |
| `getBankExposureVector()` | `NamedCopperMeasure` | Convenience method for the bank-side exposure vector |
| `getCptyExposureVector()` | `NamedCopperMeasure` | Convenience method for the counterparty-side exposure vector |
| `getBankExposureVectorScenarioLevel()` | `NamedCopperMeasure` | Convenience method for the bank-side scenario-level vector |
| `getCptyExposureVectorScenarioLevel()` | `NamedCopperMeasure` | Convenience method for the counterparty-side scenario-level vector |
| `getRawExposureVectors(Side side)` | `NamedCopperMeasure` | Exposure vector for the given side before conversion to the display currency, or `null` when the vector is not converted |
| `getBankRawExposureVector()` | `NamedCopperMeasure` | Convenience method for the bank-side exposure vector before conversion, or `null` |
| `getCptyRawExposureVector()` | `NamedCopperMeasure` | Convenience method for the counterparty-side exposure vector before conversion, or `null` |

### `IExposureMetrics`

Provides access to scalar exposure metrics.

| Accessor | Returns | Description |
| - | - | - |
| `getExposureMetric(ExposureMetric exposureMetric)` | `NamedCopperMeasure` | Metric for the given `ExposureMetric` enum value |
| `getPotentialFutureExposure()` | `NamedCopperMeasure` | PFE metric |
| `getExpectedExposure()` | `NamedCopperMeasure` | EE metric |
| `getExpectedNegativeExposure()` | `NamedCopperMeasure` | ENE metric |
| `getExpectedShortfall()` | `NamedCopperMeasure` | ES metric |
| `getPfeIndex()` | `NamedCopperMeasure` | PFE Scenario Index metric |
| `getPfeScenarioName()` | `NamedCopperMeasure` | PFE Scenario Name metric |

All convenience methods return `null` if the underlying metric is not registered.

### `IGrossMeasures`

Combines exposure vectors and inframarginal exposure for the gross measure family. `IGrossMeasures` extends `IExposureMeasures` and `IInframarginalExposureMeasures`, providing:

* Base gross exposure accessors via `baseGrossExposureMeasures()`.
* Exposure vector accessors via the inherited `exposureVectorsMeasures()`.
* Inframarginal exposure vector accessors via the inherited `inframarginalExposureVectorsMeasures()`.

| Accessor | Returns | Description |
| - | - | - |
| `baseGrossExposureMeasures()` | `IBaseGrossExposureMeasures` | Initial MtM, MtF sum, cumulative cashflow, and scenario-level variants |

### `IBaseGrossExposureMeasures`

Provides the base gross exposure measures.

| Accessor | Returns | Description |
| - | - | - |
| `initialMtm()` | `NamedCopperMeasure` | Initial mark-to-market value |
| `mtmSum()` | `NamedCopperMeasure` | Sum of MtF values |
| `cumulativeCashflow()` | `NamedCopperMeasure` | Cumulative cashflow |
| `mtmSumRaw()` | `NamedCopperMeasure` | Sum of MtF values before conversion to the display currency, or `null` when the sum is not converted |
| `mtmSumScenarioLevel()` | `NamedCopperMeasure` | MtF sum at scenario level |
| `cumulativeCashflowScenarioLevel()` | `NamedCopperMeasure` | Cumulative cashflow at scenario level |

### `INettedMeasures`

Combines exposure vectors and inframarginal exposure for the netted measure family. `INettedMeasures` extends `IExposureMeasures` and `IInframarginalExposureMeasures`, providing:

* Exposure vector accessors via the inherited `exposureVectorsMeasures()`.
* Inframarginal exposure vector accessors via the inherited `inframarginalExposureVectorsMeasures()`.

`INettedMeasures` has no own-method accessors beyond the inherited groups.

### `ICollateralizedMeasures`

Groups all collateral-related measures. `ICollateralizedMeasures<A>` is a generic interface where `A` is the type of the collateralized exposure measures.

| Accessor | Returns | Description |
| - | - | - |
| `independentAmountMeasures()` | `IIndependentAmountMeasures` | Independent amount measure |
| `exposureMeasures()` | `A` | The collateralized exposure measures. They are evaluated with the algorithm selected on the Collateral Algorithm hierarchy, or the default algorithm when none is selected. |

### `ICsaParametersMeasures`

Provides typed accessors for the CSA parameters and the `Netted` flag of the master agreement. The built-in parameters each have a dedicated accessor; configured, non-default parameters are reached by name through `additionalParameters(String)`.

| Accessor | Returns | Description |
| - | - | - |
| `netted()` | `NamedCopperMeasure` | Whether the master agreement nets the exposures of its trades. One value per master agreement. |
| `initialCollateral()` | `NamedCopperMeasure` | Initial collateral balance |
| `bankThreshold()` / `cptyThreshold()` | `NamedCopperMeasure` | Bank-side / counterparty-side collateral threshold |
| `bankMinTransferAmount()` / `cptyMinTransferAmount()` | `NamedCopperMeasure` | Bank-side / counterparty-side minimum transfer amount |
| `bankHoldingPeriod()` / `cptyHoldingPeriod()` | `NamedCopperMeasure` | Bank-side / counterparty-side margin period of risk, in days |
| `bankIndependentAmount()`, `bankScaleFactor()`, `bankFloor()` | `NamedCopperMeasure` | Bank-side independent amount constant, scale factor, and floor |
| `cptyIndependentAmount()`, `cptyScaleFactor()`, `cptyFloor()` | `NamedCopperMeasure` | Counterparty-side independent amount constant, scale factor, and floor |
| `hairCut()` | `NamedCopperMeasure` | Haircut scale factor applied to exposure values |
| `parametersCurrency()` | `NamedCopperMeasure` | Currency of the CSA threshold and minimum-transfer-amount parameters |
| `hasNettingAgreement()` | `NamedCopperMeasure` | Whether the CSA has a `CollateralAgreements` row on the queried as-of date (`false` for the default `N/A` id) |
| `additionalParameters(String name)` | `NamedCopperMeasure` | Measure for a configured, non-default parameter, by its field name; throws `IllegalArgumentException` otherwise |

### `IIndependentAmountMeasures`

Provides the independent amount measure.

| Accessor | Returns | Description |
| - | - | - |
| `independentAmount()` | `NamedCopperMeasure` | Independent amount |

### `ICollateralizedExposureMeasures`

Provides exposure vectors, inframarginal vectors, and technical collateral measures, evaluated with the selected collateral algorithm. `ICollateralizedExposureMeasures` extends `IExposureMeasures` and `IInframarginalExposureMeasures`, providing:

* Exposure vector accessors via the inherited `exposureVectorsMeasures()`.
* Inframarginal exposure vector accessors via the inherited `inframarginalExposureVectorsMeasures()`.
* Technical collateral measures via `techCollateralMeasures()`.

| Accessor | Returns | Description |
| - | - | - |
| `techCollateralMeasures()` | `ITechCollateralMeasures` | Collateral balance vector, scenario-level balance, and raw collateral data points |

### `ITechCollateralMeasures`

Provides internal technical collateral measures.

| Accessor | Returns | Description |
| - | - | - |
| `collateralAlgorithm()` | `NamedCopperMeasure` | Hidden measure that returns the selected member of the Collateral Algorithm hierarchy. The collateral measures read it for each cell. |
| `collateralBalance()` | `NamedCopperMeasure` | Collateral balance vector |
| `latestTradeMaturity()` | `NamedCopperMeasure` | Latest trade maturity, the latest member of the trade maturity level. The collateral balance measures read it to cut the balance after the latest maturity |
| `collateralBalanceScenarioLevel()` | `NamedCopperMeasure` | Scenario-level collateral balance |
| `collateralDataPoints()` | `NamedCopperMeasure` | Raw collateral data points |
| `collateralizedMtm()` | `NamedCopperMeasure` | Gross MtM of a master agreement less the collateral balances of its CSAs, unfloored |
| `collateralizedMtmScenarioLevel()` | `NamedCopperMeasure` | Scenario-level collateralized MtM |

## What types support custom collateral algorithms and cashflows?

The following types are in the `com.activeviam.solutions.common.netting.api.cube.measures.collateral` package unless another package is given. See [How to write your own collateral algorithm](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/custom-collateral-algorithm.md).

| Type | Purpose |
| - | - |
| `ICollateralConfigurer` | The bean that an application declares, as a `static @Bean`, at most once, to declare the algorithms and the cashflows service of its cubes. |
| `ICollateralConfigurator` | Carrier passed to the configurer. Its `cube(String)` method returns the configurator of one cube. |
| `ICollateralCubeConfigurator` | The algorithms and the cashflows service of one cube. It has `addEvaluator(...)` and `cashflows(...)`. |
| `ICollateralServices` | The cube services an evaluator or cashflows service is built from. `scenarioCount()` is the only method. |
| `ICollateralEvaluator<T>` | The contract of a collateral algorithm. |
| `CollateralEvaluationData<T>` | The data points of a CSA, by time point, with the serializable `DataPoint` interface. `addDataPoint(point, inputs, contributors)` adds a data point with the input vectors it was built from and the number of contributions behind it. The static `withoutMember(total, member, builder)` returns a view of the data without one member's contributions, rebuilding each data point with the builder. |
| `CsaParameters` | The collateral terms of a CSA. |
| `CsaParameter` (package `...netting.api.cube.measures.exposure.netted`) | A configured additional CSA parameter, with a field name and a type. |
| `Side` (package `...netting.api.enums`) | `BANK` or `CPTY`. |
| `CollateralDataPointsInput`, `CollateralBalanceInput`, `CollateralizedMtmInput` | Inputs of the three collateral measure factories, with the fixed plugin keys `CollateralDataPoints`, `CollateralBalance`, and `CollateralizedMtm`. `CollateralDataPointsInput` and `CollateralBalanceInput` have an `algorithmMeasure()` accessor that names the measure holding the algorithm; `CollateralizedMtmInput` reads it, and the levels and the latest maturity measure, from its `balanceInput()`. `CollateralBalanceInput` names the measure holding the latest trade maturity in `latestMaturityMeasure()`. |
| `ICashflowsService` (package `...netting.api.cube.measures.cashflows`) | Supplies the projected cashflows of a trade. See [Cashflow measures](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/cashflows.md). |
| `ICollateralProperties` (package `...netting.api.properties`) | Collateral settings of a cube. `getDefaultEvaluator()` is the only method. |

### `IInframarginalExposureMeasures`

Base interface providing inframarginal exposure vector access.

| Accessor | Returns | Description |
| - | - | - |
| `inframarginalExposureVectorsMeasures()` | `IExposureVectorMeasures` | Inframarginal exposure vectors |

### `IInframarginalExposureAndMetricsMeasures`

Extends `IInframarginalExposureMeasures` with inframarginal metrics and incremental contributions. In addition to the inherited `inframarginalExposureVectorsMeasures()`, it provides:

| Accessor | Returns | Description |
| - | - | - |
| `inframarginalExposureMetrics()` | `IExposureMetrics` | Inframarginal exposure metrics |
| `incrementalContributions()` | `IExposureMetrics` | Incremental contribution metrics |

### `IExposureAndMetricsMeasures`

Extends `IExposureMeasures` with exposure metrics. In addition to the inherited `exposureVectorsMeasures()`, it provides:

| Accessor | Returns | Description |
| - | - | - |
| `exposureMetrics()` | `IExposureMetrics` | Scalar exposure metrics (PFE, EE, ENE, ES, scenario index and name) |

## Related pages

* [Enums](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/reference/enums.md)
* [Exposure measures](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/exposure-measures.md)
* [Exposure metrics](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/exposure-metrics.md)
* [Dimensions](https://docs.activeviam.com/solutions/enterprise-risk-suite/1.1/libs/netting-set-analytics/developer-guide/cube/dimensions.md)
