# Multi-positions bankruptcy price calculation

### bankruptcy Price:

The bankruptcy price of the
$I^{\text {th}}\;$
contract
$(P_i^C)$
:
$P_{i}^{c}=\frac{P_{i}-\left[B I+\sum_{k=1}^{n} S_{k} *\left(P_{k}-P_{k}^{o}\right)\right] * \frac{\operatorname{dir}_{i} * M_{i} * P_{i}}{\sum_{k=1}^{n} \operatorname{dir}_{k} * S_{k^{*} M_{k} * P_{k}}}}{1-\operatorname{dir}_{i} * \text { FeeRate }}$

#### Variables:

• $BI$
: Static account equity
• $P_i:$
Current oracle price of the
$I^{\text {th}}\;$
contract
• $P_i^C:$
The bankruptcy price of the
$I^{\text {th}}\;$
contract
• $P_i^0$
: The opening price of the
$I^{\text {th}}\;$
contract
• $S_i:$
The number of open positions of the
$I^{\text {th}}\;$
contract, positive for long positions and negative for short positions.
• $dir_i:$
The opening direction of the
$I^{\text {th}}\;$
contract, +1 for long positions and -1 for short positions
• $M_i:$
Maintenance margin rate of the
$I^{\text {th}}\;$
contract

### Example:

Initial account balance
$BI = 1000$
Contract Type
Open Positions
Opening Price
Current Price
Maintenance Margin
PNL
ETH
4
1100
1000
200(5%)
-400
BTC
2
2200
2000
400(10%)
-400
AVA
-3
2100
2000
300(5%)
300
ETH bankruptcy Price:
$\frac{1000-[1000+(-400-400+300) ] * \frac{0.05 * 1000}{200+400+300 }}{1-0.003}=975.15$
BTC bankruptcy Price:
$\frac{2000-[1000+(-400-400+300) ] * \frac{0.1 * 2000}{200+400+300 }}{1-0.003}=1894.57$
AVA bankruptcy Price:
$\frac{2000-[1000+(-400-400+300) ] * \frac{-1*0.05 *2000}{200+400+300 }}{1+0.003}=2049.40$
ETH PNL:
$(975.15-1100)*4-975.15*4*0.003=-511.1018$
BTC PNL:
$(1894.57-2200)*2-1894.57*2*0.003=-622.23$
AVA PNL:
$(2049.40-2100)*-3-2049.40*3*0.003=133.354$