14
Get Alerts and Adjust TP on 3Commas Based on SOs
A very unwieldy title, I know. But I couldn't think of a better one. The topic is also very specific to my requirements, but maybe it will help someone.
I'm running several Urma v3 Lite (update 2021-10-27: apparently the creator took that site offline) bots on 3Commas. If you don't know what I'm talking about then stop here, this blog post is not for you ;-)
Anyway, if you are familiar with Urma v3 Lite bots you know that they often get stuck after the 4th safety order (SO) as the spacing between the SOs is large. And if it goes down to the 5th or even the 7th SO, a bounce is very common.
Hence I needed two things:
- Alerts whenever the 4th SO is completed. So that I don't need to check 3Commas the whole time. I then can play with manual safety orders to bring the deal into profit more quickly.
- Adjust the take profit (TP) value starting with the 5th SO. I usually go with 1.5% TP, but the value should be higher depending on the SO.
I wrote a Python script which does exactly the above. You can find it in my GitHub repo. I'm not a Python expert, but the script gets the job done.
The script checks all active deals whether they have 4 or more SOs completed. If yes, you get an alert. The deal ID is then saved so that you don't get further alerts for that deal. Then, it checks if 5 or more SOs are completed and sets the TP accordingly. I'm running the script every 15 minutes via cron on a Ubuntu VPS.
You need to have Python and py3cw installed.
The alerts are send to Discord. Read here why and how.
The script has a variable section which you need to modify. There are a lot of comments in the script so I won't go over the variables here. Below the variable section for your reference.
# 3Commas API info
# BOTS_READ permissions are mandatory
# BOTS_WRITE permissions are only needed if you want to adjust the take profit value
API_Key = ''
API_Secret = ''
account_id = ''
# Discord webhook for notifications
DiscordWebhook = ''
# Adjust TP, too?
adjust_TP = True # Can be True or False
# Adjust TP percentages when SO is completed
TPSO5 = 3 # Safety order 5
TPSO6 = 7 # Safety order 6
TPSO7 = 10 # Safety order 7
# Trailing settings
trailing_enabled = False
trailing_deviation = 0
14