Skip to content

Start Market Server

This document will show you how to start market server to listen subscribed symbols and exchanges.

For different deploy method, the correspond mode should be chosen, P2P is for cloud user, BROADCAST is for docker user, MULTIBROAD is for native user when you setup network configuration.

  • When the transmission type is P2P, the parameters ip and port correspond to the ip address and port that the market data server listens to.

  • When the transmission type is BROADCAST, the parameters ip ( and port correspond to the broadcast ip and the port of the receiver

  • When the transmission type is MULTIBROAD, the parameters ip ( to and port correspond to the MULTIBROAD ip and the port of the receiver

Below workflow uses cloud deploy method with P2P transmission as an example.

Click here to run directly

import time
from aats.market_service import MarketService
from aats.market_service import NetWorkType

# maintain your unique cid symbol mapping table which needs to be consistent in both market server and trade server
sym_cid_map = {
    1001: "BTCUSDT.BINANCE",
    1002: "ETHUSDT.BINANCE",

# setup control server IP and market data port
control_server_ip = ''
md_port = 15033

# start market engine
mkt_service = MarketService(sym_cid_map)
mkt_service.set_control_server(ip=control_server_ip, port=8060)  # default setting
mkt_service.set_network_cfg(ip=control_server_ip, port=md_port, send_type=NetWorkType.P2P, netcard_name = '')
mkt_service.add_listen_symbol('BTCUSDT', 'BINANCE', 5)
mkt_service.add_listen_symbol('ETHUSDT', 'BINANCE', 5)
# mkt_service.open_l2_data()

If the message returns "Failed to start the market data server. Please try another port.", it means the port is occupied and you could try another port between 10000-20000 when you call set_network_cfg function.

If the message returns "require_market_data_state: ok", it means the market server starts successfully and you can start trade server and run your strategy below.