# Exposures

Molecule's Exposures feature offers a way to decompose positions into their implicit components.

<mark style="background-color:blue;">Exposures is available as part of Molecule's Enterprise package.</mark>

#### Primary Functionality <a href="#primary_functionality" id="primary_functionality"></a>

Generally, Molecule positions are expressed in terms of a "tradable" -- a Product/[Tenor](https://help.molecule.io/core-functionality/core-concepts/tenor) combination. Exposures offers a way to decompose that position, automatically, into its components.

The most common use of this feature is to:

* Show exposures that come from a trade's Formula Price (automatically)
* Show exposures that come from a curve build (calculated based on exposures specified for each node on the curve, and uploaded via API)

#### Data Structure & Output <a href="#data_structure_output" id="data_structure_output"></a>

Exposures calculate automatically as part of the Valuation process. They are embedded on each valuation row, in a structure that looks like this (where "Side 1" and "Side 2" roughly correspond to "payer"/"receiver"):

```
{
    "side1": [],
    "side2": [
        {
            "product": "NG",
            "contract": "2023-12-01",
            "product_id": 210818,
            "contribution": 1,
            "factor": 1.0
        },
        {
            "product": "M.RVIR",
            "contract": "2023-08-01",
            "product_id": 8,
            "contribution": -0.935483871,
            "factor": 0.935483871
            "unscaled_contribution": -1
        }
    ]
}
```

When Molecule is asked for positions to be expressed in terms of exposures, it:

* takes each valuation row
* multiplies its quantity by the contribution for each exposure
* produces one line item for each exposure

In that way, the trade that produced the example above, would return one valuation row normally (for the Trade Product) -- but two valuation rows when asked for exposures (December NG and August M.RVIR).

<mark style="background-color:yellow;">Exposures output contains positions only; not P\&L metrics.</mark>

#### Getting Exposures <a href="#getting_exposures" id="getting_exposures"></a>

Because exposures are saved as JSON on a Valuation row, and then multiplied by quantity at query time, it's a little more complicated to see exposures. The easiest ways to do so are:

* Using the Valuations screen, with the Trades output in Exposures mode
* Using a custom report that contemplates Exposures, or
* Using the [Exposures API endpoint](https://developer.molecule.io/reference/exposures-3) (either in CSV or JSON mode)

#### More on Exposures <a href="#more_on_exposures" id="more_on_exposures"></a>

**Calculation Hierarchy**

While most trades calculate exposures based on formula prices and/or curve builds, there are a few other things that can create Exposures.

**Side 1**

* **Formula Price** (`Trade.FormulaPrice`): formula specified in the Trade's price field.
* If the trade is a fixed-price trade, there will be no Side 1 exposure.

**Side 2**

* **Underlying** (`Product.Underlying`): if the trade is an option, Molecule will express this exposure in terms of the underlying product.
* **Forward Estimate**: Today's best available view of the factors that will affect the final value of this side of the trade. Molecule will try to resolve each of these, in order, stopping at the first item that can be resolved:
  * **Mark** (via `Trade.MarkingProduct` first, then `Trade.Product`): Exposures will come from the Marks model directly. If a Mark is available for a Trade today, and if it has the `Mark.Exposures` column filled in, we should use those Exposures.
  * **Settlement Formula** (`Product.SettlementFormula`): the formula that, when computed at settlement, will result in a movement of cash. Exposures will come from Molecule interpreting a formula at valuation time. If Molecule gets to this branch, it's because it cannot resolve exposures via the Mark, and must compute them by parsing the `Product.SettlementFormula` itself. One of two scenarios is likely to occur:
    * Trade Product's Settlement Formula exists, and `Product.ImpliedSettlementFormula` `= true`: we will use this for spread trades on exchanges (i.e., ICE's [DGD](https://www.theice.com/products/6590132/Chicago-Basis-Future)), where we know ahead of time how this trade's exposures are constructed.
    * Trade Product's Settlement Formula exists, and `Product.ImpliedSettlementFormula = false`. In this case, we will simply create exposures from the pieces of the settlement formula.
* **Trade Product**: 1 \* the Trade Product, if nothing else on Side 2 computes an Exposure.

#### Decay

Exposures can contemplate [Decay](https://help.molecule.io/core-functionality/core-features/specialized-features/decay), scaling exposures for contracts that have priced. This uses the `factor` field in the Exposures JSON.
