Market Data Subscriptions

Subscribe Stock Quotes

Description

Subscribe to real-time stock quote pushes. Quote data is received via callbacks, including two types: basic quote (QuoteBasicData) and best bid/offer (QuoteBBOData).

Parameters

ParameterTypeDescription
symbols&strStock symbols, comma-separated, e.g. "AAPL,TSLA,00700"

Example

// Subscribe to stock quotes
push.subscribe(&SubjectType::Quote, Some("AAPL,TSLA,00700"), None, None);

Callbacks

  • on_quote(QuoteBasicData) — Basic quote data
  • on_quote_bbo(QuoteBBOData) — Best bid/offer data

Callback Data Fields

QuoteBasicData:

FieldTypeDescription
symbolstringStock symbol
typestringData type: BASIC
timestampstringData timestamp (milliseconds)
serverTimestampstringServer push timestamp
avgPricedoubleAverage price
latestPricedoubleLatest price
latestPriceTimestampstringLatest price timestamp
latestTimestringLatest trade time (readable format)
preClosedoublePrevious close price
volumestringTrading volume
amountdoubleTrading amount
opendoubleOpen price
highdoubleHigh price
lowdoubleLow price
marketStatusstringMarket status, e.g. Trading
hourTradingTagstringPre/post market tag, e.g. PreMarket (US non-regular hours only)
miobjectMinute K-line snapshot
mi.pdoubleMinute close price
mi.adoubleMinute average price
mi.tstringMinute timestamp
mi.vstringMinute volume
mi.odoubleMinute open price
mi.hdoubleMinute high price
mi.ldoubleMinute low price

QuoteBBOData:

FieldTypeDescription
symbolstringStock symbol
typestringData type: BBO
timestampstringData timestamp (milliseconds)
askPricedoubleBest ask price
askSizestringAsk size
askTimestampstringAsk quote timestamp
bidPricedoubleBest bid price
bidSizestringBid size
bidTimestampstringBid quote timestamp

Callback Data Examples

Basic quote (BASIC):

{
    "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.41,
    "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
    }
}

Best bid/offer (BBO):

{
    "symbol": "AAPL",
    "type": "BBO",
    "timestamp": "1676992715509",
    "askPrice": 149.96,
    "askSize": "200",
    "askTimestamp": "1676992715367",
    "bidPrice": 149.94,
    "bidSize": "700",
    "bidTimestamp": "1676992715367"
}

Subscribe Option Quotes

Description

Subscribe to real-time option quote pushes (supports US and HK market options). Callback data includes basic quote and best bid/offer types.

Parameters

ParameterTypeDescription
symbols&strOption symbols, comma-separated. Supports two formats: "AAPL 20230317 150.0 CALL" or identifier format "SPY 190508C00290000"

Example

// Subscribe to option quotes
push.subscribe(&SubjectType::Option, Some("AAPL 20230317 150.0 CALL"), None, None);

Callbacks

  • on_option(QuoteBasicData) — Option basic quote
  • on_option_bbo(QuoteBBOData) — Option best bid/offer

Callback Data Fields

QuoteBasicData (Option):

FieldTypeDescription
symbolstringOption symbol
typestringData type: BASIC
timestampstringData timestamp (milliseconds)
latestPricedoubleLatest price
latestPriceTimestampstringLatest price timestamp
preClosedoublePrevious close price
volumestringTrading volume
amountdoubleTrading amount
opendoubleOpen price
highdoubleHigh price
lowdoubleLow price
identifierstringStandard option code (e.g. AAPL 230317C00150000)
openIntstringOpen interest

QuoteBBOData (Option):

FieldTypeDescription
symbolstringOption symbol
typestringData type: BBO
timestampstringData timestamp (milliseconds)
askPricedoubleBest ask price
askSizestringAsk size
askTimestampstringAsk quote timestamp
bidPricedoubleBest bid price
bidSizestringBid size
bidTimestampstringBid quote timestamp

