Multi-position liquidation price calculation
Multi-position liquidation price calculation:
otTMM: Sum of maintenance margin of other contracts:
otTMM =∑k=1nabs(Sk∗Pk∗Mk)−abs(Si∗Pi∗Mi)
otUPNL: Total unrealized gain or loss of other contracts:
otUPNL =∑k=1nSk∗(Pk−Pko)−Si∗(Pi−Pio)
The liquidation price of the Ithcontract (Pil):
Pil=Si∗(1−diri∗Mi)Si∗Pio−BI+ otTMM - otUPNL Variables:
BI: Static account equity
Pi:Current oracle price of the Ithcontract
Pil:The liquidation price of the Ithcontract
Pi0: The opening price of the Ithcontract
Si: The number of open positions of the Ithcontract, positive for long positions and negative for short positions.
diri:The opening direction of the Ithcontract, +1 for long positions and -1 for short positions
Mi:Maintenance margin rate of the Ithcontract
Example:
Initial account balance BI=1000, ETH-USDC maintenance margin rateMi=3%, the opening price of ETH-USD Pi0=3000, Current oracle price Pi= 2900; BTC-USDC maintenance margin rateMi=3%, the opening price of BTC-USDC Pn0=40000, Current oracle price Pn= 38000. A trader buys Si= 1.5 ETH-USDC, sells Sn= -0.1 BTC-USDC.
The liquidation price of the ETH contracts is:
otTMM = abs(−0.1∗38000∗3%)=144
otUPNL =−0.1∗(38000−40000)=200
Pil=1.5∗(1−3%)1.5∗3000−1000+114−200=2346.39 The liquidation price of the BTC contracts is:
otTMM = abs(1.5∗2900∗3%)=130.5
otUPNL =1.5∗(2900−3000)=−150
Pnl=−0.1∗(1+3%)−0.1∗40000−1000+130.5+150=45820.388