Automated Trading Overview

API Keys : BitMEX

A quick guide to explain the steps needed to create and set up API keys for BitMEX trading.

Creating a set of API keys

You should create a set of API keys just for Alertatron, as this makes it simple to remove access at a later date without affecting any other services you use that also require API keys.

  1. Log into your BitMEX account, or your BitMEX Testnet account.
  2. Go to the API management page and create a new set of API keys. The image below shows the correct settings. You'll need to give the keys order permissions.
  3. You'll be given an ID and a secret key. Make a note of these.

Adding the keys to Alertatron

  1. From the Automated Trading menu, choose Configure Api Keys. (see image below).
  2. Choose BitMEX from the exchange list.
  3. Give the keys a name. This name is how you will refer to this set of API keys when you send orders to Alertatron. It should be letters only.
  4. Enter the ID into the Key field.
  5. Enter the secret into the Secret field.
  6. If the keys are for your Testnet account, instead of the live account, then enable the Use testnet option.
  7. Save the changes.
Choose _Configure Api Keys_ from the Alertatron menus.
Choose _Configure Api Keys_ from the Alertatron menus.
Choose BitMEX from the drop list of exchanges and enter your API key.
Choose BitMEX from the drop list of exchanges and enter your API key.

Once you have saved your API keys, Alertatron will set up and deploy an instance of the trading bot. It can take a few minutes to deploy and configure your new trading server, but once it is ready it's status will change to Ready for Commands.

Once ready, you can switch to the Logs tab to see a history of commands executed and a detailed log of how those commands handled and processed the commands.

Sending a test

Now your server is ready, it is a good idea to send a test command to it, to make sure everything is working as it should.

Set up an alert that includes the following text in it (it can have other text in the message though). Note that you'll need to change YourAPIKeyName to the name you used in step 2 of 'Adding the keys to Alertatron'.

YourAPIKeyName(XBTUSD) { limitOrder(side=buy, amount=50, offset=100); }

When this alert is triggered, your bot will place a limit order on the XBTUSD instrument to buy 50 contracts. The order will be $100 below the current price. You can simply cancel this order after it is created.

Why not take a look at our getting started guide.


Below are details of any quirks you should take into account when using BitMEX...

System Overload

When the exchange is busy you may experience system overload errors. These appear if you are using the BitMEX website, or trading using their API. They occur whenever the BitMEX matching engine is unable to cope with the volume of trades being submitted. This can happen whenever there is any significant price action and often happens multiple times a day.

Alertatron will attempt to get your orders executed during a system overload, but there is a limit what can be acheived. During a system overload, the exchange is basically rejecting the majority of API requests. We are typically asked to stop making API calls and wait a second or two before retrying, which we do. However, this can delay orders and disrupt your ability to trade during these times.

Unfortuantly there is nothing we can do to bypass this. We retry your requests, with the required delays, but this can cause problems of it's own. As this happens so often, we can't really recommend trading on BitMEX until they increase their capacity to meet normal demand. Please take system overload risks into account as part of risk management and position sizing.

Spam Orders

BitMEX places tempory bans on accounts if they appear to be placing orders in a spammy way. They are not all that clear as to what qualifies as spammy behaviour, other that this blog post from 2017.

Placing lots of orders and cancelling them quickly, especially if they are small, appears to trigger this ban. You only option should it happen is to change your behaviour and stop spamming the exchange and wait for the ban to be lifted.

As a result of this, we impose minimum order sizes or around $20-30 on most instruments traded on BitMEX, but this alone is not enough to prevent the problem.

Order Limits

BitMEX enforces limits on some types of order. For example, you can only have 10 stop orders active per contract per account. For full details of these limits, please see the BitMEX website

Percentage order sizes

For most symbols on BitMEX you can specify order sizes using percentage calculations (percentage of balance, available balance or position size). However, there are some instruments where this feature is not available.

XBTUSD and ETHUSD are supported and all symbols against XBT, such as ETHXBT, but not on symbols backed against other currencies, such as XBTJPY etc.

Some images from Unsplash


Your TradingView alerts, with charts, PM'd to you.

Get all your alerts from TradingView, sent to Telegram, Discord, Slack, Email or webhooks, with a chart snapshot attached.

Capture Charts

See a high quality chart with every alert, captured at the moment the alert was triggered. See exactly what the market was doing and make informed decisions.

Automate Trading

Trigger orders on popular cryptocurrency exchanges and trade 24/7. Access powerful algorithmic orders to maximise your profits.


Connect your alerts to Telegram (channels, groups and private chats), Discord, Slack, email or send push notifications to other services with webhooks.

Easy To Setup

Nothing to install and no browser extensions. Captures alerts 24/7, even with your computer switched off. Be up and running in seconds.