MoonBot for BinanceTrusted Management High-Frequency trading via UDP port

Original Trust Management tool was using Telegram channels to connect the main bot with slave bots. This approach is good enough for mid-term signals when delays of 1-3 seconds mean nothing. However for high-speed trading and scalping delays are critical.

Taking this into account we developed the new extra fast protocol for trust management. (Available only in PRO version).

Test results show that delays can be as small as 100ms and even less! In some cases, slave bots can be even faster than the master bot, if they use fast VPS close to exchange’s servers location (i.e. Tokyo for Binance)

Factors to achieve high speed:

  1. The UDP protocol is connectionless, hence to send a signal means to send only one 1-way datagram. It’s much faster than to establish a connection first then to send a signal and wait for confirmation. There is a drawback – very small chance that a command won’t be received, in case of trust management tasks it doesn’t really matter and means that one trade from let’s say 1000 others will be missed.
  2. Some commands are “composite”, consists of atomic sub-commands, For example, to replace an order consists of 3 operations: to cancel an existing order, to wait for exchange’s confirmation, to set new order. If the command: “replace an order” is sent to a fast VPS, it is executed by the VPS alone, and hence may be executed much faster than by master bot.

The list of all available commands and basic description of how trust management works you will find here. Please read this article first before proceeding to the next chapter.

How to setup slave bots to work with udp signals:

1) First of all, slave bots must have static IP and open UDP port. The IP address and the port you tell your manager so that he adds you to send list.

1A) How to open an UDP port: Each bot should use a unique port number, which you specify in the “Settings – Advanced” tab. The default is port 1999.

Here are steps to open a port on Windows Server 2016: open Windows Firewall

Create a new rule to allow UDP packets on the desired port:

After you have created the rule, you may open its properties and allow inbound connections from determinate IPs (belonging to your managers).(Properties – Scope – Remote IPs).

1B) How to setup the bot: Create a new strategy with SignalType = “UDP”. Set AcceptCommands = YES. Leave ChannelKey empty.

Master bot may send encrypted command (see below), in this case, set OnlyEncrypted = YES and ask your manager to give you key files to decrypt signals.

3) How to setup master bot

Right-click to the Share button:

  • Tick the “I’d like to post Trust Management UDP signals”.
  • Push the “Send List” button, fill the send list with IPs and ports of your slave bots.
  • Optionally fill the “Max. Order” value: Master bot specify max. order size, and when it uses less order, slave bots use proportionally smaller orders too
  • Optionally fill the ChannelKey: your slave bots must specify the same ChannelKey in their strategies.

You can send encrypted signals (preferred):

  • Push the “Keys” button 1 time. this will create key files: a private key (data\UDPKeys.key) and a public key data\PubKey*****.pub (where **** is the Moonbot ID digits of the Master. ex.
  • The private key must be kept safe on your PC only in the “data” folder. Do not move it and do not give anyone.
  • Give the public key to your subscribers, it’s needed to decrypt your signals.
  • NOTE! If you push the “Keys” button once more, it will overwrite key files, and you will have to give the public key to your subscribers again.

Also note:

  • To use multi-orders, you must turn encryption on (with that, the order identifier will be transmitted that will allow managed bots distinguish between orders on the same coin)! Open commands (unencrypted) do not transmit the order identifier.
  • When using multi-orders with Trusted Management, unifying sell orders is not possible. The manager should not use the order unification function!
  • Splits in TM (trusted management) should be made for orders only. This way, the order will be split in 3 parts similar to what the manager has, allowing for the management of all 3 orders.
  • ATTENTION: Do not split positions while in TM because this command depends on the precise position size of the manager and cannot be correctly copied for the managed account and also, the managed account’s position might be formed by more than one manager or the owner of the managed account directly or their strategies.
  • On Amazon and Google vps you should open the desired port in admin panel. For google the manual is here
  • With encryption turned on the signals also contains base currency, which is verified by slave bots (so that ETH slave won’t accept USDT master’s commands)..
  • Old format signals from the “export” chapter can be used in a similar way to manage remote bot.
  • If there is an open port on the server and the manager has specified the correct IP address, the strategies with enabled encryption should receive signals and write to the log, even if these cannot be processed. That said, if the log was left empty this is an indication of the port or IP address being set wrong.
  • Any bot will take up one port (even if it has no strategies and isn’t set up for Trusted Management). If you are running several bots, you should assign them different ports (Settings —> special)