Little more than a year ago, I discovered that most crypto exchanges provide APIs, and that one could actually write programs that use these APIs to check the market and trade when conditions were favorable. I thought I was going to be rich, if I used these I would have a huge advantage over traders doing manual trades. I honestly thought I was going to stop working within the year and that these bots would make my income for me.
It turns out that it is quite difficult to develop a bot that consistently makes winning trades. I have developed around 20 bots in the last year, each running a different strategy, most of them unsuccessful. I’m not close to retiring but I have learned a lot, and I thought it would be nice to share a strategy that seemed to work quite well. This might be a well-known strategy, if so forgive my ignorance. For me, I took a chance one evening and it seemed to work out well.
The strategy - Trade the spread
The spread is the difference between the highest buy offer and the lowest sell offer on a specific coin. Assuming $1 increments:
- If my highest buy order is $10
- …and my lowest sell order is $14
- …then the spread is $4
For a good depiction of the spread, have a look at https://www.luno.com/trade/XBTZAR. The spread is shown in the middle of the screen on the left, with buy orders from highest to lowest in green and sell orders from lowest to highest in red.
Usually the highest buy and lowest sell differ by a very small amount, but if a very large order is processed, or a lot of orders are processed very quickly, then the spread will increase.
- If a large amount of sell orders are happening quickly, then sellers will be using up a lot of the buy orders in the order book. Buy orders are usually matched from highest to lowest price, so the highest buy offer price will be falling. There will be much fewer buy orders, so the lowest sell price should be staying relatively constant. For our purposes, I will refer to this as the spread opening downwards.
- If a large amount of buy orders are happening quickly, then buyers will be using up a lot of the sell orders in the order book. Sell orders are usually matched from lowest to highest price, so the lowest sell offer price will be climbing. There will be much fewer sell orders, so the highest buy price should be staying relatively constant. For our purposes, I will refer to this as the spread opening upwards.
This strategy attempts to buy at the bottom of the spread and sell at the top. Using our example above, we could submit a buy offer for $11. If anyone sells at that price, we immediately submit a sell offer for $13. If we sell at that price, we’ve made a profit of $2.
You would think that this would not really work, as you would expect that traders would always want to sell at the top of the spread and buy at the bottom of the spread. However, in practice this strategy works quite well as there always seems to be traders that want their trade processed immediately, and are therefore willing to sell at the bottom of the spread, or buy at the top of the spread.
Complications
You need to take the following into account:
- The exchange is going to levy fees on your trades, so the spread needs to be large enough that your profit from your trades will exceed the fees. Per definition, you will always be the “maker” for any instruction you submit, so exchanges using a “maker/taker” fee model work well, ideally with a 0% maker fee.
- The spread can close at any time. In my example above, if a trader submits a buy order for $13, then the spread is immediately closed. Conversely, if a trader submits a sell order for $11, then my spread is also immediately closed. In practice, this usually doesn’t happen that often, and the spread will remain open for a few seconds to a few minutes, depending on the volumes being processed on the exchange.
- You generally only want to trade when the spread is opening upwards, when the price is climbing. When the spread is opening downwards, it is very easy for your sell price to “pass” your buy price on the way down, immediately putting you in a loss situation.
- The volumes being traded on the exchange define how far you can scale this strategy, in terms of the amount traded at any one time. You don’t want to submit your buy order at the bottom of the spread and then wait so long for the full order to process that the spread has closed by the time you want to submit your sell order.
Bot
The bot I developed does the following:
- Run every 30 seconds.
- Check if the spread exceeds a certain amount.
- Check if the price is currently climbing. I use the RSI indicator to check this, it is quite easy to implement and is quite accurate for this type of scenario.
- If both conditions above are true, then submit a buy order just slightly higher than the current highest buy order.
- Wait for the next cycle (30 seconds in my case)
- If my buy order was taken up, then immediately submit a sell order just slightly lower than the current lowest sell order.
- If my buy order was not taken up, then check if the spread still exceeds my amount and if the price is still climbing. If not, cancel my buy order and wait for the next opportunity.
Choosing an exchange
- As mentioned above, lower fees are better, 0% maker fees are best.
- Exchanges with bigger spreads that stay open longer are better.
- Define the minimum spread at which you want to trade.
- Launch the Exchange in a web browser. Navigate to the currency you want to trade in, and watch the order book as orders are being processed. Count how many times the spread opens wider than your minimum, and for how long it stays open.
- Alternatively, log the lowest sell and highest buy at an interval via a bot, and then use the logged stats to plot the spread in a graph. From the graph, decide if the exchange will be viable for you.
Have I missed anything? Do you have any tips? Do you disagree with any of the above? If so, leave a comment and let's chat.
Congratulations @cryptoinformer! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Congratulations @cryptoinformer! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
Click here to view your Board of Honor
If you no longer want to receive notifications, reply to this comment with the word
STOP
To support your work, I also upvoted your post!
Do not miss the last post from @steemitboard: