Multi-position liquidation price calculation

Multi-position liquidation price calculation:

  • otTMM: Sum of maintenance margin of other contracts:  otTMM =k=1nabs(SkPkMk)abs(SiPiMi)\text { otTMM }=\sum_{k=1}^{n} a b s\left(S_{k} * P_{k} * M_{k}\right)-\operatorname{abs}\left(S_{i} * P_{i} * M_{i}\right)

  • otUPNL: Total unrealized gain or loss of other contracts:

     otUPNL =k=1nSk(PkPko)Si(PiPio)\text { otUPNL }=\sum_{k=1}^{n} S_{k} *\left(P_{k}-P_{k}^{o}\right)-S_{i} *\left(P_{i}-P_{i}^{o}\right)

The liquidation price of the Ith  I^{\text {th}}\;contract (PilP_i^l):

Pil=SiPioBI+ otTMM - otUPNL Si(1diriMi)P_{i}^{l}=\frac{S_{i} * P_{i}^{o}-\mathrm{BI}+\text { otTMM - otUPNL }}{S_{i} *\left(1-\operatorname{dir}_{i} * M_{i}\right)}

Variables:

  • BIBI: Static account equity

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

  • Pil:P_i^l:The liquidation 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 = 1000, ETH-USDC maintenance margin rateMi=3M_i = 3%%, the opening price of ETH-USD Pi0=3000P_i^0 = 3000, Current oracle price PiP_i= 2900; BTC-USDC maintenance margin rateMi=3M_i = 3%%, the opening price of BTC-USDC Pn0=40000P_n^0 = 40000, Current oracle price PnP_n= 38000. A trader buys SiS_i= 1.5 ETH-USDC, sells SnS_n= -0.1 BTC-USDC.

The liquidation price of the ETH contracts is:

otTMM = abs(0.1380003%)=144abs(-0.1*38000*3\%)=144

otUPNL =0.1(3800040000)=200-0.1*(38000-40000)=200

Pil=1.530001000+1142001.5(13%)=2346.39P_{i}^{l}=\frac{1.5 *3000 -1000+114-200}{1.5 *(1-3\%)}=2346.39

The liquidation price of the BTC contracts is:

otTMM = abs(1.529003%)=130.5abs(1.5*2900*3\%)=130.5

otUPNL =1.5(29003000)=1501.5*(2900-3000)=-150

Pnl=0.1400001000+130.5+1500.1(1+3%)=45820.388P_{n}^{l}=\frac{ -0.1*40000 -1000+130.5+150}{-0.1 *(1+3\%)}=45820.388

Last updated