Subscription APIs

About 2 min

Subscription APIs

Data streaming (data push) service is implemented by PushClient object. To use those services , you need to initialize an instance of PushClient first. Please see object list for a description of PushClient. Our push services are all asynchronous functions. You need to implement your own callback function, to process the data pushed by the server.

The strategy for pushing subscription data is that subscription data with the same tigerId will only be pushed once. Therefore, only one valid tcp connection can be established for the same tigerId. If you try to create multiple tcp connections, the last one created will take effect, and the previous connection will be kicked out. If the quantitative strategy is deployed on multiple machines, it is recommended to subscribe to only one instance and share data internally.

Steps to use our push service:

  1. Implement your callback function

    Implement callback functions in IApiComposeCallback class, and pass in PushClient object. You need to implement your own callback function, to process the data pushed by the server. For detailed examples, please see next section.

  2. Initialize TigerConfig

    Construct a authentication object TigerConfig, use this object to initialize PushClient See the example below:

      TigerConfig.LogDir = "/data0/logs/tiger-openapi-cs";
      config = new TigerConfig()
      {
        // The tiger_openapi_config.properties file is stored in your local directory.
        ConfigFilePath = "your local directory",
        // IsSslSocket = true;         // default is true
        FailRetryCounts = 2, // (optional) range:[1, 5],  default is 2
        Language = Language.en_US,   // (optional) default is en_US
        TimeZone = CustomTimeZone.HK_ZONE  // (optional) default is HK_ZONE
      };
    
  3. Initialize Push Client

    Initialize PushClient:

       IApiComposeCallback callback = new DefaultApiComposeCallback();
       PushClient client = PushClient.GetInstance().Config(config)
         .ApiComposeCallback(callback);
    
  4. Connect to Sever

    Call client.Connect(), use callbacks in IApiComposeCallback to process the connection result message

  5. Use Websocket Service

    Use the methods of PushClient, such as PushClient.SubscribeQuote(), to call relevant services. A list of methods is shown below.

  6. Disconnnect If you are done using the data feed pushed by the server, you can use PushClien.Disconnect() to disconnecet from the server. Using Disconnect() will cancel any remaining data feed subscription.

List of Available Data Push Services:

Account Change

MethodDescriptionCallback functiion
Subscribesubscribe to account changeSubscribeEnd, OrderStatusChange, PositionChange, AssetChange, OrderTransactionChange
CancelSubscribeCancel account change subscriptionCancelSubscribeEnd

Subscription

MethodDescriptionCallback functiion
SubscribeQuoteSubscribe to quote dataSubscribeEnd, QuoteChange, QuoteAskBidChange
CancelSubscribeQuoteCancel quote subscriptionCancelSubscribeEnd
SubscribeOptionSubscribe to option quoteSubscribeEnd, OptionChange, OptionAskBidChange
CancelSubscribeOptionCancel option quote subscriptionCancelSubscribeEnd
SubscribeFutureSubscribe to future quoteSubscribeEnd, FutureChange, FutureAskBidChange
CancelSubscribeFutureCancel future quoteCancelSubscribeEnd
SubscribeDepthQuoteSubscribe depth quoteSubscribeEnd, DepthQuoteChange
CancelSubscribeDepthQuoteCancel depth quote subscriptionCancelSubscribeEnd
SubscribeTradeTickSubscribe trade tickSubscribeEnd, TradeTickChange
CancelSubscribeTradeTickCancel trade tick subscriptionCancelSubscribeEnd
SubscribeStockTopSubscribe stock top dataSubscribeEnd, StockTopPush
CancelSubscribeStockTopCancel stock top subscriptionCancelSubscribeEnd
SubscribeOptionTopSubscribe option top dataSubscribeEnd, OptionTopPush
CancelSubscribeOptionTopCancel option top subscriptionCancelSubscribeEnd
SubscribeTradeTickSubscribe full trade tickSubscribeEnd, FullTickChange
SubscribeKlineSubscribe minute klineSubscribeEnd, KlineChange
CancelSubscribeKlineCancel minute kline subscriptionCancelSubscribeEnd
GetSubscribedSymbolsGet a List of Subscribed SymbolsGetSubscribedSymbolEnd

Other Events

EventsDescription
void ConnectAck()Connection established
void ConnectionClosed()Connection closed
void Error(String errorMsg)Error
void Error(int id, int errorCode, String errorMsg)Error
void ConnectionKickout(int errorCode, String errorMsg)kicked by another connection.the sdk will close the local tcp connection. Please do not implement reconnection in this method, it will cause constant kicks and affect data push
void HearBeat(String s)connection heartbeat callback
Last update: