← Back to Home
advertisement
Interfacing with FMZ robot using

Interfacing with FMZ robot using "Tradingview" indicator

Introduction to background TradingView is a good tool for drawing market quotes. Pine writing is also a powerful existence! Backtesting, alarms and various links is a very complete financial tool. But there are two problems that have been plaguing us... - One is the expensive membership system. - The second is that there are very few exchanges where signals can be traded directly, there seem to be two or three. Our article today aims to take you to solve the problem of exchange coupling problems. Implementation The general idea is like this: TV (TradingView) pine script -> signal alarm webhook -> local webhook server forward request -> FMZ bot receives request to trade let's go step by step. Go to the TradingView website: Next, we first create an alert; Please refer to the figure below for more details. It is necessary to pay attention to some aspects of the image when generating an alert. The validity period, webhook address, and message content must be well defined. You will know the expiration date at a glance, and it will cease to be valid when it expires... Webhook URL, let's keep it empty first, we will fill it when the local webhook service ends. Message here, we better have a clear explanation to allow the bot to distinguish from alert messages. I usually set it like this: XXX strategy, order quantity and business direction So far, the TradingView part is basically finished! Next, let's finish the work of the local webhook service! For this type of work, Google will show you many results. This article will skip this part, you can do it yourself. Here is a simple framework for Python: GitHub: https://github.com/shawn-sterling/gitlab-webhook-receiver Safe, worry-free and comfortable, but there are problems too. This little frame, will do it!! Suicide!! Pay attention to this problem! So, I wrote another script on the server. When "die" or "offline" appears in the log, I will restart it. Later, I still don't feel safe, so I set it to restart periodically. Find an unimportant moment every hour... Restart it, it has been working safely for two months and there is no more signal loss. Also, TradingView only recognizes port 80, so don't mess up the service port. So far, we have done the Alert Message part. Next, how do we get Bot? I don't know if you have paid attention to the FMZ interface API document at the bottom: We can pass some commands to our little Bot via API! The specific request example is here, the red box is the request we need. Some prep work is needed here as well. FMZ API (avatar->account settings->API interface), A Bot that has been started (we want to get its ID, so we first create a new ID), the number in the URL of a general bot is the ID. Next, we transform the webhook service so that after receiving the message, it is automatically forwarded to the FMZ Bot. Finally, don't forget to fill in the full webhook address in the TradingView alert (format: http://xx.xx.xx.xx:80). The following is the service code I changed, you can use it for reference: #!/usr/bin/python -tt # -*- encoding: UTF-8 -*- from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer import json import record import logging.handlers import operating system import re import Shuil import thread import time import ssl ssl._create_default_https_context = ssl._create_unverified_context test: import md5 import urllib2 from urllib import urlen code except: import hashlib as md5 import urllib.request as urllib2 from urllib.parse import urlen code ############################################################## ##### You will probably need to change some of the following ##### # log file for this script log_file = '/root/webhook/VMA/webhook.log' # Bot API License password = '' secretkey = '' # HTTP configuration log_max_size = 25165824 # 24 MB log_level = log.I
advertisement

Related Articles

advertisement