Stocks

About 18 min

get_market_state Get Market Status

value QuoteClient::get_market_state(utility::string_t market);

Description

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

Rate Limit

Please refer to Rate Limit

Parameters

ParameterTypeRequiredDescription
marketutility::string_tYesMarket to query

Response

list

Each element is a MarketStatus object.

MarketStatus is structured as follows:

ParameterTypeDescription
marketMarketname of the Market being queried
trading_statusutility::string_tstatus of the market. Possible status are: NOT_YET_OPEN, PRE_HOUR_TRADING, TRADING, MIDDLE_CLOSE, POST_HOUR_TRADING, CLOSING, EARLY_CLOSED, MARKET_CLOSED;
statusutility::string_ta description of the current market status
open_timedatetimeclosest market open time in the future, a datetime object with tzinfo

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    /**
     * Use QuoteClient
     */
    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_market_state("US");
    cout << result << endl;

    return 0;
}

Response

[{"market":"HK","marketStatus":"Trading","openTime":"01-12 09:30:00","status":"TRADING"}]

get_trading_calendar

get trading calendar of market

QuoteClient::get_trading_calendar(Market market, utility::string_t begin_date, utility::string_t end_date)

Description

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

Provides a calendar from 2015 onwards to the end of this year. If it is out of range, the start and end times will be processed to be within the range of the provided data.

Rate Limit

Please refer to Rate Limit

Parameters

ParameterTypeRequiredDescription
marketutility::string_t / MarketYesMarket to query
Use the Market enum constants provided in include/tigerapi/enums.h
Refer to the enumeration parameters section for details
begin_dateutility::string_tYesbegin date of calendar,including today. format yyyy-MM-dd, like '2022-06-01'
end_dateutility::string_tYesend date of calendar,excluding today. format yyyy-MM-dd

begin_date and end_date parameters description:

begin_date providedend_date providedDate Range Result
yesyes(begin_date, end_date)
yesno(begin_date, begin_date+365)
noyes(end_date-365,end_date)

Response

list

Each item is a dict, which key's meaning as follows:

ParameterTypeDescription
dateutility::string_ttrade day date
typeutility::string_ttrade day type. TRADING: whole day trading; EARLY_CLOSE: close market early

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_trading_calendar("US", "2023-01-01", "2023-03-01");
    cout << result << endl;

    return 0;
}

Response

[{"date":"2023-01-03","type":"TRADING"},{"date":"2023-01-04","type":"TRADING"},{"date":"2023-01-05","type":"TRADING"},{"date":"2023-01-06","type":"TRADING"},{"date":"2023-01-09","type":"TRADING"},{"date":"2023-01-10","type":"TRADING"},{"date":"2023-01-11","type":"TRADING"},{"date":"2023-01-12","type":"TRADING"},{"date":"2023-01-13","type":"TRADING"},{"date":"2023-01-17","type":"TRADING"},{"date":"2023-01-18","type":"TRADING"},{"date":"2023-01-19","type":"TRADING"},{"date":"2023-01-20","type":"TRADING"},{"date":"2023-01-23","type":"TRADING"},{"date":"2023-01-24","type":"TRADING"},{"date":"2023-01-25","type":"TRADING"},{"date":"2023-01-26","type":"TRADING"},{"date":"2023-01-27","type":"TRADING"},{"date":"2023-01-30","type":"TRADING"},{"date":"2023-01-31","type":"TRADING"},{"date":"2023-02-01","type":"TRADING"},{"date":"2023-02-02","type":"TRADING"},{"date":"2023-02-03","type":"TRADING"},{"date":"2023-02-06","type":"TRADING"},{"date":"2023-02-07","type":"TRADING"},{"date":"2023-02-08","type":"TRADING"},{"date":"2023-02-09","type":"TRADING"},{"date":"2023-02-10","type":"TRADING"},{"date":"2023-02-13","type":"TRADING"},{"date":"2023-02-14","type":"TRADING"},{"date":"2023-02-15","type":"TRADING"},{"date":"2023-02-16","type":"TRADING"},{"date":"2023-02-17","type":"TRADING"},{"date":"2023-02-21","type":"TRADING"},{"date":"2023-02-22","type":"TRADING"},{"date":"2023-02-23","type":"TRADING"},{"date":"2023-02-24","type":"TRADING"},{"date":"2023-02-27","type":"TRADING"},{"date":"2023-02-28","type":"TRADING"}]


get_symbols Get Stock Symbols

value get_symbols(Market market=Market::ALL, bool include_otc=false);

Description

Get ticker symbols of all securities of the selected market, including delisted stocks or stocks that are not available for trade.

Rate LimitParameter

Please refer to Rate Limit

Parameters

ParameterTypeRequiredDescription
marketMarketNofilter by market, you can use the enums defined in include/tigerapi/enums.h, such as Market.US
default: Market::ALL
include_otcboolNoif True include OTC stocks,
default: False

Response

list

The elements are ticker symbols for all securities in the market, including symbols for delisted and untradable securities. Symbols begins with '. ' means indexes, such as '.DJI' stands for Dow Jones Index.

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_symbols();
    cout << result << endl;

    return 0;
}

Response

"ZCMD","ZD","ZDGE","ZEAL","ZECP","ZEN","ZENV","ZEPP","ZEST","ZETA","ZEUS","ZEV","ZG","ZH","ZHDG","ZI","ZIG","ZIM","ZINGU","ZION","ZIONL","ZIONO","ZIONP","ZIP","ZIVO","ZKIN","ZLAB","ZM","ZNH","ZNTEU","ZNTL","ZOM","ZROZ","ZS","ZSB","ZSL","ZT","ZTAQU","ZTO","ZTR","ZTS","ZUMZ","ZUO","ZVIA","ZWS","ZY","ZYME","ZYNE","ZYXI"]

get_symbol_names Get Symbols and Names

value get_all_symbol_names(Market market = Market::ALL, bool include_otc=false);
value get_all_symbol_names(utility::string_t market = U("ALL"), bool include_otc=false);

Description

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

Rate Limit

Please refer to Rate Limit

Parameters

ParameterTypeRequiredDescription
marketMarket / utility::string_tNofilter by market, you can use the enums defined in include/tigerapi/enums.h, such as Market::US
default: Market::ALL
include_otcboolNoif True include OTC stocks
default: false

Response

list

Structured as follows:

Each object in the list is a tuple. The first element of the tuple is the symbol and the second element is the name

ParameterTypeRequiredDescription
symbolstringYessymbol
namestringYesname

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_symbol_names(Market::HK);
    cout << result << endl;

    return 0;
}

Response

[{"name":"CKH HOLDINGS","symbol":"00001"},{"name":"CLP HOLDINGS","symbol":"00002"},
{"name":"HK & CHINA GAS","symbol":"00003"},{"name":"WHARF HOLDINGS","symbol":"00004"},
{"name":"HSBC HOLDINGS","symbol":"00005"}]

get_timeline Get timeline

value get_timeline(const value &symbols, bool include_hour_trading=false, time_t begin_time=-1);

Description

Get the latest timeline data, which contains one-minute price data of the stock. This method will only return data from last trading day, use get_bars method to inqury

Rate Limit

Please refer to Rate Limit

Parameters

ParameterTypeRequiredDescription
symbolslist<str...>YesSymbols of stocks, with a maximum of 50 per request. Example: ['AAPL', 'MSFT']
include_hour_tradingboolNoWhether data after regular trading hours is included
default: false
begin_timetime_tNoThe beginning time of the first data point, Use timestamp Format: 1639386000000
default: -1

Response

Structured as follows:

ParameterTypeDescription
symbolstringTicker symbol of asset. such as AAPL
timeintTimestamp. Example: 1639386000000
pricefloatclose price of current one-minute bar
avg_pricefloatvolume weighted average price
pre_closefloatclose price of last trading day
volumeintvolume of current one-minute bar
trading_sessionstrPossible values are: "pre_market", "regular" and "after_hours"

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value symbols = value::array();
    symbols[0] = value::string("AAPL");
    symbols[1] = value::string("JD");
    value result = quote_client->get_timeline(symbols);
    cout << result << endl;

    return 0;
}

get_history_timeline Get history timeline

value get_history_timeline(const value &symbols, utility::string_t date, QuoteRight right=QuoteRight::br);

Description

Get the historical time-share data for a certain date

Rate Limit

Please refer to Rate Limit

Parameters

ParameterTypeRequiredDescription
symbolslist<str...>Yessecurity code list, Up to 50 passes at a time, e.g. ['AAPL', 'TSLA']
datestringYestimeline date. e.g. '2022-04-14'
rightQuoteRightNoquote right,refer to: include/tigerapi/enums.h
default: QuoteRight::br

Response

As follow:

ParameterTypeDescription
symbolstringsecurity code, e.g. AAPL
timeintmillisecond timestamp, e.g. 1639386000000
pricefloatcurrent minute closing price
avg_pricefloatvolume-weighted average price to the current time

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value symbols = value::array();
    symbols[0] = value::string("AAPL");
    symbols[1] = value::string("JD");
    value result = quote_client->get_history_timeline(symbols, "2023-01-10");
    cout << result << endl;

    return 0;
}

Response

[{"items":[{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673361000000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673361060000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673361120000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673361180000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673361240000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673364660000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673364720000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673364780000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673364840000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673364900000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673364960000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673365020000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673365080000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673365140000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673365200000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673365260000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673365320000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673365380000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673365440000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673365500000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673365560000,"volume":0},{"avgPrice":130.15000000000001,"price":130.15000000000001,"time":1673365620000,"volume":0},{"avgPrice":63.130000000000003,"price":63.130000000000003,"time":1673384220000,"volume":0},{"avgPrice":63.130000000000003,"price":63.130000000000003,"time":1673384280000,"volume":0},{"avgPrice":63.662365000000001,"price":63.649999999999999,"time":1673384340000,"volume":230124}],"symbol":"JD"}]


get_trade_tick Get Trade Ticks

value get_trade_tick(const value &symbols, TradingSession trade_session=TradingSession::Regular, long begin_index=-1,
                             long end_index=-1, int limit=100);
value get_trade_tick(const value &symbols, long begin_index=-1,
                             long end_index=-1, utility::string_t trade_session=U("Regular"), int limit=100);

Description

To obtain transaction data by transaction, this interface can support the query of the full transaction record of the current trading day after the market closes, and can also support the query of the latest real-time transaction record in the market.

Rate Limit

Please refer to Rate Limit

Parameters

ParameterTypeRequiredDescription
symbolslist<str...>YesTicker symbol of a list of stocks, single request max support: 50
trade_sessioninclude/tigerapi/enums.h TradingSessionNoTrade session,PreMarket/Regular/AfterHours
default: TradingSession::Regular
begin_indexintNoStart index, the index value of the current day starts from 0. If begin_index and end_index are set to -1, the latest item-by-item data of Response will be displayed. **In subsequent queries, the end_index value of the last query Response can be used as begin_index to perform continuous queries **, Response data is a collection of front-close and back-open, for example: begin_index=1, end_index=100, it will record the Response from 1 to 99, and set begin_index=100, end_index=200 in the next query.
default: -1
end_indexintNoEnd index, The difference between the end index and the start index cannot be greater than 2000, and when it is greater than 2000, the default response is 200 records from the start index. When the limitArgument is smaller than the difference between the start and end indexes, only the limit item-by-item data starting from the start index will be returned.
default: -1
limitintNoResponse number limit, maximum limit: 2000
default: 100

begin_index, end_index arguments description

query typebegin_indexend_indexdescription
query latest data-1-1limit default value 200
query by sectionindex numberindex numberfor example:begin_index=10, end_index=100 ,Returns 90 rows containing 10 to 99. If limit is set to 20, 20 records from 10 to 29 will be returned.

Response

Structured as below:

ParameterTypeDescription
symbolutility::string_tSymbol of security
beginIndexintStart time index
endIndexintEnd time index
itemslist<TradeTickItem>list of TradeTickItems

TradeTickItem Structure

ParameterTypeDescription
timeinttimestamp in milliseconds
volumeintvolume
pricedoubleprice
typestringdirection of the price change, "+" stands for "active buy", "-" stands for "active sell", "*" stands for "neutral transaction"

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value symbols = value::array();
    symbols[0] = value::string("01810");
    value result = quote_client->get_trade_tick(symbols);
    cout << result << endl;

    return 0;
}

Response

[{"symbol":"01810","beginIndex":99437,"endIndex":99637,"items":[{"time":1741852234015,"volume":200,"price":52.9,"type":"+"},
{"time":1741852236040,"volume":200,"price":52.9,"type":"+"},{"time":1741852236720,"volume":400,"price":52.85,"type":"-"},
{"time":1741852237436,"volume":200,"price":52.9,"type":"+"},{"time":1741852237436,"volume":200,"price":52.9,"type":"+"}...

get_quote_real_time Get Stock Briefs

value get_quote_real_time(const value &symbols);

Description

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

Rate Limit

Please refer to Rate Limit

Parameters

ParameterTypeRequiredDescription
symbolslist<str...>YesSymbols of stocks, with a maximum of 50 per request. Example: ['AAPL', 'MSFT']

Response

ParameterTypeDescription
symbolstrTicker symbol of a specific stock
ask_pricefloatAsk price
ask_sizeintAsk size
bid_pricefloatBid price
bid_sizeintBid size
pre_closefloatClose price of the last trading day
latest_pricefloatLatest price
latest_timeintTime when last trade is made. Unix timestamp, example: 1547516984730
volumeintVolume
openfloatOpening price
highfloatHigh price
lowfloatLow price
statusstrTrading status

Possible trading status:

  • "UNKNOWN"
  • "NORMAL"
  • "HALTED"
  • "DELIST"
  • "NEW"
  • "ALTER"

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value symbols = value::array();
    symbols[0] = value::string("AAPL");
    symbols[1] = value::string("JD");
    value result = quote_client->get_quote_real_time(symbols);
    cout << result << endl;

    return 0;
}

Response

{"adjPreClose":216.97999999999999,"askPrice":215.78,"askSize":200,"bidPrice":215.44999999999999,"bidSize":200,
"close":216.97999999999999,"high":221.75,"latestPrice":216.97999999999999,"latestTime":1741809600000,"low":214.91,
"open":220.13999999999999,"preClose":220.84,"status":"NORMAL","symbol":"AAPL","volume":62547467}


get_quote_delay Get Delayed Data (Free)

value get_quote_delay(const value &symbols);

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

Rate Limit

Please refer to Rate Limit

Parameters

ParameterTypeRequiredDescription
symbolslist<str...>YesA list of ticker symbols, only U.Ss makret is supported. Example: ['AAPL', 'MSFT']

Response

Structured as below:

ParameterTypeDescription
symbolstrTicker symbol of the stock
pre_closefloatclose price of last trading day
timeintLast update time, format: UNIX timestamp. Example: 1639429200000
volumeintVolume
openfloatOpening price
highfloatHigh Price
lowfloatLow price
closefloatClose price
haltedfloatStatus of the stock (0: Normal 3: Halt 4: Delisted 7: New 8: Alter)

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value symbols = value::array();
    symbols[0] = value::string("AAPL");
    symbols[1] = value::string("JD");
    value result = quote_client->get_quote_delay(symbols);
    cout << result << endl;

    return 0;
}

Response

[{"close":130.72999999999999,"halted":0,"high":131.2636,"low":128.12,"open":130.25999999999999,"preClose":130.15000000000001,"symbol":"AAPL","time":1673384400000,"volume":63896155},{"close":63.649999999999999,"halted":0,"high":64.620000000000005,"low":62.950000000000003,"open":64.099999999999994,"preClose":63.130000000000003,"symbol":"JD","time":1673384400000,"volume":5537959}]


get_kline Get Bars of a Stock

value get_kline(const value &symbols, BarPeriod period=BarPeriod::DAY, time_t begin_time=-1, time_t end_time=-1,
                QuoteRight right=QuoteRight::br, int limit=251, utility::string_t page_token=U(""));
value get_kline(const value &symbols, utility::string_t period, time_t begin_time=-1, time_t end_time=-1,
                utility::string_t right=U("br"), int limit=251, utility::string_t page_token=U(""));
vector<Kline> get_kline(const value &symbols, utility::string_t period, time_t begin_time=-1, time_t end_time=-1,
                        int limit=251, utility::string_t right=U("br"), utility::string_t page_token=U(""));

Description

Get the K-line data of a specified stock, and different time granularities can be specified. Currently, this interface supports obtaining K-line data in units of day, week, month, year, minute, 5 minutes, 15 minutes, 30 minutes, and 60 minutes. Considering the performance and stability of the interface, the maximum number of requests for this interface is 1200. For users who need more historical data for analysis or backtesting, it can be requested via get_bars_by_page method. You can also implement the loop yourself to obtain historical data with a longer time range through multiple requests.

We have written an [Example](/en/cpp/quickStart/other.md#Request historical K-lines in batches) for reference. It should be noted that there may be restrictions on the length of K-lines that can be requested. For details, see Historical market restrictions

Rate Limit

Please refer to Rate Limit

Parameters

ParameterTypeRequiredDescription
symbolslist<str...>YesA list of symbols. Maximum 50 per request, example: ['AAPL', 'GOOG']
period/include/tigerapi/enums.h BarPeriodNoK line period 'day'/'week'/'month'/...
default: BarPeriod::DAY
begin_timetime_tNoBegin time. Unix time stamp in millisecond or a date string. Example: 1639371600000 / '2019-06-07 23:00:00' / '2019-06-07'
default: -1
end_timetime_tNoEnd time. Unix time stamp in millisecond or a date string. Example: 1639371600000 / '2019-06-07 23:00:00' / '2019-06-07'
default: -1
right/include/tigerapi/enums.h QuoteRightNoAdjustment type. Use enums defined in include/tigerapi/enums.h Example: QuoteRight.BR-forward adjust. QuoteRight.NR-No adjustment
default: QuoteRight::br
limitintNoThe maximum number of bars returned
default: 251
page_tokenstringNoPagination token, records the position of pagination. The next_page_token returned from the previous request can be passed as the starting marker for the next request
default: U("")

Response

Structured as below:

ParameterTypeDescription
timeintTimestamp. Example: 1639371600000
openfloatOpening price of a bar
closefloatClosing price of a bar
highfloatHigh price of a bar
lowfloatlow price of a bar
volumefloatVolume of a bar
amountfloatamount of a bar

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value symbols = value::array();
    symbols[0] = value::string("AAPL");
    symbols[1] = value::string("JD");
    value result = quote_client->get_kline(symbols);
    cout << result << endl;

    return 0;
}

Response

[
    {
        "items": [
            {
                "close": 139.5,
                "high": 141.43000000000001,
                "low": 137.49000000000001,
                "open": 140.41,
                "time": 1667883600000,
                "volume": 89908477
            },
            {
                "close": 134.87,
                "high": 138.55000000000001,
                "low": 134.5933,
                "open": 138.5,
                "time": 1667970000000,
                "volume": 74917794
            },
            {
                "close": 146.87,
                "high": 146.87,
                "low": 139.5,
                "open": 141.24000000000001,
                "time": 1668056400000,
                "volume": 118854028
            },
            {
                "close": 149.69999999999999,
                "high": 150.00999999999999,
                "low": 144.37,
                "open": 145.81999999999999,
                "time": 1668142800000,
                "volume": 93979665
            },
            {
                "close": 148.28,
                "high": 150.28,
                "low": 147.43000000000001,
                "open": 148.97,
                "time": 1668402000000,
                "volume": 73374114
            }
        ],
        "period": "day",
        "symbol": "AAPL"
    },
    {
        "items": [
            {
                "close": 45.490000000000002,
                "high": 45.840000000000003,
                "low": 43.950099999999999,
                "open": 45,
                "time": 1667883600000,
                "volume": 9351285
            },
            {
                "close": 42.460000000000001,
                "high": 43.600000000000001,
                "low": 42.195,
                "open": 43.435000000000002,
                "time": 1667970000000,
                "volume": 9533906
            },
            {
                "close": 46.030000000000001,
                "high": 46.93,
                "low": 45.229999999999997,
                "open": 45.390000000000001,
                "time": 1668056400000,
                "volume": 11965986
            },
            {
                "close": 48.93,
                "high": 50.549999999999997,
                "low": 48.530000000000001,
                "open": 49.469999999999999,
                "time": 1668142800000,
                "volume": 12951770
            },
            {
                "close": 50.850000000000001,
                "high": 52.020000000000003,
                "low": 50.119999999999997,
                "open": 50.939999999999998,
                "time": 1668402000000,
                "volume": 12662512
            }
        ],
        "period": "day",
        "symbol": "JD"
    }
]

get_quote_depth Get Depth Quote

value QuoteClient::get_quote_depth(const value &symbols, Market market = Market::US)

Description

Get market depth quote, including price, quantity and number of orders, Request limit is 50 symbols per request

CAUTION

The closing auction time of Hong Kong stocks is 16:00-16:10 (the market closes randomly between 16:08 and 16:10), and the last ask-bid data is generally delayed to update one or two minutes after 16:10 US stock market depth data includes pre-market and after-hours information. No parameters are required, and real-time data can be retrieved instantly upon request

Rate Limit

Please refer to Rate Limit

Parameters

ParameterTypeRequiredDescription
symbolslist<str...>YesA list of stock ticker symbols, maximum number is 50
marketMarketNoMarket being quoted
default: Market::US

Response

Asks and Bids (order price, order quantity, order count)

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value symbols = value::array();
    symbols[0] = value::string("AAPL");
    symbols[1] = value::string("JD");
    value result = quote_client->get_quote_depth(symbols);
    cout << result << endl;

    return 0;
}

Response

  #for a single symbol:
  {'symbol': '02833',
    'asks': [(27.4, 300, 2), (27.45, 500, 1), (27.5, 4400, 1), (27.55, 0, 0), (27.6, 5700, 3), (27.65, 0, 0),
            (27.7, 500, 1), (27.75, 0, 0), (27.8, 0, 0), (27.85, 0, 0)],
    'bids': [(27, 4000, 3), (26.95, 200, 1), (26.9, 0, 0), (26.85, 400, 1), (26.8, 0, 0), (26.75, 0, 0),
            (26.7, 0, 0), (26.65, 0, 0), (26.6, 0, 0), (26.55, 0, 0)]
  }

  #for a list of symbols:
  {'02833':
      {'symbol': '02833',
        'asks': [(27.35, 200, 1), (27.4, 2100, 2), (27.45, 500, 1), (27.5, 4400, 1), (27.55, 0, 0),
                (27.6, 5700, 3), (27.65, 0, 0), (27.7, 500, 1), (27.75, 0, 0), (27.8, 0, 0)],
        'bids': [(27.05, 100, 1), (27, 5000, 4), (26.95, 200, 1), (26.9, 0, 0), (26.85, 400, 1), (26.8, 0, 0),
              (26.75, 0, 0), (26.7, 0, 0), (26.65, 0, 0), (26.6, 0, 0)]
      },
  '02828':
      {'symbol': '02828',
        'asks': [(106.6, 6800, 7), (106.7, 110200, 10), (106.8, 64400, 8), (106.9, 80600, 8), (107, 9440, 16),
              (107.1, 31800, 5), (107.2, 11800, 4), (107.3, 9800, 2), (107.4, 9400, 1), (107.5, 21000, 9)],
        'bids': [(106.5, 62800, 17), (106.4, 68200, 9), (106.3, 78400, 6), (106.2, 52400, 4), (106.1, 3060, 4),
                (106, 33400, 4), (105.9, 29600, 3), (105.8, 9600, 2), (105.7, 15200, 2), (105.6, 0, 0)]}
      }

