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 (255.255.255.255) and port correspond to the broadcast ip and the port of the receiver

  • When the transmission type is MULTIBROAD, the parameters ip (224.0.0.0 to 239.255.255.255) 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.

#include <unistd.h>
#include "MarketDataService.h"
#include "ControlService.h"
#include "TradeService.h"
#include "Common.h"

using namespace std;
using namespace aats;


int main(int argc, char **argv)
{
    // start market data server
    CMarketDataService md;
    md.setAppName("MarketData_001");
    md.setNetworkConfig(MARKETDATA_SEND_P2P,8060,15031);
    md.addListenExchange("BINANCE");
    md.addListenSymbol(1001,"BINANCE","BTCUSDT",5);
    // md.serialization();

    CControlService control("54.199.162.238",8060);

    int pid = control.createMarketDataServer(&md);
    cout << pid << endl;

    while(1)
    {
        std::string output = control.checkProcess(pid);
        if(output == "ok")
            break;
        sleep(2);
    }

    return 1;
}