Quotation Subscription Push
Subscribe to Stock Quotes
Subscribe Method
PushClient.subscribe_quote(symbols)
Unsubscribe Method
PushClient.unsubscribe_quote(symbols)
Description
Real-time subscription and unsubscription interface for stock quotes. Once subscribed, quote data is pushed to the client whenever there are price changes or order book updates.
Callback data is returned in the following formats:
- Basic quote data:
QuoteBasicData(tigeropen.push.pb.QuoteBasicData_pb2.QuoteBasicData) - Best bid/offer (BBO) data:
QuoteBBOData(tigeropen.push.pb.QuoteBasicData_pb2.QuoteBBOData)
This interface operates asynchronously. Use the following callbacks to handle incoming data:
PushClient.quote_changedhandles basic quote updates (QuoteBasicData)PushClient.quote_bbo_changedhandles best bid/offer updates (QuoteBBOData)
Note: Subscription to US stock index quotes is not supported
Parameters
| Parameter | Type | Description |
|---|---|---|
| symbols | list[str] | List of security symbols. Symbols must be uppercase |
Return Data
For a complete description of all fields included in stock quote callback data, refer to Quote Changes
CAUTION
Stock quote callback data is returned in two distinct types:
- Trading data
- Order book data
The fields included in the callback differ between these two data types. Make sure to handle each type appropriately when processing the callback payload.
Example
from tigeropen.push.push_client import PushClient
from tigeropen.push.pb.QuoteBBOData_pb2 import QuoteBBOData
from tigeropen.push.pb.QuoteBasicData_pb2 import QuoteBasicData
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
# Initialize PushClient
protocol, host, port = client_config.socket_host_port
push_client = PushClient(host, port, use_ssl=(protocol == 'ssl'), use_protobuf=True)
# Define callback methods
def on_quote_changed(frame: QuoteBasicData):
"""Basic quote data callback
"""
print(f'quote basic change: {frame}')
def on_quote_bbo_changed(frame: QuoteBBOData):
"""Best bid/offer quote, ask/bid
"""
print(f'quote bbo changed: {frame}')
# Bind callback methods
push_client.quote_changed = on_quote_changed
push_client.quote_bbo_changed = on_quote_bbo_changed
# Establish connection
push_client.connect(client_config.tiger_id, client_config.private_key)
# Subscribe
push_client.subscribe_quote(['XYZX'])
# Unsubscribe
push_client.unsubscribe_quote(['XYZX'])
# Disconnect, will cancel all subscriptions
push_client.disconnect()Callback Data Example
tigeropen.push.pb.QuoteBasicData_pb2.QuoteBasicData data example:
symbol: "00700"
type: BASIC
timestamp: 1677742483530
serverTimestamp: 1677742483586
avgPrice: 365.37
latestPrice: 363.8
latestPriceTimestamp: 1677742483369
latestTime: "03-02 15:34:43"
preClose: 368.8
volume: 12674730
amount: 4630947968
open: 368.2
high: 369
low: 362.4
marketStatus: "Trading"
mi {
p: 363.8
a: 365.37
t: 1677742440000
v: 27300
}
tigeropen.push.pb.QuoteBasicData_pb2.QuoteBBOData data example:
symbol: "01810"
type: BBO
timestamp: 1677741267291
serverTimestamp: 1677741267329
askPrice: 12.54
askSize: 397600
askTimestamp: 1677741266304
bidPrice: 12.52
bidSize: 787400
bidTimestamp: 1677741266916
Subscribe to Option Quotes
Parameters
| Parameter | Type | Description |
|---|---|---|
| symbols | list[str] | List of option symbols. Each symbol consists of four space‑separated elements:
|
Callback Data
Bind the callback handler using push_client.quote_changed.
Option quote updates use the same callback method as stock quotes.
Example
push_client.subscribe_option(['XYZX 20230120 150.0 CALL', 'SPY 20220930 470.0 PUT'])
Alternatively,
push_client.subscribe_quote(['XYZX 20230120 150.0 CALL', 'SPY 20220930 470.0 PUT'])
from tigeropen.push.push_client import PushClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
# Initialize PushClient
protocol, host, port = client_config.socket_host_port
push_client = PushClient(host, port, use_ssl=(protocol == 'ssl'))
# Define callback methods
def on_quote_changed(frame: QuoteBasicData):
"""Basic quote data callback
"""
print(f'quote basic change: {frame}')
def on_quote_bbo_changed(frame: QuoteBBOData):
"""Best bid/offer quote, ask/bid
"""
print(f'quote bbo changed: {frame}')
# Bind callback methods
push_client.quote_changed = on_quote_changed
push_client.quote_bbo_changed = on_quote_bbo_changed
# Establish connection
push_client.connect(client_config.tiger_id, client_config.private_key)
# Subscribe to option quotes
push_client.subscribe_option(['XYZX 20240119 155.0 PUT', 'SPY 20221118 386.0 CALL'])
# Unsubscribe
push_client.unsubscribe_quote(['XYZX 20240119 155.0 PUT', 'SPY 20221118 386.0 CALL'])
# Disconnect, will cancel all subscriptions
push_client.disconnect()Subscribe to Market Depth Quotes
Subscribe Method
Push_client.subscribe_depth_quote(symbols)
Unsubscribe Method
PushClient.unsubscribe_depth_quote(symbols)
Description
Subscribe to real-time market depth quotes for stocks and options.
- US market depth quotes are pushed every 300 ms
- Each update returns up to 40 levels of bid and ask order book data
Data is delivered in real time and pushed whenever the order book changes.
This interface is asynchronous. Use PushClient.quote_depth_changed to handle incoming depth quote data in the form of QuoteDepthData (tigeropen.push.pb.QuoteDepthData_pb2.QuoteDepthData) objects.
Parameters
| Parameter | Type | Description |
|---|---|---|
| symbols | list[str] | List of security symbols |
Example
from tigeropen.push.push_client import PushClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
# Initialize PushClient
protocol, host, port = client_config.socket_host_port
push_client = PushClient(host, port, use_ssl=(protocol == 'ssl'))
# Define callback methods
def on_quote_depth_changed(frame: QuoteDepthData):
print(f'quote depth changed: {frame}')
# Print prices
print(f'ask price: {frame.ask.price}')
# First level price
print(f'ask price item 0: {frame.ask.price[0]}')
# Bind callback methods
push_client.quote_depth_changed = on_quote_depth_changed
# Establish connection
push_client.connect(client_config.tiger_id, client_config.private_key)
# Subscribe to market depth quotes
push_client.subscribe_depth_quote(['XYZX'])
# Unsubscribe
push_client.unsubscribe_depth_quote(['XYZX'])
# Disconnect, will cancel all subscriptions
push_client.disconnect()Callback Data
tigeropen.push.pb.QuoteDepthData_pb2.QuoteDepthData
CAUTION
This interface returns up to 40 levels of bid and ask order book data only.
Data structure:
| Field | Type | Description |
|---|---|---|
| symbol | string | Security symbol |
| timestamp | long | Timestamp of the depth data |
| ask | OrderBook | Ask‑side order book data |
| bid | OrderBook | Bid‑side order book data |
OrderBook data structure:
| Field | Type | Description |
|---|---|---|
| price | list[float] | Price at each order book level |
| volume | list[int] | Order volume at each corresponding level |
| exchange | string | Option data source (options only). If price or volume is 0, the quote from this data source has expired. For enum values, see: Option Exchanges |
| time | long | Order timestamp from the option exchange (options only) |
Callback Data Example
Adjacent levels may share the same price, and orderCount is optional depending on the market and asset type.
symbol: "00700"
timestamp: 1677742734822
ask {
price: 363.8
price: 364
price: 364.2
price: 364.4
price: 364.6
price: 364.8
price: 365
price: 365.2
price: 365.4
price: 365.6
volume: 26900
volume: 14800
volume: 15200
volume: 31500
volume: 15800
volume: 7700
volume: 29400
volume: 6300
volume: 6000
volume: 5500
orderCount: 27
orderCount: 20
orderCount: 19
orderCount: 22
orderCount: 14
orderCount: 10
orderCount: 20
orderCount: 12
orderCount: 10
orderCount: 11
}
bid {
price: 363.6
price: 363.4
price: 363.2
price: 363
price: 362.8
price: 362.6
price: 362.4
price: 362.2
price: 362
price: 361.8
volume: 9400
volume: 19900
volume: 35300
volume: 74200
volume: 26300
volume: 16700
volume: 22500
volume: 21100
volume: 40500
volume: 5600
orderCount: 16
orderCount: 23
orderCount: 36
orderCount: 79
orderCount: 30
orderCount: 32
orderCount: 31
orderCount: 34
orderCount: 143
orderCount: 26
}
Subscribe to Tick-by-Tick Trade Data
Subscribe Method
Push_client.subscribe_tick(symbols)
Unsubscribe Method
PushClient.unsubscribe_tick(symbols)
Description
An asynchronous subscription interface for tick‑by‑tick trade data.
To receive tick updates, implement the PushClient.tick_changed interface. Unlike other market data subscriptions, tick data is returned in a compressed format and does not use the original Protobuf schema. Instead, data is delivered as:
tigeropen.push.pb.trade_tick.TradeTick
Tick-by-tick data behavior:
- Push frequency: every 200 ms
- Delivery mode: snapshot
- Each push contains the latest 50 tick records
Parameters
| Parameter | Type | Description |
|---|---|---|
| symbols | list[str] | List of security symbols |
Example
from tigeropen.push.pb.trade_tick import TradeTick
from tigeropen.push.push_client import PushClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
# Initialize PushClient
protocol, host, port = client_config.socket_host_port
push_client = PushClient(host, port, use_ssl=(protocol == 'ssl'))
# Subscribe callback method
def on_tick_changed(data: TradeTick):
print(f'tick changed: {data}')
# Bind callback method
push_client.tick_changed = on_tick_changed
# Establish connection
push_client.connect(client_config.tiger_id, client_config.private_key)
# Subscribe to tick-by-tick transaction data
push_client.subscribe_tick(['XYZX'])
time.sleep(10)
# Unsubscribe
push_client.unsubscribe_tick(['XYZX'])
# Disconnect, will cancel all subscriptions
push_client.disconnect()Callback Data
tigeropen.push.pb.trade_tick.TradeTick
The TradeTick object is structured as follows:
| Field | Type | Description |
|---|---|---|
| symbol | str | Stock symbol |
| secType | str | Security type: STK (stock) |
| quoteLevel | str | Quote permission level where the data originates (US stocks only). USQuoteBasic provides less tick data than USStockQuote |
| timestamp | int | Timestamp of tick data batch |
| ticks | list[TradeTickItem] | Collection of tick-by-tick trade records |
Each element in ticks represents an individual trade and has the following structure:
| Field | Type | Description |
|---|---|---|
| sn | int | Tick sequence number |
| volume | int | Trade volume |
| tickType | str | Price movement indicator:
|
| price | double | Trade price |
| time | int | Trade timestamp |
| cond | str | Trade condition list for each tick. An empty value indicates automatic matching trades |
| partCode | str | Exchange code for each trade (US stocks only) |
| partName | str | Exchange name for each trade (US stocks only) |
Callback Data Example
symbol: "00700"
type: "-+"
sn: 37998
priceBase: 3636
priceOffset: 1
time: 1677742815311
time: 69
price: 0
price: 2
volume: 500
volume: 100
quoteLevel: "StockQuoteLv2"
timestamp: 1677742815776
secType: "STK"
Subscribe to Full Tick-by-Tick Trade Data
Subscribe Method
Push_client.subscribe_tick(symbols)
Unsubscribe Method
PushClient.unsubscribe_tick(symbols)
Description
An asynchronous subscription interface for full tick‑by‑tick trade data.
To receive full tick updates, implement the PushClient.full_tick_changed interface.
Full tick data is delivered using the following callback object:
tigeropen.push.pb.TickData_pb2.TickData
Parameters
| Parameter | Type | Description |
|---|---|---|
| symbols | list[str] | List of security codes |
To enable full tick mode, update the client configuration before initializing PushClient:
client_config.use_full_tick = True
push_client = PushClient(client_config=client_config)Example
from tigeropen.push.pb.TickData_pb2 import TickData
from tigeropen.push.push_client import PushClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
client_config.use_full_tick = True
# Initialize PushClient
protocol, host, port = client_config.socket_host_port
push_client = PushClient(host, port, use_ssl=(protocol == 'ssl'), client_config=client_config)
# Subscribe callback method
def on_full_tick_changed(frame: TickData):
print(f'full tick changed: {frame}')
# Bind callback method
push_client.full_tick_changed = on_full_tick_changed
# Establish connection
push_client.connect(client_config.tiger_id, client_config.private_key)
# Subscribe to tick-by-tick transaction data
push_client.subscribe_tick(['XYZX', '00700'])
time.sleep(10)
# Unsubscribe
push_client.unsubscribe_tick(['XYZX'])
# Disconnect, will cancel all subscriptions
push_client.disconnect()Callback Data
Full tick‑by‑tick trade updates are returned as TickData objects:
tigeropen.push.pb.TickData_pb2.TickData
TickData Structure:
| Field | Type | Description |
|---|---|---|
| symbol | str | Stock |
| source | str | Security type: STK (stock) |
| timestamp | int | Timestamp of the tick data batch |
| ticks | list[Tick] | Collection of tick‑by‑tick trade records |
Each element in ticks has the following data structure:
| Field | Type | Description |
|---|---|---|
| sn | int | Tick sequence number |
| volume | int | Trade volume |
| type | str | Price movement indicator:
|
| price | double | Trade price |
| time | int | Trade timestamp |
| partCode | str | Exchange code for each trade (US stocks only) |
Callback Data Example
symbol: "XYZX"
ticks {
sn: 2381
time: 1712669401076
price: 874.1
volume: 10
type: "*"
partCode: "t"
}
ticks {
sn: 2382
time: 1712669401076
price: 874.1
volume: 11
type: "*"
partCode: "t"
}
ticks {
sn: 2383
time: 1712669401076
price: 874.1
volume: 3
type: "*"
partCode: "t"
}
timestamp: 1712669403808
source: "NLS"
Query Subscribed Symbols
PushClient.query_subscribed_quote()
Description
Query the list of subscribed symbols
This interface is asynchronous. To receive the query result, implement the following callback handler:
PushClient.query_subscribed_callback
Parameters
None
Callback Data
The callback returns a summary of subscription limits and currently subscribed symbols across different data types.
Callback Data Structure:
| Field | Type | Description |
|---|---|---|
| limit | int | Maximum allowed number of subscribed quote symbols (stocks, options) |
| used | int | Current number of subscribed quote symbols (stocks, options) |
| subscribedSymbols | list | List of subscribed quote symbols |
| askBidLimit | int | Maximum allowed number of subscribed depth‑quote (bid/ask) stocks |
| askBidUsed | int | Current number of subscribed depth‑quote stocks |
| subscribedAskBidSymbols | list | List of subscribed depth‑quote stock symbols |
| tradeTickLimit | int | Maximum allowed number of subscribed tick‑by‑tick symbols |
| tradeTickUsed | int | Current number of subscribed tick‑by‑tick symbols |
| subscribedTradeTickSymbols | list | List of subscribed tick‑by‑tick symbols |
Example
from tigeropen.push.push_client import PushClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
# Initialize PushClient
protocol, host, port = client_config.socket_host_port
push_client = PushClient(host, port, use_ssl=(protocol == 'ssl'), use_protobuf=True)
# Define callback method
def query_subscribed_callback(data):
"""
data example:
{'subscribed_symbols': ['QQQ'], 'limit': 1200, 'used': 1, 'symbol_focus_keys': {'qqq': ['open', 'prev_close', 'low', 'volume', 'latest_price', 'close', 'high']},
'subscribed_quote_depth_symbols': ['XYZX'], 'quote_depth_limit': 20, 'quote_depth_used': 1,
'subscribed_trade_tick_symbols': ['QQQ', '00700'], 'trade_tick_limit': 1200, 'trade_tick_used': 3}
"""
print(f'subscribed data:{data}')
print(f'subscribed symbols:{data["subscribed_symbols"]}')
# Bind callback method
push_client.query_subscribed_callback = query_subscribed_callback
# Establish connection
push_client.connect(client_config.tiger_id, client_config.private_key)
# Subscribe to quotes
push_client.subscribe_quote(['QQQ'])
# Subscribe to depth quotes
push_client.subscribe_depth_quote(['XYZX'])
push_client.subscribe_depth_quote(['HSImain'])
# Subscribe to tick data
push_client.subscribe_tick(['QQQ'])
push_client.subscribe_tick(['HSImain'])
# Query subscribed contracts
push_client.query_subscribed_quote()
time.sleep(10)Callback Data Example
{'subscribed_symbols': ['QQQ'], 'limit': 1200, 'used': 1,
'subscribed_ask_bid_symbols': ['XYZX'], 'ask_bid_limit': 20, 'ask_bid_used': 1,
'subscribed_trade_tick_symbols': ['QQQ', '00700'], 'trade_tick_limit': 1200, 'trade_tick_used': 3
}Updated 3 days ago