Multi-positions bankruptcy price calculation

bankruptcy Price:

The bankruptcy price of the Ithβ€…β€ŠI^{\text {th}}\;contract(PiC)(P_i^C):

Pic=Piβˆ’[BI+βˆ‘k=1nSkβˆ—(Pkβˆ’Pko)]βˆ—dir⁑iβˆ—Miβˆ—Piβˆ‘k=1ndir⁑kβˆ—Skβˆ—Mkβˆ—Pk1βˆ’dir⁑iβˆ—Β FeeRateΒ 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:

  • BIBI: Static account equity

  • Pi:P_i:Current oracle price of the Ithβ€…β€ŠI^{\text {th}}\;contract

  • PiC:P_i^C:The bankruptcy price of the Ithβ€…β€ŠI^{\text {th}}\;contract

  • Pi0P_i^0: The opening price of the Ithβ€…β€ŠI^{\text {th}}\;contract

  • Si:S_i: The number of open positions of the Ithβ€…β€ŠI^{\text {th}}\;contract, positive for long positions and negative for short positions.

  • diri:dir_i: The opening direction of the Ithβ€…β€ŠI^{\text {th}}\;contract, +1 for long positions and -1 for short positions

  • Mi:M_i:Maintenance margin rate of the Ithβ€…β€ŠI^{\text {th}}\;contract

Example:

Initial account balance BI=1000BI = 1000USDC, Trading Fee = 0.3%

Contract TypeOpen PositionsOpening PriceCurrent PriceMaintenance MarginPNL

ETH

4

1100

1000

200(5%)

-400

BTC

2

2200

2000

400(10%)

-400

AVA

-3

2100

2000

300(5%)

300

ETH bankruptcy Price:

1000βˆ’[1000+(βˆ’400βˆ’400+300)]βˆ—0.05βˆ—1000200+400+3001βˆ’0.003=975.15\frac{1000-[1000+(-400-400+300) ] * \frac{0.05 * 1000}{200+400+300 }}{1-0.003}=975.15

BTC bankruptcy Price:

2000βˆ’[1000+(βˆ’400βˆ’400+300)]βˆ—0.1βˆ—2000200+400+3001βˆ’0.003=1894.57\frac{2000-[1000+(-400-400+300) ] * \frac{0.1 * 2000}{200+400+300 }}{1-0.003}=1894.57

AVA bankruptcy Price:

2000βˆ’[1000+(βˆ’400βˆ’400+300)]βˆ—βˆ’1βˆ—0.05βˆ—2000200+400+3001+0.003=2049.40\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(975.15-1100)*4-975.15*4*0.003=-511.1018

BTC PNL: (1894.57βˆ’2200)βˆ—2βˆ’1894.57βˆ—2βˆ—0.003=βˆ’622.23(1894.57-2200)*2-1894.57*2*0.003=-622.23

AVA PNL: (2049.40βˆ’2100)βˆ—βˆ’3βˆ’2049.40βˆ—3βˆ—0.003=133.354(2049.40-2100)*-3-2049.40*3*0.003=133.354

Last updated