Get Contract
Contract Overview
A contract identifies a tradable instrument, such as a stock, option, or futures contract. Exchanges standardize contract details. For example, the symbol TIGR and market US identify Tiger Brokers stock. The SDK uses contract information to identify an instrument when placing orders or retrieving market data.
Most contracts (such as stocks, CFDs, indices, or forex) can be uniquely identified by the following four basic properties:
- Symbol: US and UK stock symbols are typically alphabetic, while HK and A-share symbols are numeric. For example, Tiger Brokers' symbol is TIGR.
- Security Type (sec_type): Common types include STK (Stock), OPT (Option), FUT (Futures), CASH (Forex). For example, Tiger Brokers stock has sec_type STK.
- Currency: Common currencies include USD (US Dollar) and HKD (Hong Kong Dollar).
- Exchange: Generally not used for STK contracts as orders are auto-routed. Futures contracts typically require the exchange field.
Get a Contract
value TradeClient::get_contract(utility::string_t symbol, utility::string_t sec_type, utility::string_t currency, utility::string_t exchange, time_t expiry, utility::string_t strike, utility::string_t right)
value TradeClient::get_contract(utility::string_t symbol, SecType sec_type, Currency currency, utility::string_t exchange, time_t expiry, utility::string_t strike, Right right)
Description
Returns the contract information required to trade one instrument. Overloads accept either strings or enums.
Parameters (String Version)
| Parameter | Type | Required | Description |
|---|---|---|---|
| symbol | utility::string_t | Yes | Stock symbol, e.g., U("AAPL") |
| sec_type | utility::string_t | Yes | Security type, e.g., U("STK"), U("OPT"), U("FUT") |
| currency | utility::string_t | No | Currency, e.g., U("USD"), U("HKD") |
| exchange | utility::string_t | No | Exchange, e.g., U("CBOE") |
| expiry | time_t | No | Contract expiry timestamp (milliseconds), default -1 |
| strike | utility::string_t | No | Strike price (for options) |
| right | utility::string_t | No | Put/Call (for options), U("PUT") or U("CALL") |
Parameters (Enum Version)
| Parameter | Type | Required | Description |
|---|---|---|---|
| symbol | utility::string_t | Yes | Stock symbol |
| sec_type | SecType | No | Security type, default SecType::STK |
| currency | Currency | No | Currency, default Currency::ALL |
| exchange | utility::string_t | No | Exchange |
| expiry | time_t | No | Contract expiry timestamp, default -1 |
| strike | utility::string_t | No | Strike price |
| right | Right | No | Option direction, default Right::ALL |
Return
web::json::value JSON object containing contract information
Object Properties
| Property | Type | Description |
|---|---|---|
| identifier | string | Unique identifier. For stocks, same as symbol; for options, a 21-character identifier |
| symbol | string | Stock symbol |
| sec_type | string | STK Stock / OPT Option / FUT Futures / WAR Warrant / IOPT CBBC, etc. |
| name | string | Contract name |
| currency | string | Currency, e.g., USD/HKD/CNH |
| exchange | string | Exchange |
| expiry | string | Expiry date (options and futures) |
| strike | float | Strike price (options) |
| multiplier | float | Multiplier, quantity per lot |
| put_call | string | CALL or PUT (options) |
| market | string | Market, e.g., US/HK/CN |
| min_tick | float | Minimum tick size |
| tickSizes | array | Tick size price ranges |
| shortable | bool | Indicates whether the instrument can be sold short |
| marginable | bool | Indicates whether the instrument is marginable |
| lot_size | float | Minimum tradable quantity per transaction |
Example
#include "tigerapi/trade_client.h"
#include "tigerapi/client_config.h"
using namespace TIGER_API;
ClientConfig config(false, U("your_config_directory_path"));
TradeClient trade_client(config);
// Stock contract
value contract = trade_client.get_contract(U("AAPL"), U("STK"));
ucout << contract.serialize() << std::endl;
// Futures contract
value fut_contract = trade_client.get_contract(U("ES2306"), U("FUT"));
ucout << fut_contract.serialize() << std::endl;SDK model shape
get_contract returns raw web::json::value. Convertible Contract fields derived from include/tigerapi/model.h include contract_id, symbol, currency, sec_type, exchange, expiry, strike, right, multiplier, local_symbol, identifier, primary_exchange, market, trading_class, and lot_size. The SDK repository has no verified HTTP response fixture, so no synthetic JSON is shown.
Response Example
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{
"symbol": "AAPL",
"secType": "STK",
"exchange": "SMART",
"market": "US",
"lotSize": 1,
"currency": "USD",
"name": "Apple Inc"
}
]
}Get Multiple Contracts
value TradeClient::get_contracts(const value &symbols, utility::string_t sec_type, utility::string_t currency, utility::string_t exchange, time_t expiry, utility::string_t strike, utility::string_t right)
value TradeClient::get_quote_contract(utility::string_t symbol, utility::string_t sec_type, utility::string_t expiry)
get_quote_contract queries a quote contract by symbol, security type, and expiry. All three parameters are required and it returns web::json::value.
auto contract = trade_client.get_quote_contract(U("AAPL"), U("OPT"), U("2025-12-19"));Description
Returns contract information for multiple instruments as a JSON array.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| symbols | value | Yes | Array of stock symbols; maximum 50 per request |
| sec_type | utility::string_t | No | Security type, default U("STK") |
| currency | utility::string_t | No | Currency |
| exchange | utility::string_t | No | Exchange |
| expiry | time_t | No | Contract expiry timestamp, default -1 |
| strike | utility::string_t | No | Strike price |
| right | utility::string_t | No | Option direction |
Return
web::json::value JSON array
Example
ClientConfig config(false, U("your_config_directory_path"));
TradeClient trade_client(config);
value symbols = value::array();
symbols[0] = value::string(U("AAPL"));
symbols[1] = value::string(U("TSLA"));
value contracts = trade_client.get_contracts(symbols, U("STK"));
ucout << contracts.serialize() << std::endl;Local Contract Object Construction
The C++ SDK provides the ContractUtil utility class to build contract objects locally without making network requests.
Stock
#include "tigerapi/contract_util.h"
using namespace TIGER_API;
// US stock
Contract contract = ContractUtil::stock_contract(U("TIGR"), U("USD"));
// HK stock
Contract contract = ContractUtil::stock_contract(U("00700"), U("HKD"));Option
#include "tigerapi/contract_util.h"
using namespace TIGER_API;
// Method 1: Using four elements
Contract contract = ContractUtil::option_contract(
U("AAPL"), // symbol
U("20240621"), // expiry
U("190"), // strike
U("CALL"), // right
U("USD"), // currency
100 // multiplier
);
// Method 2: Using OCC identifier
Contract contract = ContractUtil::option_contract(U("AAPL 240621C00190000"));
// Parse option identifier
auto [symbol, expiry, right, strike] = ContractUtil::extract_option_info(U("AAPL 240621C00190000"));Futures
#include "tigerapi/contract_util.h"
using namespace TIGER_API;
// Using contract code
Contract contract = ContractUtil::future_contract(U("CL2312"), U("USD"));
// Using full parameters
Contract contract = ContractUtil::future_contract(
U("CL"), // symbol
U("USD"), // currency
U("20231220"), // expiry
U("NYMEX"), // exchange
U("202312"), // contract_month
1000 // multiplier
);Contract Object
The C++ SDK Contract struct contains the following main properties:
| Property | Type | Description |
|---|---|---|
| contract_id | long | Contract ID |
| symbol | utility::string_t | Symbol |
| sec_type | utility::string_t | Security type |
| currency | utility::string_t | Currency |
| exchange | utility::string_t | Exchange |
| market | utility::string_t | Market |
| expiry | utility::string_t | Expiry date |
| strike | utility::string_t | Strike price |
| right | utility::string_t | Option direction PUT/CALL |
| multiplier | int | Multiplier |
| contract_month | utility::string_t | Contract month (futures) |
| local_symbol | utility::string_t | Local identifier |
| identifier | utility::string_t | Unique identifier |
Updated 8 days ago
