Stocks

About 16 min

Get Market Status QuoteMarketRequest

Require: QuoteMarketRequest

Description

Get the maket status of a queried market, and get the most recent open time of this market

Argument

ArgumentTypeRequiredDescription
marketstringYesUS-U.S. Stocks,HK-Hongkong Stocks,CN-A-Shares, ALL-all markets
langstringNoLanguage: zh_CN,zh_TW,en_US, By default: en_US

Response

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

Structured as follows:

public class QuoteMarketResponse extends TigerResponse {
  @JSONField(
    name = "data"
  )
  private List<MarketItem> marketItems;
}

Use QuoteMarketResponse.getMarketItems(), acutal data returned is a list of marketItem. com.tigerbrokers.stock.openapi.client.https.domain.quote.item.MarketItem has the following attributes:

NameTypeDescription
marketstringname of the Market being queried(US, CN, HK, etc.)
marketStatusstringMarket Status, not a constant. This information includes holidays
statusstringMarket Status, NOT_YET_OPEN,PRE_HOUR_TRADING, TRADING,MIDDLE_CLOSE,POST_HOUR_TRADING, CLOSING,EARLY_CLOSED, MARKET_CLOSED
openTimestringMost recent future open time MM-dd HH:mm:ss

Use get() method of MarketItem, in this case, getMarket(), to acess the data. or use toString() to convert the data to a string

Example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
    ClientConfig.DEFAULT_CONFIG);
QuoteMarketResponse response = client.execute(QuoteMarketRequest.newRequest(Market.US));
if (response.isSuccess()) {
  System.out.println(Arrays.toString(response.getMarketItems().toArray()));
} else {
  System.out.println("response error:" + response.getMessage());
}

Response Example

{
  "code": 0,
  "message": "success",
  "timestamp": 1525938835697,
  "data": [{"market":"US","marketStatus":"Closed Independence Day","status":"CLOSING","openTime":"07-04 09:30:00 EDT"}]
}

Get Trading Calendar QuoteTradeCalendarRequest

request: QuoteTradeCalendarRequest

Description

The trading day is obtained by excluding weekends and holidays from the natural day and does not exclude temporary market closures

Argument

ArgumentTypeRequiredDescription
marketMarketYesfilter by market, you can use the enums defined in Market, such as Market.US, Market.HK, Market.CN
begin_datestringNobegin date of calendar,include this day. format yyyy-MM-dd, like '2022-06-01'
end_datestringNoend date of calendar,exclude this day. format yyyy-MM-dd

begin_time and end_time arguments' description:

begin_time is passedend_time is passeddescription
yesyesbegin_time, end_time are the values passed
yesnoend_time is 365 days after begin_time
noyesbegin_time is 365 days before end_time
nonobegin_time is the current date, end_time is 30 days after begin_time

Response

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

Structured as follows:

public class QuoteTradeCalendarResponse extends TigerResponse {

  @JSONField(name = "data")
  private List<TradeCalendar> items;
}

Use QuoteTradeCalendarResponse.getItems(), acutal data returned is a list of TradeCalendar. com.tigerbrokers.stock.openapi.client.https.domain.quote.item.TradeCalendar has the following attributes:

NameTypeDescription
datestringtrade day date
typestringtrade day type. TRADING: whole day trading; EARLY_CLOSE: close market early

Example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
      ClientConfig.DEFAULT_CONFIG);
QuoteTradeCalendarRequest request = QuoteTradeCalendarRequest.newRequest(
        Market.US, "2022-06-01", "2022-06-30");
QuoteTradeCalendarResponse response = client.execute(request);
if (response.isSuccess()) {
  System.out.println(Arrays.toString(response.getItems().toArray()));
} else {
  System.out.println("response error:" + response.getMessage());
}

Response Example

{
    "code":0,
    "message":"success",
    "timestamp":1655968809209,
    "data":[{"date":"2022-06-01","type":"TRADING"},{"date":"2022-06-02","type":"TRADING"},{"date":"2022-06-03","type":"TRADING"},{"date":"2022-06-06","type":"TRADING"},{"date":"2022-06-07","type":"TRADING"},{"date":"2022-06-08","type":"TRADING"},{"date":"2022-06-09","type":"TRADING"},{"date":"2022-06-10","type":"TRADING"},{"date":"2022-06-13","type":"TRADING"},{"date":"2022-06-14","type":"TRADING"},{"date":"2022-06-15","type":"TRADING"},{"date":"2022-06-16","type":"TRADING"},{"date":"2022-06-17","type":"TRADING"},{"date":"2022-06-21","type":"TRADING"},{"date":"2022-06-22","type":"TRADING"},{"date":"2022-06-23","type":"TRADING"},{"date":"2022-06-24","type":"TRADING"},{"date":"2022-06-27","type":"TRADING"},{"date":"2022-06-28","type":"TRADING"},{"date":"2022-06-29","type":"TRADING"}],
    "sign":"QEHsOPx7JSp5VZ3eYatbTLXy7wK7RIgWMqQfqEuEog+tQ12ThnucHPoXpcFj8wgwUU77KhLDL6KVgNBPC/D1GgXKPaWPo1E77d9Nabd9OYAwqNINP//GSuEd8ai7b32EQ4uWTrF3ycQh7g7Lb7f5nvqZypmFuaphFyTEoQfwKp8="
}

Get Symbol List QuoteSymbolRequest

request: QuoteSymbolRequest

Description

Get a list of all symbols filtered by market

Argument

