General

Initialize QuoteClient

QuoteClient(const ClientConfig &cf, bool is_grab_permission = true);

grab_quote_permission Market Data Permission Grabbing

QuoteClient.grab_quote_permission()

Description

When the same account is used on multiple devices simultaneously, market data is only returned on the primary device. If you need to view market data on other devices, you need to execute "market data permission grabbing" to set the current device as the primary device. If you don't switch devices, this operation is not required. The returned value of this function is a list of all your current quote permissions.

Arguments

None

Response

The returned dictionary has the following fields:

KEYVALUE
nameName of the quote permission subscription
expire_atExpiration time (-1 means no expiration)

Example Call

#include "tigerapi/quote_client.h"
#include "tigerapi/trade_client.h"

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


int main(int argc, char *args[]) {
  
     ClientConfig config(false, U("tiger_openapi_config.properties"));

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

    return 0;
}

Below is a working code sample to use with pre-compiled TradeUP OpenAPI SDK + Visual Studio running on Windows 11. All subsequent API calls can use same .cpp with "value" line substituted with appropirate API call. (IL)

/* This is a sample Main.cpp used with pre-compiled openapi_cpp_test TigerAPI SDK
found under output/Windows/x64/Release_MD in https://github.com/tigerfintech/openapi-cpp-sdk.git
Get configs from Tiger's Developer Info Page: https://developer.tradeup.com/profile
download tiger_openapi_config.properties and copy it to the project's home directory
*/

#include "tigerapi/quote_client.h"
#include "tigerapi/trade_client.h"
#include <iostream>
#include <memory>

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

int main(int argc, char* args[]) {
    
    ClientConfig config(false, U("tiger_openapi_config.properties"));

    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_market_state(U("US"));
    wcout << result.serialize() << endl;

    return 0;
}

Example Response

[{'name': 'usStockQuote', 'expire_at': 1698767999000}, {'name': 'usStockQuoteLv2Arca', 'expire_at': 1698767999000}, {'name': 'usStockQuoteLv2Totalview', 'expire_at': 1698767999000}, {'name': 'usOptionQuote', 'expire_at': 1698767999000}]

For permission details, refer to Market Data Permissions & Restrictions

get_quote_permission Query Market Data Permissions

QuoteClient.get_quote_permission()

Description

Use this function to query all your current quote permission subscriptions.

Arguments

None

Response

Same as grab_quote_permission Market Data Permission Grabbing

Example Call

/* This is a sample Main.cpp used with pre-compiled openapi_cpp_test TigerAPI SDK
found under output/Windows/x64/Release_MD in https://github.com/tigerfintech/openapi-cpp-sdk.git
Get configs from Tiger's Developer Info Page: https://developer.tradeup.com/profile
download tiger_openapi_config.properties and copy it to the project's home directory
*/

#include "tigerapi/quote_client.h"
#include "tigerapi/trade_client.h"
#include <iostream>
#include <memory>

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

int main(int argc, char* args[]) {
    
    ClientConfig config(false, U("tiger_openapi_config.properties"));


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

    return 0;
}

Example Response

["expireAt":4133951999000,"name":"usOptionQuote"},{"expireAt":2003052655000,"name":"usQuoteBasic"}]

get_kline_quota Historical Market Data Quota

QuoteClient.get_kline_quota()

Description

Statistics of used and remaining subscribable symbol counts based on user level (different options of the same stock only occupy one symbol, refer to Historical Market Data Restrictions & Subscription Restrictions for additional rules)

Parameters

ParameterTypeRequiredDescription
with_detailsboolNoWhether to return the details of the requested symbol, default is no

Returns

list

Each of the below fields is structured as follows:

fieldstypedescription
remainintnumber used
usedintRemaining quantity
methodstrapi interface (kline: stock kline; option_kline: option kline; history_timeline: stock history time frame
detailsvaluedetails of used underlying

Example Call

/* This is a sample Main.cpp used with pre-compiled openapi_cpp_test TigerAPI SDK
found under output/Windows/x64/Release_MD in https://github.com/tigerfintech/openapi-cpp-sdk.git
Get configs from Tiger's Developer Info Page: https://developer.tradeup.com/profile
download tiger_openapi_config.properties and copy it to the project's home directory
*/

#include "tigerapi/quote_client.h"
#include "tigerapi/trade_client.h"
#include <iostream>
#include <memory>

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

int main(int argc, char* args[]) {
    
    ClientConfig config(false, U("tiger_openapi_config.properties"));

    /**
     * Use the pre-made class, QuoteClient, to query quotes
     */
    std::shared_ptr<QuoteClient> quote_client = std::make_shared<QuoteClient>(config);
    value result = quote_client->get_kline_quota();
    cout << result << endl;

    return 0;
}

Example Response

[{"remain": 2, "used": 18, "method": "kline", "details": ["AAPL", "FB"]}, 
 {"remain": 20, "used": 0, "method": "option_kline", "details": []}, 
 {"remain": 20, "used": 0, "method": "history_timeline", "details": []}]

Did this page help you?