Callback Data Examples

Option basic quote:

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

Option BBO:

{
    "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 Future Quotes

Description

Subscribe to real-time futures quote pushes. Callback data includes basic quote and best bid/offer types.

Parameters

ParameterTypeDescription
symbols&strFutures symbols, comma-separated, e.g. "ESmain,ES2609"

Example

// Subscribe to futures quotes
push.subscribe(&SubjectType::Future, Some("ESmain,ES2609"), None, None);

Callbacks

  • on_future(QuoteBasicData) — Futures basic quote
  • on_future_bbo(QuoteBBOData) — Futures best bid/offer

Callback Data Fields

QuoteBasicData (Futures):

FieldTypeDescription
symbolstringFutures symbol
typestringData type: BASIC
timestampstringData timestamp (milliseconds)
avgPricedoubleAverage price
latestPricedoubleLatest price
latestPriceTimestampstringLatest price timestamp
latestTimestringLatest trade time
preClosedoublePrevious close price
volumestringTrading volume
opendoubleOpen price
highdoubleHigh price
lowdoubleLow price
marketStatusstringMarket status
tradeTimestringTrade timestamp
preSettlementdoublePrevious settlement price
minTickdoubleMinimum tick size
miobjectMinute K-line snapshot (same fields as stock)

QuoteBBOData (Futures): Same fields as stock BBO data.

Callback Data Examples

Futures basic quote:

{
    "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
    }
}

Futures BBO:

{
    "symbol": "ESmain",
    "type": "BBO",
    "timestamp": "1684766824130",
    "askPrice": 4202.75,
    "askSize": "70",
    "askTimestamp": "1684766824129",
    "bidPrice": 4202.5,
    "bidSize": "2",
    "bidTimestamp": "1684766824130"
}

Subscribe Crypto Quotes

Description

Subscribe to real-time cryptocurrency quote pushes. Callback data includes basic quote and best bid/offer types.

Parameters

ParameterTypeDescription
symbols&[&str]Crypto symbol array, e.g. &["BTC.USD", "ETH.USD"]

Example

// Subscribe to crypto quotes
push.subscribe_cc(&["BTC.USD", "ETH.USD"]);

Callbacks

  • on_quote(QuoteBasicData) — Crypto basic quote
  • on_quote_bbo(QuoteBBOData) — Crypto best bid/offer

Callback Data Fields

QuoteBasicData (Crypto):

FieldTypeDescription
symbolstringCrypto symbol, e.g. ETH.USD
typestringData type: BASIC
timestampstringData timestamp (milliseconds)
serverTimestampstringServer push timestamp
latestPricedoubleLatest price
latestPriceTimestampstringLatest price timestamp
latestTimestringLatest trade time
preClosedoublePrevious close price
volumeDecimaldoubleTrading volume (decimal precision)
amountdoubleTrading amount
opendoubleOpen price
highdoubleHigh price
lowdoubleLow price
marketStatusstringMarket status, e.g. TRADING

QuoteBBOData (Crypto):

FieldTypeDescription
symbolstringCrypto symbol
typestringData type: BBO
timestampstringData timestamp (milliseconds)
askPricedoubleBest ask price
askTimestampstringAsk quote timestamp
bidPricedoubleBest bid price
bidSizestringBid size
bidTimestampstringBid quote timestamp

Callback Data Examples

Crypto basic quote:

{
    "symbol": "ETH.USD",
    "type": "BASIC",
    "timestamp": "1770041127619",
    "serverTimestamp": "1770041127816",
    "latestPrice": 2322.97,
    "latestPriceTimestamp": "1770041127619",
    "latestTime": "02-02 22:05:27 HKT",
    "preClose": 2313.05,
    "volumeDecimal": 27711.5,
    "amount": 62465538.27,
    "open": 2314.18,
    "high": 2374.87,
    "low": 2156.8,
    "marketStatus": "TRADING"
}

Crypto BBO:

{
    "symbol": "ETH.USD",
    "type": "BBO",
    "timestamp": "1770041127619",
    "askPrice": 2322.97,
    "askTimestamp": "1770041127605",
    "bidPrice": 2322.95,
    "bidSize": "1",
    "bidTimestamp": "1770041127605"
}

Subscribe Depth Quotes

Description

Subscribe to multi-level depth of book data. Supports stocks (US/HK), options (US/HK), and futures. US depth pushes every 300ms, HK depth pushes every 2s. Returns up to 40 levels of order book data (HK only has 10 levels).

Parameters

ParameterTypeDescription
symbols&strStock, option, or futures symbols, comma-separated, e.g. "AAPL,ESmain"

Example

// Subscribe to depth quotes
push.subscribe(&SubjectType::Depth, Some("AAPL,00700"), None, None);

Callbacks

  • on_depth(QuoteDepthData) — Depth of book data

Callback Data Fields

QuoteDepthData:

FieldTypeDescription
symbolstringSymbol
timestampstringDepth data timestamp
askobjectAsk (sell) side data
ask.pricedouble[]Price at each level
ask.volumestring[]Volume at each level
ask.orderCountint[]Order count at each level (HK only)
bidobjectBid (buy) side data
bid.pricedouble[]Price at each level
bid.volumestring[]Volume at each level
bid.orderCountint[]Order count at each level (HK only)

Callback Data Examples

US market depth:

{
    "symbol": "AAPL",
    "timestamp": "1676993368405",
    "ask": {
        "price": [149.69, 149.70, 149.71, 149.72, 149.73],
        "volume": ["100", "200", "185", "100", "100"]
    },
    "bid": {
        "price": [149.68, 149.67, 149.66, 149.65, 149.64],
        "volume": ["84", "100", "100", "200", "100"]
    }
}

HK market depth (with order count):

{
    "symbol": "00700",
    "timestamp": "1670465696884",
    "ask": {
        "price": [311.4, 311.6, 311.8, 312.0, 312.2],
        "volume": ["15600", "5700", "16600", "33800", "61100"],
        "orderCount": [16, 13, 19, 79, 39]
    },
    "bid": {
        "price": [311.2, 311.0, 310.8, 310.6, 310.4],
        "volume": ["2300", "8300", "18000", "8800", "7700"],
        "orderCount": [10, 15, 18, 9, 6]
    }
}

Subscribe Trade Ticks

Description

Subscribe to tick-by-tick trade data for stocks and futures. Push interval is 200ms using snapshot mode, delivering the latest 50 trade records per push. Supports US and HK market stocks and futures.

Parameters

ParameterTypeDescription
symbols&strStock or futures symbols, comma-separated, e.g. "AAPL,00700,ESmain"

Example

// Subscribe to trade ticks
push.subscribe(&SubjectType::TradeTick, Some("AAPL,00700"), None, None);

Callbacks

  • on_tick(TradeTick) — Trade tick data

Callback Data Fields

TradeTick:

FieldTypeDescription
symbolstringSymbol
secTypestringSecurity type: STK / FUT
quoteLevelstringQuote permission level (e.g. usQuoteBasic, hkStockQuoteLv2)
timestamplongData timestamp
ticksTick[]Trade tick data array

Tick:

FieldTypeDescription
snlongTick sequence number
volumelongTrade volume
tickTypestring* neutral, + active buy, - active sell (not available for futures)
pricedoubleTrade price
timelongTrade timestamp
condstringTrade condition (e.g. US_REGULAR_SALE, HK_AUTOMATCH_NORMAL)
partCodestringExchange code (US stocks only)

Callback Data Examples

US stock trade ticks:

{
    "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"
        }
    ]
}

HK stock trade ticks:

{
    "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 ticks:

{
    "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
        }
    ]
}

Subscribe Minute K-line

Description

Subscribe to minute-level K-line (candlestick) data for stocks. Supports US and HK market stocks.

Parameters

ParameterTypeDescription
symbols&strStock symbols, comma-separated, e.g. "AAPL,00700"

Example

// Subscribe to minute K-line
push.subscribe(&SubjectType::Kline, Some("AAPL,00700"), None, None);

Callbacks

  • on_kline(KlineData) — Minute K-line data

Callback Data Fields

KlineData:

FieldTypeDescription
symbolstringStock symbol
timestringMinute timestamp
openfloatOpen price
highfloatHigh price
lowfloatLow price
closefloatClose price
avgfloatAverage price
volumestringTrading volume
countintTrade count
amountdoubleTrading amount
serverTimestampstringServer push timestamp

Callback Data Example

{
    "symbol": "AAPL",
    "time": "1712584560000",
    "open": 168.9779,
    "high": 169.0015,
    "low": 168.9752,
    "close": 169.0,
    "avg": 168.778,
    "volume": "3664",
    "count": 114,
    "amount": 617820.6508,
    "serverTimestamp": "1712584569746"
}

Subscribe Stock Rankings

Description

Subscribe to stock ranking data. No pushes during non-trading hours. Push interval is 30s, delivering Top 30 symbols for each subscribed indicator. Supports US and HK markets.

During regular trading hours, all indicators are available. US pre/post market only has changeRate and changeRate5Min.

Parameters

ParameterTypeDescription
market&strMarket code, e.g. "US", "HK"

Example

// Subscribe to US stock rankings
push.subscribe_market("US");
// Or use the generic method
push.subscribe(&SubjectType::StockTop, None, None, Some("US"));

Callbacks

  • on_stock_top(StockTopData) — Stock ranking data

Callback Data Fields

StockTopData:

FieldTypeDescription
marketstringMarket: US / HK
timestampstringTimestamp
topDataTopData[]Ranking data for each indicator

TopData:

FieldTypeDescription
targetNamestringIndicator name: changeRate (daily change), changeRate5Min (5-min change), turnoverRate (turnover rate), amount (trading amount), volume (trading volume), amplitude (amplitude)
itemStockItem[]Ranking list for this indicator

StockItem:

FieldTypeDescription
symbolstringSymbol
latestPricedoubleLatest price
targetValuedoubleIndicator value

Callback Data 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}
            ]
        },
        {
            "targetName": "amount",
            "item": [
                {"symbol": "TSLA", "latestPrice": 263.21, "targetValue": 10629393179.8},
                {"symbol": "SPY", "latestPrice": 435.64, "targetValue": 5839415251.67},
                {"symbol": "NVDA", "latestPrice": 428.38, "targetValue": 5123997584.1}
            ]
        },
        {
            "targetName": "volume",
            "item": [
                {"symbol": "TSLA", "latestPrice": 263.21, "targetValue": 40190416},
                {"symbol": "NKLA", "latestPrice": 1.26, "targetValue": 33326008},
                {"symbol": "SQQQ", "latestPrice": 19.93, "targetValue": 31339556}
            ]
        }
    ]
}

Subscribe Option Rankings

Description

Subscribe to option ranking data. No pushes during non-trading hours. Push interval is 30s, delivering Top 50 symbols for each subscribed indicator. Supports US market options.

Big orders are defined as single trades with volume > 1000, sorted by trade time descending. Other indicators show cumulative daily values sorted descending.

Parameters

ParameterTypeDescription
market&strMarket code, e.g. "US"

Example

// Subscribe to US option rankings
push.subscribe(&SubjectType::OptionTop, None, None, Some("US"));

Callbacks

  • on_option_top(OptionTopData) — Option ranking data

Callback Data Fields

OptionTopData:

FieldTypeDescription
marketstringMarket: US
timestampstringTimestamp
topDataTopData[]Ranking data for each indicator

TopData:

