Common

About 4 min

Grab Quote Permission TigerHttpRequest(MethodName.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.

By default, the market grab permission is executed once at startup. If you need to configure not to grab the market at startup, you can configure isAutoGrabPermission = false before obtaining the TigerHttpClient instance.

ClientConfig.DEFAULT_CONFIG.isAutoGrabPermission = false;
TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(ClientConfig.DEFAULT_CONFIG);

Argmuments

N/A

Response

Data fieldTypeDescription
namestringName of the quote permission subscription
expireAtlongExpiration time (-1 means never expire)

name description

name field valuedescription
hkStockQuoteLv2Hong Kong Stocks Lv2 permission, free Hong Kong Stocks API market for mainland IP, cannot be purchased separately, free for mainland users
hkStockQuoteLv2GlobalLv2 access to Hong Kong stocks, providing real-time quotation data, 10 orders, transaction details and brokerage queue, non-mainland users need to buy
usQuoteBasicU.S. stock Lv1 quotes, after purchasing API quotes, you can get it in the API Exchange listed securities (including U.S. stocks and ETFs, excluding U.S. stocks Lv1 real-time market information including futures and US stock options
usStockQuoteLv2TotalviewU.S. stock Lv2 quotes, After purchasing API quotes, you can get it in the API Exchange listed securities (including U.S. stocks and ETFs,* *Not including US stock futures and US stock options **) market information
usOptionQuoteU.S. stock options Lv1, data based on OPRA, displaying the latest price and best buy/sell data based on quotations from 16 exchanges
CMEFuturesQuoteLv2Chicago Mercantile Exchange Lv2 permission, after purchasing Chicago Mercantile Exchange Lv2 market data, you can obtain real-time market data of futures traded on CME through API. The futures categories traded by CME include Nasdaq, S&P 500 index futures and exchange rate futures, etc.
CBOOTFuturesQuoteLv2Chicago Board of Trade Lv2 permission, after purchasing Chicago Board of Trade Lv2 market data, you can obtain real-time market data of futures traded at CBOT through API, futures traded at CBOT include ** Dow Jones index futures, agricultural products and interest rates Futures** etc.
CBOEFuturesQuoteLv2Chicago Board Options Exchange Lv2 permission, after purchase, you can get L2 real-time market data of futures traded on Chicago Options Exchange via API
NYMEXFuturesQuoteLv2New York Mercantile Exchange Lv2 permission, after purchasing the New York Mercantile Exchange Lv2 market data, you can obtain real-time market data of futures traded on NYMEX through the API. The futures categories traded on NYMEX include US crude oil, natural gas and other energy futures.
COMEXFuturesQuoteLv2New York Mercantile Exchange Lv2 permission, after purchasing the New York Mercantile Exchange Lv2 market data, you can obtain real-time market data of futures traded on COMEX through API. The futures categories traded by COMEX include gold, silver and other metal futures.
HKEXFuturesQuoteLv2Hong Kong Exchange Lv2 authority, Hong Kong Futures Exchange Lv2 market authority includes Hong Kong Futures L2 and Hong Kong Options L2 market data (Mainland users can obtain option L2 market data for free, no need to purchase separately)
SGXFuturesQuoteLv2Singapore Exchange Lv2 permission, after purchase, you can get the L2 market data of futures traded on Singapore Futures Exchange via API
OSEFuturesQuoteLv2Osaka Exchange Lv2 permission, after purchase, you can get the L2 real-time market data of futures traded on Osaka Futures Exchange through API**
EUREXFuturesQuoteLv2European Exchange Lv2 permission, after purchase, you can obtain L2 real-time market data of futures traded on European Exchange via API

Example

TigerHttpRequest request = new TigerHttpRequest(MethodName.GRAB_QUOTE_PERMISSION);
String bizContent = AccountParamBuilder.instance()
        .buildJson();
request.setBizContent(bizContent);
TigerHttpResponse response = client.execute(request);

Response Example

{
  "code": 0,
  "message": "success",
  "timestamp": 1525938835697,
  "data": [{"name":"usQuoteBasic","expireAt":1621931026000}]
}

Get Permission List TigerHttpRequest(MethodName.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 fieldTypeDescription
namestringName of the quote permission subscription
expireAtlongExpiration time (-1 means never expire)

Example

TigerHttpRequest request = new TigerHttpRequest(MethodName.GET_QUOTE_PERMISSION);
String bizContent = AccountParamBuilder.instance()
        .buildJson();
request.setBizContent(bizContent);
TigerHttpResponse response = client.execute(request);

Response 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
        },
        {
            "name":"aStockQuoteLv1",
            "expireAt":-1
        }
    ]
}

Refresh Token

Require: UserTokenRefreshRequest

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 'clientConfig.isAutoRefreshToken = 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 fieldTypeDescription
tigerIdstringtigerId
licensestringlicense
tokenstringtoken
createTimelongcreate time
expiredTimelongexpired 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());
    }

Response 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 Kline Quota

Request: KlineQuotaRequest

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

ArgumentTypeRequiredDescription
with_detailsboolNoWhether to return the requested symbol details, default is false

Response

com.tigerbrokers.stock.openapi.client.https.response.quote.KlineQuotaResponsesourceopen in new window

Use KlineQuotaResponse.getQuotaItems() to access the data. This method returns a QuotaItem object, where com.tigerbrokers.stock.openapi.client.https.domain.quote.item.QuotaItem has the following attributes :

NameTypeDescription
usedintused count
remainintnumber left
methodStringapi method (kline: stock Kline; future_kline: futures Kline; option_kline: options Kline; history_timeline: stock history time line )
detailsList<String>list of the used symbols

Example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
      ClientConfig.DEFAULT_CONFIG);

KlineQuotaResponse response = client.execute(
        KlineQuotaRequest.newRequest(Boolean.TRUE));
if (response.isSuccess()) {
  System.out.println(JSONObject.toJSON(response));
} else {
  System.out.println("response error:" + response.getMessage());
}

Response Example

{
    "code":0,
    "data":[
        {
            "details":[
                "AAPL",
                "CCEP"
            ],
            "method":"kline",
            "remain":1998,
            "used":2
        },
        {
            "details":[
                "XC2307",
                "ES2306",
                "JPY2306"
            ],
            "method":"future_kline",
            "remain":197,
            "used":3
        },
        {
            "details":[
                "AAPL"
            ],
            "method":"option_kline",
            "remain":1999,
            "used":1
        },
        {
            "details":[],
            "method":"history_timeline",
            "remain":2000,
            "used":0
        }
    ],
    "message":"success",
    "sign":"aVVcc9ULHPQpDDUR4c7jKlB+TM49aJtyjpbKXiZhaSwbGzIKLtl+1UEQKjZjWMOOMIHsD5GId5Yod3cidPYvP0pH2HH72m6q3pyQdFl5r3cnSZ82SS1zwgPQaPP4NvMsgoeh98/iRm69S/1LUKsToIivF3ztkaepj/g0n0IT2lA=",
    "success":true,
    "timestamp":1687320236018
}
Last update: