Market Subscriptions

Example context

import { createClientConfig, PushClient } from '@tigeropenapi/tigeropen';

const config = createClientConfig();

const pushClient = new PushClient(config);

// Set up callback functions
pushClient.setCallbacks({
  onConnect: () => {
    console.log('Connected');
    // Subscribe after connection is established
    pushClient.subscribeQuote(['AAPL', '00700']);
  },
  onQuote: (data) => {
    console.log('Quote update:', data.symbol, data.latestPrice);
  },
  onTick: (data) => {
    console.log('Tick update:', data.symbol, data.ticks.length);
  },
  onKline: (data) => {
    console.log('Kline update:', data.symbol);
  },
  onDisconnect: () => {
    console.log('Disconnected');
  },
  onError: (err) => {
    console.error('Error:', err.message);
  },
});

// Initiate connection
pushClient.connect();

Stock quotes

Subscribe

Signature

subscribeQuote(symbols: string[]): void

Purpose

Subscribes to stock quote updates. Data is received through the onQuote callback.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]YesNone

Returns

void

Type-checked example

pushClient.subscribeQuote(['AAPL', '00700']);

Callback data example (received via onQuote)

BBO update (type=2, best bid/offer change only):

{
  "symbol": "00700",
  "type": 2,
  "timestamp": 1785826149941,
  "serverTimestamp": 1785826149946,
  "latestPrice": 485.4,
  "askPrice": 485.6,
  "askSize": 13000,
  "bidPrice": 485.2,
  "bidSize": 6300,
  "volume": 28453200,
  "amount": 13792456000
}

BASIC update (type=1, full quote snapshot):

{
  "symbol": "AAPL",
  "type": 1,
  "timestamp": 1785826200000,
  "serverTimestamp": 1785826200005,
  "latestPrice": 198.52,
  "latestPriceTimestamp": 1785826199800,
  "preClose": 197.96,
  "volume": 45230100,
  "amount": 8975632000,
  "open": 198.10,
  "high": 199.62,
  "low": 197.80,
  "avgPrice": 198.35
}

The type field: 1 = BASIC (full quote snapshot), 2 = BBO (best bid/offer update only).
For the Quote data type, the current dispatcher does not inspect QuoteData.type, so both BASIC and BBO go to onQuote. The public callback interface still declares onQuoteBBO, but the current dispatch path does not invoke it.


Unsubscribe

Signature

unsubscribeQuote(symbols?: string[]): void

Purpose

Unsubscribes from quote updates. If no symbols are passed, unsubscribes from all quotes.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]NoNone

Returns

void

Type-checked example

pushClient.unsubscribeQuote(['AAPL']);

Trade ticks

Ordinary ticks

Signature

subscribeTick(symbols: string[]): void

Purpose

Subscribes to trade tick updates. In ordinary mode, onTick receives PushTradeTick. Push frequency and batch size vary with available market data.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]YesNone

Returns

void

Type-checked example

pushClient.subscribeTick(['AAPL']);

Callback data example (received via onTick)

{
  "symbol": "AAPL",
  "secType": "STK",
  "quoteLevel": "usStockQuote",
  "timestamp": 1785826150651,
  "ticks": [
    {
      "sn": 63725,
      "time": 1785826150107,
      "price": 485.6,
      "volume": 200,
      "tickType": "+",
      "cond": "US_REGULAR_SALE",
      "partCode": "NSDQ",
      "partName": "NASDAQ Stock Market, LLC (NASDAQ)"
    }
  ]
}
FieldTypeDescription
symbolstringStock symbol
secTypestringSecurity type, such as STK
quoteLevelstringQuote entitlement level
timestampnumberPush time in milliseconds
ticksPushTick[]Trade ticks decoded by the SDK
ticks[].snnumberTick sequence number
ticks[].timenumberDecoded trade time in milliseconds
ticks[].pricenumberDecoded trade price
ticks[].volumenumberTrade size
ticks[].tickTypestring+ buyer-initiated, - seller-initiated, * neutral
ticks[].condstringDecoded trade condition; see Trade Tick Conditions
ticks[].partCode / ticks[].partNamestringResolved venue abbreviation/name

Full ticks

Signature

new PushClient(config, { useFullTick: true })
subscribeTick(symbols: string[]): void

Purpose

Full stock ticks use the same subscribeTick method as ordinary ticks. Set useFullTick: true before connect() to receive TickData through onFullTick. Full-tick access must be enabled separately; contact OpenAPI technical support.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]YesNone

Returns

void

Type-checked example

const pushClient = new PushClient(config, { useFullTick: true });
pushClient.setCallbacks({
  onFullTick: (data) => console.log('Full tick:', data),
});

await pushClient.connect();
pushClient.subscribeTick(['AAPL']);

Callback data example (received via onFullTick)

{
  "symbol": "AAPL",
  "timestamp": 1785826200000,
  "source": "",
  "ticks": [
    {
      "sn": 128450,
      "time": 1785826199800,
      "price": 198.52,
      "volume": 100,
      "type": "+",
      "cond": "",
      "partCode": "d"
    },
    {
      "sn": 128451,
      "time": 1785826199850,
      "price": 198.50,
      "volume": 200,
      "type": "-",
      "cond": "",
      "partCode": "d"
    }
  ]
}

Full tick data does not use delta encoding; each trade includes absolute price and time values. type: + active buy, - active sell, * neutral.

FieldTypeDescription
symbolstringStock symbol
timestampnumberPush time in milliseconds
sourcestringData source; may be empty
ticksTickData_Tick[]Full-tick list
ticks[].snnumberArrival-order sequence number, for reference only
ticks[].timenumberTrade time in milliseconds
ticks[].pricenumberTrade price
ticks[].volumenumberTrade size
ticks[].typestring+ buyer-initiated, - seller-initiated, * neutral
ticks[].condstringRaw one-character trade condition; may be empty. See Trade Tick Conditions
ticks[].partCodestringRaw execution-venue code; may be empty

Unsubscribe

Signature

unsubscribeTick(symbols?: string[]): void

Purpose

Unsubscribes from ordinary or full tick updates.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]NoNone

Returns

void

Type-checked example

pushClient.unsubscribeTick(['AAPL']);

Market depth

Subscribe

Signature

subscribeDepth(symbols: string[]): void

Purpose

Subscribes to order book depth updates. US market depth updates every 300ms, while Hong Kong market depth updates every 2s. Data is received through the onDepth callback.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]YesNone

Returns

void

Type-checked example

pushClient.subscribeDepth(['00700']);

Callback data example (received via onDepth)

{
  "symbol": "00700",
  "timestamp": 1785826150200,
  "ask": {
    "price": [485.6, 485.8, 486.0, 486.2, 486.4],
    "volume": [13000, 8500, 22000, 5600, 3200],
    "orderCount": [5, 3, 8, 2, 1],
    "exchange": [],
    "time": []
  },
  "bid": {
    "price": [485.4, 485.2, 485.0, 484.8, 484.6],
    "volume": [6300, 15200, 9800, 4100, 7500],
    "orderCount": [3, 6, 4, 2, 3],
    "exchange": [],
    "time": []
  }
}

HK market includes orderCount (number of orders at each price level). The exchange and time fields are used for option exchange information.


Unsubscribe

Signature

unsubscribeDepth(symbols?: string[]): void

Purpose

Unsubscribes from depth updates.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]NoNone

Returns

void

Type-checked example

pushClient.unsubscribeDepth(['00700']);

Option quotes

Subscribe

Signature

subscribeOption(symbols: string[]): void

Purpose

Subscribes to option quote updates. Data is received through the onOption callback with the same QuoteData structure as onQuote.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]YesNone

Returns

void

Type-checked example

pushClient.subscribeOption(['AAPL  250718C00200000']);

Callback data example (received via onOption)

{
  "symbol": "AAPL  250718C00200000",
  "type": 1,
  "timestamp": 1785826200000,
  "serverTimestamp": 1785826200003,
  "latestPrice": 5.30,
  "preClose": 5.15,
  "volume": 12580,
  "identifier": "AAPL  250718C00200000",
  "openInt": 45230,
  "askPrice": 5.35,
  "askSize": 120,
  "bidPrice": 5.25,
  "bidSize": 85
}

Option quotes additionally include identifier (contract identifier) and openInt (open interest).


Unsubscribe

Signature

unsubscribeOption(symbols?: string[]): void

Purpose

Unsubscribes from option updates.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]NoNone

Returns

void

Type-checked example

pushClient.unsubscribeOption(['AAPL  250718C00200000']);

Futures quotes

Subscribe

Signature

subscribeFuture(symbols: string[]): void

Purpose

Subscribes to futures quote updates. Data is received through the onFuture callback with the same QuoteData structure as onQuote.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]YesNone

Returns

void

Type-checked example

pushClient.subscribeFuture(['ES2506']);

Callback data example (received via onFuture)

{
  "symbol": "ES2506",
  "type": 1,
  "timestamp": 1785826200000,
  "serverTimestamp": 1785826200002,
  "latestPrice": 5425.50,
  "preClose": 5410.25,
  "preSettlement": 5412.00,
  "volume": 1520300,
  "tradeTime": 1785826199500,
  "minTick": 0.25,
  "askPrice": 5425.75,
  "askSize": 150,
  "bidPrice": 5425.50,
  "bidSize": 230
}

Futures quotes additionally include preSettlement (previous settlement price), tradeTime (latest trade time), and minTick (minimum price increment).


Unsubscribe

Signature

unsubscribeFuture(symbols?: string[]): void

Purpose

Unsubscribes from futures updates.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]NoNone

Returns

void

Type-checked example

pushClient.unsubscribeFuture(['ES2506']);

Klines

Subscribe

Signature

subscribeKline(symbols: string[]): void

Purpose

Subscribes to minute kline (candlestick) updates. Data is received through the onKline callback.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]YesNone

Returns

void

Type-checked example

pushClient.subscribeKline(['AAPL']);

Callback data example (received via onKline)

{
  "symbol": "AAPL",
  "time": 1785826140000,
  "open": 198.35,
  "high": 198.62,
  "low": 198.20,
  "close": 198.52,
  "avg": 198.41,
  "volume": 125600,
  "count": 890,
  "amount": 24920000,
  "serverTimestamp": 1785826200005
}

The same minute may receive multiple K-line callbacks; update the current minute by matching time. time is the start timestamp of that minute bar; count is the number of trades within that minute.


Unsubscribe

Signature

unsubscribeKline(symbols?: string[]): void

Purpose

Unsubscribes from kline updates.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]NoNone

Returns

void

Type-checked example

pushClient.unsubscribeKline(['AAPL']);

Stock rankings

Subscribe

Signature

subscribeStockTop(market: string, indicators: string[]): void

Purpose

Subscribes to stock top ranking updates. Data is received through the onStockTop callback.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
marketstringYesNone
indicatorsstring[]YesNone

Returns

void

Type-checked example

pushClient.subscribeStockTop('US', ['changeRate', 'volume']);

Callback data example (received via onStockTop)

{
  "market": "US",
  "timestamp": 1785826200000,
  "topData": [
    {
      "targetName": "volume",
      "item": [
        { "symbol": "NVDA", "latestPrice": 135.20, "targetValue": 82500000 },
        { "symbol": "TSLA", "latestPrice": 248.50, "targetValue": 65300000 },
        { "symbol": "AAPL", "latestPrice": 198.52, "targetValue": 45230100 }
      ]
    },
    {
      "targetName": "changeRate",
      "item": [
        { "symbol": "XYZ", "latestPrice": 12.80, "targetValue": 0.156 },
        { "symbol": "ABC", "latestPrice": 45.30, "targetValue": 0.098 }
      ]
    }
  ]
}

Supported targetName indicators: changeRate (price change %), changeRate5Min (5-min change %), turnoverRate (turnover rate), amount (trade amount), volume (trade volume), amplitude (price amplitude).


Unsubscribe

Signature

unsubscribeStockTop(market: string, indicators: string[]): void

Purpose

Unsubscribes from stock top updates.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
marketstringYesNone
indicatorsstring[]YesNone

Returns

void

Type-checked example

pushClient.unsubscribeStockTop('US', ['volume']);

Option rankings

Subscribe

Signature

subscribeOptionTop(market: string, indicators: string[]): void

Purpose

Subscribes to option top ranking updates. Data is received through the onOptionTop callback.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
marketstringYesNone
indicatorsstring[]YesNone

Returns

void

Type-checked example

pushClient.subscribeOptionTop('US', ['volume', 'bigOrder']);

Callback data example (received via onOptionTop)

{
  "market": "US",
  "timestamp": 1785826200000,
  "topData": [
    {
      "targetName": "volume",
      "bigOrder": [],
      "item": [
        {
          "symbol": "TSLA",
          "expiry": "20250718",
          "strike": "260.0",
          "right": "CALL",
          "totalAmount": 5820000,
          "totalVolume": 98500,
          "totalOpenInt": 125000,
          "volumeToOpenInt": 0.788,
          "latestPrice": 8.65,
          "updateTime": 1785826199000
        }
      ]
    },
    {
      "targetName": "bigOrder",
      "bigOrder": [
        {
          "symbol": "AAPL",
          "expiry": "20250718",
          "strike": "200.0",
          "right": "CALL",
          "dir": "BUY",
          "volume": 5000,
          "price": 5.30,
          "amount": 2650000,
          "tradeTime": 1785826180000
        }
      ],
      "item": []
    }
  ]
}

Supported targetName indicators: bigOrder (large orders), volume (trade volume), amount (trade amount), openInt (open interest). Big order threshold: single trade volume > 1000 contracts.


Unsubscribe

Signature

unsubscribeOptionTop(market: string, indicators: string[]): void

Purpose

Unsubscribes from option top updates.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
marketstringYesNone
indicatorsstring[]YesNone

Returns

void

Type-checked example

pushClient.unsubscribeOptionTop('US', ['volume']);

Cryptocurrency quotes

Subscribe

Signature

subscribeCc(symbols: string[]): void

Purpose

Subscribes to cryptocurrency real-time quotes. Data is received as QuoteData through onQuote; this method is not used for full stock ticks.

pushClient.subscribeCc(['BTC.USD', 'ETH.USD']);

Unsubscribe

Signature

unsubscribeCc(symbols?: string[]): void
pushClient.unsubscribeCc(['BTC.USD']);

HK whole-market quotes

Subscribe

Signature

subscribeMarket(market: string): void

Purpose

Subscribes to quote updates for the whole Hong Kong market. The server delivers ongoing per-symbol QuoteData through the ordinary onQuote callback; this is neither a market-status subscription nor a one-time market snapshot or stock-ranking subscription.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
marketstringYesNoneOnly HK is supported

Returns

void

Type-checked example

pushClient.subscribeMarket('HK');

Unsubscribe

Signature

unsubscribeMarket(market: string): void

Purpose

Unsubscribes from whole-market Hong Kong quote updates.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
marketstringYesNoneOnly HK is supported

Returns

void

Type-checked example

pushClient.unsubscribeMarket('HK');

Did this page help you?