Gunbot – Crypto trading bot for Bitmex

At the moment of writing this article (17th November 2018), latest Gunbot version is v11. Soon Gunbot v12 will be launched and it will include support for the most requested exchange: Bitmex. Why is Bitmex so popular? First of all, it’s the exchange with the highest volume, and , in the other hand, it allows to play shorts, that is, we can get profit even when the price is dropping.

During 2018, there has been a bear market, and, in these conditions, it’s easier to get good results following the trend, that is, playing shorts is usually more profitable than playing longs during a bear market. However, I have noticed that some people have never used shorts, and they don’t know how they work. So, I have decided to create a tutorial explaining how short operations work. Ok, let’s go.


First things first, what is a short? Short answer: Playing a short is something like betting against a coin, in other words, you get profit if the price drops. I know this is counterintuitive because most of us are used to play longs, that is, “buy cheap and sell for higher price”. For example, everyone understand that if we buy 1 Litecoin for 50$ and we sell it for 60$, we get profit. Ok, suppose we know Litecoin’s price will drop and we want to place a short. In this case, what we have to do is “sell expensive, buy at lower price“, just the opposite. As I said, it’s counterintuitive. I knows it’s a bit confusing at the beginning, but it’s easy once you understand it and you get used to it.

A typical question is: “How is it possible to sell something even before buying it?”. It’s a very normal question for someone who is used to “buy cheap, sell expensive”. Ok, we have to understand that a short is a contract, and we are borrowing the coin we are betting against. Let’s see an example. Suppose I don’t have a Lambo, but I think its price is going to drop, so I want to play a short against it. Now the price of a Lambo is 50.000$, so I place a short, that is, I borrow a Lambo and I insta sell it for 50.000$. Ok, suppose that, after 2 days, the price drops to 40.000$ and I want to close our short position. Ok, I buy a Lambo for 40.000$, I give the Lambo I borrowed back and I get 10.000$ of profit. I know this example is a little bit stupid, I just wanted to show how a short trade works. I hope it helps.


What we have to keep in mind is that there are mainly 2 types of orders: Entry orders and exit orders. Entry orders are those orders that make us to start a trade:

1- Long: We start a long order buying an asset.

2- Short: We start a short order selling an asset.

On the other hand, exit orders are those orders that close the trade:

1- Stop loss: It’s a protection, so we can set a maximum % of loss. If we want to close a long position, the stop loss is a sell operation below the current market price. If we want to close a short, the stop loss is a buy operation above current market price. Note that Stop loss allows us to limit our loses, and once the stop loss is hit, we are taking a loss.

2- Take profit: Allows us to assure a profit, so we can automatically close the trade once the price reach to the target. If we want to close a long position, take profit is a sell operation above the current market price. If we want to close a short, take profit is a buy operation below current market price.

Note: Of course that, apart from the order types I posted above, we can close a long or a short operation buying or selling anytime at the market price.

Note 2: At the moment of closing a trade, we can choose between placing a limit order or a market order. This article is not meant to explain the difference between both of them. Personally I prefer to place my stop limits as market orders, so I assure the order is filled asap.


First of all it’s important to remark that the profit we get when closing a short on Bitmex is always converted to Bitcoins. Example, if you place a short for the pair ETH-USD at 220, and we close it when the price is 200, our profit is 20$, and it will be converted to Bitcoins before being added to your account.

Let’s see an example. Suppose we want to place a short for the pair BCH-BTC:

First step is to click on the tab “Bitcoin Cash”.

Ok, what’s next? Now we have to decide our entry point. In this case, I will open the short at 0.069:

So, we click on “Limit” tab, we put our desired price and we click “Sell / Short”.

Now only 1 thing leaves: To place our exit points. Note that when closing a short, we have to buy, that is, “Take Profit Buy” or “Stop Loss Buy”.

As you can see, in the top right tab, we can choose between several options. Personally what I use is “Stop Market”, to set the price in which I will close the trade with loses, and “Take Profit Market”, which is the target price that will automatically close the short in order to assure the profit.

Ok, it’s done. Now we have set our entry point and the exit points.


Let’s take a look at Bitmex interface:

Your position BCHZ18: This is just the name of the short contract for BCH-BTC. These contracts are named this way on Bitmex.

9.39% ROE: This shows the % of profit / loss we would get if we close the short / long now.

Entry Price 0.069: It’s the price we opened our short / long at.

0.1017 Liq. Price: This is the liquidation price, that is, if the price reach to that price, we lose all the funds we used to open that short.

Leverage: We can set leverage up to 100x. The higher is it, the higher the profit we get, the higher the risk and the lower the liquidation price is.

Let’s see an example of how liquidation price and leverage work. Ok, suppose we open a long and we buy 1 Litecoin for 100$. What is the liquidation price? In this case the liquidation price is 0. Why? Because liquidation price is the point in which we lose all the funds we invested. Ok, now suppose we open the same long, buying 1 Litecoin for 100$, but this time we set Leverage 2x. Ok, now the liquidation price would be 50, because we are taking 2x risk, so we lose 2x. Of course, if the price raises, we get 2x profit. For example, if the price goes to 115 and we close the long by selling, we would get +30% instead of +15%. One more example, if we open the long with 3x leverage, the liquidation price would be 66,66 and the profit would be 3x in the case the trade is profitable.

This is an example of a short trade shown in trading history (Click on the image to view full size):

Here we can see I opened a short for BCH-BTC. The entry point is 0.069 and the exit point is 0.0467, that is 32% profit. Considering I used 2x leverage, I got 64% profit for this short.

I hope this article will help to bring some light about how the short operations works. Gunbot is an amazing tool that helps us to automate our trading operations, but obviously it’s important to understand how the trading works before trying to automate it. Remember that crypto markets are very volatile and they imply high risk, especially when using leverage.

Submit Your Comment