DEV Community

Cover image for Connecting Hodloo With  a 3Commas Bot (API Version)
Nobbi's Crypto
Nobbi's Crypto

Posted on • Updated on

Connecting Hodloo With a 3Commas Bot (API Version)

This is a follow up to my last article on Hodloo. While last time I explained how to receive Hodloo alerts for USDT pairs, this time I'm showing you how to send the signals to 3Commas and trade hands-free - so you can get rich relaxing on the beach (see the cover image). Just joking, we all know it doesn't work that way, but it is a step in the direction.

Recap

Let's recap what we have when following the other article. We have a Python script running 24/7 on a VPS that parses messages from the official Hodloo API and sends USDT pairs to a Discord channel.

Now, instead of sending alerts to a Discord channel, we want to send them to a bot which does the buying/selling.

FAQ

Why combining Hodloo with a bot? Why not trade manually?
I'm not doing this full-time. I have a day to day job. Also, the crypto market is running 24/7 and it happened too often in the past that a drop occured while I was asleep or not in front of my computer. By using a bot, I'm participating in the drop immidiatly.

In addition, I suck at trading. I'm FOMOing in all the time with too much size and then carry red bags for months. The bot keeps me away from the trading terminal.

Why 3Commas?
I find it intuitive and easy to work with. I'm using the bot mainly to get in a trade and then taking care of the rest manually. That means I often switch the bot's deal to a smart trade to get out when I want and not at a fixed percentage.

Why do you not use the built-in QFL algos in 3Commas
Because they suck - period. Hodloo bases are way better respected. And I need well-respected bases. I just can't take losses mentally and because of silly tax rules in my country.

Can I run this on my Windows/macOS machine?
Yes. Python is cross-platform. Remember that you need to let the machine running all the time. I don't want that hence I'm using a Linux VPS.

Why is this so complex and why can't I use a public service for this?
It's not available, unfortunately.

Preparing The QFL Bots

Head over to 3Commas and create two multi-pair bots. One for the 5% alerts and one for the 10% alerts. You choose the pairs you want to trade in the bot settings. While the script will send all Hodloo alerts to 3Commas, 3Commas will only create deals for the pairs you've selected in the bots.

Pairs

You can see that I've chosen six pairs for the bot but max deals is set to four. The bot will start a deal for the first Hodloo alert it receives to a maximum of four deals. Hence not all pairs you've configured will get a deal. First-come first-serve so to say.

You can also choose USDT_ALL. Note that this will include leveraged tokens and stablecoin pairs. Typically, you don't want to trade these and put them on the 3Commas blacklist. But that is cumbersome, instead you may want to use my script to do filter out leveraged tokens and stablecoin pairs. Just read on, it will be explained later.

Your safety order should be double the size of your base order.

Deal start condition

Set the deal start condition to manually as the bot receives the signal through the Python script.

Take profit

I wrote above that I like to get out of a trade manually. But, you have to set the take profit value to something and if it bounces to a 30% profit while I'm asleep - I'm okay with that ;-)

Layers

Now the juicy part - the buy layers. The above settings make sure that you get in with a small size and double-down when it goes south.

  • For the 5% bot the deepest layer is around 45% under the base.
  • For the 10% bot the deepest layer is around 50% under the base.

Save and start the bot. On the following page scroll down to the bottom and write down the bot ID. You need that later.

Bot ID

Preparing The Panic Sell Bot

Panic sells are a new Hodloo signal which is not availalbe via the Telegram alerts, but only with the new API. It detects a higher than normal sell off which is often where it bounces. If you have access to the new API, the panic sells are the green arrows in the charts.

Panic sells

I'm currently testing these myself and do not have a best-practice bot setting for you, you have to find it out yourself. So, create a bot and write down the bot ID.

Script Requirements

  1. Copy everything from my GitHub repository to a local folder. I'm using /opt/nobbi/hodloo.
  2. Install required Python libraries for all users:
sudo su
cd ~
pip install -r /opt/nobbi/hodloo/requirements.txt
Enter fullscreen mode Exit fullscreen mode
  1. Rename config.py.example to config.py and change the variables. The variables are very well documented in the file itself hence I won't cover this here. For your reference the variables below:
# 3c
TC_API_KEY = ''
TC_API_SECRET = ''
BOT_ID_5 = '' # Bot to start deal for pair 5% under the base. Leave empty if not desired.
BOT_ID_10 = '' # Bot to start deal for pair 10% under the base. Leave empty if not desired.
BOT_ID_PANIC = '' # Bot to start a deal for a panic sell. Leave empty if not desired.
MODE = 'paper' # 'real' or 'paper'
TC_EXCLUDE_LEVERAGED_TOKENS = True # Set to false to trade leveraged tokens. Currently supports excluding Binance and Kucoin leveraged tokens.
TC_DENYLIST = ["USDN/USDT","USDC/USDT","USDJ/USDT","CEUR/USDT","SUSD/USDT"] # Pairs on this list will not be traded.

