Trust Management and Social Trading

Quick article search

Trust Management Via UDP Protocol

When using the trust management function, commands between the master and follower terminals can be transmitted via Telegram. In this case, the delay is approximately 1–3 seconds. Such an interval is acceptable for mid-term trading signals; however, in scalping and high-frequency trading even this delay may be critical, therefore it must be minimized.


For this purpose, a trust management mechanism via the UDP protocol was implemented. It allows commands to be transmitted between Moonbot terminals with virtually no delay. This functionality is available only in the PRO version.


Based on testing results, it was established that using UDP reduces command transmission latency to 100 ms or even less. In some cases, follower terminals may execute a command earlier than the master — for example, if they are hosted on a server located closer to the exchange infrastructure and have significantly lower network latency.


Higher terminal control speed when using the UDP protocol is achieved due to the following features:


  • Data exchange via UDP does not require establishing a persistent connection.
    A data packet is sent in one direction without delivery confirmation, which significantly accelerates command transmission over the network. Each command is placed in a separate datagram, minimizing delays and increasing exchange speed.

  • Some commands are composite from the perspective of interaction with the exchange.
    For example, the “move order” command includes three phases: canceling the current order, verifying the operation result, and placing a new order. When using UDP, such a composite command is transmitted to the follower terminal in a single packet, allowing it to be fully executed on the follower terminal without additional data exchange with the master terminal, thereby saving time and reducing latency.


The operating principles and the list of available Trust Management commands are described in the section "Trust Management via Telegram".


When working via the UDP protocol, the same commands are used — they are simply not sent to Telegram but are transmitted directly to the follower terminals. 


Setting up a follower terminal to receive Trust Management commands via the UDP protocol


Step 1. Configuring a static IP address and opening a UDP port


For correct operation, the follower terminal must have a static IP address and an open UDP port. This IP address and port must be provided to the managing trader so that they can add your terminal to the Trust Management command distribution list.


How to open a UDP port:


  1. Each Moonbot terminal participating in Trust Management must use a unique port, which is set in Settings → Advanced → System in the Listen UDP port field. By default, the port is set to 1999;

  2. If you are using Windows Server 2016, you must open the port in Windows Firewall. To do this, follow these steps:


1) Open Open Network and Sharing Center → Windows Firewall window;




2) Go to Advanced settings;



3)   Create a new rule that allows incoming UDP packets on the selected port;



4) Open the properties of the created rule and restrict access — allow packet reception only from the IP addresses provided by the managing trader.


Step 2. Configuring the UDP strategy on the follower terminal


In the Strategies window of the follower terminal, create a strategy of type UDP. On its Main tab, set AcceptCommands = YES — this will allow the reception of Trust Management commands. Leave the ChannelKey field empty.


⚠️ Attention! If the master terminal transmits signals in encrypted form, enable OnlyEncryptedCommands = YES on the Main tab and obtain the key file from the managing trader (details are provided below).


Setting up the master terminal to send Trust Management commands via the UDP protocol


1) Open the Share market window


Open any coin in full-screen mode and click the Share button on the right control panel — this will open the Share market window.



2) Enable signal transmission via UDP


Check the option I`d like to post Trust Management signals via UDP.


3) Configure the parameters in the UDP Settings section


Encryption


It is recommended to always transmit signals in encrypted form to enhance security. To do this, enable the option Encrypt signals sent over UDP. When encryption is enabled, each command will additionally contain information about the base currency, which is verified on the follower terminal side, providing an additional level of validation and security.


Legacy-format signals from the Export section can continue to be forwarded to a remote terminal without changes.


Multi-orders


To use the multi-order mode, encryption must be enabled. This is because when data is transmitted in encrypted form, a unique order identifier is added to each command, allowing follower terminals to correctly distinguish multiple orders on the same coin. If commands are not encrypted, the order identifier is not transmitted, and multi-order functionality will either be unavailable or operate incorrectly.


Order splitting


Order splitting in Trust Management is supported, but it should be used only for one specific order. In this case, the order will be split into three equal parts, and the splitting process will be synchronized in the same way on both the master and follower terminals, maintaining full control over all three parts of the order.


Order splitting in Trust Management is supported; however, it should be applied only to a single specific order. In this case, the order will be divided into three parts identically on both the master and follower terminals, while full control over all three parts is preserved.


⚠️ Attention! Avoid using position splitting in Trust Management. This may lead to incorrect copying of the command to the follower terminal, since this operation depends on the exact position size on the master terminal. In addition, a position on the follower terminal may have been formed not only by the master terminal, but also by other masters, by the user manually, or by their own strategies, which may cause errors in command processing and replication.


4) When using encryption — create key files.


To do this, click the Keys button once — the terminal will generate two files: a private key (data\UDPKeys.key) and a public key (data\UDPKeys.pub).


  • The private key (UDPKeys.key) must not be shared with anyone. It is already encrypted and must be stored only on the managing trader’s computer — in the data folder of the Moonbot terminal from which management commands are sent. It is important that the private key is not accessible to third parties or external systems to ensure secure data transmission;

  • The public key (UDPKeys.pub) must be distributed to all follower users. They must place it in the data folder of their follower terminals.


⚠️ Attention! If you press the Keys button again, the existing keys will be overwritten. In this case, you will need to redistribute the updated public keys to all follower traders to maintain proper encryption functionality.


5) Click the Send List button and configure the distribution list by obtaining the IP addresses and ports from the follower users.


Click the Send List button and configure the distribution list by obtaining the IP addresses and ports from the follower users.


  • Send only share signals
    Send only buy signals or the full set of Trust Management commands;

  • Send Panic Sell for closed orders
    Send a PanicSell command when the master terminal closes a sell order;

  • Send Cancel_Buy for closed orders
    Send a CancelBuy command when the master terminal closes a sell order;

  • Send Cancel_Buy on buy fill
    Send a CancelBuy command 5 seconds after the master terminal buys the coin;

  • SendFirstSell
    Send a Sell command immediately after purchase; if not enabled, the sell price from the follower terminal settings will be used;

  • Sell If master not filled
    Send a PanicSell command if the managing terminal cancels the Buy order without purchasing anything;

  • Max Order
    Optional field for specifying the maximum order size in the master terminal (for example, 1000$ in the given example). When the master terminal uses a smaller order size, follower terminals automatically use a proportionally smaller order while maintaining the defined ratios and limits;

  • ChannelKey
    Optional field for specifying a channel key in the master terminal (for example, “Trust” in the given example). If a channel key is set in the master terminal, the same key must be specified on the follower terminal in the UDP strategy settings on the Main tab in the ChannelKey parameter.
    For example, in the screenshot: if ChannelKey: Trust is specified in the master terminal, then in the follower terminal’s UDP strategy settings on the Main tab it must be set as ChannelKey = Trust.


When working with Moonbot terminals on Amazon and Google servers, you must additionally create a rule that allows incoming data packets.


Instructions for configuring rules for Google servers are available at the following link: 🔗 Google Cloud Firewall Documentation..


Each terminal uses a separate port, even if it does not use strategies or is not configured for Trust Management (TM).


If you are running multiple terminals, you must assign different ports for each terminal in Settings → Advanced → System in the Listen UDP port field.


If the port on the server is open and your IP address is correctly specified in the master terminal settings, the UDP strategy will receive signals and write data to the log, even if it is unable to process them. If there is no data in the log, this may indicate that the ports or IP address are configured incorrectly.


No additional port configuration is required for sending Trust Management commands. If you see a rating displayed on the Share button, this means that command transmission from the master terminal is functioning correctly.