期权
其他当前期权方法
value QuoteClient::get_option_kline_value(value identifiers, time_t begin_time, time_t end_time = 4070880000000)
value QuoteClient::get_option_symbols(utility::string_t market = U("HK"), utility::string_t lang = U(""))
value QuoteClient::get_option_analysis(const value &symbols, utility::string_t market = U("US"), utility::string_t lang = U(""))get_option_kline_value 要求期权标识数组和开始时间,返回原始 JSON;结束时间 SDK 默认 4070880000000。get_option_symbols 默认 HK 市场。get_option_analysis 要求代码数组,市场默认 US。均返回 web::json::value 并需要对应期权行情权限。
auto raw_bars = quote_client.get_option_kline_value(identifiers, 1704067200000);
auto hk_symbols = quote_client.get_option_symbols();
auto analysis = quote_client.get_option_analysis(symbols);响应依据:这些接口返回未建模 JSON,SDK 仓库没有已验证期权分析 fixture,不提供合成 Greeks。
获取期权到期日
value QuoteClient::get_option_expiration(const value &symbols)
说明
获取指定标的的所有期权到期日
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | value | Yes | 标的代码数组,最多 30 只,如 value::array({value::string(U("AAPL"))}) |
返回
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 symbols = value::array();
symbols[0] = value::string(U("AAPL"));
value result = quote_client.get_option_expiration(symbols);
ucout << result.serialize() << std::endl;返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{
"symbol": "AAPL",
"dates": ["2025-08-08", "2025-08-15", "2025-08-22"],
"timestamps": [1754625600000, 1755230400000, 1755835200000],
"count": 3
}
]
}指数期权的特殊代码
- 标普 500(
.SPX):月度期权符号为SPX,周期权和季度期权为SPXW。 - 纳斯达克 100:月度期权为
NDX,周期权为NDXP。 - VIX 指数:月度期权为
VIX,周期权为VIXW。
获取期权链
value QuoteClient::get_option_chain(const utility::string_t symbol, utility::string_t expiry, value option_filter)
说明
获取指定标的、到期日的期权链数据
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | utility::string_t | Yes | 标的代码,如 U("AAPL") |
| expiry | time_t 或 utility::string_t | Yes | 到期日,时间戳(毫秒)或日期字符串如 U("2024-06-21") |
| option_filter | value | No | 筛选条件 JSON 对象,默认 value::null() |
option_filter 筛选条件
| 字段名 | 类型 | 描述 |
|---|---|---|
| implied_volatility_min | double | 隐含波动率最小值 |
| implied_volatility_max | double | 隐含波动率最大值 |
| delta_min | double | Delta 最小值 |
| delta_max | double | Delta 最大值 |
| open_interest_min | int | 未平仓合约数最小值 |
| open_interest_max | int | 未平仓合约数最大值 |
| in_the_money | bool | 是否为价内期权 |
返回
web::json::value JSON 对象
示例
ClientConfig config(false, U("your_config_directory_path"));
QuoteClient quote_client(config);
// 不带筛选条件
value result = quote_client.get_option_chain(U("AAPL"), U("2024-06-21"));
ucout << result.serialize() << std::endl;
// 带筛选条件
value filter = value::object();
filter[U("in_the_money")] = value::boolean(true);
value result2 = quote_client.get_option_chain(U("AAPL"), U("2024-06-21"), filter);返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{
"symbol": "AAPL",
"expiry": 1754625600000,
"items": [
{"identifier": "AAPL 250808C00230000", "strike": 230.0, "right": "CALL", "latestPrice": 80.50, "volume": 1200, "openInterest": 5600},
{"identifier": "AAPL 250808P00230000", "strike": 230.0, "right": "PUT", "latestPrice": 1.25, "volume": 800, "openInterest": 3200}
]
}
]
}获取期权行情快照
value QuoteClient::get_option_brief(value identifiers)
说明
获取期权合约的实时行情快照
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| identifiers | value 或 utility::string_t | Yes | 期权标识符,支持单个字符串或数组。如 U("AAPL 240621C00190000") |
返回
web::json::value JSON 对象
示例
ClientConfig config(false, U("your_config_directory_path"));
QuoteClient quote_client(config);
value result = quote_client.get_option_brief(U("AAPL 240621C00190000"));
ucout << result.serialize() << std::endl;返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{
"identifier": "AAPL 250808C00230000",
"symbol": "AAPL",
"strike": 230.0,
"right": "CALL",
"multiplier": 100,
"expiry": 1754625600000,
"latestPrice": 80.50,
"volume": 1200,
"openInterest": 5600,
"impliedVol": 0.3702,
"delta": 0.92,
"gamma": 0.008,
"theta": -0.15,
"vega": 0.12
}
]
}获取期权 K 线
vector<Kline> QuoteClient::get_option_kline(
value identifiers, time_t begin_time, time_t end_time = 4070880000000)说明
获取期权合约的 K 线数据
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| identifiers | value | Yes | 期权标识符数组,最多 30 个 |
| begin_time | time_t | Yes | 起始时间戳(毫秒) |
| end_time | time_t | No | 结束时间戳(毫秒),默认 4070880000000 |
返回
web::json::value JSON 对象,或 vector<Kline> Kline 对象列表
示例
ClientConfig config(false, U("your_config_directory_path"));
QuoteClient quote_client(config);
value identifiers = value::array();
identifiers[0] = value::string(U("AAPL 240621C00190000"));
vector<Kline> klines = quote_client.get_option_kline(identifiers, 1700000000000);返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{
"identifier": "AAPL 250808C00230000",
"period": "day",
"items": [
{"time": 1785355200000, "open": 78.00, "high": 82.00, "low": 77.50, "close": 80.50, "volume": 1200},
{"time": 1785441600000, "open": 80.50, "high": 83.00, "low": 79.00, "close": 81.25, "volume": 950}
]
}
]
}获取期权逐笔成交
value QuoteClient::get_option_trade_tick(value identifiers)
说明
获取期权合约的逐笔成交数据
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| identifiers | value | Yes | 期权标识符数组,最多 30 个 |
返回
web::json::value JSON 对象
返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{
"identifier": "AAPL 250808C00230000",
"items": [
{"time": 1785527900000, "price": 80.50, "volume": 5, "type": "+"},
{"time": 1785527920000, "price": 80.45, "volume": 3, "type": "-"}
]
}
]
}获取期权深度行情
value QuoteClient::get_option_depth(const value &symbols, utility::string_t market)
说明
获取期权的深度行情数据
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | value | Yes | 期权标识符数组,最多 30 个 |
| market | utility::string_t | No | 市场,默认 U("US") |
返回
web::json::value JSON 对象
返回示例
{
"code": 0,
"message": "success",
"timestamp": 1785528000000,
"data": [
{
"identifier": "AAPL 250808C00230000",
"asks": [
{"price": 80.80, "volume": 20, "count": 0},
{"price": 80.90, "volume": 15, "count": 0}
],
"bids": [
{"price": 80.50, "volume": 10, "count": 0},
{"price": 80.40, "volume": 25, "count": 0}
]
}
]
}获取期权分时
value QuoteClient::get_option_timeline(const value &symbols, utility::string_t market, time_t begin_time)
说明
获取期权的分时数据
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | value | Yes | 期权标识符数组,最多 30 个 |
| market | utility::string_t | No | 市场,默认 U("US") |
| begin_time | time_t | No | 起始时间戳,默认 -1 |
返回
web::json::value JSON 对象
Updated 8 days ago