ArgumentTypeRequiredDescription
marketstringYesUS, HK, CN
include_otcbooleanNoWhether to include OTC symbols, default: false
langstringNoLanguage: zh_CN,zh_TW,en_US. en_US by default

Response

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

Structured as follows

public class QuoteSymbolResponse extends TigerResponse {

  @JSONField(name = "data")
  private List<String> symbols;
}

Use QuoteSymbolResponse.getSymbols() to get the data returned from the server. The result is a list that contains the stock symbols

Example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(ClientConfig.DEFAULT_CONFIG);
QuoteSymbolResponse response = client.execute(QuoteSymbolRequest.newRequest(Market.US).includeOTC(false));
if (response.isSuccess()) {
  System.out.println(Arrays.toString(response.getSymbols().toArray()));
} else {
  System.out.println("response error:" + response.getMessage());
}

Return Example

{
  "code": 0,
  "message": "success",
  "timestamp": 1525938835697,
  "data": ["A", "A.W", "AA", "AA-B", "AAAP", "AABA", "AAC", "AADR", "AAIT", "AAL", "AALCP", "AAMC", "AAME"]
}

Get Symbols and Names QuoteSymbolNameRequest

request: QuoteSymbolNameRequest

Description

Get the ticker symbols and names of all securities in the selected market

Argument

ArgumentTypeRequiredDescription
marketstringYesUS, HK, CN
include_otcbooleanNoWhether to include OTC symbols, default: false
langstringNoLanguage: zh_CN,zh_TW,en_US, en_US by default

Response

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

Structured as follows

public class QuoteSymbolNameResponse extends TigerResponse {

  @JSONField(name = "data")
  private List<SymbolNameItem> symbolNameItems;
}

Use QuoteSymbolNameResponse.getSymbolNameItems() to acess the data. The return of this method is a list of SymbolNameItem objects, where com.tigerbrokers.stock.openapi.client.https.domain.quote.item.symbolNameItems has the following attributes:

NameTypeDescription
namestringName
symbolstringSymbol

To access the data in SymbolNameItem object, one can use getName() method, or use toString() method to convert the data to a string

Example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(ClientConfig.DEFAULT_CONFIG);
QuoteSymbolNameResponse response = client.execute(QuoteSymbolNameRequest.newRequest(Market.US).includeOTC(false));
if (response.isSuccess()) {
  System.out.println(Arrays.toString(response.getSymbolNameItems().toArray()));
} else {
  System.out.println("response error:" + response.getMessage());
}

Response Example

{
  "code": 0,
  "message": "success",
  "timestamp": 1525938835697,
  "data": [{"name":"CKH Holdings","symbol":"00001"},{"name":"CLP","symbol":"00002"}]
}

Get Delayed Data QuoteDelayRequest

request:

Description

Get delayed market data for U.S. stocks. An active market data permission subscription is not required. This data is only available for U.S stocks. The data is delayed by 15 minutes

Argument

ArgumentTypeRequiredDescription
symbolsarrayYesStock ticker symbols, U.S. stock only

Example

List<String> symbols = new ArrayList<>();
symbols.add("AAPL");
symbols.add("TSLA");
QuoteDelayRequest delayRequest = QuoteDelayRequest.newRequest(symbols);
QuoteDelayResponse response = client.execute(delayRequest);

Response

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

Structured as follows:

public class QuoteDelayResponse extends TigerResponse {

  @JSONField(name = "data")
  private List<QuoteDelayItem> quoteDelayItems;
  }

Use TigerResponse.getQuoteDelayItems() to access the data. This method will return a list of QuoteDelayItem objects, wherecom.tigerbrokers.stock.openapi.client.https.domain.quote.item.quoteDelayItem has the following attributes:

ArgumentTypeDescription
closedoubleclose price
highdoublehigh price
lowdoublelow price
opendoubleopening price
preClosedoubleclose price of the last trading day
timelongtime
volumelongvolume

Use the get method, such as getClose() , to access the data fields in QuoteDelayItem

Response Example

[
  {
    "close": 156.81,
    "halted": 0,
    "high": 160.45,
    "low": 156.36,
    "open": 159.565,
    "preClose": 161.94,
    "symbol": "AAPL",
    "time": 1637949600000,
    "volume": 76959752
  },
  {
    "close": 1081.92,
    "halted": 0,
    "high": 1108.7827,
    "low": 1081,
    "open": 1099.47,
    "preClose": 1116,
    "symbol": "TSLA",
    "time": 1637949600000,
    "volume": 11680890
  }
]

Get Timeline Data QuoteTimelineRequest

request: QuoteTimelineRequest

Description

Get timeline data

Argument

ArgumentTypeRequiredDescription
symbolsarrayYesAn array of stock ticker symbols
periodstringYesperiod. 'day' or 'day5'
trade_sessionStringNoTradeSession:PreMarket,Regular,AfterHours; Regular by default
begin_timelongNoBegin time (timestamp in ms), default value is to return the data starting from today
langstringNoLangauge: zh_CN,zh_TW,en_US. en_US by default

Response

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

structured as follows:

The returned data can be accessed with QuoteTimelineResponse.getTimelineItems(). This method will return a list of TimelineItem objects, where com.tigerbrokers.stock.openapi.client.https.domain.quote.item.TimelineItem has the following attributes:

NameTypeDescription
symbolstringTicker symbol of the stocks
periodstringperiod, day or 5day
preClosedoubleclose price of the last trading day
intradayobjectintraday data, see below for contained data fields
preMarketobject(U.S. Stocks Only) pre-market data object
afterHoursobject(U.S. Stocks Only) after-market data object
Use corresponding get method, such as getSymbol() to access data in TimelineItem

intraday:

NameDescription
volumeVolume
avgPriceaverage price
pricelast price
timetimestamp of the strating time of the minute

Example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(ClientConfig.DEFAULT_CONFIG);
QuoteTimelineResponse response = client.execute(QuoteTimelineRequest.newRequest(List.of("AAPL"), 1544129760000L));
if (response.isSuccess()) {
  System.out.println(Arrays.toString(response.getTimelineItems().toArray()));
} else {
  System.out.println("response error:" + response.getMessage());
}

Response Example

{
  "code": 0,
  "data": [
    {
      "symbol": "AAPL",
      "preMarket": {
        "endTime": 1544106600000,
        "beginTime": 1544086800000,
        "items": [
           
        ]
      },
      "period": "day",
      "preClose": 176.69000244140625,
      "afterHours": {
        "endTime": 1544144400000,
        "beginTime": 1544130000000,
        "items": [
          {
            "volume": 872772,
            "avgPrice": 174.71916,
            "price": 174.69,
            "time": 1544130000000
          },
          {
            "volume": 3792,
            "avgPrice": 174.71893,
            "price": 174.66,
            "time": 1544130060000
          }
        ]
      },
      "intraday": [
        {
          "items": [
            {
              "volume": 201594,
              "avgPrice": 172.0327,
              "price": 174.34,
              "time": 1544129760000
            },
            {
              "volume": 139040,
              "avgPrice": 172.03645,
              "price": 174.4156,
              "time": 1544129820000
            },
            {
              "volume": 178427,
              "avgPrice": 172.0413,
              "price": 174.44,
              "time": 1544129880000
            },
            {
              "volume": 2969567,
              "avgPrice": 172.21619,
              "price": 174.72,
              "time": 1544129940000
            }
          ]
        }
      ]
    }
  ],
  "timestamp": 1544185099595,
  "message": "success"
}

Get Historical Timeline Data QuoteHistoryTimelineRequest

request: QuoteHistoryTimelineRequest

Description

Obtain historical time-sharing data of 1 minute

parameter

parametertyperequireddescription
symbolsarrayYesStock symbol list
datestringYesyear, month, day yyyyMMdd, such as 20220420
rightRightOptionNoBefore restoration: br, No restoration: nr; Default: nr

return

com.tigerbrokers.stock.openapi.client.https.response.quote.QuoteHistoryTimelineResponse [source](https://github.com/tigerfintech/openapi-java-sdk/blob/master/src/main/java/com /tigerbrokers/stock/openapi/client/https/response/quote/QuoteHistoryTimelineResponse.java)

The specific structure is as follows:

The returned data can be accessed through the QuoteHistoryTimelineResponse.getTimelineItems() method, which returns a List containing HistoryTimelineItem objects, where com.tigerbrokers.stock.openapi.client.https.domain.quote.item.HistoryTimelineItem properties are as follows:

FieldTypeDescription
symbolstringstock code
itemsTimelinePointIntraday time-sharing array, please refer to the description below for the fields

The specific fields of TimelineItem can be accessed through the get method of the object, such as getSymbol()

Time-sharing data items field TimelinePoint:

Timeshare fieldDescription
volumeVolume
avgPriceaverage transaction price
priceLatest Price
timecurrent time-sharing time

example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
       ClientConfig.DEFAULT_CONFIG);
List<String> symbols = new ArrayList<>();
symbols.add("AAPL");
QuoteHistoryTimelineRequest request = QuoteHistoryTimelineRequest.newRequest(symbols, "20220420");
request.withRight(RightOption.br);
QuoteHistoryTimelineResponse response = client. execute(request);
if (response. isSuccess()) {
   System.out.println(Arrays.toString(response.getTimelineItems().toArray()));
} else {
   System.out.println("response error:" + response.getMessage());
}

Response

{
     "code": 0,
     "message": "success",
     "timestamp": 1651737871819,
     "data":[
         {
             "symbol": "AAPL",
             "items":[
                 {
                     "time": 1650461400000,
                     "volume": 1414143,
                     "price": 168.75,
                     "avgPrice": 168.66885
                 },
                 {
                     "time": 1650461460000,
                     "volume":392862,
                     "price": 168.25,
                     "avgPrice": 168.65086
                 },
                 // ....
                 {
                     "time": 1650484680000,
                     "volume": 443549,
                     "price": 167.24,
                     "avgPrice": 167.47902
                 },
                 {
                     "time": 1650484740000,
                     "volume":6457118,
                     "price": 167.23,
                     "avgPrice": 167.45808
                 }
             ]
         }
     ]
}

Get Realtime Quote QuoteRealTimeQuoteRequest

request: QuoteRealTimeQuoteRequest

Description

Get real-time data for a stock/stocks. An active market quote permission is required.

Argument

ArgumentTypeRequiredDescription
symbolsarrayYeslist of stock ticker symbols (maximum 50 per request)
includeHourTradingBooleanNoWhether to include U.S. stocks before and after the market data, default: false
langstringNolanguage: zh_CN,zh_TW,en_US. en_US by default

Response

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

Use QuoteRealTimeQuoteResponse.getRealTimeQuoteItems() to access data. The method returns a RealTimeQuoteItem object,where com.tigerbrokers.stock.openapi.client.https.domain.quote.item.RealTimeQuoteItem has the following attributes:

NameTypeDescription
symbolstringstock ticker symbol
opendoubleopening price
highdoublehigh price
lowdoublelow price
closedoubleclose price
preClosedoubleclose price of last trading day
latestPricedoublelast price
latestTimelonglatest trade time
askPricedoubleask price
askSizelongask size
bidPricedoublebid price
bidSizelongbid size
volumelongvolume
statusstringstatus
hourTradingobjectU.S. stocks pre-market and post-market data(Response hourTrading only before and after the market time)

hourTrading has the following attributes:

NameTypeDescription
tagstringpre-market("Pre-Mkt")、post-market("Post-Mkt") tag
latestPricedoublelast price
preClosedoubleclose price of the last trading day
latestTimestringlatest trade time
volumelongtrading volume
timestamplonglatest trade time in timestamp(ms)

Use the get method, getSymbol() to access the actual data

Example

QuoteRealTimeQuoteResponse response = client.execute(QuoteRealTimeQuoteRequest.newRequest(List.of("AAPL"), true));
if (response.isSuccess()) {
  System.out.println(Arrays.toString(response.getRealTimeQuoteItems().toArray()));
} else {
  System.out.println("response error:" + response.getMessage());
}

Response

{
    "code":0,
    "data":[
        {
            "askPrice":174.8,
            "latestPrice":175.08,
            "symbol":"AAPL",
            "bidSize":200,
            "bidPrice":174.71,
            "volume":116803357,
            "high":175.96,
            "preClose":171.18,
            "low":170.7,
            "hourTrading":{
                "volume":3418089,
                "latestPrice":174.72,
                "preClose":175.08,
                "latestTime":"18:50 EST",
                "tag":"Post-Mkt",
                "timestamp":1639007439976
            },
            "latestTime":1638997200000,
            "close":175.08,
            "askSize":200,
            "open":172.125,
            "status":"NORMAL"
        }
    ],
    "success":true,
    "sign":"BxcUz9YfmWcnSsmQKLcnFnVpHAT5bDdX69YntqaVIVdVqMlhSaaaW8ur3yaWP6GB6NAec2ds6s1ZB/4X40kg8lHb6u6y2V0hvHE2Q3uDNgkoukmDcAetdwRo/MAiqtQRACFGAd/AOlyhDsJyuzTf7T14zDMl5cfOfbwe2+RDjgg=",
    "message":"success",
    "timestamp":1639007449806
}

Get Bars QuoteKlineRequest

Description

Get K-line (bar) Data, including different time periods, such as daily, weekly, minute, etc.

Argument

ArgumentTypeRequiredDescription
symbolsarrayYesA list of symbols. Maximum 50 per request, 10 for A-Shares
periodstringYesK line period, possible values are: day, week, month, year, 1min, 3min, 5min, 15min, 30min, 60min
rightstringNoAdjuestment type. Default value is forward adjustment. br: forward adjust,nr: No adjustment
begin_timelongNoBegin time. Unix time stamp in millisecond or a date string. Example: 1639371600000, default value is -1, which means unbounded.
end_timelongNoEnd time. Unix time stamp in millisecond or a date string. Example: 1639371600000, default value is -1, which means unbounded.
limitintegerNoThe maximum number of bars returned. Default value is 300. Maximum is 1200
langstringNoLanguage: zh_CN,zh_TW,en_US. en_US by default
pageTokenstringNoPaging query token (only a single symbol is supported, while using 'begin_time' query), other query conditions cannot be changed when using pageToken to pull data by paging

Response

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

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

NameTypeDescription
symbolstringSymbol
periodstringK-line period
nextPageTokenstringthe page token used for querying the next page, if there is no more data, return null
itemsarrayarray that contains the KlinePoint object

KlinePoint have the following attributes:

NameTypeDescription
closedoubleclose price
highdoublehigh price
lowdoublelow price
opendoubleopen price
timelongtime
volumelongvolume
amountdoubletrading amount

Use the get method getSymbol() to acess the actual data

Example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
      ClientConfig.DEFAULT_CONFIG);
List<String> symbols = new ArrayList<>();
symbols.add("AAPL");
QuoteKlineResponse response = client.execute(QuoteKlineRequest.newRequest(symbols, KType.day, "2023-05-16", "2023-05-19")
        .withLimit(1000)
        .withRight(RightOption.br));
if (response.isSuccess()) {
  System.out.println(JSONObject.toJSONString(response));
} else {
  System.out.println("response error:" + response.getMessage());
}

Response Example

{
    "code":0,
    "data":[
        {
            "items":[
                {
                    "amount":7140962535.379684,
                    "close":172.07,
                    "high":173.1383,
                    "low":171.7991,
                    "open":171.99,
                    "time":1684209600000,
                    "volume":42110293
                },
                {
                    "amount":9878512463.233082,
                    "close":172.69,
                    "high":172.925,
                    "low":170.4201,
                    "open":171.71,
                    "time":1684296000000,
                    "volume":57951604
                },
                {
                    "amount":9839606365.96335,
                    "close":175.05,
                    "high":175.24,
                    "low":172.58,
                    "open":173,
                    "time":1684382400000,
                    "volume":65496657
                }
            ],
            "period":"day",
            "symbol":"AAPL"
        }
    ],
    "message":"success",
    "sign":"vayBuY47WEr6fJeKKlylYqtpNHlWLbguhO9EbUQNR8Y0MdN51ju2BnPuGnNMyBZkiwBL+rG0KuUW0vbQYXGGmiIV3gfxAJA2NwXaLvOK2iQiSOzc6fAuBzyGe1etDtcvnn5apBFB5opLKVqb+lpLEhsPLzcv8rPV6I1ZCLMeQhU=",
    "success":true,
    "timestamp":1684831488647
}

PageToken Example

    List<String> symbols = new ArrayList<>();
    symbols.add("AAPL");
    QuoteKlineRequest request = QuoteKlineRequest.newRequest(symbols, KType.min1,
        "2022-04-25 00:00:00",
        "2022-04-28 00:00:00", TimeZoneId.NewYork);
    request.withLimit(200);
    request.withRight(RightOption.br);

    int count = 1;
    while (true) {
      QuoteKlineResponse response = client.execute(request);
      System.out.println(
          "search time:" + count + ", success:" + response.isSuccess() + ", msg:" + response.getMessage());
      if (!response.isSuccess()) {
        break;
      }
      System.out.println(response.getKlineItems());
      if (response.getKlineItems().size() == 0) {
        break;
      }
      KlineItem klineItem = response.getKlineItems().get(0);
      if (klineItem.getNextPageToken() == null) {
        break;
      }
      count++;
      // 10 times per minute
      try {
        TimeUnit.SECONDS.sleep(6);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      // set pagination token then query the next page
      request.withPageToken(klineItem.getNextPageToken());
    }

PageToken Tools The default is 1,000 per page, and 10,000 pieces of data for paging query will be returned after the client merges. You can refer to several overloaded methods provided by the tool class. The tool method can collect up to 10,000 pieces of data at a time; in addition, pay attention to the data size setting of each page. The server will calculate a request for each paging request, which will affect the frequency of interface calls. You can implement it yourself by referring to the example, pay attention to the page turning boundary to avoid infinite loops


  List<KlinePoint> list =
      PageTokenUtil.getKlineByPage("AAPL", KType.min1,
          "2022-04-25 00:00:00",
          "2022-04-28 00:00:00", TimeZoneId.NewYork,
          RightOption.br, 10, 30, PageTokenUtil.DEFAULT_TIME_INTERVAL);
  for (KlinePoint item : list) {
    System.out.println("content:" + item);
  }

Get in-depth market data

Corresponding request class: QuoteDepthRequest

Description

Obtain the N file pending order data of the input securities code, including entrusted price, quantity and order number, and the upper limit of a single request is 50

warning CAUTION The closing auction time of Hong Kong stocks trading day is 16:00-16:10 (the market is randomly closed between 16:08 and 16:10), and the last in-depth ranking data of the day is usually updated a minute or two after 16:10

Request Frequency For frequency limit, please refer to: Request Frequency Limit

parameter

parametertyperequireddescription
symbolsarrayYesStock code list (up to 50 for one time)
marketstringYesUS US stocks, HK stocks, CN A shares, ALL (refer to the Market enumeration class)

return

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

The specific structure is as follows

public class QuoteDepthResponse extends TigerResponse {

   @JSONField(name = "data")
   private List<QuoteDepthItem> quoteDepthItems;
}

The returned data can be accessed through the QuoteDepthResponse.getQuoteDepthItems() method, which returns a List containing QuoteDepthItem objects, where com.tigerbrokers.stock.openapi.client.https.domain.quote.item.QuoteDepthItem properties are as follows:

FieldTypeDescription
symbolstringstock code
askslist
bidslistbuy order

The order details fields are as follows:

FieldTypeDescription
pricedoubleorder price
volumelongorder volume
countintNumber of entrusted orders (only available in the Hong Kong stock market, not available in the US stock market)

Example

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

List<String> symbols = new ArrayList<>();
symbols.add("DD");
QuoteDepthResponse response = client.execute(QuoteDepthRequest.newRequest(symbols, Market.US.name()));
if (response. isSuccess()) {
   for (QuoteDepthItem item : response. getQuoteDepthItems()) {
     System.out.println(item.getSymbol());
     System.out.println(Arrays.toString(item.getAsks().toArray()));
     System.out.println(Arrays.toString(item.getBids().toArray()));
   }
} else {
   System.out.println("response error:" + response.getMessage());
}

Response

{
   "code": 0,
   "message": "success",
   "timestamp": 1653064415298,
   "data":[
     {"symbol":"DD",
      "asks":[{"price":62.88,"count":0,"volume":50},{"price":62.88,"count":0,"volume":27},{"price": 62.89,"count":0,"volume":50},{"price":62.89,"count":0,"volume":200},{"price":62.89,"count":0,"volume ":100},{"price":62.9,"count":0,"volume":50},{"price":62.9,"count":0,"volume":10},{"price": 62.91,"count":0,"volume":50},{"price":62.91,"count":0,"volume":100},{"price":62.92,"count":0,"volume ":50},{"price":62.92,"count":0,"volume":50},{"price":62.92,"count":0,"volume":100},{"price": 62.93,"count":0,"volume":50},{"price":62.93,"count":0,"volume":49},{"price":62.93,"count":0,"volume ":100},{"price":62.94,"count":0,"volume":50},{"price":62.94,"count":0,"volume":300},{"price": 62.95,"count":0,"volume":50},{"price":62.96,"count":0,"volume":50},{"price":62.97,"count":0,"volume ":50},{"price":62.98,"count":0,"volume":50},{"price":62.99,"count":0,"volume":50},{"price": 62.99,"count":0,"volume":100},{"price":63.0,"count":0,"volume":50},{"price":63.01,"count":0,"volume ":50},{"price":63.02,"count":0,"volume":100},{"price":63.02,"count":0,"volume":50},{"price": 63.03,"count":0,"volume":100},{"price":63.03,"count":0,"volume":50},{"price":63.05,"count":0,"volume ":18},{"price":63.05,"count":0,"volume":100},{"price":63.07,"count":0,"volume":200},{"price": 63.16,"count":0,"volume":100},{"price":63.32,"count":0,"volume":100},{"price":63.32,"count":0,"volume ":100},{"price":63.48,"count":0,"volume":100},{"price":63.5,"count":0,"volume":100},{"price": 63.88,"count":0,"volume":800},{"price":63.88,"count":0,"volume":100},{"price":64.14,"count":0,"volume ":100}],
      "bids":[{"price":62.86,"count":0,"volume":50},{"price":62.86,"count":0,"volume":200},{"price": 62.86,"count":0,"volume":2},{"price":62.86,"count":0,"volume":6},{"price":62.85,"count":0,"volume ":50},{"price":62.84,"count":0,"volume":50},{"price":62.84,"count":0,"volume":100},{"price": 62.83,"count":0,"volume":50},{"price":62.82,"count":0,"volume":50},{"price":62.82,"count":0,"volume ":300},{"price":62.81,"count":0,"volume":50},{"price":62.8,"count":0,"volume":50},{"price": 62.79,"count":0,"volume":50},{"price":62.78,"count":0,"volume":50},{"price":62.77,"count":0,"volume ":50},{"price":62.76,"count":0,"volume":50},{"price":62.76,"count":0,"volume":100},{"price": 62.75,"count":0,"volume":50},{"price":62.75,"count":0,"volume":100},{"price":62.74,"count":0,"volume ":50},{"price":62.73,"count":0,"volume":50},{"price":62.73,"count":0,"volume":100},{"price": 62.7,"count":0,"volume":100},{"price":62.67,"count":0,"volume":50},{"price":62.67,"count":0,"volume ":200},{"price":62.62,"count":0,"volume":11},{"price":62.62,"count":0,"volume":100},{"price": 62.61,"count":0,"volume":100},{"price":62.59,"count":0,"volume":100},{"price":62.58,"count":0,"volume ":45},{"price":62.5,"count":0,"volume":20},{"price":62.27,"count":0,"volume":100},{"price": 62.25,"count":0,"volume":100},{"price":62.25,"count":0,"volume":100},{"price":62.1,"count":0,"volume ":500},{"price":62.1,"count":0,"volume":10},{"price":62.0,"count":0,"volume":8},{"price": 61.94,"count":0,"volume":100},{"price":61.9,"count":0,"volume":100},{"price":61.74,"count":0,"volume ":800}]
     }
   ]
}

Get Trade Ticks QuoteTradeTickRequest

request:QuoteDepthRequest

Description

Get the tick data of selected stocks

Argument

ArgumentTypeRequiredDescription
symbolsarrayYesAn array of ticker symbol of a list of stocks
trade_sessionStringNoTradeSession:PreMarket,Regular,AfterHours; Regular by default
limitintegerNoMaximum number of data points, 2000 by default. Returns the number of recent deals for each symbol.
langstringNoLanguage: zh_CN,zh_TW,en_US, en_US by default

beginIndex and endIndex parameter usage instructions

Query methodbeginIndexendIndexDescription
Query the latest record by record-1-1By default, return the latest record by limit. limit is 200 by default
Query each day according to the intervalSpecific valueSpecific valueFor example: beginIndex=10, endIndex=100, 90 records including 10 to 99 will be returned. If limit is set to 20, 20 records from 10 to 29 will be returned.

Response

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

Structured as follows:

public class QuoteTradeTickResponse extends TigerResponse {

  @JSONField(name = "data")
  private List<TradeTickItem> tradeTickItems;
}

Use QuoteTradeTickResponse.getTradeTickItems() to access returned data. The method will return a TradeTickItem object,com.tigerbrokers.stock.openapi.client.https.domain.quote.item.TradeTickItem has the following attributes:

NameTypeDescription
beginIndexlongStart index of the returned data
endIndexlongEnd index of the returned data
symbolstringStock ticker symbol
itemsList<TickPoint>List contains the acutal data, a TickPoint corresponds to a data point

TickPoint has the following attributes:

NameTypeDescription
timelongTrading time
pricedoublePrice
volumelongVolume
typestringDirection of the price change, "+" stands for "active buy", "-" stands for "active sell", "*" stands for "neutral transaction"

Use the get method, getTime() to access the data, or use toString() method to convert the data to a string

Example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
      ClientConfig.DEFAULT_CONFIG);
List<String> symbols = new ArrayList<>();
symbols.add("AAPL");
QuoteTradeTickRequest request = QuoteTradeTickRequest.newRequest(symbols, 0, 30, 10);
request.setTradeSession(TradeSession.Regular);
QuoteTradeTickResponse response = client.execute(request);
if (response.isSuccess()) {
  System.out.println(JSONObject.toJSONString(response));
} else {
  System.out.println("response error:" + response.getMessage());
}

Response Example

{
    "code": 0,
    "data": [
        {
            "beginIndex": 0,
            "endIndex": 10,
            "items": [
                {
                    "price": 169.59,
                    "time": 1712323800003,
                    "type": "*",
                    "volume": 32
                },
                {
                    "price": 169.59,
                    "time": 1712323800003,
                    "type": "*",
                    "volume": 8
                },
                {
                    "price": 169.59,
                    "time": 1712323800003,
                    "type": "*",
                    "volume": 148
                },
                {
                    "price": 169.59,
                    "time": 1712323800003,
                    "type": "*",
                    "volume": 1010
                },
                {
                    "price": 169.59,
                    "time": 1712323800005,
                    "type": "*",
                    "volume": 600
                },
                {
                    "price": 169.59,
                    "time": 1712323800007,
                    "type": "*",
                    "volume": 32
                },
                {
                    "price": 169.59,
                    "time": 1712323800008,
                    "type": "*",
                    "volume": 33
                },
                {
                    "price": 169.59,
                    "time": 1712323800011,
                    "type": "*",
                    "volume": 12
                },
                {
                    "price": 169.59,
                    "time": 1712323800011,
                    "type": "*",
                    "volume": 186
                },
                {
                    "price": 169.59,
                    "time": 1712323800012,
                    "type": "*",
                    "volume": 40
                }
            ],
            "symbol": "AAPL"
        }
    ],
    "message": "success",
    "sign": "XEEDI1HLzWT8rkZp4boFge4OehCeXOVuXJ6U4Lgve1vUz898Ne8Q4CF/f/OIUVcHfC7XbrjqYmHJBwDdQEdfucRdsKH7g0SimlMAnyimNnya4lKIaQ6CRbfE5faEe2sdopjnwZggFkycnCeB0JhiTK72xR5uTC0gGlcaaPY36o4=",
    "success": true,
    "timestamp": 1712557783317
}

Get Trading Requirement QuoteStockTradeRequest

Description

Get the required information for trading, such as lot size, for a tradable asset.

Argument

ArgumentTypeRequiredDescription
symbolsarrayYesSymbols, maximum number supported is 50

Response

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

Structured as follows:

public class QuoteStockTradeResponse extends TigerResponse {

  @JSONField(name = "data")
  private List<QuoteStockTradeItem> stockTradeItems;

  public List<QuoteStockTradeItem> getStockTradeItems() {
    return stockTradeItems;
  }
}

Use QuoteStockTradeResponse.getStockTradeItems()to access the response. The data is contained in QuoteStockTradeItem objects,com.tigerbrokers.stock.openapi.client.https.domain.quote.item.QuoteStockTradeItem has the following attributes:

NameTypeDescription
symbolStringsymbol
lotSizeIntegerlotsize
spreadScaleIntegertick size
minTickDoubleminimum tick

Use the get method getSymbol() to access, or use toString() method to convert the data to a string.

Example

List<String> symbols = new ArrayList<>();
symbols.add("00700");
symbols.add("00810");
QuoteStockTradeResponse response = client.execute(QuoteStockTradeRequest.newRequest(symbols));
if (response.isSuccess()) {
  System.out.println(Arrays.toString(response.getStockTradeItems().toArray()));
} else {
  System.out.println("response error:" + response.getMessage());
}

Response Example

{
  "code": 0,
  "data": [{
    "lotSize": 100,
    "minTick": 0.2,
    "spreadScale": 0,
    "symbol": "00700"
  }, {
    "lotSize": 6000,
    "minTick": 0.001,
    "spreadScale": 0,
    "symbol": "00810"
  }],
  "message": "success",
  "timestamp": 1546853907390
}

Get Capital Flow QuoteCapitalFlowRequest

Description

Get capital net inflow Data, including different time periods, such as daily, weekly, monthly, etc.

Argument

ArgumentTypeRequiredDescription
symbolstringYessymbol
periodstringYesperiod, possible values are: intraday, day, week, month, year, quarter, 6month
marketstringYesUS-U.S. Stocks, HK-Hongkong Stocks, CN-A-Shares
begin_timelongNoBegin time. Unix time stamp in millisecond or a date string. Example: 1639371600000, default value is -1, which means unbounded.
end_timelongNoEnd time. Unix time stamp in millisecond or a date string. Example: 1639371600000, default value is -1, which means unbounded.
limitintegerNoThe maximum number of points returned. Default value is 200. Maximum is 1200
langstringNoLanguage: zh_CN,zh_TW,en_US. en_US by default

Response

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

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

NameTypeDescription
symbolstringsymbol
periodstringcapital period
itemsarrayarray that contains the capital flow data

items has the following attributes:

NameTypeDescription
netInflowdoublenet inflow
timestringtime, "11-25 12:48:00 EST"
timestamplongtimestamp

Example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
      ClientConfig.DEFAULT_CONFIG);
// real-time data
QuoteCapitalFlowRequest request = QuoteCapitalFlowRequest.newRequest(
  "AAPL", Market.US, CapitalPeriod.intraday);
QuoteCapitalFlowResponse response = client.execute(request);
if (response.isSuccess()) {
  System.out.println(JSONObject.toJSON(response.getCapitalFlowItem()));
} else {
  System.out.println("response error:" + response.getMessage());
}

// net capital inflow data in the last 10 days
QuoteCapitalFlowRequest request = QuoteCapitalFlowRequest.newRequest(
  "00700", Market.HK, CapitalPeriod.day);
request.setLimit(10);
QuoteCapitalFlowResponse response = client.execute(request);
if (response.isSuccess()) {
  System.out.println(JSONObject.toJSON(response.getCapitalFlowItem()));
} else {
  System.out.println("response error:" + response.getMessage());
}

Response Example

// real-time data
{
    "symbol":"AAPL",
    "items":[
        {
            "netInflow":-109057032.2042,
            "time":"11-25 09:30:00 EST",
            "timestamp":1669386600000
        },
        {
            "netInflow":-116890065.471,
            "time":"11-25 09:31:00 EST",
            "timestamp":1669386660000
        }
    ]
}

// net capital inflow data in the last 10 days
{
    "symbol":"00700",
    "period":"day",
    "items":[
        {
            "netInflow":687742300,
            "time":"2022-11-14",
            "timestamp":1668355200000
        },
        {
            "netInflow":1926444000,
            "time":"2022-11-15",
            "timestamp":1668441600000
        },
        {
            "netInflow":1033900840,
            "time":"2022-11-16",
            "timestamp":1668528000000
        },
        {
            "netInflow":1667729580,
            "time":"2022-11-17",
            "timestamp":1668614400000
        },
        {
            "netInflow":284728680,
            "time":"2022-11-18",
            "timestamp":1668700800000
        },
        {
            "netInflow":661046060,
            "time":"2022-11-21",
            "timestamp":1668960000000
        },
        {
            "netInflow":-86129700,
            "time":"2022-11-22",
            "timestamp":1669046400000
        },
        {
            "netInflow":350223200,
            "time":"2022-11-23",
            "timestamp":1669132800000
        },
        {
            "netInflow":-161005460,
            "time":"2022-11-24",
            "timestamp":1669219200000
        },
        {
            "netInflow":17355680,
            "time":"2022-11-25",
            "timestamp":1669305600000
        }
    ]
}

Get Capital Distribution QuoteCapitalDistributionRequest

Description

Get capital distribution.

Argument

ArgumentTypeRequiredDescription
symbolstringYessymbol
marketstringYesUS-U.S. Stocks, HK-Hongkong Stocks, CN-A-Shares
langstringNoLanguage: zh_CN,zh_TW,en_US. en_US by default

Response

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

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

NameTypeDescription
symbolstringsymbol
netInflowdoublenet inflow(inAll - outAll)
inAlldoubleall inflow(inBig + inMid + inSmall)
inBigdoublebig orders's inflow
inMiddoublemedian orders's inflow
inSmalldoublesmall orders's inflow
outAlldoubleall outflow(outBig + outMid + outSmall)
outBigdoublebig orders's outflow
outMiddoublemedian orders's outflow
outSmalldoublesmall orders's outflow

Example

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

QuoteCapitalDistributionRequest request = QuoteCapitalDistributionRequest.newRequest(
    "00700", Market.HK);
QuoteCapitalDistributionResponse response = client.execute(request);
if (response.isSuccess()) {
  System.out.println(JSONObject.toJSON(response.getCapitalDistributionItem()));
} else {
  System.out.println("response error:" + response.getMessage());
}

Response Example

{
    "inBig":721190520,
    "netInflow":481406280,
    "symbol":"00700",
    "outBig":464624440,
    "outAll":3639820460,
    "inAll":4121226740,
    "inMid":604918520,
    "inSmall":2795117700,
    "outMid":572017220,
    "outSmall":2603178800
}

Get Stock Broker QuoteStockBrokerRequest

Description

Get stock broker infomation.

Argument

ArgumentTypeRequiredDescription
symbolstringYessymbol
limitintegerNoThe maximum number of points returned. Default value is 40. Maximum is 60
langstringNoLanguage: zh_CN,zh_TW,en_US. en_US by default

Response

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

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

NameTypeDescription
symbolstringsymbol
bidBrokerarrayarray that contains the 'LevelBroker' data
askBrokerarrayarray that contains the 'LevelBroker' data

'LevelBroker' has the following attributes:

NameTypeDescription
levelintegerprice level
pricedoubleprice
brokerCountintegerthe count of borkers
brokerarraythe list of borkers

Example

TigerHttpClient client = TigerHttpClient.getInstance().clientConfig(
      ClientConfig.DEFAULT_CONFIG);
QuoteStockBrokerRequest request = QuoteStockBrokerRequest.newRequest("00700", 10, Language.en_US);
QuoteStockBrokerResponse response = client.execute(request);
if (response.isSuccess()) {
  System.out.println(JSONObject.toJSON(response.getStockBrokerItem()));
} else {
  System.out.println("response error:" + response.getMessage());
}

Response Example

{
    "bidBroker":[
        {
            "level":1,
            "price":287.8,
            "brokerCount":7,
            "broker":[
                {
                    "name":"China Investment",
                    "id":"6997"
                },
                {
                    "name":"China Investment",
                    "id":"6998"
                },
                {
                    "name":"BOCI",
                    "id":"8134"
                },
                {
                    "name":"China Investment",
                    "id":"6998"
                },
                {
                    "name":"China Innovation",
                    "id":"5999"
                },
                {
                    "name":"China Investment",
                    "id":"6996"
                },
                {
                    "name":"J.P. Morgan",
                    "id":"5342"
                }
            ]
        },
        {
            "level":2,
            "price":287.6,
            "brokerCount":3,
            "broker":[
                {
                    "name":"China Investment",
                    "id":"6998"
                },
                {
                    "name":"China Investment",
                    "id":"6999"
                },
                {
                    "name":"China Innovation",
                    "id":"5998"
                }
            ]
        }
    ],
    "symbol":"00700",
    "askBroker":[
        {
            "level":1,
            "price":288,
            "brokerCount":10,
            "broker":[
                {
                    "name":"FUTU Securities",
                    "id":"8461"
                },
                {
                    "name":"China Innovation",
                    "id":"5998"
                },
                {
                    "name":"ICBC (Asia)",
                    "id":"8117"
                },
                {
                    "name":"China Innovation",
                    "id":"5998"
                },
                {
                    "name":"China Investment",
                    "id":"6999"
                },
                {
                    "name":"HSBC Securities Brokers",
                    "id":"8577"
                },
                {
                    "name":"China Investment",
                    "id":"6996"
                },
                {
                    "name":"China Investment",
                    "id":"6999"
                },
                {
                    "name":"FUTU Securities",
                    "id":"8462"
                },
                {
                    "name":"HSBC Securities Brokers",
                    "id":"8575"
                }
            ]
        }
    ]
}
Last update: