行情查询
Rust SDK 通过 QuoteClient 提供全部行情接口,所有方法均为异步(async),返回 Result<Option<Value>, TigerError>。以下为完整可运行示例:
use tigeropen::config::ClientConfig;
use tigeropen::quote::QuoteClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = ClientConfig::from_properties_file("tiger_openapi_config.properties")?;
let qc = QuoteClient::new(config);
// 获取市场状态
let states = qc.market_state("US").await?;
println!("美股市场状态: {:?}", states);
// 获取实时报价
let briefs = qc.quote_real_time(&["AAPL", "TSLA"]).await?;
println!("实时报价: {:?}", briefs);
// 获取 K 线数据
let klines = qc.kline("AAPL", "day").await?;
println!("K 线数据: {:?}", klines);
Ok(())
}基础行情
market_state 获取市场状态
qc.market_state(market: &str) -> Result<Option<Value>, TigerError>
说明
查询指定市场(美股、港股等)的当前交易状态,包括是否开盘、下次开盘时间等。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| market | &str | 是 | 市场代码,如 "US"(美股)、"HK"(港股)、"CN"(A股) |
返回
Result<Option<Value>, TigerError>
返回市场状态数组,每个元素包含 market、status(trading / closed 等)、openTime 等字段。
示例
let states = qc.market_state("US").await?;
if let Some(data) = states {
println!("{:?}", data);
}
// 查询港股市场状态
let hk_states = qc.market_state("HK").await?;数据示例
请求参数:
{ "market": "US" }返回数据:
[
{
"market": "US",
"status": "trading",
"openTime": 1735020600000,
"closeTime": 1735044000000,
"timezone": "America/New_York"
}
]quote_real_time 获取实时报价
qc.quote_real_time(symbols: &[&str]) -> Result<Option<Value>, TigerError>
说明
批量获取股票的实时快照行情,包括最新价、涨跌幅、成交量等核心字段。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | &[&str] | 是 | 股票代码切片,如 &["AAPL", "TSLA"];港股如 &["00700"] |
返回
Result<Option<Value>, TigerError>
返回行情快照数组,每个元素包含 symbol、latestPrice、preClose、change、changePercentage、volume、amount 等字段。
示例
let briefs = qc.quote_real_time(&["AAPL", "TSLA", "00700"]).await?;
if let Some(data) = briefs {
println!("{}", serde_json::to_string_pretty(&data)?);
}数据示例
请求参数:
{ "symbols": ["AAPL", "TSLA"] }返回数据:
[
{
"symbol": "AAPL",
"market": "US",
"name": "Apple Inc.",
"latestPrice": 227.52,
"preClose": 225.01,
"change": 2.51,
"changePercentage": 1.115,
"volume": 62345678,
"amount": 14189233280.0,
"open": 225.50,
"high": 228.10,
"low": 224.80,
"timestamp": 1735042800000
},
{
"symbol": "TSLA",
"market": "US",
"name": "Tesla Inc.",
"latestPrice": 410.44,
"preClose": 403.84,
"change": 6.60,
"changePercentage": 1.634,
"volume": 98765432,
"amount": 40542123456.0,
"open": 405.00,
"high": 415.20,
"low": 402.30,
"timestamp": 1735042800000
}
]kline 获取K线数据
qc.kline(symbol: &str, period: &str) -> Result<Option<Value>, TigerError>
说明
获取指定股票的历史 K 线数据,支持日线、周线、月线及分钟级别。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 股票代码,如 "AAPL" |
| period | &str | 是 | K 线周期:"day" / "week" / "month" / "year" / "1min" / "5min" / "15min" / "30min" / "60min" |
返回
Result<Option<Value>, TigerError>
返回 K 线数组,每条记录包含 time、open、high、low、close、volume 字段。
示例
// 获取日线
let klines = qc.kline("AAPL", "day").await?;
println!("{:?}", klines);
// 获取 5 分钟 K 线
let klines_5min = qc.kline("AAPL", "5min").await?;数据示例
请求参数:
{ "symbols": ["AAPL"], "period": "day" }返回数据:
{
"symbol": "AAPL",
"period": "day",
"items": [
{
"time": 1734912000000,
"open": 222.56,
"high": 225.72,
"low": 222.11,
"close": 225.01,
"volume": 55234100
},
{
"time": 1734998400000,
"open": 225.50,
"high": 228.10,
"low": 224.80,
"close": 227.52,
"volume": 62345678
}
]
}timeline 获取分时数据
qc.timeline(symbols: &[&str]) -> Result<Option<Value>, TigerError>
说明
获取当日分时走势数据(逐分钟价格与成交量),用于绘制分时图。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | &[&str] | 是 | 股票代码切片 |
返回
Result<Option<Value>, TigerError>
每个 symbol 返回分时数据数组,包含 time、price、volume、avgPrice 等字段。
示例
let timeline = qc.timeline(&["AAPL", "TSLA"]).await?;
println!("{:?}", timeline);数据示例
请求参数:
{ "symbols": ["AAPL"] }返回数据:
{
"symbol": "AAPL",
"items": [
{
"time": 1735020600000,
"price": 225.50,
"volume": 3021456,
"avgPrice": 225.48
},
{
"time": 1735020660000,
"price": 225.80,
"volume": 1234567,
"avgPrice": 225.55
}
]
}trade_tick 获取逐笔成交
qc.trade_tick(symbols: &[&str]) -> Result<Option<Value>, TigerError>
说明
获取最新逐笔成交记录,每一笔成交的价格、数量和方向(买/卖)。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | &[&str] | 是 | 股票代码切片 |
返回
Result<Option<Value>, TigerError>
返回逐笔成交数组,每条包含 time、price、volume、direction 字段。
示例
let ticks = qc.trade_tick(&["AAPL"]).await?;
println!("{:?}", ticks);数据示例
请求参数:
{ "symbols": ["AAPL"] }返回数据:
{
"symbol": "AAPL",
"items": [
{
"time": 1735042780000,
"price": 227.52,
"volume": 100,
"direction": "BUY"
},
{
"time": 1735042781000,
"price": 227.50,
"volume": 200,
"direction": "SELL"
}
]
}quote_depth 获取深度行情
qc.quote_depth(symbol: &str) -> Result<Option<Value>, TigerError>
说明
获取买卖五档盘口深度数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 股票代码 |
返回
Result<Option<Value>, TigerError>
返回 askList(卖盘)和 bidList(买盘),每档包含 price、volume、orderCount 字段。
示例
let depth = qc.quote_depth("AAPL").await?;
println!("{:?}", depth);数据示例
请求参数:
{ "symbol": "AAPL" }返回数据:
{
"symbol": "AAPL",
"askList": [
{ "price": 227.53, "volume": 300, "orderCount": 2 },
{ "price": 227.55, "volume": 500, "orderCount": 4 },
{ "price": 227.58, "volume": 200, "orderCount": 1 },
{ "price": 227.60, "volume": 800, "orderCount": 6 },
{ "price": 227.65, "volume": 1200, "orderCount": 8 }
],
"bidList": [
{ "price": 227.52, "volume": 400, "orderCount": 3 },
{ "price": 227.50, "volume": 600, "orderCount": 5 },
{ "price": 227.48, "volume": 300, "orderCount": 2 },
{ "price": 227.45, "volume": 700, "orderCount": 5 },
{ "price": 227.40, "volume": 1000, "orderCount": 7 }
]
}期权行情
option_expiration 获取期权到期日
qc.option_expiration(symbol: &str) -> Result<Option<Value>, TigerError>
说明
获取指定标的股票的所有期权到期日列表,用于构建期权链查询条件。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 标的股票代码,如 "AAPL" |
返回
Result<Option<Value>, TigerError>
返回到期日字符串列表,格式为 "YYYY-MM-DD"。
示例
let exp_dates = qc.option_expiration("AAPL").await?;
println!("{:?}", exp_dates);数据示例
请求参数:
{ "symbols": ["AAPL"] }返回数据:
["2025-01-17", "2025-02-21", "2025-03-21", "2025-06-20", "2025-09-19", "2025-12-19", "2026-01-16"]option_chain 获取期权链
qc.option_chain(symbol: &str, expiry: &str) -> Result<Option<Value>, TigerError>
说明
获取指定标的和到期日的完整期权链,包含所有行权价的认购和认沽期权信息。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 标的股票代码 |
| expiry | &str | 是 | 到期日,格式 "YYYY-MM-DD",如 "2025-01-17" |
返回
Result<Option<Value>, TigerError>
返回期权链列表,每条包含 strike、callSymbol、putSymbol、callLatestPrice、putLatestPrice 等字段。
示例
let chain = qc.option_chain("AAPL", "2025-01-17").await?;
println!("{:?}", chain);数据示例
请求参数:
{ "symbol": "AAPL", "expiry": "2025-01-17" }返回数据:
[
{
"strike": 220.0,
"callSymbol": "AAPL 250117C00220000",
"putSymbol": "AAPL 250117P00220000",
"callLatestPrice": 9.50,
"putLatestPrice": 2.10,
"callImpliedVolatility": 0.285,
"putImpliedVolatility": 0.312
},
{
"strike": 225.0,
"callSymbol": "AAPL 250117C00225000",
"putSymbol": "AAPL 250117P00225000",
"callLatestPrice": 6.20,
"putLatestPrice": 3.80,
"callImpliedVolatility": 0.278,
"putImpliedVolatility": 0.299
}
]option_brief 获取期权报价
qc.option_brief(identifiers: &[&str]) -> Result<Option<Value>, TigerError>
说明
批量获取期权合约的实时报价,包含 Greeks(Delta、Gamma、Theta、Vega)等数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| identifiers | &[&str] | 是 | 期权合约代码切片,美股格式:"AAPL 250117C00150000"(注意双空格) |
返回
Result<Option<Value>, TigerError>
返回期权报价列表,包含 latestPrice、impliedVolatility、delta、gamma、theta、vega 等字段。
示例
let opt_briefs = qc.option_brief(&["AAPL 250117C00150000"]).await?;
println!("{:?}", opt_briefs);数据示例
请求参数:
{ "identifiers": ["AAPL 250117C00220000"] }返回数据:
[
{
"identifier": "AAPL 250117C00220000",
"latestPrice": 9.50,
"preClose": 9.10,
"change": 0.40,
"impliedVolatility": 0.285,
"delta": 0.612,
"gamma": 0.028,
"theta": -0.085,
"vega": 0.156,
"openInterest": 12540,
"volume": 3820
}
]option_kline 获取期权K线
qc.option_kline(identifier: &str, period: &str) -> Result<Option<Value>, TigerError>
说明
获取指定期权合约的历史 K 线数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| identifier | &str | 是 | 期权合约代码 |
| period | &str | 是 | K 线周期,如 "day"、"1min" |
返回
Result<Option<Value>, TigerError>
返回 K 线数组,字段同股票 K 线。
示例
let opt_kline = qc.option_kline("AAPL 250117C00150000", "day").await?;
println!("{:?}", opt_kline);数据示例
请求参数:
{ "identifier": "AAPL 250117C00220000", "period": "day" }返回数据:
{
"identifier": "AAPL 250117C00220000",
"period": "day",
"items": [
{
"time": 1734912000000,
"open": 8.80,
"high": 9.60,
"low": 8.70,
"close": 9.10,
"volume": 2100
},
{
"time": 1734998400000,
"open": 9.10,
"high": 9.80,
"low": 9.00,
"close": 9.50,
"volume": 3820
}
]
}期货行情
future_exchange 获取期货交易所列表
qc.future_exchange() -> Result<Option<Value>, TigerError>
说明
获取平台支持的所有期货交易所列表。
参数
无参数。
返回
Result<Option<Value>, TigerError>
返回交易所列表,每个元素包含 exchange(如 "CME")及交易所名称。
示例
let exchanges = qc.future_exchange().await?;
println!("{:?}", exchanges);数据示例
返回数据:
[
{ "exchange": "CME", "name": "Chicago Mercantile Exchange" },
{ "exchange": "CBOT", "name": "Chicago Board of Trade" },
{ "exchange": "NYMEX", "name": "New York Mercantile Exchange" },
{ "exchange": "HKEX", "name": "Hong Kong Exchanges and Clearing" }
]future_contracts 获取期货合约列表
qc.future_contracts(exchange: &str) -> Result<Option<Value>, TigerError>
说明
获取指定交易所下所有可交易期货合约列表。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| exchange | &str | 是 | 交易所代码,如 "CME"、"HKEX" |
返回
Result<Option<Value>, TigerError>
返回期货合约列表,包含 symbol、name、contractMultiplier、currency 等字段。
示例
let contracts = qc.future_contracts("CME").await?;
println!("{:?}", contracts);数据示例
请求参数:
{ "exchange": "CME" }返回数据:
[
{
"symbol": "ES",
"name": "E-mini S&P 500",
"contractMultiplier": 50,
"currency": "USD",
"minTick": 0.25,
"exchange": "CME"
},
{
"symbol": "NQ",
"name": "E-mini NASDAQ-100",
"contractMultiplier": 20,
"currency": "USD",
"minTick": 0.25,
"exchange": "CME"
}
]future_real_time_quote 获取期货实时报价
qc.future_real_time_quote(symbols: &[&str]) -> Result<Option<Value>, TigerError>
说明
批量获取期货合约的实时行情数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | &[&str] | 是 | 期货合约代码切片,如 &["ES2506", "NQ2506"] |
返回
Result<Option<Value>, TigerError>
返回期货行情列表,包含 symbol、latestPrice、change、volume、openInterest 等字段。
示例
let fut_quotes = qc.future_real_time_quote(&["ES2506", "NQ2506"]).await?;
println!("{:?}", fut_quotes);数据示例
请求参数:
{ "symbols": ["ES2506", "NQ2506"] }返回数据:
[
{
"symbol": "ES2506",
"latestPrice": 5920.50,
"preClose": 5895.25,
"change": 25.25,
"changePercentage": 0.428,
"volume": 1234567,
"openInterest": 2345678,
"open": 5900.00,
"high": 5935.00,
"low": 5895.00,
"timestamp": 1735042800000
}
]future_kline 获取期货K线
qc.future_kline(symbol: &str, period: &str) -> Result<Option<Value>, TigerError>
说明
获取期货合约的历史 K 线数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 期货合约代码,如 "ES2506" |
| period | &str | 是 | K 线周期:"day" / "week" / "1min" / "5min" / "15min" / "30min" / "60min" |
返回
Result<Option<Value>, TigerError>
返回 K 线数组,字段同股票 K 线。
示例
let fut_kline = qc.future_kline("ES2506", "day").await?;
println!("{:?}", fut_kline);数据示例
请求参数:
{ "symbol": "ES2506", "period": "day" }返回数据:
{
"symbol": "ES2506",
"period": "day",
"items": [
{
"time": 1734912000000,
"open": 5870.00,
"high": 5900.00,
"low": 5860.00,
"close": 5895.25,
"volume": 1023456
},
{
"time": 1734998400000,
"open": 5900.00,
"high": 5935.00,
"low": 5895.00,
"close": 5920.50,
"volume": 1234567
}
]
}基本面数据
financial_daily 获取财务日报
qc.financial_daily(symbol: &str) -> Result<Option<Value>, TigerError>
说明
获取股票的每日财务指标数据,如市盈率(PE)、市净率(PB)、股息率等。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 股票代码 |
返回
Result<Option<Value>, TigerError>
返回财务日报列表,包含 date、pe、pb、eps、dividendYield 等字段。
示例
let daily = qc.financial_daily("AAPL").await?;
println!("{:?}", daily);数据示例
请求参数:
{ "symbol": "AAPL" }返回数据:
[
{
"date": "2024-12-24",
"pe": 38.5,
"pb": 58.2,
"eps": 6.52,
"dividendYield": 0.0044,
"marketCap": 3420000000000
}
]financial_report 获取财务报告
qc.financial_report(symbol: &str) -> Result<Option<Value>, TigerError>
说明
获取股票的季度/年度财务报告数据,包含利润表、资产负债表、现金流量表等核心数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 股票代码 |
返回
Result<Option<Value>, TigerError>
返回财务报告列表,包含 revenue、netIncome、totalAssets、totalLiabilities、cashFlow 等字段。
示例
let report = qc.financial_report("AAPL").await?;
println!("{:?}", report);数据示例
请求参数:
{ "symbol": "AAPL" }返回数据:
[
{
"period": "2024Q4",
"periodType": "quarterly",
"revenue": 124300000000,
"netIncome": 36330000000,
"totalAssets": 352583000000,
"totalLiabilities": 308030000000,
"cashFlow": 29943000000,
"eps": 2.40
}
]corporate_action 获取公司行动
qc.corporate_action(symbol: &str) -> Result<Option<Value>, TigerError>
说明
获取股票的公司行动记录,包括分红、股票拆分(拆股/合股)、配股等事件。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 股票代码 |
返回
Result<Option<Value>, TigerError>
返回公司行动列表,每条包含 actionType(dividend / split 等)、exDate、amount、ratio 等字段。
示例
let actions = qc.corporate_action("AAPL").await?;
println!("{:?}", actions);数据示例
请求参数:
{ "symbol": "AAPL" }返回数据:
[
{
"actionType": "dividend",
"exDate": "2024-11-08",
"payDate": "2024-11-14",
"amount": 0.25,
"currency": "USD"
},
{
"actionType": "split",
"exDate": "2020-08-31",
"ratio": 4.0,
"description": "4:1 股票拆分"
}
]资金流向
capital_flow 获取资金流向
qc.capital_flow(symbol: &str) -> Result<Option<Value>, TigerError>
说明
获取股票的资金流向数据,区分大单/中单/小单的流入流出情况,帮助判断主力资金动向。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 股票代码 |
返回
Result<Option<Value>, TigerError>
返回资金流向数据,包含 inflow、outflow、netInflow、largeOrderInflow、smallOrderOutflow 等字段。
示例
let flow = qc.capital_flow("AAPL").await?;
println!("{:?}", flow);数据示例
请求参数:
{ "symbol": "AAPL" }返回数据:
{
"symbol": "AAPL",
"inflow": 8234567890,
"outflow": 7123456789,
"netInflow": 1111111101,
"largeOrderInflow": 5123456789,
"largeOrderOutflow": 4012345678,
"mediumOrderInflow": 2012345678,
"smallOrderInflow": 1098765432,
"timestamp": 1735042800000
}capital_distribution 获取资金分布
qc.capital_distribution(symbol: &str) -> Result<Option<Value>, TigerError>
说明
获取股票当前资金分布快照,按散户/机构/大户等维度展示持仓比例。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 股票代码 |
返回
Result<Option<Value>, TigerError>
返回资金分布数据,包含各类投资者的 buyRatio、sellRatio、holdRatio 等字段。
示例
let dist = qc.capital_distribution("AAPL").await?;
println!("{:?}", dist);数据示例
请求参数:
{ "symbol": "AAPL" }返回数据:
{
"symbol": "AAPL",
"retailBuyRatio": 0.18,
"retailSellRatio": 0.15,
"institutionBuyRatio": 0.42,
"institutionSellRatio": 0.38,
"largeholderBuyRatio": 0.40,
"largeholderSellRatio": 0.47,
"timestamp": 1735042800000
}选股器
market_scanner 选股器
qc.market_scanner(params: serde_json::Value) -> Result<Option<Value>, TigerError>
说明
根据自定义条件筛选符合要求的股票,支持按市值、涨跌幅、成交量、技术指标等多维度过滤。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| params | serde_json::Value | 是 | 筛选条件 JSON 对象,包含 market(市场)和 filter(过滤条件数组) |
返回
Result<Option<Value>, TigerError>
返回符合条件的股票列表。
示例
let scan_result = qc.market_scanner(serde_json::json!({
"market": "US",
"filter": [
{"fieldName": "marketCap", "filterMin": 1000000000},
{"fieldName": "changePercentage", "filterMin": 2.0},
],
})).await?;
println!("{:?}", scan_result);数据示例
请求参数:
{
"market": "US",
"filter": [
{ "fieldName": "marketCap", "filterMin": 1000000000 },
{ "fieldName": "changePercentage", "filterMin": 2.0 }
]
}返回数据:
[
{
"symbol": "AAPL",
"name": "Apple Inc.",
"latestPrice": 227.52,
"changePercentage": 1.115,
"marketCap": 3420000000000,
"volume": 62345678
},
{
"symbol": "NVDA",
"name": "NVIDIA Corporation",
"latestPrice": 138.85,
"changePercentage": 3.240,
"marketCap": 3390000000000,
"volume": 185432100
}
]grab_quote_permission 获取行情权限
qc.grab_quote_permission() -> Result<Option<Value>, TigerError>
说明
查询当前账户开通的行情权限列表,确认是否有权限访问实时行情数据。
参数
无参数。
返回
Result<Option<Value>, TigerError>
返回已开通的行情权限列表。
示例
let perm = qc.grab_quote_permission().await?;
println!("{:?}", perm);数据示例
返回数据:
["US_BASIC", "HK_BASIC", "US_REALTIME"]Updated 8 days ago
