Stocks

About 17 min

get_market_state Get Market Status

value QuoteClient::get_market_state(string market);

Description

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

Rate Limit

Please refer to Rate Limit

Argument

ArgumentTypeDescription
marketMarketMarket being queried, use enums defined in tigeropen.common.consts.Market, such as Market.US, see enums for details
langLanguageLanguage, use enums defined in tigeropen.common.consts.Language, such as Language.zh_CN

Response

list

Each element is a MarketStatus object.

MarketStatus is structured as follows:

ArgumentTypeDescription
marketstrname of the Market being queried
trading_statusstrstatus of the market. Possible status are: NOT_YET_OPEN, PRE_HOUR_TRADING, TRADING, MIDDLE_CLOSE, POST_HOUR_TRADING, CLOSING, EARLY_CLOSED, MARKET_CLOSED;
statusstra 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;
}

ResponseExample

[{"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, begin_date, 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

Argument

ArgumentTypeDescription
marketMarketfilter by market, you can use the enums defined in tigeropen.common.consts.Market, such as Market.US
begin_datestrbegin date of calendar,include this day. format yyyy-MM-dd, like '2022-06-01'
end_datestrend 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

list

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

ArgumentTypeDescription
datestrtrade day date
typestrtrade 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;
}

ResponseExample

[{"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);

Description

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

Rate Limit

Please refer to Rate Limit

Argument

ArgumentTypeDescription
marketMarketfilter by market, you can use the enums defined in tigeropen.common.consts.Market, such as Market.US

Response

list

The element 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;
}

ResponseExample

"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);
value get_all_symbol_names(string market="ALL");

Description

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

Rate Limit

Please refer to Rate Limit

Argument

ArgumentTypeDescription
marketMarketfilter by market, you can use the enums defined in tigeropen.common.consts.Market, such as Market.US

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

ArgumentTypeRequiredDescription
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();
    cout << result << endl;

    return 0;
}

ResponseExample

[{"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, long 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

Argument

ArgumentTypeDescription
symbolslist<str...>Symbols of stocks, with a maximum of 50 per request. Example: ['AAPL', 'MSFT']
include_hour_tradingboolWhether data after regular trading hours is included. Optional. Use True or False
begin_timestrThe beginning time of the first data point, Use timestamp or a time string. Format: 1639386000000 or '2019-06-07 23:00:00' or '2019-06-07'
langLanguageLanguage supported, use enums defined in tigeropen.common.consts.Language

Response

Structured as follows:

COLUMNTypeDescription
symbolstrTicker 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;
}

ResponseExample


get_history_timeline Get history timeline

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

Description

Get the historical time-share data for a certain date

Rate Limit

Please refer to Rate Limit

Argument

ArgumentTypeRequiredDescription
symbolslist<str...>Yessecurity code list, Up to 50 passes at a time, e.g. ['AAPL', 'TSLA']
datestrYestimeline date. e.g. '2022-04-14'
rightQuoteRightNoquote right,refer to: tigeropen.common.consts.QuoteRight enum.

Response

As follow:

ArgumentTypeDescription
symbolstrsecurity 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;
}

ResponseExample

[{"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);

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

Argument

ArgumentTypeDescription
symbolslist<str...>Ticker symbol of a list of stocks, single request max support: 50
trade_sessiontigeropen.common.consts.TradingSessionTrade session,PreMarket/Regular/AfterHours. Optional,default TradingSession.Regular
begin_indexintStart 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.
end_indexintEnd 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 Responsed.
limitintResponse number limit, default Response: 200, maximum limit: 2000
langLanguageLanguage supported, Use enums defined under tigeropen.common.consts.Language

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:

ArgumentTypeDescription
indexintindex
timeinttimestamp in millisecond
pricefloatprice
volumeintvolume
directionstrdirection 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("AAPL");
    symbols[1] = value::string("JD");
    value result = quote_client->get_trade_tick(symbols);
    cout << result << endl;

    return 0;
}

ResponseExample


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

Argument

ArgumentTypeDescription
symbolslist<str...>Symbols of stocks, with a maximum of 50 per request. Example: ['AAPL', 'MSFT']
langLanguageLanguage supported, use enums defined in tigeropen.common.consts.Language

Response

ColumnTypeDescription
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;
}

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

Argument

ArgumentTypeDescription
symbolslist<str...>A list of ticker symbols, only U.Ss makret is supported. Example: ['AAPL', 'MSFT']
langLanguageSupported languages, Use enums defined by tigeropen.common.consts.Language. Example: Language.en_US

Response

Structured as below:

ArgumentTypeDescription
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;
}

ResponseExample

[{"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, long begin_time=-1, long end_time=-1,
                QuoteRight right=QuoteRight::br, int limit=251, string page_token="");
value get_kline(const value &symbols, string period, long begin_time=-1, long end_time=-1,
                string right="br", int limit=251, string page_token="");

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

Argument

ArgumentTypeDescription
symbolslist<str...>A list of symbols. Maximum 50 per request, example: ['AAPL', 'GOOG']
periodBarPeriodK line period. Default is BarPeriod.DAY. Use enums defined in tigeropen.common.consts.BarPeriod. Example: BarPeriod.DAY。 'day'/'week'/'month'/'year'/'1min'/'5min'/'15min'/'30min'/'60min'
begin_timeint/strBegin time. Unix time stamp in millisecond or a date string. Example: 1639371600000 / '2019-06-07 23:00:00' / '2019-06-07'
end_timeint/strEnd time. Unix time stamp in millisecond or a date string. Example: 1639371600000 / '2019-06-07 23:00:00' / '2019-06-07'
rightQuoteRightAdjuestment type. Default value is forward adjustment. Use enums defined in tigeropen.common.consts.QuoteRight. Example: QuoteRight.BR-forward adjust. QuoteRight.NR-No adjustment
limitintThe maximum number of bars returned. Default value is 251
langLanguageSupported language. Use enums defined in tigeropen.common.consts.Language. Example: Language.zh_CN

Response

Strutured as below:

ArgumentTypeDescription
timeintTimestamp. Example: 1639371600000
openfloatOpening price of a bar
closefloatClosing price of a bar
highfloatHigh pricce 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;
}

ResponseExample

[
    {
        "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_bars_by_page Get bars by page

QuoteClient.get_bars_by_page(symbol, period=BarPeriod.DAY, begin_time=-1, end_time=-1, total=10000, page_size=1000, right=QuoteRight.BR, time_interval=2)

Description

Get the bar data of the specified stock in a pagination.

Rate Limit

Please refer to Rate Limit

Argument

ArgumentTypeRequiredDescription
symbolstrYessecurity code
periodBarPeriodNoBar period type.Default is BarPeriod.DAY, refer to: tigeropen.common.consts.BarPeriod enum. e.g. BarPeriod.DAY. all available values: 'day'/'week'/'month'/'year'/'1min'/'5min'/'15min'/'30min'/'60min'
begin_timeint or strNobegin time. supports millisecond-level timestamps or date strings, e.g. 1639371600000 or '2019-06-07 23:00:00' or '2019-06-07'
end_timeint or strNoend time.supports millisecond-level timestamps or date strings, e.g. 1639371600000 or '2019-06-07 23:00:00' or '2019-06-07'
totalintNototal request bar count. default: 10000
page_sizeintNobar page size. default: 1000
time_intervalintNotime interval seconds, default: 2 seconds
rightQuoteRightNoQuote Right. refer to tigeropen.common.consts.QuoteRight enum, e.g. QuoteRight.BR, QuoteRight.NR
limitintNolimitation count. default: 251
langLanguageNosupport language, refer to tigeropen.common.consts.Language enum, e.g. Language.zh_CN

Response

ArgumentTypeDescription
timeintmillsecond timestamp,e.g. 1639371600000
openfloatBar open price
closefloatBar close price
highfloatBar highest price
lowfloatBar lowest price
volumefloatBar volume
next_page_tokenstrnext page token

get_depth_quote Get Depth Quote

value QuoteClient::get_depth_quote(symbols, market)

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

Rate Limit

Please refer to Rate Limit

Argument

ArgumentTypeDescription
symbolslist<str...>A list of stock ticker symbols, maximum number is 50
marketMarketMarket being quoted, use enums defined by tigeropen.common.consts.Market

Response

asks and bids array dict. include entrusted price, entrusted quantity, entrusted order number.

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;
}

ResponseExample

  #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(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

Argument

ArgumentTypeRequiredDescription
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;
}

ResponseExample

[{"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

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.

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

ArgumentTypeDescription
symbolstringstock symbol
periodstringperiod type
timestringtime 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", "US", "intraday");
    cout << result << endl;

    return 0;
}

ResponseExample

{"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(string symbol, Market market = Market::US);

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

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;
}

ResponseExample

{"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(string symbol, int limit=40);

Description

Get Hong Kong 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

NameTypeDescription
symbolstrstock symbol
bid_brokertigeropen.quote.domain.stock_broker.LevelBrokerLevelBroker
ask_brokertigeropen.quote.domain.stock_broker.LevelBrokerLevelBroker

LevelBroker:

NameTypeDescription
levelintegerprice level
pricedoubleprice
broker_countintegerthe count of borkers
brokerlist[igeropen.quote.domain.stock_broker.Broker]list of Broker

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 symbols = value::array();
    symbols[0] = value::string("AAPL");
    symbols[1] = value::string("JD");
    value result = quote_client->get_stock_broker(symbols);
    cout << result << endl;

    return 0;
}

Return example

StockBroker({'symbol': '01810',
    'bid_broker': [
        LevelBroker({'level': 1, 'price': 11.46, 'broker_count': 5,
            'broker': [Broker({'id': '5999', 'name': 'China Chuangying'}), Broker({'id': '4374', 'name': 'Barclays Asia'}),
                    Broker({'id': '1438', 'name': 'Susquehanna'}), Broker({'id': '4821', 'name': 'Washington'}),
                     Broker({'id': '6998', 'name': 'Chinese investment'})]})],
    'ask_broker': [
        LevelBroker({'level': 1, 'price': 11.48, 'broker_count': 5,
            'broker': [Broker({'id': '4374', 'name': 'Barclays Asia'}), Broker({'id': '9056', 'name': 'UBS'}),
                    Broker({'id': '2027', 'name': 'East Asia'}), Broker({'id': '4821', 'name': 'Washington'}),
                    Broker({'id': '4374', 'name': 'Barclays Asia'})]})]})
Last update: