MoonCMD Remote Control Protocol

Quick article search

General Information about the MoonCMD Protocol

How to use:
The MoonBot terminal can receive remote control commands via a UDP port, send responses, and transmit regular status updates.


Commands are accepted in the following format:


hash command


where hash = HMAC-SHA256(command, password); the port and password are configured in “Settings → Special → Remote”.


Fields: UDP Commands Port\passEnter the port on which MoonBot will listen for commands, and the password that will be used to sign the commands.



General response format:


Responses are sent in JSON format, gzipped:


{‘cmd’:‘’,‘bot’:‘string Bot Name’,“N”: int,‘data’:string or object}


Основные команды


  • buy ... – the standard rules for buy signals apply;

  • short ... – the standard rules apply to short signals (futures);

  • sell token – enable PanicSell for the coin. Example: sell NEO;

  • SellALL – enable PanicSell on ALL active orders and close the terminal;

  • list (or "lst" for the short format) – list of active sell orders;

  • silent – disable terminal notifications in the chat regarding closed trades;

  • talk – enable terminal notifications in the chat regarding closed trades;

  • STOP –click “Stop” in the terminal (do not buy new signals);

  • CancelBuy – cancel all unfilled limit BUY orders;

  • START – click “Start” in the terminal, run the strategies;

  • BL – show the blacklist of coins;

  • BL + coin – add the coin to the blacklist;

  • BL - coin – remove the coin from the blacklist;

  • TempBL +N coin1 coin2 – activate a temporary blacklist on the specified coins for N hours;

  • SetParam Strategy Param Value – change the parameter in the strategy ("empty" for an empty string);

  • SetBL+ Strategy coin – add a coin to the blacklist of a strategy or folder;

  • SetBL- Strategy coin – remove a coin from a strategy’s blacklist or a folder;

  • SetWL+ Strategy coin – add a coin to the whitelist of a strategy or folder;

  • SetWL- Strategy coin – remove a coin from a strategy’s whitelist or a folder;

  • sgStart Strategy, sgStop Strategy <время, минуты> – start or stop strategies for a specified period;

  • ResetSession coin | ALL – reset sessions on a single market or across all markets;

  • ResetLoss – reset the profit counter;

  • Leverage X [coin,coin] – change the denomination on the coins to X;

  • Margin [coin,coin \ ALL] ISO\Cross – change the margin type to isolated or cross on the specified markets or on all markets;

  • ConvertBNB – convert small amounts of coins into BNB;

  • report [N days \ weeks] [coin] [hide] – send the report. By default, for today;

  • SellPiece [coin\ALL] – sell a portion of each order (if SellPiece is not 0);

  • DoUpdate – update to the release version.


Additional commands


  • GetStrategiesFull - send all strategies;

  • GetStrategiesActive -send only active strategies.


Output format:


{‘cmd’:‘strats’,‘bot’:‘BotName’,‘N’:number,“data”:‘string’}, where:


N: packet number (not all strategies may fit into a single packet, in which case they are split into N packets)


Data: list of strategies (standard format, as when copying a tag to the clipboard):


##Begin_Strategy



##End_Strategy


A single packet may contain several strategies in succession.


Regular updates from the terminal to the port from which the command was received


  • Orders
    {‘cmd’:‘order’,‘bot’:‘BotName’,‘oid’:number,“sql”:‘string’} Oid: The order ID in the Moonbot terminal database. This must be used to ensure records in the database are updated correctly when new SQL queries are received following price changes or the partial or full execution of an order

  • Balances: (sent every 5 seconds)
    {‘cmd’:‘acc’,‘bot’:‘BotName’, ‘data’:{ ‘A’:”double”,‘T’:‘double’, “S”:bool,‘V’:int}}
    - A: Available balance;
    - T: Total balance;
    - S: whether the terminal is running;
    - V: version number (without a decimal point; for example, for version 7.56, send as “756”);

  • API errors: (sent as they occur; in batches of 5 seconds. Error messages are stored in the data.E array)
    {"cmd":"errors","bot":"BB-Futures","data":{"E":[
    "04.12 00:12:56.268: TON [400] CheckMarginRatio fail! InsufficientAB\n Timing: 203 ms",
    "04.12 00:12:57.104: TON [400] CheckMarginRatio fail! InsufficientAB\n Timing: 203 ms",
    "04.12 00:12:57.966: TON [400] CheckMarginRatio fail! InsufficientAB\n Timing: 203 ms"]}};

  • Bin files containing charts:
    SubscribeCharts
    : Subscribe to the file distribution list.
    UnsubscribeCharts: Unsubscribe from the file distribution list.

    Header format
    TMoonCmdHeader
    = packed record
    Flag: byte; // Always 0, to distinguish from plain gzip
    Kind: byte; // Payload type. 1 = chart
    id: integer; // 4 bytes for a chart – order ID (dbID)
    blockNum: byte; // datagram block number, starting from 0
    blocksCount: byte; // total number of blocks. 1 if not split
    end;
    The file may be split into blocksCount parts.

    Reading format
    The format of the binary file written by TMarket.SaveToStreamShort