Filtering Hodloo Alerts
Published: 2021-09-22 18:01:30

> Using Telegram to filter Hodloo alerts is outdated. Please read my [other article](https://dev.to/nobbi/filtering-hodloo-alerts-api-version-5deo) instead.

[QFL](https://help.3commas.io/en/articles/3108941-what-s-qfl) is a popular crypto trading strategy. In a nutshell, you mark strong buying action as a base, buy when the price falls under that base and sell when it reaches the base again.

![Alerts example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jjy4f6i5lp0te809lnuc.png)

While the founder of QFL marked bases manually, many services were created that can draw bases automatically. You can find some indicators on TradingView (search for QFL) or use something like 3commas which has several algorithms built-in.

The best service, in my opinion, is [Hodloo](https://qft.hodloo.com/). Its bases are very well respected hence the winning rate is very high. You even get [Telegram alerts](https://qft.hodloo.com/alerts/) for free! But, the alerts can get quite spammy when BTC drops. Also, you get alerts for BTC and ETH pairs while I only care about USDT pairs. So I needed a way to filter the Hodloo alerts. Luckily that's possible with Python.

This article outlines how to filter Hodloo alerts and forward them to a Discord server. The latter is what I'm using as my personal notification system as I prefer it over a flooded mailbox. A second blog post will cover how you can forward the alerts to a bot for automated trading.

# My Setup
## VPS

The alerts need to be monitored constantly, hence a normal computer is not the ideal place to run this as it is not always on. I'm using an Ubuntu VPS for stuff like this. More precisely a [CX11 Cloud server from Hetzner](https://www.hetzner.com/cloud). But you can go with whatever you like, of course.

Anyway, I can't teach you Linux here. You need some basic knowledge to follow this article.

## Discord

Discord is what I use as my notification system. I created a server just for me where I collect all kinds of notifications. The script currently supports only Discord as its notification system.

## Binance

Hodloo alerts are available for multiple exchanges. I use Binance hence the script is optimized for it. If you use other exchanges please change the script accordingly.

## Telegram

Obviously, you need to have a Telegram account and must be a member of the Hoodlo alert groups to be able to parse and filter the alerts.

# Script Requirements

The script is written in Python and uses a public Python library to interact with Telegram. The following things must be present on your machine for everything to work. Installation instructions can be found via Google.

* Python, should be installed by default on Ubuntu
* Telethon, the library to interact with Telegram

# Customizing and Running the Script

The script `hodloo-alerts.py` is available on [GitHub](https://github.com/NobbisCrypto/Crypto/tree/main/Hodloo_telegram). The variable section needs to be customized.

```
###
### Variables
###
api_id = 
api_hash = ''
binance_10_webhook = ''
binance_5_webhook = ''

# Only include USDT pairs but exclude anything with "DOWN/" or "UP/" in the name aka Binance Leveraged Tokens.
# Valid pair examples: ADA/USDT, LINK/USDT and so on
# Non-valid pairs: ADADOWN/USDT, ADA/BUSD, LINK/ETH, LINK/BTC and so on
pattern = '(?i)^(?!.*DOWN\/)(?!.*UP\/).*\/USDT.*'
```

Let's go over each.

* `api_id` and `api_hash` - Telegram API information. You need to get yours from my.telegram.org.

* `binance_5_webhook` and `binance_10_webhook` - The webhooks for the notification channels in Discord. Read [this post](https://dev.to/nobbi/send-exchange-updates-to-discord-5efd) on how to get the webhooks.

* `pattern` - See description in the script. If you are trading only USDT pairs like me you don't need to change anything.

Save the script somewhere on your Linux box. I like to create a folder in `/opt` for these kinds of scripts. Then run it with Python, like:

```
python3 /opt/nobbi/hodloo/hodloo-alerts.py
```

The script will ask you to verify your phone number. You only need to do this once.

Running the script like above will work but is not very handy because as soon as you close the terminal or the session, the script stops. So we need a way to run the script in the background and also after a server reboot. Check the next chapter on how to achieve this.

# Running the Script in Background

We need a way to run the script in the background and also after a server reboot. There are multiple ways to achieve that and the easiest method for Ubuntu I found is using the tool supervisor.

Installing supervisor:
```
sudo apt-get install supervisor
```
Checking the status of supervisor:
```
sudo service supervisor status
```
Starting supervisor:
```
sudo service supervisor start
```
Stopping and restarting supervisor:
```
sudo service supervisor stop
sudo service supervisor restart
```
Create an entry for the `hodloo-alerts.py` script. The following example uses vi.
```
sudo vi /etc/supervisor/conf.d/hodloo-alerts.conf
```
Contents of the file (change the paths accordingly):
```
[program:hodloo-alerts]
command=python3 -u hodloo-alerts.py
directory=/opt/nobbi/hodloo
stdout_logfile=/opt/nobbi/hodloo/hodloo-alerts.log
redirect_stderr=true
```
Configure supervisor:
```
sudo supervisorctl
reread
add hodloo-alerts
status
```
To check whether your python script is running use the following:
```
sudo ps -axs | grep python
```
# Conclusion

That's it! You're successfully filtering the Hodloo telegram alerts for USDT pairs. I know the setup is quite cumbersome and I would love to pay a monthly fee to the creator of Hodloo for the filtered alerts, but sadly that service is not available.