期货
其他当前期货方法
value QuoteClient::get_future_real_time_quote_value(value contract_codes)
value QuoteClient::get_future_history_main_contract(value contract_codes, time_t begin_time = -1, time_t end_time = -1)contract_codes 为必填 JSON 字符串数组。第一个方法返回原始实时行情 JSON;第二个方法查询历史主力合约,起止时间默认 -1 且仅正值会发送。需要对应期货行情权限。
auto quotes = quote_client.get_future_real_time_quote_value(contract_codes);
auto history = quote_client.get_future_history_main_contract(contract_codes);响应依据:原始 JSON 方法没有固定 SDK 模型或已验证 fixture;历史主力合约字段以服务端响应为准。
获取期货交易所列表
value QuoteClient::get_future_exchange(SecType sec_type)
说明
获取期货支持的交易所列表
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| sec_type | SecType | No | 合约类型,默认 SecType::FUT |
返回
web::json::value JSON 对象
示例
#include "tigerapi/quote_client.h"
#include "tigerapi/client_config.h"
using namespace TIGER_API;
ClientConfig config(false, U("your_config_directory_path"));
QuoteClient quote_client(config);
value result = quote_client.get_future_exchange();
ucout << result.serialize() << std::endl;获取期货合约列表
value QuoteClient::get_future_contracts(utility::string_t type)
说明
获取指定品种的期货合约列表
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| type | utility::string_t | Yes | 期货品种代码,如 U("CL")(原油)、U("ES")(标普 500) |
返回
web::json::value JSON 对象
示例
ClientConfig config(false, U("your_config_directory_path"));
QuoteClient quote_client(config);
value result = quote_client.get_future_contracts(U("CL"));
ucout << result.serialize() << std::endl;返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{"contractCode": "ES2609", "type": "ES", "name": "E-mini S&P 500", "exchangeCode": "CME", "multiplier": 50.0, "contractMonth": "202609"},
{"contractCode": "ES2612", "type": "ES", "name": "E-mini S&P 500", "exchangeCode": "CME", "multiplier": 50.0, "contractMonth": "202612"}
]
}获取连续合约
value QuoteClient::get_future_continuous_contracts(utility::string_t type)
说明
获取指定品种的连续合约信息
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| type | utility::string_t | Yes | 期货品种代码 |
返回
web::json::value JSON 对象
返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{"contractCode": "ESmain", "type": "ES", "name": "E-mini S&P 500 (Main)", "exchangeCode": "CME", "multiplier": 50.0}
]
}获取当前合约
value QuoteClient::get_future_current_contract(utility::string_t type)
说明
获取指定品种的当前主力合约
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| type | utility::string_t | Yes | 期货品种代码 |
返回
web::json::value JSON 对象
返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": {
"contractCode": "ES2609",
"type": "ES",
"name": "E-mini S&P 500",
"exchangeCode": "CME",
"multiplier": 50.0,
"contractMonth": "202609"
}
}通过合约代码获取期货合约
value QuoteClient::get_future_contract_by_contract_code(utility::string_t contract_code)
说明
通过具体的合约代码获取期货合约信息
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| contract_code | utility::string_t | Yes | 合约代码,如 U("CL2312") |
返回
web::json::value JSON 对象
通过交易所获取期货合约
value QuoteClient::get_future_contract_by_exchange_code(utility::string_t exchange_code)
说明
通过交易所代码获取期货合约列表
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| exchange_code | utility::string_t | Yes | 交易所代码,如 U("CME")、U("NYMEX") |
返回
web::json::value JSON 对象
获取期货 K 线
value QuoteClient::get_future_kline(value contract_codes, utility::string_t period, time_t begin_time, time_t end_time, int limit, utility::string_t page_token)
说明
获取期货合约的 K 线数据
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| contract_codes | value | Yes | 合约代码数组,最多 50 个 |
| period | BarPeriod 或 utility::string_t | No | K 线周期,默认 BarPeriod::DAY。可选值:day/week/month/year/1min/5min/15min/30min/60min |
| begin_time | time_t | No | 起始时间戳,默认 -1 |
| end_time | time_t | No | 结束时间戳,默认 -1 |
| limit | int | No | 返回条数,默认 251 |
| page_token | utility::string_t | No | 翻页标记 |
返回
web::json::value JSON 对象,或 vector<Kline> Kline 对象列表
示例
ClientConfig config(false, U("your_config_directory_path"));
QuoteClient quote_client(config);
value codes = value::array();
codes[0] = value::string(U("CL2312"));
value result = quote_client.get_future_kline(codes, U("day"));
ucout << result.serialize() << std::endl;返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{
"contractCode": "ES2612",
"period": "day",
"items": [
{"time": 1785355200000, "open": 7600.0, "high": 7640.0, "low": 7580.0, "close": 7625.0, "volume": 125000},
{"time": 1785441600000, "open": 7625.0, "high": 7650.0, "low": 7610.0, "close": 7640.0, "volume": 98000}
]
}
]
}获取期货实时行情
vector<RealtimeQuote> QuoteClient::get_future_real_time_quote(value contract_codes)说明
获取期货合约的实时行情数据
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| contract_codes | value | Yes | 合约代码数组,最多 50 个 |
返回
vector<RealtimeQuote> 实时行情对象列表
RealtimeQuote 对象属性(期货额外字段)
| 属性名 | 类型 | 描述 |
|---|---|---|
| contract_code | utility::string_t | 合约代码 |
| open_interest | long long | 未平仓合约数 |
| limit_down | int | 跌停价 |
| limit_up | int | 涨停价 |
示例
ClientConfig config(false, U("your_config_directory_path"));
QuoteClient quote_client(config);
value codes = value::array();
codes[0] = value::string(U("CL2312"));
vector<RealtimeQuote> quotes = quote_client.get_future_real_time_quote(codes);
for (auto& q : quotes) {
ucout << q.contract_code << U(" price: ") << q.latest_price << std::endl;
}获取期货逐笔成交
value QuoteClient::get_future_tick(utility::string_t contract_code, long begin_index, long end_index, int limit)
说明
获取期货合约的逐笔成交数据
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| contract_code | utility::string_t | Yes | 合约代码 |
| begin_index | long | No | 起始索引,默认 0 |
| end_index | long | No | 结束索引,默认 100 |
| limit | int | No | 返回条数,默认 1000 |
返回
web::json::value JSON 对象
返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{
"contractCode": "ES2612",
"items": [
{"time": 1785527980000, "price": 7625.0, "volume": 12, "type": "+"},
{"time": 1785527980100, "price": 7624.75, "volume": 5, "type": "-"}
]
}
]
}获取期货交易日
value QuoteClient::get_future_trading_date(utility::string_t contract_code, utility::string_t trading_date)
说明
获取期货合约的交易日信息
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| contract_code | utility::string_t | Yes | 合约代码 |
| trading_date | utility::string_t | Yes | 交易日期 |
返回
web::json::value JSON 对象
返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{"date": "2025-07-28", "type": "TRADING"},
{"date": "2025-07-29", "type": "TRADING"}
]
}获取期货深度行情
value QuoteClient::get_future_depth(value contract_codes, utility::string_t lang)
说明
获取期货合约的深度行情数据
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| contract_codes | value | Yes | 合约代码数组,最多 50 个 |
| lang | utility::string_t | No | 语言,默认空 |
返回
web::json::value JSON 对象
返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{
"contractCode": "ES2612",
"asks": [
{"price": 7623.50, "volume": 120},
{"price": 7624.00, "volume": 85}
],
"bids": [
{"price": 7622.25, "volume": 95},
{"price": 7622.00, "volume": 150}
]
}
]
}Updated 8 days ago
