This article builds on the crypto trading bot guide from the previous article. I highly recommend you read the previous article first if you’re looking for a detailed guide on how to build your own simple crypto trading bot using Python. The scope of this article is to add a small but rather useful feature to your cryptocurrency trading bot – push notifications!
Does your crypto trading bot need push notifications?
The crypto market is quite a bit more volatile compared to the stock market, and while you may have spent countless hours optimising your bot and are seeing decent returns, your bot will make a mistake. It’s only a matter of time, no matter how sophisticated the algorithm is. Being aware of every trade your bot is placing, could be a much needed manual override if you notice the market is going in a different direction.
Push notifications are less important when you’re testing your bot, but you need to make sure they work – so they should naturally be part of your testing. However not all bots are suited for this so this you may use this simple checklist to decide:
What kind of bot is it?
If your answer is HFT (or high frequency algorithm) you don’t need them, unless you want hundreds of notifications every day.
Is it a scalper/ trend-reversal/ trend continuation bot? In this case you and your peace of mind will definitely benefit from this. The crypto bot explained in the previous blog looks for a quick surge in the price which can sometimes determine if the trend will continue, and will place a buy position. Because most of the time it will only listen to the market for a rapid change, I find it useful to know exactly when the trade was executed, and it helps with my reports as well.
Do you like data?
I find that a push notification enables me to determine exactly which market movement caused the bot to place a trade, allowing me granular detail and opportunity for optimising the bot.
You need a crypto trading bot for this one to work – in case you don’t have one you can get started by with the crypto trading bot I designed to work in a test environment. Use the push-notifications-trade branch! The main branch does not have the push notifications in.
First you want to download the Spontit app from the app store and create an account on your mobile phone. Once you have created your account head over to the Spontit website, on your computer and sign yourself in and grab a secret key from API > Get Secret Keys
Integrating it with your bot
Once you have your secret key and username start by installing the Spontit Python wrapper using pip.
Now import the module into your code and add your account name and secret key
Integrating with you code
In order to get the notification at the right time, make sure you add the following code after a successful trading request has been made.
Customising your push
You can, of course customise the text in your push to include variables such as the asset bought, the price and more. Here’s an example of how this is integrated in the bot that I shared in my last blog
And this is that it looks like on my phone:
If you found this useful subscribe to the newsletter for more amazing content!