FieldTypeDescription
targetNamestringIndicator name: bigOrder (large orders), volume (volume), amount (amount), openInt (open interest)
bigOrderBigOrder[]Large order data list (bigOrder indicator only)
itemOptionItem[]Ranking list for this indicator

BigOrder:

FieldTypeDescription
symbolstringStock/ETF symbol
expirystringExpiry date, format: yyyyMMdd
strikestringStrike price
rightstringCALL / PUT
dirstringDirection: Buy / Sell / NONE
volumedoubleTrade volume
pricedoubleTrade price
amountdoubleTrade amount
tradeTimelongTrade timestamp

OptionItem:

FieldTypeDescription
symbolstringStock/ETF symbol
expirystringExpiry date, format: yyyyMMdd
strikestringStrike price
rightstringCALL / PUT
totalAmountdoubleTotal amount
totalVolumedoubleTotal volume
totalOpenIntdoubleTotal open interest
volumeToOpenIntdoubleVolume to open interest ratio
latestPricedoubleLatest price
updateTimestringData update timestamp

Callback Data 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"
                }
            ]
        },
        {
            "targetName": "bigOrder",
            "bigOrder": [
                {
                    "symbol": "AMC",
                    "expiry": "20230818",
                    "strike": "10.0",
                    "right": "PUT",
                    "dir": "Buy",
                    "volume": 1000,
                    "price": 6.94,
                    "amount": 694000,
                    "tradeTime": 1687276860753
                },
                {
                    "symbol": "AMD",
                    "expiry": "20230818",
                    "strike": "140.0",
                    "right": "CALL",
                    "dir": "Buy",
                    "volume": 1700,
                    "price": 3.25,
                    "amount": 552500,
                    "tradeTime": 1687276467421
                }
            ]
        }
    ]
}

Get Subscribed Symbols

Description

Query locally subscribed symbols. Returns a mapping from subject type to symbol list. List order is not guaranteed to be stable.

Example

// Get subscribed symbols
let subscriptions = push.get_subscriptions();
// Returns HashMap<SubjectType, Vec<String>>

Return Value

HashMap<SubjectType, Vec<String>> — Map from subject to locally recorded symbol list.


Utility Methods

subscribe

Generic subscription method. Builds and queues a subscription frame by subject type.

pub fn subscribe(
    &self,
    subject: &SubjectType,
    symbols: Option<&str>,
    account: Option<&str>,
    market: Option<&str>,
) -> bool
ParameterTypeDescription
subject⋐jectTypeSubject type (Quote, Option, Future, Depth, TradeTick, Kline, StockTop, OptionTop)
symbolsOption<&str>Symbols, comma-separated
accountOption<&str>Account (for trade subscriptions)
marketOption<&str>Market (for ranking subscriptions)

Returns bool: only indicates whether the protocol frame was queued locally, not server acceptance.

unsubscribe

Generic unsubscription method. Same parameter semantics as subscribe.

pub fn unsubscribe(
    &self,
    subject: &SubjectType,
    symbols: Option<&str>,
    account: Option<&str>,
    market: Option<&str>,
) -> bool

subscribe_market

Subscribe to market ranking data (StockTop).

pub fn subscribe_market(&self, market: &str) -> Result<(), TigerError>

unsubscribe_market

Unsubscribe from market ranking data.

pub fn unsubscribe_market(&self, market: &str) -> Result<(), TigerError>

subscribe_cc

Subscribe to cryptocurrency quotes.

pub fn subscribe_cc(&self, symbols: &[&str]) -> Result<(), TigerError>

unsubscribe_cc

Unsubscribe from cryptocurrency quotes. symbols=None unsubscribes all crypto.

pub fn unsubscribe_cc(&self, symbols: Option<&[&str]>) -> Result<(), TigerError>

get_subscriptions

Returns a snapshot of local subscription state.

pub fn get_subscriptions(&self) -> HashMap<SubjectType, Vec<String>>

Did this page help you?