Common
Grab Quote Permission TigerRequest(QuoteApiService.GRAB_QUOTE_PERMISSION)
Description
"Grab quote permission", the purpose of this function is that: When a single tiger id is shared by multiple devices, only the primary device can receive the quote information. As a result, every time you switch to another device, and wish to receive quote information on this device, you must call this function to set it as your primary device. You do not need to call this function if you are not switching between multiple devices. The returned value of this function is a list of permission map, which contains all your current quote permissions.
Argmuments
N/A
Response
Data field | Type | Description |
---|---|---|
name | string | Name of the quote permission subscription |
expireAt | long | Expiration time (-1 means never expire) |
Example
static async Task<QuotePermissionResponse?> GrabQuotePermissionAsync(QuoteClient quoteClient)
{
TigerRequest<QuotePermissionResponse> request = new TigerRequest<QuotePermissionResponse>()
{
ApiMethodName = QuoteApiService.GRAB_QUOTE_PERMISSION
};
return await quoteClient.ExecuteAsync(request);
}
Response Example
{
"data":[
{
"name":"hkStockQuoteLv2",
"expireAt":1698767999000
},
{
"name":"usStockQuote",
"expireAt":1698767999000
},
{
"name":"usStockQuoteLv2Arca",
"expireAt":1698767999000
},
{
"name":"usStockQuoteLv2Totalview",
"expireAt":1698767999000
},
{
"name":"usOptionQuote",
"expireAt":1698767999000
}
],
"code":0,
"message":"success",
"timestamp":1677741384290,
"sign":"vN6hnR0kCj3ZHpM+e0AlE744PrpcxjqDPMF+VSpHAqARWwDiq8wTmJOQjcd3O2USoKRrnXuhSChQfN6pP/A9HylTP7UC5mzKdi1vkxx9YYIZ/852/WfPV0BdkJ4nOw72gsqpvDI7e5tYHDX5UrTXsn6A8au1XK2oG9cb8m2fwCw="
}
Get Permission List TigerRequest(QuoteApiService.GET_QUOTE_PERMISSION)
Description
"Get quote permission", The returned value of this function is a list of permission map, which contains all your current quote permissions. If the obtained value is empty, may be grabed by another device.
Argmuments
N/A
Response
Data field | Type | Description |
---|---|---|
name | string | Name of the quote permission subscription |
expireAt | long | Expiration time (-1 means never expire) |
Example
static async Task<QuotePermissionResponse?> GetQuotePermissionAsync(QuoteClient quoteClient)
{
TigerRequest<QuotePermissionResponse> request = new TigerRequest<QuotePermissionResponse>()
{
ApiMethodName = QuoteApiService.GET_QUOTE_PERMISSION
};
return await quoteClient.ExecuteAsync(request);
}
Response Example
{
"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
}
],
"code":0,
"message":"success",
"timestamp":1677742241908,
"sign":"jrG1K0mls0eIXHVuBX4SqWzJ1fsLR8VEm9PNRzOrVghkACMpAClZXm4Tz7Oa6vu9JCliGkfbQtdYqLBZNt9L79b5DCBE724l+409YjtR5HxukIQENWcAuRJYRhF/F5j9Gw/SgjnMpi8Fsbm0HRVMKy8pd4UJGRrfzdUAXzRuJ0o="
}
Refresh Token TigerRequest(QuoteApiService.USER_TOKEN_REFRESH)
Description
Only the Hong Kong license TBHK needs to use the token (the user license can be found on the developer information page).
About the refresh token interface, which can be called successful only if the local token is valid. If the token is invalid, you need to refresh the token on the developer information registration page and export it to the local file tiger_openapi_token.properties for use.
The token is valid for 15 days, and the default behavior of the sdk: the sdk will automatically refresh the token every 5 days. After the refresh is successful, it will automatically update the local configuration file tiger_openapi_token.properties and update the token value of ClientConfig in memory, Configurable automatic refresh cycle days (RefreshTokenIntervalDays) and specific time (RefreshTokenTime). If you want to implement automatic refresh by yourself, please configure 'tigerConfig.AutoRefreshToken = false'.
Argmuments
N/A,Every request, the token will be automatically added to the HTTP request header 'Authorization', and the server will verify the token
Response
Data field | Type | Description |
---|---|---|
tigerId | string | tigerId |
license | string | license |
token | string | token |
createTime | long | create time |
expiredTime | long | expired time |
Example
static async Task<UserTokenResponse?> RefreshUserTokenAsync(QuoteClient quoteClient, TigerConfig config)
{
TigerRequest<UserTokenResponse> request = new TigerRequest<UserTokenResponse>()
{
ApiMethodName = QuoteApiService.USER_TOKEN_REFRESH
};
UserTokenResponse? response = await quoteClient.ExecuteAsync(request);
if (response is not null && response.IsSuccess())
{
List<IRefreshTokenCallback> callbackList = TokenManager.GetInstance().GetCallbackList();
foreach (IRefreshTokenCallback callback in callbackList)
{
try
{
Console.WriteLine(callback.GetType() + " tokenChange() is called");
callback.TokenChange(config, config.Token, response.Data);
}
catch (Exception e)
{
ApiLogger.Error(e, callback.GetType() + " tokenChange() is called fail");
}
}
}
return response;
}
Response Example
{
"data":{
"tigerId":"20151141",
"license":"TBHK",
"token":"MTY3Nzc0NTk3NzMzMiwxNjc5MDQxOTc3MzMyCJ/FLxjALbWg0cVW3R4bHg==",
"createTime":1677745977332,
"expiredTime":1679041977332
},
"code":0,
"message":"success",
"timestamp":1677745977338,
"sign":"mKX3qja7VHt/p9h698TcEc/jToQmPDTraHYqDCDc+CaIjnILHJbQn0ZD2sGmhfo6oZivZFIeGgle5Z0he6rIfip439LfLgtDg2RdajeyebJF6Qjy4vH7nrX8gTrfa2SjdnYSf0NHUzvBCbTCnPXtQKgiz74hzkmHuthWdnEBuJU="
}
Get Kline Quota
Request: TigerRequest(QuoteApiService.KLINE_QUOTA)
Description
Query the number of used and remaining symbols according to this user's level, including stocks, futures, options corresponding to stocks (different options of the same stock, only occupy a symbol)
Argument
Argument | Type | Required | Description |
---|---|---|---|
with_details | bool | No | Whether to return the requested symbol details, default is false |
Response
TigerOpenAPI.Quote.Response.KlineQuotaResponse
source
Use KlineQuotaResponse.Data
to access the data. This property returns a QuotaItem
object list, where TigerOpenAPI.Quote.Response.QuotaItem
has the following attributes :
Name | Type | Description |
---|---|---|
used | int | used count |
remain | int | number left |
method | string | api method (kline: stock Kline; future_kline: futures Kline; option_kline: options Kline; history_timeline: stock history time line ) |
details | List<string> | list of the used symbols |
Example
static async Task<KlineQuotaResponse?> GetKlineQuotaAsync(QuoteClient quoteClient)
{
TigerRequest<KlineQuotaResponse> request = new TigerRequest<KlineQuotaResponse>()
{
ApiMethodName = QuoteApiService.KLINE_QUOTA,
ModelValue = new KlineQuotaModel() { WithDetails = true }
};
return await quoteClient.ExecuteAsync(request);
}
Response Example
{
"data":[
{
"remain":1998,
"used":2,
"method":"kline",
"details":[
"AAPL",
"CCEP"
]
},
{
"remain":197,
"used":3,
"method":"future_kline",
"details":[
"XC2307",
"ES2306",
"JPY2306"
]
},
{
"remain":1999,
"used":1,
"method":"option_kline",
"details":[
"AAPL"
]
},
{
"remain":2000,
"used":0,
"method":"history_timeline",
"details":[
]
}
],
"code":0,
"message":"success",
"timestamp":1687329229764,
"sign":"Z9Xdhfqr87AFb7uWozzWosRT9s902+KN3Se64hct2MWz1tuugv8feK+DkZpPD8597GlTqWvabtl/RqYGWL7zQSWxYkclnER1OxBDGjq/Lu0zZEWpjAiCsfi5w93FlkSPn6iA9gvy44KSLVVBY0nWQaVyGAnOyQ1+8FYfuFeek+Y="
}