Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does FMZ dock with Tradingview implementation to place an order

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "FMZ how to dock Tradingview implementation to place an order", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how FMZ docks Tradingview implementation to place an order".

The webhook characteristics of the system are as follows:

1. Standardize json messaging

2. Join try..except.. Exception handling

3. Join with..as.. Memory recovery

4. Adopt async async

5. Adopt ASGI protocol

6. Adopt AUTO HTTP1.X-2.0 protocol

7. The code has passed 100% test coverage

8. The application of the decorator makes the program simple, efficient, stable and reliable.

I. preparatory work

You need to install python 3.8.2 or above

You need to install the pippackage manager

Install the necessary packages

Principle and realization

What we need to do is simply to receive the data from the tradingview post and then encode it and send it to the http get to the FMZ's custodian. It's kind of like a middleware service.

FMZ terminal receiver

We are going to fmz to set up a python policy, as follows:

And then we get the robot running.

Here, we should pay great attention to the robot ID to fill in the python code.

Webhook server server building

The first step

Create a new python file. Name it fz1.py.

Step two

Write import module

Step three

Register api on the fmz home page

And find the managed host ID

And defined in the python code.

The RobotID here needs to obtain the ID in the previous hosting policy

The fourth step

Define an api function to submit CMD instructions to fmz hosting.

The fourth step

Custom data types (json format)

Use the BaseModel method of the pydantic module to define a type

Of course, you can define more fields yourself, depending on what you want to achieve.

All of the above are non-empty fields. If one of the parameters is missing, an error will be reported.

Step five

Write Tradingview receiver module (webhook server)

Webhook's protocol uses the http post method.

So we need to define a http server side and accept the data passed by post.

All the python server code

The above is the implementation of all the core code.

I handled the exception handling module and the retry mechanism a little bit. Integrate all the code.

Startup of the server

Remember to save the file as fz1 file name

Then we open the command line tool. Start the python server

The command is as follows:

It represents the py file that uses fz1 and invokes the webhook task.

Host means to receive 0.0.0.0 ip access, that is, all.

Port means to set the port to 8001 (it should be noted here that tradingview is only accessed through port 80, you need to map the port at the firewall, or use 80 directly)

Reload indicates that if the py master file has iterations, the server automatically reloads the latest version.

When you see the Application startup complete shown in the picture, it means that the startup is successful.

At this time, you can open your browser and visit http://127.0.0.1:8001/redoc.

Fast api has implemented api interface documentation and automatic debugger for you.

Local debugging

We are using the chrome plug-in TALEND API TESTER

You can also use other http debugging tools to do this.

Emulate the local tradingview to send webhook messages.

Adjust the mode to post

The url address is 127.0.0.1:8001/tv/.

Write json in the body field of post

At the same time, application/json is automatically generated in HEADER.

Click send when you are finished

As shown in the figure. The local test has been completed.

The data we sent from the local simulation to the webhook was passed to the managed device through python, and the relevant data was successfully obtained.

Deploy webhook to the public network

Part of this paragraph belongs to the personal network environment, everyone is different.

Log in to the Juniper terminal

Add rule-set outside-to-inside

Specify the link to go to from untruset to trust

Increase the tradingview source address IP break source-address [58.35.162.147ax 32 52.89.214.238 pm 32 34.212.75.30 pm 32 54.218.53.128 max 32 52.32.178.7 Universe 32]

Specify the destination address (local public network ip) destination-address xxx.xxx.xxx.xxx/32

Specify the destination port (local public network port) destination-port 80

Do port redirection destination-nat pool inside-8001

These steps are mainly to allow tradingview to access my public network ip

And specify port 80 to redirect to port 8001 of the local device.

After the implementation of the equipment rules. Tradingview will be able to push the message to us.

Tradingvew message test

We open tradingview and create a new alarm on a high-level indicator

This method can be used for tradingview various advanced metrics to automatically place orders.

Check webhook and fill in the server address http://xxx.xxx.xxx.xxx/tv/

Fill in the field message in the message box below.

{"apikey": "FMZ", "exchange": "bybit", "symbol": "BTC-USD", "side": "buy", "amount": "100"}

As shown in the picture, our early warning information has been shown on the indicators.

When the price crosses the target, tradingview generates an alarm.

At this point, I believe you have a deeper understanding of "FMZ how to dock Tradingview implementation order", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report