General
QuoteClient Description
QuoteClient(client_config, logger=None, is_grab_permission=True)
When initiating market data API calls in the SDK, you need to use QuoteClient, which encapsulates all market data related API interface calls.
By default, QuoteClient will automatically perform market data permission grabbing (is_grab_permission=True). To avoid frequent permission grabbing due to multiple instantiations that may trigger rate limiting, it is recommended to create a QuoteClient instance only at the top level of one module and reference this instance through import in other parts of the program, rather than repeatedly instantiating in each module. If you need to control market data permission grabbing manually, you can set is_grab_permission to False.
grab_quote_permission Market Data Permission Grabbing
QuoteClient.grab_quote_permission()
Description
When the same account is used on multiple devices simultaneously, market data is only returned on the primary device. If you need to view market data on other devices, you need to execute "market data permission grabbing" to set the current device as the primary device. If you don't switch devices, this operation is not required.
Note: Starting from Python SDK version 2.0.9, QuoteClient automatically calls this interface and grabs permissions during initialization by default.
Devices that haven't grabbed market data permissions will receive the following error when requesting real-time market data:
code=4 msg=4000:permission denied(current device does not have permission)
Parameters
None
Returns
list, where each item is a dict composed of permission data
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 permission |
| usStockQuoteLv2Totalview | US stock L2 market data permission |
| hkStockQuoteLv2 | HK stock L2 permission for mainland users |
| hkStockQuoteLv2Global | HK stock L2 permission purchased by non-mainland users |
| usOptionQuote | US option L1 market data permission |
| CBOEFuturesQuoteLv2 | Chicago Board Options Exchange L2 permission |
| HKEXFuturesQuoteLv2 | Hong Kong Futures Exchange L2 permission |
| SGXFuturesQuoteLv2 | Singapore Exchange L2 permission |
| OSEFuturesQuoteLv2 | Osaka Exchange L2 permission |
For permission details, refer to Market Data Permissions & Restrictions
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
quote_client = QuoteClient(client_config)
permissions = quote_client.grab_quote_permission()
print(permissions)Return Example
[{'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_quote_permission Query Market Data Permissions
QuoteClient.get_quote_permission()
Description
Query the current market data permissions owned
Parameters
None
Returns
Same as grab_quote_permission Market Data Permission Grabbing
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
quote_client = QuoteClient(client_config)
permissions = quote_client.get_quote_permission()Return Example
[{'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_kline_quota Historical Market Data Quota
QuoteClient.get_kline_quota()
Description
Statistics of used and remaining subscribable symbol counts based on user level (different options of the same stock only occupy one symbol, other rules can refer to Historical Market Data Restrictions & Subscription Restrictions)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| with_details | bool | No | Whether to return requested symbol details, default is not to return |
Returns
list. Each item as follows
| Field | Type | Description |
|---|---|---|
| remain | int | Used quantity |
| used | int | Remaining quantity |
| method | str | API interface (kline: stock K-line; future_kline: futures K-line; option_kline: option K-line; history_timeline: stock historical 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 code |
| last_request_timestamp | string | Last fetch time string |
Example
from tigeropen.quote.quote_client import QuoteClient
from tigeropen.common.consts import TradingSession, Market
from tigeropen.common.consts.filter_fields import MultiTagField
from tigeropen.tiger_open_config import TigerOpenClientConfig
client_config = TigerOpenClientConfig(props_path='/path/to/your/properties/file/')
quote_client = QuoteClient(client_config)
result = quote_client.get_kline_quota()
print(result)
Return Example
[ {
"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 1 day ago
