> For the complete documentation index, see [llms.txt](https://optifi.gitbook.io/optifi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://optifi.gitbook.io/optifi/optifi-in-depth/margin-requirements/portfolio-margin-calculations.md).

# Portfolio Margin Calculations

The total margin requirement has three main components:

[Stress Requirement](#stress-requirement) + [Option Value Add-On](#option-value-add-on) + [Liquidity Adjustment](#liquidity-adjustment)

### Stress Requirement&#x20;

Portfolio margin is calculated by market stress approach – for each user, changes in OptiFi position values are calculated under different stress scenarios on the underlying asset. Currently, market stress scenarios are set from -30% to +30%.

For each instrument, the profit or loss can be calculated by multiplying its long (+) or short (-) position with each stress. The **most severe stress** for the user in terms of loss provides the collateral requirement on a portfolio basis to support open positions.

For example, we check positions separately at first: If you spend $1,489 to long a BTC-38000-1w-Call, the most severe stress is -$1,489 when the BTCUSDC spot price drops 30%. If you receive $198 to short a BTC-43000-1w-Call, the most severe stress is -$6,364 when the BTCUSDC spot price rises 30%.

![](/files/DGLvlmD9an0exykcwSym)

However, OptiFi considers two positions as a whole strategy. Hence the most severe stress becomes -$1,292 when the BTCUSDC spot price drops 30%. It means:

**Stress Requirement** = **-$1,292**

![](/files/MS8r8iQR86xGQDTnM73A)

### Option Value Add-On

In addition to collateral for stresses, Option Value is added to account for intrinsic and premium values on top of [stress requirement](#stress-requirement) to ensure that there are enough funds to settle or close positions. OptiFi sets a minimum of net intrinsic or net premium value for each user:

<mark style="color:purple;">Option Value Add-On = min ⁡( ∑〖 Position x Option Intrinsic Value〗 , ∑〖Position x Option Premium〗)</mark>

Please note, that option value add-on here is a negative number, which corresponds to premiums or intrinsic value owed by an account in short positions.

According to the formula above, if you long a BTC-38000-1w-Call at $1,489 and short a BTC-43000-1w-Call at $198, when the current spot price is $38,000:

**Option Value Add-On** = min ⁡( ∑〖 $0 + $0 〗, ∑〖 $1,489 - $198 〗) = min ( $0 , $1,292 ) = **$0**

![](/files/XtKzUzulyX18Cbic51zA)

### Liquidity Adjustment

Finally, liquidity adjustment is made to account for settlement of closest maturity contracts to ensure that there are enough funds for settlement of maturating positions. A liquidity add-on is calculated for the closest maturity contracts only:

<mark style="color:purple;">Liquidity Adjustment = (Time to maturity x 2/365 + 1) ( ∑〖Position x Option Intrinsic Value〗)</mark>

Please note that liquidity adjustment is added only in cases where Net Option Intrinsic value is negative.

![](https://lh3.googleusercontent.com/khFAwTv1S1-nYB5q2LM_YT3IRzVu9TL2Y1JPMF75_iMKMsNLBSc5rHfoHEDJM_6mu71DikciHwfU_lz3N6qmYMeFTp6v0et0rldUHaAEyqmSFPGbjAr_15O1x_FjfsqpHgoTd-T7)

Per the case above, if you long a BTC-38000-1w-Call at $1,489 and short a BTC-43000-1w-Call at $198, when the current spot price is $38,000:

**Liquidity Adjustment** = (7\**2/365+1)*($0) + (7\**2/365+1)*($0) = $0 + $0  = **$0**

![](/files/sVQH42Rqkj6RujZxHNDQ)

In summary, if you long a BTC-38000-1w-Call at $1,489 and short a BTC-43000-1w-Call at $198, when the current spot price is $38,000:

**Total margin requirement = -$1,292 + $0 + $0 = -$1,292**

If you have $5,000 USDC in Account Equity, the Available Balance = $5,000 - $1,292 = $3,708
