Ventures of an ex indie game developer

BitMEX's websocket bug got me

I finally found the bug that rekd my cryptocurrency trading bot. This was another bug, or perhaps limitation is a better word, inside BitMEX's websocket API. I only polled the websocket library once per minute, and if the number of trades in that time exceeded 200 half were thrown away. That happens often during volatile periods. That was actually a good thing if I was running a high risk/high return operation. But not otherwise.

This chart shows price (top), bitcoin funds (middle) and position (bottom). The yellow line in the bottom chart shows actual position, while the blue line shows simulated (and desired) position.


In the circled instance the bot bought 2450 USD worth of XBT, but it should only have bought 1970 USD equivalents.

I'll have to wait and see if they diverge again during volatile periods, but this definitely looks like the one. As soon as Bitcoin price levels out at 5k-ish I'll buy some more and THEN! =]

PS. The reason the blue and yellow position lines are not exactly on top of one another is because the bot uses small upkeep orders to keep it from getting banned. BitMEX has an anti-spamming mechanism to keep users from only making order updates but without ever actually trading. To my bot this can happen in slow times where only a few, or none, orders are taken, but many moves happen in the course of days (or even weeks).

About the author

Mitt foto
Gothenburg, Sweden