Accessing BitMEX liquidations in realtime


Staff member

Getting started:

WolfBot has an indicator to access BitMEX future contract liquidations in realtime during live trading.
To do this you simply have to add the Liquidator indicator. In the constructor of your trading strategy add:
this.addIndicator("Liquidator", "Liquidator", this.action);
Example usage anywhere in your trading strategy - for example in checkIndicators():
const liquidator = this.getLiquidator("Liquidator");
console.log("total liquidation volume of buys and sells %s", liquidator.getTotalVolume("both"));
if (liquidator.getCurrentLiquidationVolume("sell") > 10000.0)
    this.emitBuy(this.defaultWeight, "many sell liquidations occurred");

// get the latest buy liquidation
let buyLiq = liquidator.getLatest("buy");
console.log("liqudation of %s at %s", buyLiq.amount, buyLiq.rate);

// get all liquidations of current candle
let allLiquidations = liquidator.getCurrentLiquidations();
allLiquidations.forEach((liq) => { // iterate over liquidations of current candle
    let side = liq.type === Trade.TradeType.BUY ? "buy" : "sell";
    console.log("%s liquidation at %s of %s", side, liq.rate, liq.amount);

The Liquidator indicator adds the following config properties to your strategy (the following values are defaults, so you don't have to add them):
                "MyStrategy": {
                    "interval": 48, // the number of candles to store liquidations for
                    "feed": "BitmexMarketData", // The exchange feed to use to get liquidations from
                    "currencyPairs": ["USD_BTC"], // The currency pairs to subscribe to for liquidation data
                    "enableLog": true // Log events of this strategy and all its indicators
Check out the Liquidator indicator source code for more public API functions.

While this indicator always gets its data from BitMEX (configurable with the "feed" property), you can use it for trading on any exchange you like. You can also use it for trading other currency pairs that have a high price-correlation with the specified BitMEX contract.
Last edited: