General
Grab Quote Permission
Corresponding request class: TigerHttpRequest(MethodName.GRAB_QUOTE_PERMISSION)
Description
When the same account is used on multiple devices simultaneously, market data is only returned on the primary device. To view market data on other devices, you need to execute "grab quote permission" to set the current device as the primary device. If you don't switch devices, this operation is not required.
By default, grab quote permission is executed once at startup. If you need to configure not to execute grab permission at startup, you can configure isAutoGrabPermission = false before getting the TigerHttpClient instance.
ClientConfig.DEFAULT_CONFIG.isAutoGrabPermission = false;
TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(ClientConfig.DEFAULT_CONFIG);Parameters
None
Returns
| Field Name | Type | Description |
|---|---|---|
| name | string | Permission name, see below for specific permission values |
| expireAt | long | Expiration time in timestamp format, -1 indicates unlimited |
Permission name enumeration values for the name field:
| 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 for 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 |
Example
TigerHttpRequest request = new TigerHttpRequest(MethodName.GRAB_QUOTE_PERMISSION);
String bizContent = AccountParamBuilder.instance()
.buildJson();
request.setBizContent(bizContent);
TigerHttpResponse response = client.execute(request);Return Example
{
"code": 0,
"message": "success",
"timestamp": 1525938835697,
"data": [
{
"name": "usQuoteBasic",
"expireAt": 1621931026000
}
]
}Get Quote Permission List
Corresponding request class: TigerHttpRequest(MethodName.GET_QUOTE_PERMISSION)
Description
Query the currently owned market data permissions.
Parameters
None
Returns
| Field Name | Type | Description |
|---|---|---|
| name | string | Permission name |
| expireAt | long | Expiration time in timestamp format, -1 indicates unlimited |
Example
TigerHttpRequest request = new TigerHttpRequest(MethodName.GET_QUOTE_PERMISSION);
String bizContent = AccountParamBuilder.instance()
.buildJson();
request.setBizContent(bizContent);
TigerHttpResponse response = client.execute(request);Return Example
{
"code": 0,
"message": "success",
"timestamp": 1651734899995,
"data": [
{
"name": "usStockQuote",
"expireAt": 1698767999000
},
{
"name": "usStockQuoteLv2Arca",
"expireAt": 1698767999000
},
{
"name": "usStockQuoteLv2Totalview",
"expireAt": 1698767999000
},
{
"name": "hkStockQuoteLv2",
"expireAt": 1698767999000
},
{
"name": "usOptionQuote",
"expireAt": 1698767999000
},
{
"name": "hkStockQuoteLv2",
"expireAt": -1
}
]
}Refresh Token
Corresponding request class: UserTokenRefreshRequest
Description
Only Hong Kong license TBHK needs to use Token (user license can be viewed by logging into the developer information page).
Refresh Token interface, only valid local Token can be refreshed successfully. If the Token has expired, you need to refresh the Token on the developer information registration page and export it to the local file tiger_openapi_token.properties before use.
After successful refresh, the local tiger_openapi_token.properties file will be updated simultaneously, and the Token value in the memory ClientConfig will be updated. You can configure the automatic refresh cycle days (refreshTokenIntervalDays) and specific time (refreshTokenTime). If you need to refresh the Token manually, please configure ClientConfig.DEFAULT_CONFIG.isAutoRefreshToken = false and refresh the Token manually.
Token validity period is 15 days, SDK does not refresh by default.
Parameters
None, the SDK will automatically add the Token to the Http request header Authorization for each request, and the server will validate the Token.
Returns
| Field Name | Type | Description |
|---|---|---|
| tigerId | string | tigerId |
| license | string | License info |
| token | string | Token string |
| createTime | long | Creation time |
| expiredTime | long | Expiration time |
Example
UserTokenRefreshRequest request = new UserTokenRefreshRequest();
UserTokenResponse response = TigerHttpClient.getInstance().execute(request);
if (response.isSuccess()) {
System.out.println(JSONObject.toJSONString(response));
List<RefreshTokenCallback> callbackList = TokenManager.getInstance().getCallbackList();
for (RefreshTokenCallback callback : callbackList) {
try {
System.out.println(callback.getClass() + " tokenChange() is called");
callback.tokenChange(ClientConfig.DEFAULT_CONFIG,
ClientConfig.DEFAULT_CONFIG.token,
response.getUserToken());
} catch (Throwable th) {
th.printStackTrace();
}
}
} else {
System.out.println("response error:" + response.getMessage());
}Return Example
{
"code":0,
"data":{
"createTime":1676547570673,
"expiredTime":1677152370673,
"license":"TBHK",
"tigerId":"20150001",
"token":"MTY3NjU0NzU3MDY3MywxNjc3MTUyMzcwNjczCJ/FLxjALbWg0cVW3R4bHg=="
},
"message":"success",
"sign":"Yufg4/bYSeuvZz3b+7MsSAde+lgUCNJskle1zbOSxta66b9h0LjfZAmHNpx1tz4HnPK1AGfS9cdNaC964ts7Uakvr/kKzFEN3y5CfB8UgRsPKSR75z1GwSFq5v6gc/1hEAdrFdcHTmRbHhT362E5GYEuvvlfwIEX60/GYveSHIo=",
"success":true,
"timestamp":1676547570681
}Get Historical Quote Quota
Corresponding request class: KlineQuotaRequest
Description
Based on user level, count the number of symbols that the user has used and remaining available for subscription (different options of the same stock only occupy one symbol, other rules can refer to Historical Quote Limits & Subscription Limits)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| with_details | bool | No | Whether to return requested symbol details, default false |
Returns
com.tigerbrokers.stock.openapi.client.https.response.quote.KlineQuotaResponsesource
Return data can be accessed through KlineQuotaResponse.getQuotaItems() method, returning a list of QuotaItem objects, where com.tigerbrokers.stock.openapi.client.https.domain.quote.item.QuotaItem properties are:
| Field | Type | Description |
|---|---|---|
| used | int | Used quantity |
| remain | int | Remaining quantity |
| method | String | API interface name (kline: stock K-line; future_kline: futures K-line; option_kline: option K-line;) |
| symbolDetails | List<SymbolDetail> | List of used symbols, including the last fetch time for each symbol |
SymbolDetail type:
| Field | Type | Description |
|---|---|---|
| code | string | Stock code |
| lastRequestTimestamp | string | Last fetch time string |
Example
KlineQuotaRequest request = KlineQuotaRequest.newRequest(Boolean.TRUE);
TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
ClientConfig.DEFAULT_CONFIG);
KlineQuotaResponse response = client.execute(request);
if (response.isSuccess()) {
System.out.println(JSONObject.toJSON(response));
} else {
System.out.println("response error:" + response.getMessage());
}Return Example
{
"code": 0,
"message": "success",
"timestamp": 1750851389623,
"sign": "myCpSB+GFgzlgOMnyIyD6yXib0m5LjKvRq+gT3sARfX4Z6AgNib/s0mpVniQs+H85yP1GlLHmAE/pCCKPNvGKyITynUiPWAIippg/o3Z4W//KlA868LaukA0Y+3fmqB4pnDQgoMH4zdcKEGgYS6X6bTPDCPTWCDAk43rXGJW94g=",
"quotaItems": [
{
"remain": 200,
"used": 0,
"method": "kline",
"symbolDetails": []
},
{
"remain": 20,
"used": 0,
"method": "future_kline",
"symbolDetails": []
},
{
"remain": 197,
"used": 3,
"method": "option_kline",
"symbolDetails": [
{
"code": "TCH.HK",
"lastRequestTimestamp": "1750851341848"
},
{
"code": "ALB.HK",
"lastRequestTimestamp": "1750851341848"
},
{
"code": "LNI.HK",
"lastRequestTimestamp": "1750851341848"
}
]
}
],
"success": true
}Updated 1 day ago