# Discord
DISCORD_NOTIFICATIONS = '' # Discord Webhook of channel for trade notifications. Leave empty if not desired.
DISCORD_ERRORS = '' # Discord Webhook of channel for script errors. Mandatory.

# Hodloo
HODLOO_URI = '' # Hodloo Websocket API. Request the info from Pete in the Hodloo Discussions Telegram channel as it is private.
HODLOO_EXCHANGES = ["Binance"] # Multiple exchanges -> ["Binance","Kucoin"] Note that only Binance and Kucoin are fully supported at the moment.
Enter fullscreen mode Exit fullscreen mode

Saw the variables TC_EXCLUDE_LEVERAGED_TOKENS and TC_DENYLIST? By using these you don't need to click 1,000 times in 3Commas to build a blacklist. I prefer the term denylist btw, it's 2021 after all...

Running The Script

Run the script to see if everything is running as expected: python3 /opt/nobbi/hodloo/hodloo-to-3commas.py

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
Enter fullscreen mode Exit fullscreen mode

Checking the status of supervisor:

sudo service supervisor status
Enter fullscreen mode Exit fullscreen mode

Starting supervisor:

sudo service supervisor start
Enter fullscreen mode Exit fullscreen mode

Stopping and restarting supervisor:

sudo service supervisor stop
sudo service supervisor restart
Enter fullscreen mode Exit fullscreen mode

Create an entry for the hodloo-to-3commas.py script. The following example uses vi.

sudo vi /etc/supervisor/conf.d/hodloo-to-3commas.conf
Enter fullscreen mode Exit fullscreen mode

Contents of the file (change the paths accordingly):

[program:hodloo-to-3commas]
command=python3 -u hodloo-to-3commas.py
directory=/opt/nobbi/hodloo
stdout_logfile=/opt/nobbi/hodloo/hodloo-to-3commas.log
redirect_stderr=true
autorestart=true
Enter fullscreen mode Exit fullscreen mode

Configure supervisor:

sudo supervisorctl
reread
add hodloo-to-3commas
status
Enter fullscreen mode Exit fullscreen mode

To check whether your python script is running use the following:

sudo ps -axs | grep python
Enter fullscreen mode Exit fullscreen mode

Conclusion

Congratulations! You've automated QFL-style trading with Hodloo bases, Python, and 3Commas.

Discord example

Happy Hodlooing!

Update 2021-11-18

Volume Filter

The new variable HODLOO_MIN_VOLUME allows to filter coins based on a certain amount of volume. If the volume is below the variable's threshold, the coin will be ignored. See the variable description for an example.

Multiple Config Files

Until now the script required one config file named config.py. It now supports passing the name of the config file as a parameter, which allows running multiple instances of the script with different config files. Examples below.

# Old behavior where the script uses config.py as variable source (still supported btw)
> python hodloo-to-3commas.py

# Use kucoin.py file as variable source instead.
> python hodloo-to-3commas.py kucoin.py

Enter fullscreen mode Exit fullscreen mode

Oldest comments (4)

Collapse
 
nobbi profile image
Nobbi's Crypto

I like crypto and scripting. If my stuff makes you money, please consider supporting me.

  • USDT (TRC20) - TMAroqHEg7Z41x8fhY14Xp4R9FtzWkFMpR
  • BTC - bc1qh45t0q0vgazf6l8qe8wf3ek6j3d7pr8awu5rgr
  • ETH - 0x9686360226dAedEf32E904CF3ecEcf6EE4fC31e5
Collapse
 
freskhu profile image
Info Comment hidden by post author - thread only accessible via permalink
freskhu

Hello there,
Have you heard about Tuned? After reading your posts i think you would want to check it out.
tuned.com
Join the discord server and check what you can do with it.
Cheers

Collapse
 
andrewbb profile image
Andrei • Edited

Hello,

First of all, thanks for the script, works great.
The var HODLOO_MIN_VOLUME (I assume the value should be in USD), can it be replaced with "Don't start deal(s) if the daily volume is less than" option from the 3commas bot advanced options?
And is there any way I could get access to hodloo's api docs? I see there are a lot more signals coming from it, would love to figure them out.

Thanks

Collapse
 
crazyivan2 profile image
crazyivan2

hi nobbi crazyivan2 aus dem ES scalping channel hier.
hab gesehen du bist nicht auf dem neuen channel im discord.
der alte wurde ja gelöscht.
wenn du mich anschreibst können wir dich adden.
wir suchen die alten leute zusammen. mfg

crazyivan2#9029

Some comments have been hidden by the post's author - find out more