get_quote_stock_trade Get Quote Stock Trade

QuoteClient::get_quote_stock_trade(const value &symbols)

Description

Obtain the information needed for stock trading, such as the number of shares per lot, for example, the number of shares placed in Hong Kong stocks must be an integral multiple of the number of shares per lot

Rate Limit

Please refer to Rate Limit

Parameters

ParameterTypeRequiredDescription
symbolslist<str...>Yessymbol list, per request max support: 50

Response

ColumnTypeDescription
symbolstrsymbol
lot_sizeintlot size
min_tickfloatThe smallest unit of price change
spread_scalefloatspread scale

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value symbols = value::array();
    symbols[0] = value::string("AAPL");
    symbols[1] = value::string("JD");
    value result = quote_client->get_quote_stock_trade(symbols);
    cout << result << endl;

    return 0;
}

Response

[{"lotSize":1,"minTick":0.01,"spreadScale":1,"symbol":"AAPL"},{"lotSize":1,"minTick":0.01,"spreadScale":1,"symbol":"JD"}]

get_capital_flow Get Capital Flow

value QuoteClient::get_capital_flow(utility::string_t symbol, Market market = Market::US, CapitalPeriod period = CapitalPeriod::DAY); value QuoteClient::get_capital_flow(utility::string_t symbol, utility::string_t market, utility::string_t period = U("day"));

Description

Obtain the net inflow data of stock funds, including the real-time minute data of the latest trading day, and the net inflow data of different periods. For different time granularities, it supports obtaining data in units of day, week, month, quarter, half year, and year. The maximum limit is 1200, and the default is 200.

Parameters

ParameterTypeRequiredDescription
symbolutility::string_tYessymbol
marketMarketNoUS-U.S. Stocks, HK-Hong Kong Stocks, CN-A-Shares
default: Market::US
periodCapitalPeriodNoperiod, possible values are: intraday, day, week, month, year, quarter, 6month
default: CapitalPeriod::DAY)
                |

Response

ParameterTypeDescription
symbolutility::string_tstock symbol
periodutility::string_tperiod type
timeutility::string_ttime string,real-time format is "11-25 12:48:00 EST",non real-time format is "2022-11-22"
timestampinttimestamp in millisecond
net_inflowfloatnet inflow, negative means outflow

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
/************************** set config **********************/
ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value symbols = value::array();
    symbols[0] = value::string("AAPL");
    symbols[1] = value::string("JD");
    value result = quote_client->get_capital_flow("AAPL");
    cout << result << endl;

    return 0;
}

Response

{"items":[{"netInflow":66792509.8979,"time":"01-10 09:30:00 EST","timestamp":1673361000000},{"netInflow":68356370.344899997,"time":"01-10 09:31:00 EST","timestamp":1673361060000},
  {"netInflow":70886790.490799993,"time":"01-10 09:32:00 EST","timestamp":1673361120000},{"netInflow":73072909.183300003,"time":"01-10 09:33:00 EST","timestamp":1673361180000},
  {"netInflow":18778097.630399998,"time":"01-10 15:45:00 EST","timestamp":1673383500000},{"netInflow":17920771.363000002,"time":"01-10 15:46:00 EST","timestamp":1673383560000},
  {"netInflow":16638279.7092,"time":"01-10 15:47:00 EST","timestamp":1673383620000},{"netInflow":16618314.0484,"time":"01-10 15:48:00 EST","timestamp":1673383680000},
  {"netInflow":16369111.518200001,"time":"01-10 15:49:00 EST","timestamp":1673383740000},{"netInflow":24502314.359200001,"time":"01-10 15:50:00 EST","timestamp":1673383800000},
  {"netInflow":25853726.0222,"time":"01-10 15:51:00 EST","timestamp":1673383860000},{"netInflow":22492884.448399998,"time":"01-10 15:52:00 EST","timestamp":1673383920000},
  {"netInflow":23272406.638500001,"time":"01-10 15:53:00 EST","timestamp":1673383980000},{"netInflow":22988058.011999998,"time":"01-10 15:54:00 EST","timestamp":1673384040000},
  {"netInflow":28326520.442699999,"time":"01-10 15:55:00 EST","timestamp":1673384100000},{"netInflow":24328584.693300001,"time":"01-10 15:56:00 EST","timestamp":1673384160000},
  {"netInflow":29597845.616900001,"time":"01-10 15:57:00 EST","timestamp":1673384220000},{"netInflow":27514469.558699999,"time":"01-10 15:58:00 EST","timestamp":1673384280000},
  {"netInflow":35487493.496799998,"time":"01-10 15:59:00 EST","timestamp":1673384340000}],"period":"intraday","symbol":"AAPL"}


