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%

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