> ## Documentation Index
> Fetch the complete documentation index at: https://docs.derive.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Portfolio Margin

Portfolio margin evaluates the portfolio holistically. The portfolio’s options, perpetuals and (risk cancelling) collateral are revalued under a range of expected and "tail" scenarios, with the worst outcome taken as the margin requirement. Extra contingency margin is added for risks the scenarios do not capture. Compared to standard margin, this can substantially increase a portfolio’s capital efficiency.

> 📘 **\[New!] Portfolio margin is now cross-currency.** In V2 a portfolio margin subaccount was restricted to a single market, e.g. an ETH account could not hold BTC options.
>
> In V3 a portfolio margin subaccount can hold every currency its risk universe lists. A Prime account holds BTC *and* ETH derivatives; an Alt account holds SOL, ADA, XRP, ZEC and CC.

Netting stops at the universe boundary. One portfolio margin manager runs **per universe**: it evaluates each currency's scenario grid independently, sums the per-currency worst-case losses, adds the contingencies, and then applies the universe's collateral haircut table. Losses in one currency never offset gains in another.

If a portfolio margin account's collateral falls below its maintenance margin requirement, the account will be liquidated.

# Margin Calculation

A user's initial and maintenance margin requirements are calculated as follows:

```python Formula theme={null}
Initial Margin = Portfolio MtM
    + Σ_currency [ (im_factor + depeg_factor) * maxLoss_currency + Contingencies_currency ]
    + Collateral Contingency + Oracle Contingency

Maintenance Margin = Portfolio MtM
    + Σ_currency [ mm_factor * maxLoss_currency + Contingencies_currency ]
    + Collateral Contingency
```

Where:

```python Formula theme={null}
maxLoss = min(Regular Loss, Tail Loss, Skew Loss, Forward Loss)

Contingencies_currency = Risk Cancelling Collateral Contingency + Perp Contingency
                       + Option Contingency + Oracle Contingency
```

and

* `Portfolio MtM` is the mark-to-market value of the portfolio. This includes the account's cash balance, all collateral (marked to current value), all option positions and all perpetual funding and PNL.
* `mm_factor = 0.8` and `im_factor = 1.0` are the loss factors applied to the worst-case loss. They are set per currency.
* `depeg_factor` is extra initial margin conditionally required to protect against the cash asset depegging.
* `maxLoss` is the greatest PNL loss the currency's positions will endure under a set of scenarios: "regular scenarios", "tail scenarios", "skew scenarios" and the "forward scenario".
* `Regular Loss` is the maximum PNL loss the portfolio will endure under 23 scenarios comprised of various forward and volatility shocks.
* `Tail Loss` is similarly the worst PNL the portfolio will endure under a number of "tail scenario" moves involving substantial price shocks (and a volatility increase). These PNLs are dampened to ensure users are not over-margined.
* `Skew Loss` is the maximum loss resulting from a change in the skew of the volatility surface. This can involve the skew rotating about the at-the-money or the smile widening/narrowing.
* `Forward Loss` accounts for the forward basis for each expiry moving unfavourably against the trader.
* `Collateral Contingency` is extra margin applied to each collateral asset held — or borrowed — in the account (i.e. a risk based haircut). Risk cancelling collateral is charged inside its currency's bucket; everything else is charged at account level.
* `Perp Contingency` is extra margin added for each perp position held by the account.
* `Option Contingency` is extra margin added for each naked short option held by the account.
* `Oracle Contingency` is extra initial margin conditionally required to protect against inaccurate oracle data feeds.

> 📘 Oracle Contingencies are typically zero and only add to initial margin requirements, i.e. they do not change margin requirements for already open positions, but may block opening new positions.

As described in [Standard Margin](doc:standard-margin), an account is subject to liquidation if `Maintenance Margin` falls beneath 0 and can only open new positions if the final state has `Initial Margin` above 0.

# Collateral and Risk Cancellation

Every collateral token a universe accepts is supported by its portfolio margin manager. For each universe, some assets are **risk cancelling**: they are attached to a currency and shocked inside that currency's scenario grid, so a short BTC call delta can be offset by cbBTC. Everything else earns credit through its haircut alone.

```python Formula theme={null}
Collateral Contingency = - Σ_long  n(collateral) * HAIRCUT_LONG  * Spot
                         - Σ_short abs(n(collateral)) * HAIRCUT_SHORT * Spot
```

Where:

* `n(collateral)` is the balance of a given collateral asset in the account, negative if borrowed.
* `Spot` is the spot price of the collateral asset.
* `HAIRCUT_LONG` is the fraction of mark value **not** credited. `MM_LONG = 0.126` for cbBTC in Prime means a long balance counts at 87.4% of mark towards maintenance margin. Initial margin haircuts are larger than maintenance ones.
* `HAIRCUT_SHORT` means that a borrow increases the margin required by more than the mark value of the borrowed asset.

# Option Mark Values

All options are marked with a dynamic discounting rate, so long dated options are not over-margined. The price of a call is given by

```python Formula theme={null}
Call Price = exp(-r_T * T) * [F * N(d1) -  K * N(d2)]
d1 = (ln(F/K) + (sigma **2)/2 * T) / (sigma * sqrt(T))
d2 = d1 - sigma * sqrt(T)
```

where

* `r_T` is the discounting rate for the expiry `T`, typically marked to US T-bills.
* `T` is the time to expiry in years
* `F` is the forward price
* `K` is the strike
* `N()` is the cumulative normal distribution function

# Regular Loss

To compute `Regular Loss`, a currency's options, perpetuals and risk cancelling collateral are evaluated under 23 forward and volatility shocks. The largest loss is set as `Regular Loss`.

The grid is the same shape in every market with 9 spot steps, with up/down/static vol shocks at every step except the two outermost, which are evaluated vol-up only. The **size** of the steps is set per currency. For BTC the grid runs from -14% to +14% in steps of 3.5%:

| #     | Spot shock | Vol shock             |
| ----- | ---------- | --------------------- |
| 1     | +14.0%     | Up                    |
| 2-4   | +10.5%     | Up / Unchanged / Down |
| 5-7   | +7.0%      | Up / Unchanged / Down |
| 8-10  | +3.5%      | Up / Unchanged / Down |
| 11-13 | 0%         | Up / Unchanged / Down |
| 14-16 | -3.5%      | Up / Unchanged / Down |
| 17-19 | -7.0%      | Up / Unchanged / Down |
| 20-22 | -10.5%     | Up / Unchanged / Down |
| 23    | -14.0%     | Up                    |

## Shocked Risk Cancelling Asset Value

The account’s risk cancelling collateral is shocked by a constant factor under scenario `k`:

```python Formula theme={null}
Shocked Risk Cancelling Valueₖ = Σ Collateral * (1 + Spot Shockₖ) * collateral_spot
```

Where:

* `Collateral` is the balance of the risk cancelling asset (e.g. cbBTC, LBTC in the BTC bucket)
* `Spot Shockₖ` is the shock to the spot price for scenario `k`.
* `collateral_spot` is the spot price of the underlying risk cancelling asset.
* The sum is taken over all risk cancelling assets **of that currency**.

## Shocked Perpetual Value

The account’s perpetual position value is shocked by a constant factor under scenario `k`:

```python Formula theme={null}
Shocked Perp Valueₖ = Perp Position * (1 + Spot Shockₖ) * Perp Price
```

Where:

* `Perp Position` is the number of perpetual contracts (this number is negative for shorts).
* `Spot Shockₖ` is the shock to the spot price for scenario `k`.
* `Perp Price` is the mark-to-market value of the perpetual.

## Shocked Option Value

The account’s option positions are grouped and shocked per expiry. Each expiry `i` is evaluated for a given shock scenario `k`. The shocked value for an expiry `i` is the value of each option position with strike price `j` calculated with shocked forward and volatility values.

The forward is shocked to:

```python Formula theme={null}
Shocked Forwardᵢₖ = Forwardᵢ * (1 + Spot Shockₖ)
```

The IV shock is multiplicative. The magnitude of the shock depends on time to expiry and whether or not the shock is positive or negative. We have:

```python Formula theme={null}
Shocked IVⱼₖ = max(IV Shockₖ * IVⱼ, MIN_VOL_EVAL_SHOCKED)

IV Shockₖ = 1 + VOL_RANGE * ((30 / 365) / max(DTE_FLOOR / 365, Time To Expiryᵢ))**VEGA_POWER
```

Where:

* `IV` is the implied volatility of strike `j`.
* `Time To Expiry` is the number of years until expiry.
* `VOL_RANGE = -VOLRANGEDOWN` if IV is being shocked down and `VOLRANGEUP` if it is being shocked up (see the table above).
* `VEGA_POWER = SHORTTERMPOWER = 0.3` if time to expiry ≤ 30 days.
* `VEGA_POWER = LONGTERMPOWER = 0.13` if time to expiry > 30 days.
* `DTE_FLOOR = 1` day floors the term scaling so the shock does not blow up at expiry.

## Discounting

Net positive sub-portfolios are discounted and net short sub-portfolios are anti-discounted (marked up), so that neither side is under-margined.

For an expiry `i`, suppose the rate is `r_i` (clamped at zero) and time to expiry in years is `tau_i`. The mark discounting is

```python Formula theme={null}
mark_discounting = exp(-r_i * tau_i)
```

The discount applied to the sub-portfolio of expiry `i` is

```python Formula theme={null}
Discountᵢ =

Expiry Value > 0: STATIC_DISCOUNT * exp(-(r_i * RFR_FACTOR1_POS + RFR_FACTOR2_POS) * tau_i)
                       

Expiry Value < 0: min(1/mark_discounting,
                      STATIC_DISCOUNT_NEG / exp(-(r_i * RFR_FACTOR1_NEG + RFR_FACTOR2_NEG) * tau_i))
```

Where

* `STATIC_DISCOUNT = 0.98`
* `STATIC_DISCOUNT_NEG = 1.02`
* `RFR_FACTOR1_POS = RFR_FACTOR1_NEG = 0.0`
* `RFR_FACTOR2_POS = RFR_FACTOR2_NEG = 0.10`

An expiry group’s shocked value is then the sum of the shocked value of each option in the expiry using Black76, with the discount applied:

```python Formula theme={null}
Shocked Expiry Valueᵢₖ = Discountᵢ x Σ Shocked Option Valueᵢⱼₖ
```

## Scenario Analysis

The portfolio’s loss under scenario `k` is the sum of perpetual, risk cancelling collateral and each option expiry’s shocked value minus its unshocked value:

```python Formula theme={null}
Portfolio Lossₖ = [Shocked Risk Cancelling Valueₖ - Risk Cancelling Value]
                + [Shocked Perp Valueₖ - Perp Value]
                + Σᵢ [Shocked Expiry Valueᵢₖ - Expiry Valueᵢ]
```

`Regular Loss` is then the smallest (i.e. most negative) portfolio loss under all 23 scenarios:

```python Formula theme={null}
Regular Loss = min(Portfolio Loss(1), Portfolio Loss(2), ..., Portfolio Loss(23))
```

# Tail Loss

To ensure sufficient collateral is posted for very out-of-the-money options, we also consider "tail scenarios". These involve substantial spot shocks up and down and always occur with a volatility increase.

To prevent over margining of positions, a `dampening_factor` specific to each tail scenario is applied to the PNL for that scenario:

```python Formula theme={null}
Tail Loss = min(dampening_1 * Tail PNL(1), ..., dampening_n * Tail PNL(n))
```

The BTC tail ladder is:

| # | Spot shock | Vol shock | Dampening | Effective shock |
| - | ---------- | --------- | --------- | --------------- |
| 1 | -66%       | Up        | 0.12262   | 0.578           |
| 2 | -33%       | Up        | 0.24500   | 0.578           |
| 3 | +50%       | Up        | 0.16174   | 0.578           |
| 4 | +100%      | Up        | 0.08087   | 0.578           |
| 5 | +200%      | Up        | 0.02022   | 0.289           |
| 6 | +300%      | Up        | 0.00898   | 0.192           |
| 7 | +400%      | Up        | 0.00504   | 0.144           |
| 8 | +500%      | Up        | 0.00323   | 0.115           |

The "effective shock" column is `dampening x |spot shock| / max grid shock` with the size of the shock actually charged at that node, expressed as a fraction of the main grid. A falling effective shock is deliberate: the further into the tail a scenario goes, the less of it is charged.

# Skew Loss

Portfolios that are vega neutral can still lose money if the *shape* of the volatility surface moves. The skew scenarios charge for that.

## Motivation

Plotted in log moneyness space (`k = log[K/F]`), an SVI surface has a minimum at `k = m` and a tilt about it. This means vols with `k > m` may be higher than those with `k < m`. That tilt can change: the surface can **rotate** (one wing's vols rise while the other's fall), or it can **widen and narrow** (both wings move the same way).

Ordinarily skew is not a significant risk, because the regular grid already applies large parallel volatility shocks. The skew scenarios exist to make sure the portfolios those shocks miss are still adequately margined.

## \[New!] Four directional rails

V2 tested two skew shapes. V3 tests **four**, by giving each shape both directions:

| Rail         | Shape                                                             |
| ------------ | ----------------------------------------------------------------- |
| `LINEAR_CW`  | Rotation clockwise: raises high-strike vol, lowers low-strike vol |
| `LINEAR_CCW` | Rotation counter-clockwise: the mirror image                      |
| `ABS_UP`     | Symmetric: both wings widen                                       |
| `ABS_DOWN`   | Symmetric: both wings narrow                                      |

For each strike `K_i` in an expiry `T_j`, the rail applies a multiplicative shock

```python Formula theme={null}
ivSkewShock(i,j) = IV(i,j) * (1 + skew_multiplier(i,j))
```

The multiplier is capped by

```python Formula theme={null}
mult_cap_j = SCALE_CAP + CBASE * sqrt(tau_j)
```

with `LINEAR_SCALE_CAP = ABS_SCALE_CAP = 0.25` and `LINEAR_CBASE = ABS_CBASE = -0.1`, so the cap shrinks with tenor.

`k_star` sets the log-moneyness beyond which the shock is capped:

```python Formula theme={null}
k_star = max(MIN_K_STAR, MIN_WIDTH_SCALE * sqrt(tau_j) * sig_est)
sig_est = VOL_PARAM_1 + VOL_PARAM_2 * sqrt(tau_j)
```

with `MIN_K_STAR = 0.01`, `MIN_WIDTH_SCALE = 4`, `VOL_PARAM_1 = 0.6` and `VOL_PARAM_2 = 0`.

The multiplier is then

```python Formula theme={null}
LINEAR:   base = min(mult_cap * k/k_star, mult_cap)   if k > 0
                 max(mult_cap * k/k_star, -mult_cap)  if k < 0
ABS:      base = min(mult_cap * abs(k)/k_star, mult_cap)

skew_multiplier = direction * base
```

where `direction` is `+1` for `LINEAR_CW` / `ABS_UP` and `-1` for `LINEAR_CCW` / `ABS_DOWN`.

## \[New!] Decoupled aggregation

The shocked PNL of an expiry under a rail is

```python Formula theme={null}
expiryPNL(j, rail) = Discountᵢ * Σᵢ BS(ivSkewShock(i,j)) - Σᵢ BS(IV(i,j))
```

V2 assumed one coherent smile move across the whole book and summed each rail separately. V3 charges **each expiry its own worst rail**, floored at zero, and sums:

```python Formula theme={null}
Skew Loss = dampening * Σⱼ min(0, minᵣₐᵢₗ expiryPNL(j, rail))
```

# Forward Loss

The forward loss accounts for the forward basis for an account’s options moving unfavourably against the trader.

We consider an up and down scenario where the forward moves by `FWD_CONT_SHOCK` (3.5% for BTC, 4% for ETH, and larger in the higher-volatility markets). For each expiry `i`, we calculate the basis loss, or the worse of the up and down scenario:

```python Formula theme={null}
Basis Lossᵢ = min(
    min(0, Up Expiry Valueᵢ - Expiry Valueᵢ),
    min(0, Down Expiry Valueᵢ - Expiry Valueᵢ)
)
```

The forward loss is then the weighted sum of each expiry’s basis loss:

```python Formula theme={null}
Forward Loss = Σ (ADD_FACTOR + MULT_FACTOR * Time To Expiryᵢ) * Basis Lossᵢ
```

Where:

* `ADD_FACTOR = 0.5`
* `MULT_FACTOR = 2.0`
* `Time To Expiryᵢ` is the number of years until expiry.

Note that the forward loss is one of the four candidates inside `maxLoss`, not an addition on top of them: only the single worst of the four is charged.

# Contingencies

The contingencies are typically small extra margin requirements to ensure adequate collateral is posted under all conditions.

## Perp Contingency

The account's perpetual position has a small amount of margin associated with it, based on the number of perpetual contracts and spot price:

```python Formula theme={null}
Perp Contingency = -abs(Perp Size) * PERP_STATIC_MARGIN * Spot
```

Where `PERP_STATIC_MARGIN` is `0.0075` (maintenance) and `0.015` (initial) for BTC and ETH, rising to `0.025` / `0.04` for ADA.

## Option Contingency

For each strike with a **net short** position, a small amount of margin is charged:

```python Formula theme={null}
Option Contingency = Σ min(0, Net Option Sizeⱼ) x OPTION_STATIC_MARGIN x Spot 
```

Where:

* `Net Option Sizeⱼ` is the net number of option contracts held at strike `j` within an expiry (negative for net short).
* `OPTION_STATIC_MARGIN` is `0.0015` (maintenance) and `0.0025` (initial) for BTC and ETH.

Because the skew scenarios do most of this work, the option contingency is small.

## Oracle Contingency

This works as in the Standard margin, but with three differences:

1. The option contingency counts the total (absolute value of the) number of **long and short** option contracts at a strike, not just short contracts.
2. The perpetual feed's confidence also enters the option contingency: `min(Spot, Forward, Vol, Perp)`.
3. The threshold is strict and extra margin is added when confidence is **below** `THRESHOLD_CONFIDENCE = 0.55`, not at it.

```python Formula theme={null}
Option Oracle Contingency = - CONFIDENCE_SCALE * Options Size * Spot
    * (1 - min(Spot Confidence, Forward Confidence, Vol Confidence, Perp Confidence))
```

Where `CONFIDENCE_SCALE = 0.4` and `Options Size` is the total number of long and short option contracts for a given strike/expiry. For example, if there are 4 long calls and 3 short puts on the \$2000 3 weekly strike, then `Options Size = 4 + 3 = 7`.

Risk cancelling collateral takes the **minimum** of its own token confidence and the confidence of the currency it cancels against, and is charged inside that currency's bucket.

## Depeg Contingency

When the cash asset depegs from \$1, the initial margin loss factor increases in proportion to the depeg:

```python Formula theme={null}
im_factor -> im_factor + max(0, PEG_LOSS_THRESHOLD - Cash Asset Price) * PEG_LOSS_FACTOR 
```

where

* `PEG_LOSS_FACTOR = 4.0`
* `PEG_LOSS_THRESHOLD = 0.99`

# Open Interest Caps

Each universe caps the open interest, spot supply and spot borrow of every instrument its portfolio manager supports. See [Supported Products](doc:supported-products).

# Risk Reducing Trades and Risk Assessors

As is the case with the standard manager, on the smart contract level the portfolio margin risk manager will allow any trade to be conducted so long as it satisfies either of the following conditions:

* the initial margin of the portfolio after the transaction is conducted is positive (`IM(post) > 0`) OR
* the trade is risk reducing (see the description in [Standard Margin](doc:standard-margin)).

A subtle but key difference is that closing perpetual positions for portfolio margined accounts is not considered a risk reducing transaction. This is because perpetuals could act as a delta hedge and so removing these positions might increase the risk of the portfolio.

As with the standard manager, the portfolio margin manager will also support risk assessors. In addition to the aforementioned benefits of allowing general risk reducing trades, risk assessors are necessary because computing all scenarios for portfolio margin on chain is expensive.

In order to minimise such gas costs and offer traders large portfolio margined accounts, risk assessors only have to compute 3 scenarios on chain: the "mark-to-market" (mtm) scenario (where spot and vol are static) and the two scenarios used to compute the forward loss.

**This means that the risk assessors cannot allow insolvent positions to be opened.**

They can, however, allow liquidatable positions to be opened.

# Example

Consider an account in the **Prime** universe comprised of the following:

* 0.1 x SHORT BTC \$100,000 CALL
* 0.1 x LONG BTC \$115,000 CALL
* 0.1 cbBTC
* \$2,000 USDC

Both options share an expiry 30 days out. BTC spot is $100,000, the 30 day forward is $100,500, implied volatility is 55% at both strikes and the risk free rate for the expiry is 5%.

The unshocked option value is **-\$468.86**, so the portfolio's mark-to-market value is

```python Formula theme={null}
Portfolio MtM = 2,000 + 0.1 * 100,000 + (-468.86) = $11,531.14
```

## Computing Regular Loss

The volatility shocks for this expiry are, with `tau = 30/365` so `VEGA_POWER = 0.3`:

```python Formula theme={null}
IV shock up   = 1 + 0.40 * ((30/365) / (30/365))**0.3 = 1.40  ->  vol 77.0%
IV shock down = 1 - 0.25 * ((30/365) / (30/365))**0.3 = 0.75  ->  vol 41.25%, floored to 50.0%
```

The down shock is a good illustration of `MIN_VOL_EVAL_SHOCKED`: the arithmetic gives 41.25%, but BTC's floor of 50% binds, so the vol-down scenarios are priced at 50%.

The discount factors are

```python Formula theme={null}
pos_disc = 0.98 * exp(-(30/365) * 0.10) = 0.971978
neg_disc = min(exp((30/365) * 0.05), 1.02 * exp((30/365) * 0.10)) = 1.004118
```

The expiry's value is negative in every scenario below, so `neg_disc` applies throughout. The cbBTC balance is risk cancelling, so it is shocked alongside the options.

| #  | Spot shock | Vol  | Option PNL | cbBTC PNL | Total PNL     |
| -- | ---------- | ---- | ---------- | --------- | ------------- |
| 1  | +14.0%     | Up   | -387.57    | +1,400.00 | +1,012.43     |
| 2  | +10.5%     | Up   | -304.99    | +1,050.00 | +745.01       |
| 3  | +10.5%     | Same | -357.62    | +1,050.00 | +692.38       |
| 4  | +10.5%     | Down | -373.22    | +1,050.00 | +676.78       |
| 5  | +7.0%      | Up   | -219.29    | +700.00   | +480.71       |
| 6  | +7.0%      | Same | -239.59    | +700.00   | +460.41       |
| 7  | +7.0%      | Down | -244.37    | +700.00   | +455.63       |
| 8  | +3.5%      | Up   | -132.08    | +350.00   | +217.92       |
| 9  | +3.5%      | Same | -119.38    | +350.00   | +230.62       |
| 10 | +3.5%      | Down | -113.09    | +350.00   | +236.91       |
| 11 | 0%         | Up   | -45.25     | 0.00      | -45.25        |
| 12 | 0%         | Same | -1.93      | 0.00      | **-1.93**     |
| 13 | 0%         | Down | +14.18     | 0.00      | +14.18        |
| 14 | -3.5%      | Up   | +39.16     | -350.00   | -310.84       |
| 15 | -3.5%      | Same | +107.66    | -350.00   | -242.34       |
| 16 | -3.5%      | Down | +130.96    | -350.00   | -219.04       |
| 17 | -7.0%      | Up   | +119.05    | -700.00   | -580.95       |
| 18 | -7.0%      | Same | +204.82    | -700.00   | -495.18       |
| 19 | -7.0%      | Down | +231.78    | -700.00   | -468.22       |
| 20 | -10.5%     | Up   | +192.47    | -1,050.00 | -857.53       |
| 21 | -10.5%     | Same | +286.23    | -1,050.00 | -763.77       |
| 22 | -10.5%     | Down | +313.13    | -1,050.00 | -736.87       |
| 23 | -14.0%     | Up   | +257.75    | -1,400.00 | **-1,142.25** |

```python Formula theme={null}
Regular Loss = -1,142.25
```

The account is long 0.1 BTC of spot against a call spread that only covers it above \$100,000, so the worst regular scenario is the bottom of the grid.

## Computing Tail Loss

Running the same calculation over BTC's 8 tail nodes and applying each node's dampening:

```python Formula theme={null}
Tail Loss = min(-751.80, -698.87, ...) = -751.80     (at -66%, dampening 0.12262)
```

The -66% node's raw loss is -6,131.14; dampened, it charges -751.80.

## Computing Skew Loss

With `tau = 30/365`, `k_star = max(0.01, 4 * sqrt(30/365) * 0.6) = 0.6881` and `mult_cap = 0.25 - 0.1 * sqrt(30/365) = 0.2213`. The four rails give:

| Rail         | Expiry PNL |
| ------------ | ---------- |
| `LINEAR_CW`  | +19.67     |
| `LINEAR_CCW` | **-22.89** |
| `ABS_UP`     | +17.65     |
| `ABS_DOWN`   | -20.88     |

```python Formula theme={null}
Skew Loss = -22.89
```

## Computing Forward Loss

Shocking the forward by ±3.5% with volatility unchanged:

```python Formula theme={null}
Up Loss   = min(0, -585.83 - (-468.86)) = -116.97
Down Loss = min(0, -359.73 - (-468.86)) = 0
Forward Loss = (0.5 + 2.0 * 30/365) * (-116.97) = -77.71
```

## Putting it together

```python Formula theme={null}
maxLoss = min(-1,142.25, -751.80, -22.89, -77.71) = -1,142.25
```

The contingencies are the option contingency (one net short strike, 0.1 contracts) and the risk cancelling collateral haircut on the cbBTC:

```python Formula theme={null}
Option Contingency (MM) = -0.1 * 0.0015 * 100,000 = -$15.00
Option Contingency (IM) = -0.1 * 0.0025 * 100,000 = -$25.00

Collateral Contingency (MM) = -0.1 * 100,000 * 0.126 = -$1,260.00
Collateral Contingency (IM) = -0.1 * 100,000 * 0.14  = -$1,400.00
```

And finally:

```python Formula theme={null}
Maintenance Margin = 11,531.14 + 0.8 * (-1,142.25) - 15.00 - 1,260.00 = $9,342.34
Initial Margin     = 11,531.14 + 1.0 * (-1,142.25) - 25.00 - 1,400.00 = $8,963.89
```

Had this account also held ETH positions, their own 23-cell grid, tail ladder, skew rails and contingencies would be computed independently and the resulting `maxLoss` added to the BTC one. Losses in ETH would not be offset by gains in BTC.


## Related topics

- [Portfolio Margin Parameters](/untitled-page-3.md)
- [Standard Margin](/standard-margin.md)
- [public/get_margin](/api-reference/subaccounts/publicget_margin.md)
