If you’ve been following my recent posts, you’re probably aware of the project that we’re talking about today. Otherwise, welcome and allow me to fill you in on the details.
For the past couple of weeks, I’ve been testing a cryptocurrency trading bot that should detect new coin listings on Binance and automatically place buy and sell orders. I’ve included a trailing stop loss and several customisation options to allow users to modify their exit strategy. It’s like a custom indicator for Biance where you can decide when to exit the market (ideally at a good time).
Let me share with you a quick timeline of how this last week has been from the perspective of this project.
Open sourcing this crypto trading bot
I believe that, as long as it’s reasonable to do so, code should be open-sourced and shared freely online. Personally, I have found open sourcing my trading algorithms is improving the quality of my code and adding features that I might not have known how to implement myself. This was the case with the new coins listing bot I wrote two weeks ago.
Because the code really only fires once a new coin is listed on Binance, it’s a bit difficult to test it beforehand. I’ve run some initial tests, but when the time came, the bot errored in the middle of an order. On the bright side, it did in fact detect a new coin as soon as it was listed, so there’s potential there.
It was helpful to open source the trading bot and have a few more people testing it out as well, as this enabled me to make significant improvements and bug fixes to the code.
The main issue
A few days after open sourcing and running the bot, it became clear that the main bug was related to the step_size. On Binance, the step_size of an asset simply refers to the order accuracy of that asset. For example BTC has a step_size of 6 decimal points (0.000001) while XRP has only 1 (0.1). It turns out that, due to the format of the new coins symbols, the function that calculates the step size has been breaking mid-order.
In the following days I’ve ran some more tests and also devised a way to test the order-placing functions by feeding dummy data. I’m quite happy with the results, and I’m relatively confident that the bot is more or less stable. Though connection issues are still occuring from time to time.
That being said, I did manage to stabilise the script and make a significant improvement to the speed of execution.
Fixes and improvements
- Corrected the step size issue (should hopefully be able to complete an order now)
- Fixed the buy and sell logic to stop it from breaking
- Reduced the time it takes to detect a coin from 6 seconds to 0.3 seconds.
Next steps for the new coins trading bot
Well, it’s back to testing. I’m leaving the code to run on my raspberry pi and waiting for new coins to be listed on Binance. I will post the results once the bot actually buys something.