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 claims market data device access (is_grab_permission=True). To avoid repeated claims and possible rate limiting, create one module-level QuoteClient instance and reuse it. To manage device access manually, set is_grab_permission=False.
Claim Market Data Device 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 holds market data device access and device B calls grab_quote_permission(), device access transfers to device B and is removed from device A. Only one device can hold market data device access at a time. This operation does not purchase or grant new market data access.
QuoteClient calls this method automatically during initialization by default.
Devices without market data device 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 permission.
Dict data format:
| KEY | VALUE |
|---|---|
| name | Market data permission 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}]Rate Limit
The base rate limit is 10 requests/minute.
Query Market Data Permissions
QuoteClient.get_quote_permission()
Description
Returns the market data permissions currently available to the account.
Parameters
None
Returns
Same as Claim Market Data Device 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}]Rate Limit
The base rate limit is 10 requests/minute.
Get Historical Market Data Quota
QuoteClient.get_kline_quota(with_details=False)
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) |
| details | list[str] | Used symbol codes when with_details=True; otherwise an empty array |
| symbol_details | list[dict] | Used symbols and last-fetch times when with_details=True; otherwise an empty array |
Each item in symbol_details:
| Field | Type | Description |
|---|---|---|
| code | string | stock symbol |
| last_request_timestamp | string | Last-fetch timestamp in milliseconds, represented as a string |
Example
result = quote_client.get_kline_quota()
print(result)
Example Response
[ {
"remain" : 200,
"used" : 0,
"method" : "kline",
"details" : [ ],
"symbol_details" : [ ]
}, {
"remain" : 20,
"used" : 0,
"method" : "future_kline",
"details" : [ ],
"symbol_details" : [ ]
}, {
"remain" : 197,
"used" : 3,
"method" : "option_kline",
"details" : [ ],
"symbol_details" : [ ]
} ]Rate Limit
The base rate limit is 10 requests/minute.
Updated about 1 month ago
