General
Initialization
All examples on this page assume the following initialization has been completed:
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='your_config_directory_path')
quote_client = QuoteClient(client_config)For details, see Prerequisites.
QuoteClient Overview
QuoteClient(client_config, logger=None, is_grab_permission=True)
Use QuoteClient for all market data API calls in the SDK.
By default, QuoteClient automatically acquires market data access (is_grab_permission=True). To avoid repeated transfers and possible rate limiting, create one module-level QuoteClient instance and reuse it. To manage access manually, set is_grab_permission=False.
Acquire Market Data Access
QuoteClient.grab_quote_permission()
Description
When the same account is active on multiple devices, real-time market data is available only on the primary device. Call this method to make the current device primary. You do not need to call it if you have not switched devices.
For example, if device A currently has access and device B calls grab_quote_permission(), access transfers to device B and is removed from device A. Only one device can hold access at a time.
QuoteClient calls this method automatically during initialization by default.
Devices that have not acquired market data access receive the following error when requesting real-time data:
code=4 msg=4000:permission denied(current device does not have permission)
Parameters
None
Returns
list, where each item is a dictionary describing one market data entitlement.
Dict data format:
| KEY | VALUE |
|---|---|
| name | market data access name |
| expire_at | Permission expiration time (-1 for permanent validity) |
Name field enumeration values:
| name Field Value | Description |
|---|---|
| usQuoteBasic | US stock L1 market data access |
| usStockQuote | US real-time stock market data access |
| usStockQuoteLv2Arca | US stock ARCA L2 market data access |
| usStockQuoteLv2Totalview | US stock L2 market data access |
| hkStockQuoteLv2 | HK stock L2 permission for mainland users |
| hkStockQuoteLv2Global | HK stock L2 permission purchased by non-mainland users |
| usOptionQuote | US option L1 market data access |
| usOptionQuoteLv2 | US option L2 market data access |
| usQuoteOtc | US OTC market data access |
| usOvernight | US overnight market data access |
| CBOEFuturesQuoteLv2 | Chicago Board Options Exchange L2 permission |
| EUREXFuturesQuoteLv2 | Eurex futures L2 permission |
| HKEXFuturesQuoteLv2 | Hong Kong Futures Exchange L2 permission |
| SGXFuturesQuoteLv2 | Singapore Exchange L2 permission |
| OSEFuturesQuoteLv2 | Osaka Exchange L2 permission |
| CMEFuturesQuoteLv2 | Chicago Mercantile Exchange L2 permission |
| COMEXFuturesQuoteLv2 | COMEX gold L2 permission |
| COMEXFuturesQuoteLv1 | COMEX gold L1 permission |
| NYMEXFuturesQuoteLv2 | NYMEX energy L2 permission |
| NYMEXFuturesQuoteLv1 | NYMEX energy L1 permission |
| futureQuote | Futures market data access |
| aStockQuoteLv1 | China A-share L1 permission |
For details, see Market Data Access and Restrictions.
Example
permissions = quote_client.grab_quote_permission()
print(permissions)Example Response
[{'name': 'usStockQuote', 'expire_at': 1698767999000}, {'name': 'usStockQuoteLv2Arca', 'expire_at': 1698767999000}, {'name': 'usStockQuoteLv2Totalview', 'expire_at': 1698767999000}, {'name': 'hkStockQuoteLv2', 'expire_at': 1698767999000}, {'name': 'usOptionQuote', 'expire_at': 1698767999000}]Query Market Data Access
QuoteClient.get_quote_permission()
Description
Returns the market data entitlements currently available to the account.
Parameters
None
Returns
Same as Acquire Market Data Access.
Example
permissions = quote_client.get_quote_permission()Example Response
[{'name': 'usStockQuote', 'expire_at': 1698767999000}, {'name': 'usStockQuoteLv2Arca', 'expire_at': 1698767999000}, {'name': 'usStockQuoteLv2Totalview', 'expire_at': 1698767999000}, {'name': 'hkStockQuoteLv2', 'expire_at': 1698767999000}, {'name': 'usOptionQuote', 'expire_at': 1698767999000}]Get Historical Market Data Quota
QuoteClient.get_kline_quota()
Description
Returns the used and remaining historical-data symbol quotas for the user's tier. Multiple options on the same underlying stock count as one symbol. See Historical Market Data and Subscription Restrictions for the counting rules.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| with_details | bool | No | Whether to include details for requested symbols. Defaults to False |
Returns
list. Each item contains the following fields:
| Field | Type | Description |
|---|---|---|
| used | int | Used quantity |
| remain | int | Remaining quantity |
| method | str | API name (kline: stock bars; future_kline: futures bars; option_kline: option bars; history_timeline: historical stock timeline) |
| symbol_details | list[dict] | List of used symbols, including the last fetch time for each symbol |
Each item in symbol_details:
| Field | Type | Description |
|---|---|---|
| code | string | stock symbol |
| last_request_timestamp | string | Last fetch time string |
Example
result = quote_client.get_kline_quota()
print(result)
Example Response
[ {
"remain" : 200,
"used" : 0,
"method" : "kline",
"symbol_details" : [ ]
}, {
"remain" : 20,
"used" : 0,
"method" : "future_kline",
"symbol_details" : [ ]
}, {
"remain" : 197,
"used" : 3,
"method" : "option_kline",
"symbol_details" : [ {
"code" : "TCH.HK",
"last_request_timestamp" : "1750851341848"
}, {
"code" : "ALB.HK",
"last_request_timestamp" : "1750851341848"
}, {
"code" : "LNI.HK",
"last_request_timestamp" : "1750851341848"
} ]
} ]Updated 7 days ago