get_capital_distribution Get Capital Distribution

value get_capital_distribution(utility::string_t symbol, Market market = Market::US);;

Description

Get capital distribution.

Parameters

ParameterTypeRequiredDescription
symbolstring_tYesstock symbol
marketMarketNoUS-U.S. Stocks, HK-Hongkong Stocks, CN-A-Shares
default: Market::US

Response

NameTypeDescription
symbolstringsymbol
net_inflowdoublenet inflow(inAll - outAll)
in_alldoubleall inflow(inBig + inMid + inSmall)
in_bigdoublebig orders's inflow
in_middoublemedian orders's inflow
in_smalldoublesmall orders's inflow
out_alldoubleall outflow(outBig + outMid + outSmall)
out_bigdoublebig orders's outflow
out_middoublemedian orders's outflow
out_smalldoublesmall orders's outflow

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value symbols = value::array();
    symbols[0] = value::string("AAPL");
    symbols[1] = value::string("JD");
    value result = quote_client->get_capital_distribution("AAPL");
    cout << result << endl;

    return 0;
}

Response

{"inAll":3333362528.4099998,"inBig":577964736.26520014,"inMid":273636829.47490007,"inSmall":2481760962.6747251,
  "netInflow":35487493.5,"outAll":3297875034.9200001,"outBig":483301755.98959994,"outMid":292564622.11769968,"outSmall":2522008656.8106923,"symbol":"AAPL"}


get_stock_broker Get Stock Broker

value get_stock_broker(utility::string_t symbol, int limit=40);

Description

Get Hong Kong stock broker information.

Parameters

ParameterTypeRequiredDescription
symbolstringYesstock symbol
limitintegerNoThe maximum number of points returned.
default: 40, Maximum is 60

Response

NameTypeDescription
ask_brokerLevelBrokerLevelBroker
bid_brokerLevelBrokerLevelBroker
symbolstrstock symbol

LevelBroker:

NameTypeDescription
brokerBrokerlist of Broker
broker_countintegerthe count of brokers
levelintegerprice level
pricedoubleprice

Broker:

NameTypeDescription
idstrbroker id
namestrbroker name

Example

#include "tigerapi/quote_client.h"

using namespace std;
using namespace web;
using namespace web::json;
using namespace TIGER_API;


int main(int argc, char *args[]) {
    /************************** set config **********************/
    ClientConfig config = ClientConfig(true);

    config.private_key = "-----BEGIN RSA PRIVATE KEY-----\n"
                         "xxxxxx private key xxxxxxxx"
                         "-----END RSA PRIVATE KEY-----";
    config.tiger_id = "Tiger ID";
    config.account = "Account ID";


    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_stock_broker(U("03132"));
    cout << result << endl;

    return 0;
}

Return example

{
    "askBroker": [
        {
            "broker": [
                {
                    "id": "6698",
                    "name": "Interactive"
                }
            ],
            "brokerCount": 1,
            "level": 1,
            "price": 21.6
        },
        {
            "broker": [
                {
                    "id": "8574",
                    "name": "HSBC Securities Brokers"
                }
            ],
            "brokerCount": 1,
            "level": 10,
            "price": 21.78
        }
    ],
    "bidBroker": [
        {
            "broker": [
                {
                    "id": "1292",
                    "name": "CMB"
                },
                {
                    "id": "8460",
                    "name": "FUTU Securities"
                },
                {
                    "id": "1799",
                    "name": "Bright Smart (H.K.)"
                }
            ],
            "brokerCount": 3,
            "level": 1,
            "price": 21.5
        }
    ],
    "symbol": "03132"
}
Last update: