Market Subscriptions

Example context

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

const config = createClientConfig({
  tigerId: 'your_tiger_id',
  privateKey: 'your_private_key',
  account: 'your_account',
});

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.volume);
  },
  onKline: (data) => {
    console.log('Kline update:', data.symbol);
  },
  onDisconnect: () => {
    console.log('Disconnected');
  },
  onError: (err) => {
    console.error('Error:', err.message);
  },
});

// Initiate connection
pushClient.connect();

subscribeQuote

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).


unsubscribeQuote

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']);

subscribeTick

Signature

subscribeTick(symbols: string[]): void

Purpose

Subscribes to trade tick updates. Data is received through the onTick callback.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]YesNone

Returns

void

Type-checked example

pushClient.subscribeTick(['00700']);

Callback data example (received via onTick)

{
  "symbol": "00700",
  "type": "+",
  "cond": "",
  "sn": 63725,
  "priceBase": 4856,
  "priceOffset": 1,
  "time": [1785826150107],
  "price": [0],
  "volume": [200],
  "partCode": [],
  "quoteLevel": "hkStockQuoteLv2",
  "timestamp": 1785826150651,
  "secType": "STK",
  "mergedVols": []
}

Tick data uses delta encoding for transmission efficiency:

  • Price reconstruction: (priceBase + price[i]) / 10^priceOffset. In this example: (4856 + 0) / 10^1 = 485.6
  • Time reconstruction: time[0] is an absolute timestamp; subsequent time[i] = time[i] + time[i-1] (this example has only one tick)
  • type: + active buy, - active sell, * neutral trade

unsubscribeTick

Signature

unsubscribeTick(symbols?: string[]): void

Purpose

Unsubscribes from tick updates.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]NoNone

Returns

void

Type-checked example

pushClient.unsubscribeTick(['00700']);

subscribeDepth

Signature

subscribeDepth(symbols: string[]): void

Purpose

Subscribes to order book depth updates. 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.


unsubscribeDepth

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']);

subscribeOption

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).


unsubscribeOption

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']);

subscribeFuture

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).


unsubscribeFuture

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']);

subscribeKline

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
}

A new kline bar is pushed every minute. time is the start timestamp of that minute bar; count is the number of trades within that minute.


unsubscribeKline

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']);

subscribeStockTop

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).


unsubscribeStockTop

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']);

subscribeOptionTop

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.


unsubscribeOptionTop

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']);

subscribeCc

Signature

subscribeCc(symbols: string[]): void

Purpose

Subscribes to full tick updates (uncompressed). Data is received through the onFullTick callback, with each trade pushed individually without delta encoding.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]YesNone

Returns

void

Type-checked example

pushClient.subscribeCc(['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": "Q"
    },
    {
      "sn": 128451,
      "time": 1785826199850,
      "price": 198.50,
      "volume": 200,
      "type": "-",
      "cond": "",
      "partCode": "Q"
    }
  ]
}

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


unsubscribeCc

Signature

unsubscribeCc(symbols?: string[]): void

Purpose

Unsubscribes from full tick updates.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
symbolsstring[]NoNone

Returns

void

Type-checked example

pushClient.unsubscribeCc(['AAPL']);

subscribeMarket

Signature

subscribeMarket(market: string): void

Purpose

Subscribes to full market quote updates (market-wide snapshots). Data is received through the onQuote callback.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
marketstringYesNone

Returns

void

Type-checked example

pushClient.subscribeMarket('US');

unsubscribeMarket

Signature

unsubscribeMarket(market: string): void

Purpose

Unsubscribes from full market updates.

Parameters, defaults, and constraints

ParameterTypeRequiredSDK defaultConstraints
marketstringYesNone

Returns

void

Type-checked example

pushClient.unsubscribeMarket('US');

Did this page help you?