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
| Parameter | Type | Description |
|---|---|---|
| symbols | &str | Stock 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 dataon_quote_bbo(QuoteBBOData)— Best bid/offer data
Callback Data Fields
QuoteBasicData:
| Field | Type | Description |
|---|---|---|
| symbol | string | Stock symbol |
| type | string | Data type: BASIC |
| timestamp | string | Data timestamp (milliseconds) |
| serverTimestamp | string | Server push timestamp |
| avgPrice | double | Average price |
| latestPrice | double | Latest price |
| latestPriceTimestamp | string | Latest price timestamp |
| latestTime | string | Latest trade time (readable format) |
| preClose | double | Previous close price |
| volume | string | Trading volume |
| amount | double | Trading amount |
| open | double | Open price |
| high | double | High price |
| low | double | Low price |
| marketStatus | string | Market status, e.g. Trading |
| hourTradingTag | string | Pre/post market tag, e.g. PreMarket (US non-regular hours only) |
| mi | object | Minute K-line snapshot |
| mi.p | double | Minute close price |
| mi.a | double | Minute average price |
| mi.t | string | Minute timestamp |
| mi.v | string | Minute volume |
| mi.o | double | Minute open price |
| mi.h | double | Minute high price |
| mi.l | double | Minute low price |
QuoteBBOData:
| Field | Type | Description |
|---|---|---|
| symbol | string | Stock symbol |
| type | string | Data type: BBO |
| timestamp | string | Data timestamp (milliseconds) |
| askPrice | double | Best ask price |
| askSize | string | Ask size |
| askTimestamp | string | Ask quote timestamp |
| bidPrice | double | Best bid price |
| bidSize | string | Bid size |
| bidTimestamp | string | Bid 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
| Parameter | Type | Description |
|---|---|---|
| symbols | &str | Option 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 quoteon_option_bbo(QuoteBBOData)— Option best bid/offer
Callback Data Fields
QuoteBasicData (Option):
| Field | Type | Description |
|---|---|---|
| symbol | string | Option symbol |
| type | string | Data type: BASIC |
| timestamp | string | Data timestamp (milliseconds) |
| latestPrice | double | Latest price |
| latestPriceTimestamp | string | Latest price timestamp |
| preClose | double | Previous close price |
| volume | string | Trading volume |
| amount | double | Trading amount |
| open | double | Open price |
| high | double | High price |
| low | double | Low price |
| identifier | string | Standard option code (e.g. AAPL 230317C00150000) |
| openInt | string | Open interest |
QuoteBBOData (Option):
| Field | Type | Description |
|---|---|---|
| symbol | string | Option symbol |
| type | string | Data type: BBO |
| timestamp | string | Data timestamp (milliseconds) |
| askPrice | double | Best ask price |
| askSize | string | Ask size |
| askTimestamp | string | Ask quote timestamp |
| bidPrice | double | Best bid price |
| bidSize | string | Bid size |
| bidTimestamp | string | Bid 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
| Parameter | Type | Description |
|---|---|---|
| symbols | &str | Futures 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 quoteon_future_bbo(QuoteBBOData)— Futures best bid/offer
Callback Data Fields
QuoteBasicData (Futures):
| Field | Type | Description |
|---|---|---|
| symbol | string | Futures symbol |
| type | string | Data type: BASIC |
| timestamp | string | Data timestamp (milliseconds) |
| avgPrice | double | Average price |
| latestPrice | double | Latest price |
| latestPriceTimestamp | string | Latest price timestamp |
| latestTime | string | Latest trade time |
| preClose | double | Previous close price |
| volume | string | Trading volume |
| open | double | Open price |
| high | double | High price |
| low | double | Low price |
| marketStatus | string | Market status |
| tradeTime | string | Trade timestamp |
| preSettlement | double | Previous settlement price |
| minTick | double | Minimum tick size |
| mi | object | Minute 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
| Parameter | Type | Description |
|---|---|---|
| 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 quoteon_quote_bbo(QuoteBBOData)— Crypto best bid/offer
Callback Data Fields
QuoteBasicData (Crypto):
| Field | Type | Description |
|---|---|---|
| symbol | string | Crypto symbol, e.g. ETH.USD |
| type | string | Data type: BASIC |
| timestamp | string | Data timestamp (milliseconds) |
| serverTimestamp | string | Server push timestamp |
| latestPrice | double | Latest price |
| latestPriceTimestamp | string | Latest price timestamp |
| latestTime | string | Latest trade time |
| preClose | double | Previous close price |
| volumeDecimal | double | Trading volume (decimal precision) |
| amount | double | Trading amount |
| open | double | Open price |
| high | double | High price |
| low | double | Low price |
| marketStatus | string | Market status, e.g. TRADING |
QuoteBBOData (Crypto):
| Field | Type | Description |
|---|---|---|
| symbol | string | Crypto symbol |
| type | string | Data type: BBO |
| timestamp | string | Data timestamp (milliseconds) |
| askPrice | double | Best ask price |
| askTimestamp | string | Ask quote timestamp |
| bidPrice | double | Best bid price |
| bidSize | string | Bid size |
| bidTimestamp | string | Bid 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
| Parameter | Type | Description |
|---|---|---|
| symbols | &str | Stock, 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:
| Field | Type | Description |
|---|---|---|
| symbol | string | Symbol |
| timestamp | string | Depth data timestamp |
| ask | object | Ask (sell) side data |
| ask.price | double[] | Price at each level |
| ask.volume | string[] | Volume at each level |
| ask.orderCount | int[] | Order count at each level (HK only) |
| bid | object | Bid (buy) side data |
| bid.price | double[] | Price at each level |
| bid.volume | string[] | Volume at each level |
| bid.orderCount | int[] | 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
| Parameter | Type | Description |
|---|---|---|
| symbols | &str | Stock 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:
| Field | Type | Description |
|---|---|---|
| symbol | string | Symbol |
| secType | string | Security type: STK / FUT |
| quoteLevel | string | Quote permission level (e.g. usQuoteBasic, hkStockQuoteLv2) |
| timestamp | long | Data timestamp |
| ticks | Tick[] | Trade tick data array |
Tick:
| Field | Type | Description |
|---|---|---|
| sn | long | Tick sequence number |
| volume | long | Trade volume |
| tickType | string | * neutral, + active buy, - active sell (not available for futures) |
| price | double | Trade price |
| time | long | Trade timestamp |
| cond | string | Trade condition (e.g. US_REGULAR_SALE, HK_AUTOMATCH_NORMAL) |
| partCode | string | Exchange 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
| Parameter | Type | Description |
|---|---|---|
| symbols | &str | Stock 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:
| Field | Type | Description |
|---|---|---|
| symbol | string | Stock symbol |
| time | string | Minute timestamp |
| open | float | Open price |
| high | float | High price |
| low | float | Low price |
| close | float | Close price |
| avg | float | Average price |
| volume | string | Trading volume |
| count | int | Trade count |
| amount | double | Trading amount |
| serverTimestamp | string | Server 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
| Parameter | Type | Description |
|---|---|---|
| market | &str | Market 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:
| Field | Type | Description |
|---|---|---|
| market | string | Market: US / HK |
| timestamp | string | Timestamp |
| topData | TopData[] | Ranking data for each indicator |
TopData:
| Field | Type | Description |
|---|---|---|
| targetName | string | Indicator name: changeRate (daily change), changeRate5Min (5-min change), turnoverRate (turnover rate), amount (trading amount), volume (trading volume), amplitude (amplitude) |
| item | StockItem[] | Ranking list for this indicator |
StockItem:
| Field | Type | Description |
|---|---|---|
| symbol | string | Symbol |
| latestPrice | double | Latest price |
| targetValue | double | Indicator 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
| Parameter | Type | Description |
|---|---|---|
| market | &str | Market 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:
| Field | Type | Description |
|---|---|---|
| market | string | Market: US |
| timestamp | string | Timestamp |
| topData | TopData[] | Ranking data for each indicator |
TopData:
| Field | Type | Description |
|---|---|---|
| targetName | string | Indicator name: bigOrder (large orders), volume (volume), amount (amount), openInt (open interest) |
| bigOrder | BigOrder[] | Large order data list (bigOrder indicator only) |
| item | OptionItem[] | Ranking list for this indicator |
BigOrder:
| Field | Type | Description |
|---|---|---|
| symbol | string | Stock/ETF symbol |
| expiry | string | Expiry date, format: yyyyMMdd |
| strike | string | Strike price |
| right | string | CALL / PUT |
| dir | string | Direction: Buy / Sell / NONE |
| volume | double | Trade volume |
| price | double | Trade price |
| amount | double | Trade amount |
| tradeTime | long | Trade timestamp |
OptionItem:
| Field | Type | Description |
|---|---|---|
| symbol | string | Stock/ETF symbol |
| expiry | string | Expiry date, format: yyyyMMdd |
| strike | string | Strike price |
| right | string | CALL / PUT |
| totalAmount | double | Total amount |
| totalVolume | double | Total volume |
| totalOpenInt | double | Total open interest |
| volumeToOpenInt | double | Volume to open interest ratio |
| latestPrice | double | Latest price |
| updateTime | string | Data 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
subscribeGeneric 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| Parameter | Type | Description |
|---|---|---|
| subject | ⋐jectType | Subject type (Quote, Option, Future, Depth, TradeTick, Kline, StockTop, OptionTop) |
| symbols | Option<&str> | Symbols, comma-separated |
| account | Option<&str> | Account (for trade subscriptions) |
| market | Option<&str> | Market (for ranking subscriptions) |
Returns bool: only indicates whether the protocol frame was queued locally, not server acceptance.
unsubscribe
unsubscribeGeneric unsubscription method. Same parameter semantics as subscribe.
pub fn unsubscribe(
&self,
subject: &SubjectType,
symbols: Option<&str>,
account: Option<&str>,
market: Option<&str>,
) -> boolsubscribe_market
subscribe_marketSubscribe to market ranking data (StockTop).
pub fn subscribe_market(&self, market: &str) -> Result<(), TigerError>unsubscribe_market
unsubscribe_marketUnsubscribe from market ranking data.
pub fn unsubscribe_market(&self, market: &str) -> Result<(), TigerError>subscribe_cc
subscribe_ccSubscribe to cryptocurrency quotes.
pub fn subscribe_cc(&self, symbols: &[&str]) -> Result<(), TigerError>unsubscribe_cc
unsubscribe_ccUnsubscribe from cryptocurrency quotes. symbols=None unsubscribes all crypto.
pub fn unsubscribe_cc(&self, symbols: Option<&[&str]>) -> Result<(), TigerError>get_subscriptions
get_subscriptionsReturns a snapshot of local subscription state.
pub fn get_subscriptions(&self) -> HashMap<SubjectType, Vec<String>>Updated about 13 hours ago
