Market Data Subscription

About 15 min

Subscribe Quote

SubscribeQuote(ISet<String> symbols)
Unsubscribe
CancelSubscribeQuote(ISet<String> symbols)

Description

Besides the APIs that allows you to actively pull the market data from the server, we offer data streaming services which let the server push relevent data, such as stock price quotes to clients. Our push services are implemented with asynchronous functions. Implement the callback functions in IApiComposeCallback, to process the data. The data pushed by the server is the basic quotation QuoteBasicData object, and the BBO quotation QuoteBBOData object.

Argument

ArgumentTypeRequiredDescription
symbolsISet<String>YesSet of symbols

symbol is the ticker symbol of the stocks, such as: AAPL, 00700

Return Value

NameTypeDescription
idstringID generated locally when the sdk sends a subscription request, and the sequence is incremented. In the subscribeEnd(int id, String subject, String result) callback method, return the request id and the result of whether the subscription is successful

Callback

void QuoteChange(QuoteBasicData data)void QuoteAskBidChange(QuoteBBOData data)

Example

using System;
using System.Text.Json.Nodes;
using Newtonsoft.Json;
using TigerOpenAPI.Common;
using TigerOpenAPI.Common.Util;
using TigerOpenAPI.Push;
using TigerOpenAPI.Push.Model;
using TigerOpenAPI.Quote.Pb;

namespace Test
{
  public class DefaultApiComposeCallback : IApiComposeCallback
  {
    public DefaultApiComposeCallback()
    {
    }

    void IApiComposeCallback.ConnectionAck()
    {
      ApiLogger.Info("connect success.");
    }

    void IApiComposeCallback.ConnectionAck(int serverSendInterval, int serverReceiveInterval)
    {
      ApiLogger.Info($"connect success. serverSendInterval:{serverSendInterval}," +
        $" serverReceiveInterval:{serverReceiveInterval}");
    }

    void IApiComposeCallback.HearBeat(string heartBeatContent)
    {
      ApiLogger.Info("HearBeat:" + heartBeatContent);
    }

    void IApiComposeCallback.ServerHeartBeatTimeOut(string channelId)
    {
      ApiLogger.Warn("ServerHeartBeatTimeOut:" + channelId);
    }

    void IApiComposeCallback.ConnectionClosed()
    {
      ApiLogger.Info("connection closed.");
    }

    void IApiComposeCallback.ConnectionKickout(int errorCode, string errorMsg)
    {
      ApiLogger.Info($"ConnectionKickout, errorCode:{errorCode}, errorMsg:{errorMsg}");
    }

    void IApiComposeCallback.Error(string errorMsg)
    {
      ApiLogger.Error("receive error:" + errorMsg);
    }

    void IApiComposeCallback.Error(int id, int errorCode, string errorMsg)
    {
      ApiLogger.Error($"receive error, id:{id}, errorCode:{errorCode}, errorMsg:{errorMsg}");
    }


    void ISubscribeApiCallback.GetSubscribedSymbolEnd(SubscribedSymbol subscribedSymbol)
    {
      ApiLogger.Info("GetSubscribedSymbolEnd:"
        + JsonConvert.SerializeObject(subscribedSymbol, TigerClient.JsonSet));
    }

    void ISubscribeApiCallback.SubscribeEnd(int id, string subject, string result)
    {
      ApiLogger.Info($"SubscribeEnd, {subject}, id:{id}, result:{result}");
    }

    void ISubscribeApiCallback.CancelSubscribeEnd(int id, string subject, string result)
    {
      ApiLogger.Info($"CancelSubscribeEnd, {subject}, id:{id}, result:{result}");
    }


    void ISubscribeApiCallback.AssetChange(AssetData data)
    {
      ApiLogger.Info("AssetChange:" + data);
    }

    void ISubscribeApiCallback.PositionChange(PositionData data)
    {
      ApiLogger.Info("PositionChange:" + data);
    }

    void ISubscribeApiCallback.OrderStatusChange(OrderStatusData data)
    {
      ApiLogger.Info("OrderStatusChange:" + data);
    }

    void ISubscribeApiCallback.OrderTransactionChange(OrderTransactionData data)
    {
      ApiLogger.Info("OrderTransactionChange:" + data);
    }


    void ISubscribeApiCallback.QuoteAskBidChange(QuoteBBOData data)
    {
      ApiLogger.Info("QuoteAskBidChange:" + data);
    }

    void ISubscribeApiCallback.QuoteChange(QuoteBasicData data)
    {
      ApiLogger.Info("QuoteChange:" + data);
    }

    void ISubscribeApiCallback.TradeTickChange(TradeTick data)
    {
      ApiLogger.Info("TradeTickChange:"
        + JsonConvert.SerializeObject(data, TigerClient.JsonSet));
    }

    void ISubscribeApiCallback.FullTickChange(TickData data)
    {
      ApiLogger.Info("FullTickChange:" + data);
    }

    void ISubscribeApiCallback.KlineChange(KlineData data)
    {
      ApiLogger.Info("KlineChange:" + data);
    }

    void ISubscribeApiCallback.DepthQuoteChange(QuoteDepthData data)
    {
      ApiLogger.Info("DepthQuoteChange:" + data);
    }

    void ISubscribeApiCallback.FutureAskBidChange(QuoteBBOData data)
    {
      ApiLogger.Info("FutureAskBidChange:" + data);
    }

    void ISubscribeApiCallback.FutureChange(QuoteBasicData data)
    {
      ApiLogger.Info("FutureChange:" + data);
    }

    void ISubscribeApiCallback.OptionAskBidChange(QuoteBBOData data)
    {
      ApiLogger.Info("OptionAskBidChange:" + data);
    }

    void ISubscribeApiCallback.OptionChange(QuoteBasicData data)
    {
      ApiLogger.Info("OptionChange:" + data);
    }

    void ISubscribeApiCallback.StockTopPush(StockTopData data)
    {
      ApiLogger.Info("StockTopPush, market:" + data.Market);
      foreach (StockTopData.Types.TopData topData in data.TopData)
      {
        ApiLogger.Info("StockTopPush, targetName:" + topData.TargetName
            + ", topList:" + topData);
      }
    }

    void ISubscribeApiCallback.OptionTopPush(OptionTopData data)
    {
      ApiLogger.Info("OptionTopPush, market:" + data.Market);
      foreach (OptionTopData.Types.TopData topData in data.TopData)
      {
        ApiLogger.Info("OptionTopPush, targetName:" + topData.TargetName
            + ", topList:" + topData);
      }
    }
  }
}
using System;
using Newtonsoft.Json;
using TigerOpenAPI.Common;
using TigerOpenAPI.Common.Enum;
using TigerOpenAPI.Common.Util;
using TigerOpenAPI.Config;
using TigerOpenAPI.Model;
using TigerOpenAPI.Push;
using TigerOpenAPI.Quote;
using TigerOpenAPI.Quote.Model;

namespace Test
{
  public class SubscribeDemo
  {
    private static TigerConfig config;

    static SubscribeDemo()
    {
      TigerConfig.LogDir = "/data0/logs/tiger-openapi-cs";
      config = new TigerConfig()
      {
        // The tiger_openapi_config.properties file is stored in your local directory.
        ConfigFilePath = "/data0/tiger_config",
        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
      };
    }

    static async Task Main(string[] args)
    {
      IApiComposeCallback callback = new DefaultApiComposeCallback();
      PushClient client = PushClient.GetInstance().Config(config)
        .ApiComposeCallback(callback);
      ApiLogger.Info($"======================{client.GetUrl()}");

      //Establish connection
      client.Connect();
      
      ISet<string> symbols = new HashSet<string>();

      //Stock quote subscription
      symbols.add("AAPL");
      symbols.add("SPY");

      //subscribe to symbol of interest
      client.SubscribeQuote(symbols);

      //subscibe to market depth quote(Only valid for stocks)
      client.SubscribeDepthQuote(symbols);

      //get subscribed symbols
      client.GetSubscribedSymbols();

      //Wait to receive the data
      Thread.Sleep(TimeSpan.FromSeconds(60));
      // Cancel subscription
      client.CancelSubscribeQuote(symbols);
      client.CancelSubscribeDepthQuote(symbols);
      // Cancel all quote subscriptions(Security, Options, Futures)
      client.CancelSubscribeQuote();
      // Cancel all depth quote subscriptions(Security, Futures)
      client.CancelSubscribeDepthQuote();
      // Cancel all tick quote subscriptions(Security, Futures)
      client.CancelSubscribeTradeTick();

      //Note: sending disconnect will clear all subscribed data
      //client.disconnect();
    }
  }
}

Stock's callback data:Quote push data

Response Example

Note: There are two types of callback data, trading basic data and BBO data. Example of Hong Kong stock trading data:

{"symbol":"00700","type":"BASIC","timestamp":"1684824663658","serverTimestamp":"1684824663671","avgPrice":341.161,"latestPrice":336,"latestPriceTimestamp":"1684824663602","latestTime":"05-23 14:51:03","preClose":340.2,"volume":"10464466","amount":3569992579,"open":345.2,"high":345.6,"low":336,"marketStatus":"Trading","mi":{"p":336,"a":341.161,"t":"1684824660000","v":"2800","o":336,"h":336.2,"l":336}}

Example of Hong Kong stock ask-bid data:

{"symbol":"00700","type":"BBO","timestamp":"1684824663658","askPrice":336.2,"askSize":"8100","askTimestamp":"1684824663294","bidPrice":336,"bidSize":"29100","bidTimestamp":"1684824663492"}

Example of US stock trading data:

{"symbol":"AAPL","type":"BASIC","timestamp":"1684767294253","serverTimestamp":"1684767294267","avgPrice":174.15846,"latestPrice":173.71,"latestPriceTimestamp":"1684767294083","latestTime":"05-22 10:54:54 EDT","preClose":175.16,"volume":"14144955","amount":2462689816.7102866,"open":173.98,"high":174.71,"low":173.45,"marketStatus":"Trading","mi":{"p":173.71,"a":174.15846,"t":"1684767240000","v":"103691","o":173.8,"h":173.83,"l":173.67}}

Example of US stock ask-bid data:

{"symbol":"AAPL","type":"BBO","timestamp":"1684767294303","askPrice":173.72,"askSize":"1000","askTimestamp":"1684767294130","bidPrice":173.7,"bidSize":"1400","bidTimestamp":"1684767294130"}

Example of US stock market pre-market trading data(Field name is different from the trading session):

{"symbol":"AAPL","type":"BASIC","timestamp":"1684753867189","serverTimestamp":"1684753867197","latestPrice":173.55,"latestPriceTimestamp":"1684753867189","latestTime":"07:11 EDT","preClose":175.16,"volume":"395061","amount":68630257.3399999,"hourTradingTag":"PreMarket","mi":{"p":173.55,"a":173.72179,"t":"1684753860000","v":"7106","o":173.58,"h":173.58,"l":173.55}}

Subscribe Option Quote

SubscribeOption(ISet<String> symbols)
Unsubscribe
CancelSubscribeOption(ISet<String> symbols)

Description

Subscribe to option maket data(Only supports the US market)

Our push services are implemented with asynchronous functions. Implement the callback functions in IApiComposeCallback, to process the data.

The data pushed by the server is the basic quotation QuoteBasicData object, and the BBO quotation QuoteBBOData object.

Argument

ArgumentTypeRequiredDescription
symbolsISet<String>Yesset of option symbols

Option symbols:

  1. symbol of the underlying asset+expiration data+strike price+PUT/CALL, divided with spaces, for example: (AAPL 20190329 182.5 PUT)
  2. Another format is option identifier,you can obtain this identifier by option quote APIs. For example: (SPY 190508C00290000)

Return Value

NameTypeDescription
iduintID generated locally when the sdk sends a subscription request, and the sequence is incremented. In the SubscribeEnd(int id, string subject, string result) callback method, return the request id and the result of whether the subscription is successful

Example

ISet<string> symbols = new HashSet<string>();
//subscribe to option quotes
symbols.add("AAPL 20230317 150.0 CALL");
//Another way to subscribe to option quotes
symbols.add("SPY   190508C00290000");

client.SubscribeOption(symbols);

//Wait to receive the data
TimeUnit.SECONDS.sleep(120000);
// Cancel subscription
client.CancelSubscribeOption(symbols);

Callback

void OptionChange(QuoteBasicData data)void OptionAskBidChange(QuoteBBOData data)

Response Example

Example of US option trading data:

{"symbol":"AAPL 20230317 150.0 CALL","type":"BASIC","timestamp":"1676994444927","latestPrice":4.83,"latestPriceTimestamp":"1676994444927","latestTime":"","preClose":6.21,"volume":"3181","amount":939117.0060634613,"open":4.85,"high":5.6,"low":4.64,"identifier":"AAPL  230317C00150000","openInt":"82677"}

Example of US option ask-bid data:

{"symbol":"AAPL 20230317 150.0 CALL","type":"BBO","timestamp":"1676994393156","askPrice":4.85,"askSize":"11","askTimestamp":"1676994393156","bidPrice":4.8,"bidSize":"992","bidTimestamp":"1676994390931"}

Subscribe Futures Quote

SubscribeFuture(ISet<String> symbols)
Unsubscribe
CancelSubscribeFuture(ISet<String> symbols)

Description

Subscribe to futures maket data

Our push services are implemented with asynchronous functions. Implement the callback functions in IApiComposeCallback, to process the data.

The data pushed by the server is the basic quotation QuoteBasicData object, and the BBO quotation QuoteBBOData object.

Argument

ArgumentTypeRequiredDescription
symbolsISet<String>YesSet of futures code

Return Value

NameTypeDescription
idstringID generated locally when the sdk sends a subscription request, and the sequence is incremented. In the SubscribeEnd(int id, string subject, string result) callback method, return the request id and the result of whether the subscription is successful

Example

ISet<string> symbols = new HashSet<string>();
symbols.add("ESmain");
symbols.add("ES2306");

client.SubscribeFuture(symbols);

//Wait to receive the data
TimeUnit.SECONDS.sleep(120000);
// Cancel subscription
client.CancelSubscribeFuture(symbols);

Callbacksvoid FutureChange(QuoteBasicData data)void FutureAskBidChange(QuoteBBOData data)

Response Example

Example of trading data:

{"symbol":"ESmain","type":"BASIC","timestamp":"1684767707106","avgPrice":4206.201,"latestPrice":4206.5,"latestPriceTimestamp":"1684767706000","latestTime":"05-22 10:01:46 -0500","preClose":4204.75,"volume":"605805","open":4189,"high":4221.75,"low":4186.5,"marketStatus":"Trading","tradeTime":"1684767706000","preSettlement":4204.75,"minTick":0.25,"mi":{"p":4206.25,"a":4206.201,"t":"1684767660000","v":"2447","o":4207.5,"h":4207.5,"l":4205.25}}

Example of ask-bid data:

{"symbol":"ESmain","type":"BBO","timestamp":"1684767707106","askPrice":4206.75,"askSize":"112","askTimestamp":"1684767707106","bidPrice":4206.5,"bidSize":"53","bidTimestamp":"1684767707106"}

Subscribe Depth Quote

SubscribeDepthQuote(ISet<String> symbols)
Unsubscribe
CancelSubscribeDepthQuote(ISet<String> symbols)

Description

Subscribe to market depth quote data streaming service, supports U.S. and Hong Kong stocks, U.S. stock options and futures.

Our push services are implemented with asynchronous functions. Implement the callback functions in IApiComposeCallback, to process the data.

The data pushed by the server is the QuoteDepthData object.

Arguemnt

ArgumentTypeRequiredDescription
symbolsISet<String>Yeslist of stock / options / futures symbols

Return Value

NameTypeDescription
iduintID generated locally when the sdk sends a subscription request, and the sequence is incremented. In the SubscribeEnd(int id, string subject, string result) callback method, return the request id and the result of whether the subscription is successful

Example

ISet<string> symbols = new HashSet<string>();

symbols.add("AAPL");
symbols.add("ESmain");
symbols.add("AAPL 20240209 180.0 CALL");

client.SubscribeDepthQuote(symbols);

//Wait to receive the data
TimeUnit.SECONDS.sleep(120000);
// Cancel subscription
client.CancelSubscribeDepthQuote(symbols);

Callback

void DepthQuoteChange(QuoteDepthData data)

Callback data

The data structure is as follows:

fieldtypeDescription
symbolstringstock symbol
timestamplongdepth quote data’s time
askList<OrderBook>List of ask data
bidList<OrderBook>List of bid data

OrderBook's data structure:

FieldTypeDescription
pricedoubleprice
volumelongvolume
orderCountintorder count(HK only)
exchangestringOptions data source(Options only),if 'price'or 'volume' is 0,indicates that the quote for this data source is invalid. Detail: [Options Exchange](../../appendix2/overview.md#Options Exchange)
timelongOptions exchange pending order timestamp(Options only)

Response Example

// US Market
{"symbol":"AAPL","timestamp":"1676993368405","ask":{"price":[149.69,149.69,149.69,149.69,149.69,149.69,149.7,149.7,149.7,149.7,149.7,149.7,149.7,149.7,149.7,149.7,149.71,149.71,149.71,149.71,149.71,149.71,149.71,149.71,149.72,149.72,149.72,149.72,149.72,149.72,149.72,149.72,149.72,149.72,149.73,149.73,149.73,149.73,149.73,149.73],"volume":["100","100","23","200","100","100","200","100","100","100","82","100","100","200","25","100","185","100","100","82","87","25","100","100","100","100","76","200","100","100","16","87","100","100","100","100","200","100","76","100"]},"bid":{"price":[149.68,149.68,149.68,149.68,149.67,149.67,149.67,149.67,149.67,149.67,149.67,149.67,149.66,149.66,149.66,149.66,149.66,149.66,149.66,149.66,149.66,149.66,149.66,149.66,149.66,149.65,149.65,149.65,149.65,149.65,149.65,149.65,149.65,149.65,149.65,149.64,149.64,149.64,149.64,149.64],"volume":["84","87","100","100","100","49","100","100","87","200","100","100","100","100","100","20","1","4","1","200","100","87","25","100","200","200","100","1","25","87","100","100","100","25","100","100","100","1","87","100"]}}

// HK Market
{"symbol":"00700","timestamp":"1670465696884","ask":{"price":[311.4,311.6,311.8,312.0,312.2,312.4,312.6,312.8,313.0,313.2],"volume":["15600","5700","16600","33800","61100","14800","28300","28400","61100","39200"],"orderCount":[16,13,19,79,39,29,66,56,160,27]},"bid":{"price":[311.2,311.0,310.8,310.6,310.4,310.2,310.0,309.8,309.6,309.4],"volume":["2300","8300","18000","8800","7700","8500","26700","11700","13700","22600"],"orderCount":[10,15,18,9,6,11,17,30,10,5]}}

Subscribe Trade Tick

SubscribeTradeTick(ISet<String> symbols)
Unsubscribe
CancelSubscribeTradeTick(ISet<String> symbols)

Description

Subscribe to trade tick.

Our push services are implemented with asynchronous functions. Implement the callback functions in IApiComposeCallback, to process the data.

The data pushed by the server is the basic quotation TradeTick object.

Supports subscriptions for stock/futures in the US and Hong Kong markets

Argument

ArgumentTypeRequiredDescription
symbolsISet<String>Yesset of stock and futures symbols

Return Value

NameTypeDescription
iduintID generated locally when the sdk sends a subscription request, and the sequence is incremented. In the SubscribeEnd(int id, string subject, string result) callback method, return the request id and the result of whether the subscription is successful

Example

ISet<string> symbols = new HashSet<string>();
//trade tick symbol
symbols.add("AAPL");
symbols.add("00700");
symbols.add("ESmain");

client.SubscribeTradeTick(symbols);

//Wait to receive the data
TimeUnit.SECONDS.sleep(120000);
// Cancel subscription
client.CancelSubscribeTradeTick(symbols);

Callback

void TradeTickChange(TradeTick data)

The callback data structure is as follows:

FieldTypeDescription
symbolstringStock symbol
secTypeSecTypeSTK/FUT
quoteLevelstringThe market authority level from which the data comes (for US stocks, usQuoteBasic/usStockQuote;stock only)
timestamplongdata timestamp
ticksList<Tick>List of trade tick data

ticks's data structure:

FieldTypeDescription
snlongThe serial number of the first trade tick data
volumelongtrading volume
tickTypestringDirection of the price change, "-" stands for decrease, "+" stands for increase(stocks only)
pricedoubletrading price
timelongtrading time
condstringtrading condition(stocks only)
partCodestringexchange code(US stocks only)
partNamestringexchange name(US stocks only)

Response Example

// US market
{"symbol":"AAPL","secType":"STK","quoteLevel":"usQuoteBasic","timestamp":1676993925700,"ticks":[{"sn":116202,"volume":50,"tickType":"*","price":149.665,"time":1676993924289,"cond":"US_REGULAR_SALE"},{"sn":116203,"volume":1,"tickType":"*","price":149.68,"time":1676993924459,"cond":"US_REGULAR_SALE"},{"sn":116204,"volume":1,"tickType":"*","price":149.67,"time":1676993925200,"cond":"US_REGULAR_SALE"},{"sn":116205,"volume":5,"tickType":"*","price":149.6652,"time":1676993925410,"cond":"US_REGULAR_SALE"}]}

// HK market
{"symbol":"00700","secType":"STK","quoteLevel":"hkStockQuoteLv2","timestamp":1669345639970,"ticks":[{"sn":35115,"volume":300,"tickType":"+","price":269.2,"time":1669345639496,"cond":"HK_AUTOMATCH_NORMAL"},{"sn":35116,"volume":200,"tickType":"+","price":269.2,"time":1669345639610,"cond":"HK_AUTOMATCH_NORMAL"}]}

// Futures trade tick
{"symbol":"HSImain","secType":"FUT","timestamp":1669345640575,"ticks":[{"sn":261560,"volume":1,"price":17465.0,"time":1669345639000},{"sn":261561,"volume":1,"price":17465.0,"time":1669345639000},{"sn":261562,"volume":1,"price":17465.0,"time":1669345639000},{"sn":261563,"volume":1,"price":17465.0,"time":1669345639000}]}

Subscribe Stock Top

SubscribeStockTop(Market market, ISet<Indicator> indicators)
Unsubscribe
CancelSubscribeStockTop(Market market, ISet<Indicator> indicators)

Description

Subscribe to the stock market ranking list data. Data is not pushed during non-trading hours, and the push interval is 30 seconds. Each push subscribes to the top 30 targets of the subscription indicator. The push interface is an asynchronous callback, and the asynchronous request result can be obtained by implementing the IApiComposeCallback interface. The callback interface returns a StockTopData object, and the various indicator data is sorted in reverse order by indicator value.

Subscription of stock indicators in the US and Hong Kong markets is supported. The stock ranking list during trading hours includes all indicators of the StockRankingIndicator, and only two indicators, changeRate and changeRate5Min, are included in the pre- and post-market trading hours of US stocks.

Argument

ArgumentTypeRequiredDescription
marketMarketYesmarket,US/HK
indicatorsISet<Indicator>NoThe stock ranking indicators refer to the default list of all indicators, with reference to the enumerated values of StockRankingIndicator, including changeRate (change in price for the day), changeRate5Min (change in price for the past 5 minutes), turnoverRate, amount (total trading volume for the day), volume (number of shares traded for the day), and amplitude (price fluctuation for the day).

Return Value

NameTypeDescription
idstringID generated locally when the sdk sends a subscription request, and the sequence is incremented. In the SubscribeEnd(int id, string subject, string result) callback method, return the request id and the result of whether the subscription is successful

Example

Market market = Market.US;
ISet<Indicator> indicators = new HashSet<Indicator>();
indicators.Add(StockRankingIndicator.Amplitude);
indicators.Add(StockRankingIndicator.TurnoverRate);
//Subscribe to Market All Stock Indicators
client.SubscribeStockTop(market)

//Wait to receive the data
Thread.Sleep(TimeSpan.FromSeconds(1200));
// Cancel subscription of ’amplitude‘ and 'turnoverRate'
client.CancelSubscribeStockTop(market, indicators);
// Cancel all indicators's subscription
client.CancelSubscribeStockTop(market);

Callbacks

void StockTopPush(StockTopData data)

The data structure of StockTopData is as follows:

fieldtypeDescription
marketstringmarket:US/HK
timestamplongtimestamp
topDataList<TopData>Data list of each indicator list

TopData's data structure:

fieldtypeDescription
targetNamestringindicator name(changeRate, changeRate5Min, turnoverRate, amount, volume, amplitude)
itemList<StockItem>List of ranking data under this indicator dimension

StockItem's data structure:

fieldtypeDescription
symbolstringsymbol
latestPricedoublelatest price
targetValuedoubletarget value

Response Example

{
    "market":"US",
    "timestamp":"1687278300595",
    "topData":[
        {
            "targetName":"changeRate",
            "item":[
                {
                    "symbol":"VCIG",
                    "latestPrice":9.3627,
                    "targetValue":2.308375
                },
                {
                    "symbol":"DICE",
                    "latestPrice":46.49,
                    "targetValue":0.373412
                },
                {
                    "symbol":"GYRO",
                    "latestPrice":12.4802,
                    "targetValue":0.280021
                },
                {
                    "symbol":"SPCE",
                    "latestPrice":5.7519,
                    "targetValue":0.216047
                },
                {
                    "symbol":"MGOL",
                    "latestPrice":2.5005,
                    "targetValue":0.190714
                }
                // ......
            ]
        },
        {
            "targetName":"turnoverRate",
            "item":[
                {
                    "symbol":"VCIG",
                    "latestPrice":9.3627,
                    "targetValue":36.208107
                },
                {
                    "symbol":"NUWE",
                    "latestPrice":3.03,
                    "targetValue":7.611091
                },
                {
                    "symbol":"BOF",
                    "latestPrice":4.67,
                    "targetValue":6.410152
                },
                {
                    "symbol":"RTL",
                    "latestPrice":7.04,
                    "targetValue":3.29593
                },
                {
                    "symbol":"DFLI",
                    "latestPrice":1.45,
                    "targetValue":2.224986
                }
                // ......
            ]
        },
        {
            "targetName":"amount",
            "item":[
                {
                    "symbol":"NVDA",
                    "latestPrice":431.245,
                    "targetValue":639469059.345
                },
                {
                    "symbol":"QQQ",
                    "latestPrice":365.32,
                    "targetValue":407949960.433
                },
                {
                    "symbol":"SPY",
                    "latestPrice":436.38,
                    "targetValue":402747009.348
                },
                {
                    "symbol":"AMD",
                    "latestPrice":118.3376,
                    "targetValue":224640977.406
                },
                {
                    "symbol":"RACE",
                    "latestPrice":305.745,
                    "targetValue":200281616.599
                }
                // ......
            ]
        },
        {
            "targetName":"volume",
            "item":[
                {
                    "symbol":"VCIG",
                    "latestPrice":9.3627,
                    "targetValue":77989039
                },
                {
                    "symbol":"TSLA",
                    "latestPrice":265.73,
                    "targetValue":72095435
                },
                {
                    "symbol":"SQQQ",
                    "latestPrice":19.84,
                    "targetValue":58098894
                },
                {
                    "symbol":"PLTR",
                    "latestPrice":15.74,
                    "targetValue":52396039
                },
                {
                    "symbol":"SPCE",
                    "latestPrice":5.7519,
                    "targetValue":51996141
                }
                // ......
            ]
        },
        {
            "targetName":"amplitude",
            "item":[
                {
                    "symbol":"VCIG",
                    "latestPrice":9.3627,
                    "targetValue":2.738516
                },
                {
                    "symbol":"HKIT",
                    "latestPrice":6.2411,
                    "targetValue":0.603175
                },
                {
                    "symbol":"BOF",
                    "latestPrice":4.67,
                    "targetValue":0.428894
                },
                {
                    "symbol":"ICAD",
                    "latestPrice":1.29,
                    "targetValue":0.376068
                },
                {
                    "symbol":"ATIP",
                    "latestPrice":11.3501,
                    "targetValue":0.366667
                }
                // ......
            ]
        },
        {
            "targetName":"changeRate5Min",
            "item":[
                {
                    "symbol":"CADL",
                    "latestPrice":1.36,
                    "targetValue":0.065693
                },
                {
                    "symbol":"WKLY",
                    "latestPrice":46.72,
                    "targetValue":0.039549
                },
                {
                    "symbol":"NSPR",
                    "latestPrice":2.7829,
                    "targetValue":0.031513
                },
                {
                    "symbol":"STIX",
                    "latestPrice":2.18,
                    "targetValue":0.029557
                },
                {
                    "symbol":"ELTX",
                    "latestPrice":12.41,
                    "targetValue":0.025431
                }
                // ......
            ]
        }
    ]
}

Subscribe Option Top

SubscribeOptionTop(Market market, ISet<Indicator> indicators)
Unsubscribe
CancelSubscribeOptionTop(Market market, ISet<Indicator> indicators)

Description

The subscription option for the stock ranking indicators, only pushes data during trading hours, with a push interval of 30 seconds, and each push includes data for the top 50 subscribed indicators. The push interface is an asynchronous callback, and the asynchronous request result can be obtained by implementing the IApiComposeCallback interface. The callback interface returns an OptionTopData object, which includes data on large transactions with a single trade volume greater than 1000, sorted in reverse order by transaction time, and other indicator data is the reverse order data of the accumulated value indicator value of the trading day.

Subscriptions for US market option indicators are supported, with all indicators listed in the OptionRankingIndicator data list.

Argument

ArgumentTypeRequiredDescription
marketMarketYesmarket:US
indicatorsISet<Indicator>NoOption top list indicator, the default is all indicators, refer to the value of enumeration OptionRankingIndicator (bigOrder: transaction big order, volume: cumulative trading volume of the day, amount: cumulative trading volume of the day, openInt: open interest volume)

Return Value

NameTypeDescription
idstringID generated locally when the sdk sends a subscription request, and the sequence is incremented. In the SubscribeEnd(int id, string subject, string result) callback method, return the request id and the result of whether the subscription is successful

Example

Market market = Market.US;
ISet<Indicator> indicators = new HashSet<Indicator>();
indicators.Add(OptionRankingIndicator.Amount);
indicators.Add(OptionRankingIndicator.OpenInt);
//Subscribe to all indicators of the option top list
client.SubscribeOptionTop(market)

//Wait to receive the data
Thread.Sleep(TimeSpan.FromSeconds(1200));
// Cancel subscription of ’amount‘ and 'openInt'
client.CancelSubscribeOptionTop(market, indicators);
// Cancel all indicators's subscription
client.CancelSubscribeOptionTop(market);

Callback

void OptionTopPush(OptionTopData data)

Callback data

The data(OptionTopData) structure is as follows:

fieldtypeDescription
marketstringmarket:US
timestamplongtimestamp
topDataList<TopData>Data list of each indicator list

TopData's data structure:

fieldtypeDescription
targetNamestringindicator name(bigOrder, volume, amount, openInt)
bigOrderList<BigOrder>Big Order indicator (bigOrder) Data List
itemList<OptionItem>List of ranking data under this indicator dimension

BigOrder's data structure:

fieldtypeDescription
symbolstringsymbol
expirystringexpiry date,format:yyyyMMdd
strikestringstrike price
rightstringCALL/PUT
dirstringBuying and selling direction:BUY/SELL/NONE
volumedoubletrade volume
pricedoubletrade price
amountdoubletrade amount
tradeTimelongtrade timestamp

OptionItem's data structure:

fieldtypeDescription
symbolstringsymbol
expirystringexpiry date,format:yyyyMMdd
strikestringstrike price
rightstringCALL/PUT
totalAmountdoubletotal trade amount
totalVolumedoubletotal trade volume
totalOpenIntdoubletotal open interest volume
volumeToOpenIntdoubletotalVolume/totalOpenInt
latestPricedoublelatest price
updateTimelongindicator data update timestamp

Response Example

{
    "market":"US",
    "timestamp":"1687278750057",
    "topData":[
        {
            "targetName":"volume",
            "item":[
                {
                    "symbol":"SPY",
                    "expiry":"20230620",
                    "strike":"435.0",
                    "right":"PUT",
                    "totalAmount":5623370,
                    "totalVolume":239696,
                    "totalOpenInt":16377,
                    "volumeToOpenInt":0.014064,
                    "latestPrice":0.07,
                    "updateTime":"1687278845240"
                },
                {
                    "symbol":"SPY",
                    "expiry":"20230620",
                    "strike":"436.0",
                    "right":"PUT",
                    "totalAmount":8795321,
                    "totalVolume":233445,
                    "totalOpenInt":13403,
                    "volumeToOpenInt":0.013697,
                    "latestPrice":0.2,
                    "updateTime":"1687278795127"
                },
                {
                    "symbol":"SPY",
                    "expiry":"20230620",
                    "strike":"438.0",
                    "right":"CALL",
                    "totalAmount":4834527,
                    "totalVolume":212219,
                    "totalOpenInt":961,
                    "volumeToOpenInt":0.012452,
                    "latestPrice":0.3,
                    "updateTime":"1687278790123"
                },
                {
                    "symbol":"SPY",
                    "expiry":"20230620",
                    "strike":"437.0",
                    "right":"PUT",
                    "totalAmount":11348973,
                    "totalVolume":200958,
                    "totalOpenInt":13973,
                    "volumeToOpenInt":0.011791,
                    "latestPrice":0.49,
                    "updateTime":"1687278795127"
                },
                {
                    "symbol":"SPY",
                    "expiry":"20230620",
                    "strike":"436.0",
                    "right":"CALL",
                    "totalAmount":9323080,
                    "totalVolume":189574,
                    "totalOpenInt":238,
                    "volumeToOpenInt":0.011123,
                    "latestPrice":1.42,
                    "updateTime":"1687278795127"
                }
                // ......
            ]
        },
        {
            "targetName":"amount",
            "item":[
                {
                    "symbol":"TSLA",
                    "expiry":"20230721",
                    "strike":"5.0",
                    "right":"CALL",
                    "totalAmount":85957053,
                    "totalVolume":4881,
                    "totalOpenInt":18,
                    "volumeToOpenInt":0.000618,
                    "latestPrice":263.28,
                    "updateTime":"1687278710026"
                },
                {
                    "symbol":"TSLA",
                    "expiry":"20230721",
                    "strike":"500.0",
                    "right":"PUT",
                    "totalAmount":77230234,
                    "totalVolume":5049,
                    "volumeToOpenInt":0.00064,
                    "latestPrice":231.68,
                    "updateTime":"1687278710026"
                },
                {
                    "symbol":"TSLA",
                    "expiry":"20230623",
                    "strike":"265.0",
                    "right":"CALL",
                    "totalAmount":31774072,
                    "totalVolume":72064,
                    "totalOpenInt":12928,
                    "volumeToOpenInt":0.009128,
                    "latestPrice":8.55,
                    "updateTime":"1687278840237"
                },
                {
                    "symbol":"TSLA",
                    "expiry":"20230623",
                    "strike":"270.0",
                    "right":"CALL",
                    "totalAmount":21701753,
                    "totalVolume":69172,
                    "totalOpenInt":14302,
                    "volumeToOpenInt":0.008761,
                    "latestPrice":6.15,
                    "updateTime":"1687278845240"
                },
                {
                    "symbol":"SPY",
                    "expiry":"20230721",
                    "strike":"420.0",
                    "right":"CALL",
                    "totalAmount":21633683,
                    "totalVolume":11108,
                    "totalOpenInt":46931,
                    "volumeToOpenInt":0.000652,
                    "latestPrice":20.9,
                    "updateTime":"1687278800214"
                }
                // ......
            ]
        },
        {
            "targetName":"openInt",
            "item":[
                {
                    "symbol":"AMC",
                    "expiry":"20230721",
                    "strike":"10.0",
                    "right":"CALL",
                    "totalAmount":4954,
                    "totalVolume":847,
                    "totalOpenInt":340843,
                    "volumeToOpenInt":0.000248,
                    "latestPrice":0.09,
                    "updateTime":"1687277769115"
                },
                {
                    "symbol":"AMC",
                    "expiry":"20230721",
                    "strike":"10.0",
                    "right":"PUT",
                    "totalVolume":1,
                    "totalOpenInt":321814,
                    "latestPrice":6.2,
                    "updateTime":"1687276853278"
                },
                {
                    "symbol":"AMC",
                    "expiry":"20230721",
                    "strike":"4.0",
                    "right":"PUT",
                    "totalAmount":271188,
                    "totalVolume":4568,
                    "totalOpenInt":242101,
                    "volumeToOpenInt":0.00134,
                    "latestPrice":0.83,
                    "updateTime":"1687278630111"
                },
                {
                    "symbol":"ATVI",
                    "expiry":"20240119",
                    "strike":"85.0",
                    "right":"PUT",
                    "totalAmount":3500,
                    "totalVolume":26,
                    "totalOpenInt":230702,
                    "volumeToOpenInt":0.000016,
                    "latestPrice":7.62,
                    "updateTime":"1687277689616"
                },
                {
                    "symbol":"EEM",
                    "expiry":"20231215",
                    "strike":"47.0",
                    "right":"CALL",
                    "totalAmount":610,
                    "totalVolume":35,
                    "totalOpenInt":183054,
                    "volumeToOpenInt":0.000007,
                    "latestPrice":0.15,
                    "updateTime":"1687277518874"
                }
                // ......
            ]
        },
        {
            "targetName":"bigOrder",
            "bigOrder":[
                {
                    "symbol":"EOSE",
                    "expiry":"20230721",
                    "strike":"4.0",
                    "right":"CALL",
                    "dir":"Buy",
                    "volume":10000,
                    "price":0.3,
                    "amount":300000,
                    "tradeTime":"1687278525704"
                },
                {
                    "symbol":"CSCO",
                    "expiry":"20250117",
                    "strike":"45.0",
                    "right":"PUT",
                    "dir":"Sell",
                    "volume":1200,
                    "price":2.64,
                    "amount":316800,
                    "tradeTime":"1687278259382"
                },
                {
                    "symbol":"TSLA",
                    "expiry":"20240119",
                    "strike":"190.0",
                    "right":"PUT",
                    "dir":"None",
                    "volume":1851,
                    "price":11.45,
                    "amount":2119395,
                    "tradeTime":"1687277970685"
                },
                {
                    "symbol":"TSLA",
                    "expiry":"20240119",
                    "strike":"425.0",
                    "right":"CALL",
                    "dir":"None",
                    "volume":1851,
                    "price":11.75,
                    "amount":2174925,
                    "tradeTime":"1687277970679"
                },
                {
                    "symbol":"GOOG",
                    "expiry":"20230721",
                    "strike":"120.0",
                    "right":"CALL",
                    "dir":"Sell",
                    "volume":1000,
                    "price":5.87,
                    "amount":587000,
                    "tradeTime":"1687277435533"
                }
                // ......
            ]
        }
    ]
}

Subscribe Full Trade Tick

SubscribeTradeTick(ISet<String> symbols)
Unsubscribe
CancelSubscribeTradeTick(ISet<String> symbols)

Description

Subscribe to full trade tick. need to ask the administrator to apply for permission, after the permission is activated, you need to configure UseFullTick = true;

Our push services are implemented with asynchronous functions. Implement the callback functions in IApiComposeCallback, to process the data.

The data pushed by the server is the basic quotation TickData object.

Supports subscriptions for stock in the US and Hong Kong markets

Argument

ArgumentTypeRequiredDescription
symbolsISet<String>Yesset of stock symbols

Return Value

NameTypeDescription
iduintID generated locally when the sdk sends a subscription request, and the sequence is incremented. In the SubscribeEnd(int id, string subject, string result) callback method, return the request id and the result of whether the subscription is successful

Example

ISet<string> symbols = new HashSet<string>();
//trade tick symbol
symbols.add("AAPL");
symbols.add("00700");

client.SubscribeTradeTick(symbols);

//Wait to receive the data
TimeUnit.SECONDS.sleep(120000);
// Cancel subscription
client.CancelSubscribeTradeTick(symbols);

Callback

void FullTickChange(TickData data)

The callback data structure is as follows:

FieldTypeDescription
symbolstringStock symbol
timestamplongdata timestamp
ticksList<Tick>List of trade tick data

ticks's data structure:

FieldTypeDescription
snlongThe serial number
timelongtrading time
pricefloattrading price
volumelongtrading volume
typestringbuy/sell direction. Active buy(+); Active sell(-); Neutral transaction(*)
condstringtrading condition
partCodestringexchange code

Response Example

{"symbol":"AAPL","ticks":[{"sn":"239962","time":"1712761836887","price":167.72,"volume":1,"type":"+"},{"sn":"239963","time":"1712761836887","price":167.72,"volume":1,"type":"+"},{"sn":"239964","time":"1712761836887","price":167.72,"volume":1,"type":"+"}],"timestamp":"1712761837063","source":"NLS"}

Subscribe Minute Kline

SubscribeKline(ISet<String> symbols)
Unsubscribe
CancelSubscribeKline(ISet<String> symbols)

Description

Subscribe to minute kline. need to ask the administrator to apply for permission.

Our push services are implemented with asynchronous functions. Implement the callback functions in IApiComposeCallback, to process the data.

The data pushed by the server is the basic quotation KlineData object.

Supports subscriptions for stock in the US and Hong Kong markets

Argument

ArgumentTypeRequiredDescription
symbolsISet<String>Yesset of stock symbols

Return Value

NameTypeDescription
iduintID generated locally when the sdk sends a subscription request, and the sequence is incremented. In the SubscribeEnd(int id, string subject, string result) callback method, return the request id and the result of whether the subscription is successful

Example

ISet<string> symbols = new HashSet<string>();
//trade tick symbol
symbols.add("AAPL");
symbols.add("00700");

client.SubscribeKline(symbols);

//Wait to receive the data
TimeUnit.SECONDS.sleep(120000);
// Cancel subscription
client.CancelSubscribeKline(symbols);

Callback

void KlineChange(KlineData data)

The callback data structure is as follows:

FieldTypeDescription
timelongtrading time
openfloatThe first transaction price of current minute.
highfloatThe highest price of current minute.
lowfloatThe lowest price of current minute.
closefloatThe last transaction price in the current minute.
avgfloatThe average price of current minute.
volumelongCumulative trading volume in current minute.
countintThe number of transaction in current minute.
symbolstringStock symbol
amountdoubleCumulative turnover in current minute
serverTimestamplongserver push timestamp

Response Example

{ "time": "1712734200000", "open": 313.8, "high": 314.2, "low": 313.8, "close": 314.2, "avg": 311.78256, "volume": "31800", "count": 70, "symbol": "00700", "amount": 9827320, "serverTimestamp": "1712734243040" }

Get Subscribed Symbols

GetSubscribedSymbols()

Description

Get a List of Subscribed Symbols

Argument

N/A

Example

client.GetSubscribedSymbols();

Callback

void GetSubscribedSymbolEnd(SubscribedSymbol subscribedSymbol)

The callback data structure is as follows:

FieldTypeDescription
limitintSubscription symbols(stocks/options/futures) limit maximum
usedintThe num of subscribed symbols(stocks/options/futures)
subscribedSymbolsarraysubscribed symbols(stocks/options/futures)
askBidLimitintSubscription depth quote stock limit max
askBidUsedintThe num of subscribed depth quote symbols
subscribedAskBidSymbolsarraysubscribed depth quote symbols
tradeTickLimitintSubscription trade tick stock limit max
tradeTickUsedintThe num of subscribed trade tick symbols
subscribedTradeTickSymbolsarraysubscribed trade tick symbols

Response Example

{
    "askBidLimit":10,
    "askBidUsed":0,
    "limit":20,
    "subscribedAskBidSymbols":[

    ],
    "subscribedSymbols":[

    ],
    "subscribedTradeTickSymbols":[
        "PDD",
        "AMD",
        "SPY",
        "01810"
    ],
    "tradeTickLimit":20,
    "tradeTickUsed":4,
    "used":0
}
Last update: