项目作者: tugwitt

项目描述 :
Utility scripts for BitMEX
高级语言: Python
项目地址: git://github.com/tugwitt/bitmex_utils.git
创建时间: 2018-02-03T06:21:21Z
项目社区:https://github.com/tugwitt/bitmex_utils

开源协议:

下载


bitmex_utils

Utility scripts for BitMEX

Liquidation Calculator

The code is a little bit buggy but the formulas were provided from BitMEX support. The prices are off usually off by less than a dollar, don’t think this is resolvable.

The formulas are:

Long:

  1. Bankrupt = avg_entry_price / (1 + initial_margin)
  2. Liquidation = bankrupt + (avg_entry_price * (maintenance_margin + funding_rate)

Short:

  1. Bankrupt = avg_entry_price / (1 - initial_margin)
  2. Liquidation = bankrupt - (avg_entry_price * (maintenance_margin - funding_rate)

For margin calculations:

  1. initial_margin = (1 / leverage) - taker_fee - taker_fee
  2. maintenance_margin = 0.5% * taker_fee

For XBTUSD the taker fee is 0.075%.

Code

  1. from liquidation import Liquidation
  2. liq = Liquidation()
  3. # Buy 1000 contracts at $10,0000 with 10x leverage
  4. liq.calc_buy(10000, 1000, 10, 0.000375)
  5. # Sell 1000 contracts at $10,0000 with 10x leverage
  6. liq.calc_sell(10000, 1000, 10, 0.000375)