Market Data Subscription
Subscribe Quote
subscribeQuote(Set<String> symbols)
UnsubscribecancelSubscribeQuote(Set<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 ApiComposeCallback, to process the data. The data pushed by the server is the basic quotation QuoteBasicData
object, and the BBO quotation QuoteBBOData
object.
Argument
Argument | Type | Required | Description |
---|---|---|---|
symbols | Set<String> | Yes | Set of symbols |
symbol is the ticker symbol of the stocks, such as: AAPL
, 00700
Return Value
Name | Type | Description |
---|---|---|
id | string | ID 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
package com.tigerbrokers.stock.openapi.demo;
import com.tigerbrokers.stock.openapi.client.socket.ApiComposeCallback;
import com.tigerbrokers.stock.openapi.client.socket.data.TradeTick;
import com.tigerbrokers.stock.openapi.client.socket.data.pb.AssetData;
import com.tigerbrokers.stock.openapi.client.socket.data.pb.KlineData;
import com.tigerbrokers.stock.openapi.client.socket.data.pb.OptionTopData;
import com.tigerbrokers.stock.openapi.client.socket.data.pb.OrderStatusData;
import com.tigerbrokers.stock.openapi.client.socket.data.pb.OrderTransactionData;
import com.tigerbrokers.stock.openapi.client.socket.data.pb.PositionData;
import com.tigerbrokers.stock.openapi.client.socket.data.pb.QuoteBBOData;
import com.tigerbrokers.stock.openapi.client.socket.data.pb.QuoteBasicData;
import com.tigerbrokers.stock.openapi.client.socket.data.pb.QuoteDepthData;
import com.tigerbrokers.stock.openapi.client.socket.data.pb.StockTopData;
import com.tigerbrokers.stock.openapi.client.socket.data.pb.TickData;
import com.tigerbrokers.stock.openapi.client.struct.SubscribedSymbol;
import com.tigerbrokers.stock.openapi.client.util.ApiLogger;
import com.tigerbrokers.stock.openapi.client.util.ProtoMessageUtil;
public class DefaultApiComposeCallback implements ApiComposeCallback {
/*Callback for stock quote updates*/
@Override
public void quoteChange(QuoteBasicData data) {
ApiLogger.info("quoteChange:" + ProtoMessageUtil.toJson(data));
}
/*Callback for stock‘s best bid and off quote updates*/
@Override
public void quoteAskBidChange(QuoteBBOData data) {
ApiLogger.info("quoteAskBidChange:" + ProtoMessageUtil.toJson(data));
}
/*Callback for option quote updates*/
@Override
public void optionChange(QuoteBasicData data) {
ApiLogger.info("optionChange:" + ProtoMessageUtil.toJson(data));
}
/*Callback for option‘s best bid and off quote updates*/
@Override
public void optionAskBidChange(QuoteBBOData data) {
ApiLogger.info("optionAskBidChange:" + ProtoMessageUtil.toJson(data));
}
/*Callback for futures quote updates*/
@Override
public void futureChange(QuoteBasicData data) {
ApiLogger.info("futureChange:" + ProtoMessageUtil.toJson(data));
}
/*Callback for futures‘s best bid and off quote updates*/
@Override
public void futureAskBidChange(QuoteBBOData data) {
ApiLogger.info("futureAskBidChange:" + ProtoMessageUtil.toJson(data));
}
/*Callback for depth quote updates*/
@Override
public void depthQuoteChange(QuoteDepthData data) {
ApiLogger.info("depthQuoteChange:" + ProtoMessageUtil.toJson(data));
}
/*Callback for trade tick updates*/
@Override
public void tradeTickChange(TradeTick data) {
ApiLogger.info("tradeTickChange:" + JacksonUtil.writeValueAsString(data));
}
/*Callback for full trade tick updates*/
@Override
public void fullTickChange(TickData data) {
ApiLogger.info("fullTickChange:" + ProtoMessageUtil.toJson(data));
}
/*Callback for minute kline data updates*/
@Override
public void klineChange(KlineData data) {
ApiLogger.info("klineChange:" + ProtoMessageUtil.toJson(data));
}
/**Stock quote top list data push*/
@Override
public void stockTopPush(StockTopData data) {
ApiLogger.info("stockTopPush, market:" + data.getMarket());
for (StockTopData.TopData topData : data.getTopDataList()) {
ApiLogger.info("stockTopPush, targetName:" + topData.getTargetName()
+ ", topList:" + ProtoMessageUtil.toJson(topData));
}
}
/**Option quote top list data push*/
@Override
public void optionTopPush(OptionTopData data) {
ApiLogger.info("optionTopPush, market:" + data.getMarket());
for (OptionTopData.TopData topData : data.getTopDataList()) {
ApiLogger.info("optionTopPush, targetName:" + topData.getTargetName()
+ ", topList:" + ProtoMessageUtil.toJson(topData));
}
}
/*End subscription*/
@Override
public void subscribeEnd(int id, String subject, String result) {
ApiLogger.info("subscribe " + subject + " end. id:" + id + ", " + result);
}
/*Cancel subscription*/
@Override
public void cancelSubscribeEnd(int id, String subject, String result) {
ApiLogger.info("cancel subscribe " + subject + " end. id:" + id + ", " + result);
}
/*Callback for checking subscribed symbols*/
@Override
public void getSubscribedSymbolEnd(SubscribedSymbol subscribedSymbol) {
ApiLogger.info("getSubscribedSymbolEnd:" + JSONObject.toJSONString(subscribedSymbol));
}
}
subscription
public class WebSocketDemo {
//Fill in your tigerId and privateKey. You also need to implement your own callback function in ApiComposeCallback. This demo uses DefaultApiComposeCallback
private static ClientConfig clientConfig = ClientConfig.DEFAULT_CONFIG;
private static WebSocketClient client;
static {
// The tiger_openapi_config.properties file is stored in your local directory.
clientConfig.configFilePath = "your local directory";
// clientConfig.secretKey = "xxxxxx";// institutional trader private key
client = WebSocketClient.getInstance().clientConfig(clientConfig).apiComposeCallback(new DefaultApiComposeCallback());
}
public static void subscribe() {
client.connect();
Set<String> symbols = new HashSet<>();
//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
TimeUnit.SECONDS.sleep(60000);
// Cancel subscription
client.cancelSubscribeQuote(symbols);
client.cancelSubscribeDepthQuote(symbols);
//Cancel all quote subscriptions(Security, Options, Futures)
client.cancelSubscribeQuote(new HashSet<>());
//Cancel all depth quote subscriptions(Security, Futures)
client.cancelSubscribeDepthQuote(new HashSet<>());
//Cancel all tick quote subscriptions(Security, Futures)
client.cancelSubscribeTradeTick(new HashSet<>());
//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":"1684721758123",
"serverTimestamp":"1684721758228",
"avgPrice":330.493,
"latestPrice":332.2,
"latestPriceTimestamp":"1684721758103",
"latestTime":"05-22 10:15:58",
"preClose":333.2,
"volume":"4400026",
"amount":1454057948,
"open":331.8,
"high":334.2,
"low":328.2,
"marketStatus":"Trading",
"mi":{
"p":332.2,
"a":330.493,
"t":"1684721700000",
"v":"75400",
"o":331.6,
"h":332.2,
"l":331.4
}
}
Example of Hong Kong stock ask-bid data:
{
"symbol":"00700",
"type":"BBO",
"timestamp":"1684721757927",
"askPrice":332.2,
"askSize":"32100",
"askTimestamp":"1684721757344",
"bidPrice":332,
"bidSize":"3500",
"bidTimestamp":"1684721757773"
}
Example of US stock trading data:
{
"symbol":"AAPL",
"type":"BASIC",
"timestamp":"1684766012120",
"serverTimestamp":"1684766012129",
"avgPrice":174.1721,
"latestPrice":174.175,
"latestPriceTimestamp":"1684766011918",
"latestTime":"05-22 10:33:31 EDT",
"preClose":175.16,
"volume":"12314802",
"amount":2144365591.410586,
"open":173.98,
"high":174.71,
"low":173.45,
"marketStatus":"Trading",
"mi":{
"p":174.175,
"a":174.1721,
"t":"1684765980000",
"v":"57641",
"o":174.21,
"h":174.22,
"l":174.14
}
}
Example of US stock ask-bid data:
{
"symbol":"AAPL",
"type":"BBO",
"timestamp":"1676992715509",
"askPrice":149.96,
"askSize":"200",
"askTimestamp":"1676992715367",
"bidPrice":149.94,
"bidSize":"700",
"bidTimestamp":"1676992715367"
}
Example of US stock market pre-market trading data(Field name is different from the trading session):
{
"symbol":"AAPL",
"type":"BASIC",
"timestamp":"1684753559744",
"serverTimestamp":"1684753559752",
"latestPrice":173.66,
"latestPriceTimestamp":"1684753559744",
"latestTime":"07:05 EDT",
"preClose":175.16,
"volume":"366849",
"amount":63731858.18000001,
"hourTradingTag":"PreMarket",
"mi":{
"p":173.66,
"a":173.72891,
"t":"1684753500000",
"v":"5604",
"o":173.64,
"h":173.67,
"l":173.63
}
}
Subscribe Option Quote
subscribeOption(Set<String> symbols)
UnsubscribecancelSubscribeOption(Set<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 ApiComposeCallback, to process the data.
The data pushed by the server is the basic quotation QuoteBasicData
object, and the BBO quotation QuoteBBOData
object.
Argument
Argument | Type | Required | Description |
---|---|---|---|
symbols | Set<String> | Yes | set of option symbols |
Option symbols:
- symbol of the underlying asset+expiration data+strike price+PUT/CALL, divided with spaces, for example: (AAPL 20190329 182.5 PUT)
- Another format is option identifier,you can obtain this identifier by option quote APIs. For example: (SPY 190508C00290000)
Return Value
Name | Type | Description |
---|---|---|
id | string | ID 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
Set<String> symbols = new HashSet<>();
//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(Set<String> symbols)
UnsubscribecancelSubscribeFuture(Set<String> symbols)
Description
Subscribe to futures maket data
Our push services are implemented with asynchronous functions. Implement the callback functions in ApiComposeCallback, to process the data.
The data pushed by the server is the basic quotation QuoteBasicData
object, and the BBO quotation QuoteBBOData
object.
Argument
Argument | Type | Required | Description |
---|---|---|---|
symbols | Set<String> | Yes | Set of futures code |
Return Value
Name | Type | Description |
---|---|---|
id | string | ID 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
Set<String> symbols = new HashSet<>();
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":"1684766824130",
"avgPrice":4206.476,
"latestPrice":4202.5,
"latestPriceTimestamp":"1684766824000",
"latestTime":"05-22 09:47:04 -0500",
"preClose":4204.75,
"volume":"557570",
"open":4189,
"high":4221.75,
"low":4186.5,
"marketStatus":"Trading",
"tradeTime":"1684766824000",
"preSettlement":4204.75,
"minTick":0.25,
"mi":{
"p":4202.25,
"a":4206.476,
"t":"1684766820000",
"v":"96",
"o":4202.25,
"h":4202.5,
"l":4202.0
}
}
Example of ask-bid data:
{
"symbol":"ESmain",
"type":"BBO",
"timestamp":"1684766824130",
"askPrice":4202.75,
"askSize":"70",
"askTimestamp":"1684766824129",
"bidPrice":4202.5,
"bidSize":"2",
"bidTimestamp":"1684766824130"
}
Subscribe Depth Quote
subscribeDepthQuote(Set<String> symbols)
UnsubscribecancelSubscribeDepthQuote(Set<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 ApiComposeCallback, to process the data.
The data pushed by the server is the QuoteDepthData
object.
Arguemnt
Argument | Type | Required | Description |
---|---|---|---|
symbols | Set<String> | Yes | list of stock / options / futures symbols |
Return Value
Name | Type | Description |
---|---|---|
id | string | ID 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
Set<String> symbols = new HashSet<>();
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:
field | type | Description |
---|---|---|
symbol | string | stock symbol |
timestamp | long | depth quote data’s time |
ask | List<OrderBook> | List of ask data |
bid | List<OrderBook> | List of bid data |
OrderBook's data structure:
Field | Type | Description |
---|---|---|
price | double | price |
volume | long | volume |
orderCount | int | order count(HK only) |
exchange | string | Options 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) |
time | long | Options 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(Set<String> symbols)
UnsubscribecancelSubscribeTradeTick(Set<String> symbols)
Description
Subscribe to trade tick.
Our push services are implemented with asynchronous functions. Implement the callback functions in ApiComposeCallback, 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
Argument | Type | Required | Description |
---|---|---|---|
symbols | Set<String> | Yes | set of stock and futures symbols |
Return Value
Name | Type | Description |
---|---|---|
id | string | ID 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
Set<String> symbols = new HashSet<>();
//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:
Field | Type | Description |
---|---|---|
symbol | string | Stock symbol |
secType | SecType | STK/FUT |
quoteLevel | string | The market authority level from which the data comes (for US stocks, usQuoteBasic/usStockQuote;stock only) |
timestamp | long | data timestamp |
ticks | List<Tick> | List of trade tick data |
ticks's data structure:
Field | Type | Description |
---|---|---|
sn | long | The serial number of the first trade tick data |
volume | long | trading volume |
tickType | string | buy/sell direction. Active buy(+); Active sell(-); Neutral transaction(*)(stocks only) |
price | double | trading price |
time | long | trading time |
cond | string | trading condition(stocks only) |
partCode | string | exchange code(US stocks only) |
partName | string | exchange 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, Set<Indicator> indicators)
UnsubscribecancelSubscribeStockTop(Market market, Set<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 ApiComposeCallback 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
Argument | Type | Required | Description |
---|---|---|---|
market | Market | Yes | market,US/HK |
indicators | Set<Indicator> | No | The 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
Name | Type | Description |
---|---|---|
id | string | ID 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;
Set<Indicator> indicators = new HashSet<>();
indicators.add(StockRankingIndicator.Amplitude);
indicators.add(StockRankingIndicator.TurnoverRate);
//Subscribe to Market All Stock Indicators
client.subscribeStockTop(market, null)
//Wait to receive the data
TimeUnit.SECONDS.sleep(120000);
// Cancel subscription of ’amplitude‘ and 'turnoverRate'
client.cancelSubscribeStockTop(market, indicators);
// Cancel all indicators's subscription
client.cancelSubscribeStockTop(market, null);
Callbacks
void stockTopPush(StockTopData data)
The data structure of StockTopData
is as follows:
field | type | Description |
---|---|---|
market | string | market:US/HK |
timestamp | long | timestamp |
topData | List<TopData> | Data list of each indicator list |
TopData's data structure:
field | type | Description |
---|---|---|
targetName | string | indicator name(changeRate, changeRate5Min, turnoverRate, amount, volume, amplitude) |
item | List<StockItem> | List of ranking data under this indicator dimension |
StockItem's data structure:
field | type | Description |
---|---|---|
symbol | string | symbol |
latestPrice | double | latest price |
targetValue | double | target value |
Response Example
{
"market":"US",
"timestamp":"1687271010482",
"topData":[
{
"targetName":"changeRate",
"item":[
{
"symbol":"ICAD",
"latestPrice":1.63,
"targetValue":0.393162
},
{
"symbol":"DICE",
"latestPrice":46.54,
"targetValue":0.374889
},
{
"symbol":"VCIG",
"latestPrice":3.88,
"targetValue":0.371025
},
{
"symbol":"LYRA",
"latestPrice":3.75,
"targetValue":0.237624
},
{
"symbol":"CANO",
"latestPrice":1.4847,
"targetValue":0.18776
}
// ......
]
},
{
"targetName":"turnoverRate",
"item":[
{
"symbol":"SBBA",
"latestPrice":24.8,
"targetValue":191.046512
},
{
"symbol":"VCIG",
"latestPrice":3.88,
"targetValue":13.82794
},
{
"symbol":"BOIL",
"latestPrice":3.225,
"targetValue":10.681214
},
{
"symbol":"GDV",
"latestPrice":20.86,
"targetValue":8.257162
},
{
"symbol":"NUWE",
"latestPrice":3.1611,
"targetValue":6.755784
}
// ......
]
},
{
"targetName":"amount",
"item":[
{
"symbol":"TSLA",
"latestPrice":263.21,
"targetValue":10629393179.8
},
{
"symbol":"SPY",
"latestPrice":435.64,
"targetValue":5839415251.67
},
{
"symbol":"NVDA",
"latestPrice":428.3801,
"targetValue":5123997584.1
},
{
"symbol":"QQQ",
"latestPrice":364.72,
"targetValue":3979912590.29
},
{
"symbol":"BRK.A",
"latestPrice":509004,
"targetValue":2529965164.19
}
// ......
]
},
{
"targetName":"volume",
"item":[
{
"symbol":"TSLA",
"latestPrice":263.21,
"targetValue":40190416
},
{
"symbol":"NKLA",
"latestPrice":1.2586,
"targetValue":33326008
},
{
"symbol":"FISV",
"latestPrice":114.23,
"targetValue":31689406
},
{
"symbol":"SQQQ",
"latestPrice":19.93,
"targetValue":31339556
},
{
"symbol":"PLTR",
"latestPrice":15.98,
"targetValue":30249797
}
// ......
]
},
{
"targetName":"amplitude",
"item":[
{
"symbol":"ICAD",
"latestPrice":1.63,
"targetValue":0.333333
},
{
"symbol":"VCIG",
"latestPrice":3.88,
"targetValue":0.293286
},
{
"symbol":"GRCL",
"latestPrice":3.8285,
"targetValue":0.281059
},
{
"symbol":"ZJYL",
"latestPrice":10.2165,
"targetValue":0.278427
},
{
"symbol":"NUWE",
"latestPrice":3.1611,
"targetValue":0.262799
}
// ......
]
},
{
"targetName":"changeRate5Min",
"item":[
{
"symbol":"ICAD",
"latestPrice":1.63,
"targetValue":0.077419
},
{
"symbol":"EUDA",
"latestPrice":1.3,
"targetValue":0.072
},
{
"symbol":"WEL",
"latestPrice":10.75,
"targetValue":0.070233
},
{
"symbol":"TYGO",
"latestPrice":17.255,
"targetValue":0.068901
},
{
"symbol":"SSU",
"latestPrice":3.2512,
"targetValue":0.065967
}
// ......
]
}
]
}
Subscribe Option Top
subscribeOptionTop(Market market, Set<Indicator> indicators)
UnsubscribecancelSubscribeOptionTop(Market market, Set<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 ApiComposeCallback 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
Argument | Type | Required | Description |
---|---|---|---|
market | Market | Yes | market:US |
indicators | Set<Indicator> | No | Option 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
Name | Type | Description |
---|---|---|
id | string | ID 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;
Set<Indicator> indicators = new HashSet<>();
indicators.add(OptionRankingIndicator.Amount);
indicators.add(OptionRankingIndicator.OpenInt);
//Subscribe to all indicators of the option top list
client.subscribeOptionTop(market, null)
//Wait to receive the data
TimeUnit.SECONDS.sleep(120000);
// Cancel subscription of ’amount‘ and 'openInt'
client.cancelSubscribeOptionTop(market, indicators);
// Cancel all indicators's subscription
client.cancelSubscribeOptionTop(market, null);
Callback
void optionTopPush(OptionTopData data)
Callback data
The data(OptionTopData
) structure is as follows:
field | type | Description |
---|---|---|
market | string | market:US |
timestamp | long | timestamp |
topData | List<TopData> | Data list of each indicator list |
TopData's data structure:
field | type | Description |
---|---|---|
targetName | string | indicator name(bigOrder, volume, amount, openInt) |
bigOrder | List<BigOrder> | Big Order indicator (bigOrder) Data List |
item | List<OptionItem> | List of ranking data under this indicator dimension |
BigOrder's data structure:
field | type | Description |
---|---|---|
symbol | string | symbol |
expiry | string | expiry date,format:yyyyMMdd |
strike | string | strike price |
right | string | CALL/PUT |
dir | string | Buying and selling direction:BUY/SELL/NONE |
volume | double | trade volume |
price | double | trade price |
amount | double | trade amount |
tradeTime | long | trade timestamp |
OptionItem's data structure:
field | type | Description |
---|---|---|
symbol | string | symbol |
expiry | string | expiry date,format:yyyyMMdd |
strike | string | strike price |
right | string | CALL/PUT |
totalAmount | double | total trade amount |
totalVolume | double | total trade volume |
totalOpenInt | double | total open interest volume |
volumeToOpenInt | double | totalVolume/totalOpenInt |
latestPrice | double | latest price |
updateTime | long | indicator data update timestamp |
Response Example
{
"market":"US",
"timestamp":"1687277160445",
"topData":[
{
"targetName":"volume",
"item":[
{
"symbol":"SPY",
"expiry":"20230620",
"strike":"435.0",
"right":"PUT",
"totalAmount":5394115,
"totalVolume":212478,
"totalOpenInt":16377,
"volumeToOpenInt":0.012467,
"latestPrice":0.25,
"updateTime":"1687277254390"
},
{
"symbol":"SPY",
"expiry":"20230620",
"strike":"436.0",
"right":"PUT",
"totalAmount":7754077,
"totalVolume":194423,
"totalOpenInt":13403,
"volumeToOpenInt":0.011408,
"latestPrice":0.58,
"updateTime":"1687277213603"
},
{
"symbol":"SPY",
"expiry":"20230620",
"strike":"437.0",
"right":"PUT",
"totalAmount":10420625,
"totalVolume":182078,
"totalOpenInt":13973,
"volumeToOpenInt":0.010683,
"latestPrice":1.17,
"updateTime":"1687277213602"
},
{
"symbol":"SPY",
"expiry":"20230620",
"strike":"438.0",
"right":"CALL",
"totalAmount":4482482,
"totalVolume":181899,
"totalOpenInt":961,
"volumeToOpenInt":0.010673,
"latestPrice":0.09,
"updateTime":"1687277213603"
},
{
"symbol":"SPY",
"expiry":"20230620",
"strike":"436.0",
"right":"CALL",
"totalAmount":7331667,
"totalVolume":150604,
"totalOpenInt":238,
"volumeToOpenInt":0.008837,
"latestPrice":0.66,
"updateTime":"1687277208599"
}
// ......
]
},
{
"targetName":"amount",
"item":[
{
"symbol":"TSLA",
"expiry":"20230721",
"strike":"5.0",
"right":"CALL",
"totalAmount":34061561,
"totalVolume":1812,
"totalOpenInt":18,
"volumeToOpenInt":0.00023,
"latestPrice":259.99,
"updateTime":"1687276953360"
},
{
"symbol":"TSLA",
"expiry":"20230721",
"strike":"500.0",
"right":"PUT",
"totalAmount":30877216,
"totalVolume":1960,
"volumeToOpenInt":0.000248,
"latestPrice":234.97,
"updateTime":"1687276953360"
},
{
"symbol":"TSLA",
"expiry":"20230623",
"strike":"265.0",
"right":"CALL",
"totalAmount":27928028,
"totalVolume":66361,
"totalOpenInt":12928,
"volumeToOpenInt":0.008405,
"latestPrice":6.5,
"updateTime":"1687277264395"
},
{
"symbol":"SPY",
"expiry":"20230721",
"strike":"420.0",
"right":"CALL",
"totalAmount":21629503,
"totalVolume":11105,
"totalOpenInt":46931,
"volumeToOpenInt":0.000652,
"latestPrice":19.27,
"updateTime":"1687273142271"
},
{
"symbol":"TSLA",
"expiry":"20230623",
"strike":"270.0",
"right":"CALL",
"totalAmount":17657903,
"totalVolume":61012,
"totalOpenInt":14302,
"volumeToOpenInt":0.007728,
"latestPrice":4.52,
"updateTime":"1687277254390"
}
// ......
]
},
{
"targetName":"openInt",
"item":[
{
"symbol":"AMC",
"expiry":"20230721",
"strike":"10.0",
"right":"CALL",
"totalAmount":4933,
"totalVolume":750,
"totalOpenInt":340843,
"volumeToOpenInt":0.00022,
"latestPrice":0.1,
"updateTime":"1687276788220"
},
{
"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":117982,
"totalVolume":2748,
"totalOpenInt":242101,
"volumeToOpenInt":0.000806,
"latestPrice":0.81,
"updateTime":"1687277034280"
},
{
"symbol":"ATVI",
"expiry":"20240119",
"strike":"85.0",
"right":"PUT",
"totalAmount":3500,
"totalVolume":26,
"totalOpenInt":230702,
"volumeToOpenInt":0.000016,
"latestPrice":7,
"updateTime":"1687274092822"
},
{
"symbol":"EEM",
"expiry":"20231215",
"strike":"47.0",
"right":"CALL",
"totalAmount":310,
"totalVolume":15,
"totalOpenInt":183054,
"volumeToOpenInt":0.000003,
"latestPrice":0.18,
"updateTime":"1687269619956"
}
// ......
]
},
{
"targetName":"bigOrder",
"bigOrder":[
{
"symbol":"AMC",
"expiry":"20230818",
"strike":"10.0",
"right":"PUT",
"dir":"Buy",
"volume":1000,
"price":6.94,
"amount":694000,
"tradeTime":"1687276860753"
},
{
"symbol":"GLPI",
"expiry":"20230818",
"strike":"50.0",
"right":"CALL",
"dir":"Sell",
"volume":1094,
"price":1.2,
"amount":131280,
"tradeTime":"1687276744519"
},
{
"symbol":"AMD",
"expiry":"20230818",
"strike":"140.0",
"right":"CALL",
"dir":"Buy",
"volume":1700,
"price":3.25,
"amount":552500,
"tradeTime":"1687276467421"
},
{
"symbol":"AAPL",
"expiry":"20230915",
"strike":"185.0",
"right":"PUT",
"dir":"Sell",
"volume":1500,
"price":6.65,
"amount":997500,
"tradeTime":"1687276413267"
},
{
"symbol":"BABA",
"expiry":"20240119",
"strike":"75.0",
"right":"PUT",
"dir":"Sell",
"volume":1500,
"price":4.8,
"amount":720000,
"tradeTime":"1687276036749"
}
// ......
]
}
]
}
Subscribe Full Trade Tick
subscribeTradeTick(Set<String> symbols)
UnsubscribecancelSubscribeTradeTick(Set<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 ClientConfig.DEFAULT_CONFIG.useFullTick = true;
Our push services are implemented with asynchronous functions. Implement the callback functions in ApiComposeCallback, 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
Argument | Type | Required | Description |
---|---|---|---|
symbols | Set<String> | Yes | set of stock symbols |
Return Value
Name | Type | Description |
---|---|---|
id | string | ID 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
Set<String> symbols = new HashSet<>();
//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:
Field | Type | Description |
---|---|---|
symbol | string | Stock symbol |
timestamp | long | data timestamp |
ticks | List<Tick> | List of trade tick data |
ticks's data structure:
Field | Type | Description |
---|---|---|
sn | long | The serial number |
time | long | trading time |
price | float | trading price |
volume | long | trading volume |
type | string | buy/sell direction. Active buy(+); Active sell(-); Neutral transaction(*) |
cond | string | trading condition |
partCode | string | exchange code |
Response Example
{"symbol":"AAPL","ticks":[{"sn":"69745","time":"1712585464248","price":168.96,"volume":26,"type
":"+","partCode":"t"},{"sn":"69746","time":"1712585464248","price":168.96,"volume":22,"type":"+","partCode":"t"}],"timestamp":"1712585464415"
,"source":"NLS"}
Subscribe Minute Kline
subscribeKline(Set<String> symbols)
UnsubscribecancelSubscribeKline(Set<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 ApiComposeCallback, 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
Argument | Type | Required | Description |
---|---|---|---|
symbols | Set<String> | Yes | set of stock symbols |
Return Value
Name | Type | Description |
---|---|---|
id | string | ID 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
Set<String> symbols = new HashSet<>();
//minute kline 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:
Field | Type | Description |
---|---|---|
time | long | trading time |
open | float | The first transaction price of current minute. |
high | float | The highest price of current minute. |
low | float | The lowest price of current minute. |
close | float | The last transaction price in the current minute. |
avg | float | The average price of current minute. |
volume | long | Cumulative trading volume in current minute. |
count | int | The number of transaction in current minute. |
symbol | string | Stock symbol |
amount | double | Cumulative turnover in current minute |
serverTimestamp | long | server push timestamp |
Response Example
{"time":"1712584560000","open":168.9779,"high":169.0015,"low":168.9752,"close":169.0,"avg":168.778,"volume":"3664","count":114,"symbol":"AAPL","amount":617820.6508,"serverTimestamp":"1712584569746"}
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:
Field | Type | Description |
---|---|---|
limit | int | Subscription symbols(stocks/options/futures) limit maximum |
used | int | The num of subscribed symbols(stocks/options/futures) |
subscribedSymbols | array | subscribed symbols(stocks/options/futures) |
askBidLimit | int | Subscription depth quote stock limit max |
askBidUsed | int | The num of subscribed depth quote symbols |
subscribedAskBidSymbols | array | subscribed depth quote symbols |
tradeTickLimit | int | Subscription trade tick stock limit max |
tradeTickUsed | int | The num of subscribed trade tick symbols |
subscribedTradeTickSymbols | array | subscribed trade tick symbols |
Response Example
{
"askBidLimit":10,
"askBidUsed":0,
"limit":20,
"subscribedAskBidSymbols":[
],
"subscribedSymbols":[
],
"subscribedTradeTickSymbols":[
"PDD",
"AMD",
"SPY",
"01810"
],
"tradeTickLimit":20,
"tradeTickUsed":4,
"used":0
}