行情查询
Rust SDK 通过 QuoteClient 提供全部行情接口。自 v0.3.0 起,所有方法均以 get_* 命名并返回强类型响应(如 Vec<MarketState>、Vec<Brief>、Vec<Kline> 等),请求参数通过结构体或扁平函数参数传入,内部以 snake_case 序列化发往服务端,响应以 camelCase 反序列化。v0.4.0 将 4 个方法(get_brief / get_trade_tick / get_quote_depth / get_future_real_time_quote)改为 Request struct 签名(breaking),并新增约 41 个方法覆盖股票基础 / 期权 / 期货 / 基金 / 窝轮 / 行业 / 财务日历等场景。以下为完整可运行示例:
use tigeropen::client::http_client::HttpClient;
use tigeropen::config::ClientConfig;
use tigeropen::model::quote_requests::BriefRequest;
use tigeropen::quote::QuoteClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = ClientConfig::builder().build()?;
// 行情客户端需要行情专用 HttpClient
let http = HttpClient::with_quote_server(config);
let qc = QuoteClient::new(&http);
// 获取市场状态
let states = qc.get_market_state("US").await?;
println!("美股市场状态: {:?}", states);
// 获取实时报价 (v0.4.0: Request struct)
let briefs = qc.get_brief(BriefRequest {
symbols: Some(vec!["AAPL".to_string(), "TSLA".to_string()]),
..Default::default()
}).await?;
println!("实时报价: {:?}", briefs);
// 获取 K 线数据
let klines = qc.get_kline("AAPL", "day").await?;
println!("K 线数据: {:?}", klines);
Ok(())
}基础行情
get_market_state 获取市场状态
qc.get_market_state(market: &str) -> Result<Vec<MarketState>, TigerError>
说明
查询指定市场(美股、港股等)的当前交易状态,包括是否开盘、下次开盘时间等。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| market | &str | 是 | 市场代码,如 "US"(美股)、"HK"(港股)、"CN"(A股) |
返回
Result<Vec<MarketState>, TigerError>
每个 MarketState 包含 market、market_status、status、open_time 字段。
示例
let states = qc.get_market_state("US").await?;
if let Some(s) = states.first() {
println!("market={} status={} openTime={}", s.market, s.market_status, s.open_time);
}
// 查询港股市场状态
let hk_states = qc.get_market_state("HK").await?;数据示例
请求参数:
{ "market": "US" }返回数据:
[
{
"market": "US",
"marketStatus": "TRADING",
"status": "trading",
"openTime": "2025-05-06 09:30:00"
}
]get_brief 获取实时报价
async fn get_brief(&self, req: BriefRequest) -> Result<Vec<Brief>, TigerError>
v0.4.0 Breaking:由位置参数
symbols: &[&str]改为BriefRequeststruct。
说明
批量获取股票的实时快照行情,包括最新价、涨跌幅、成交量等核心字段。内部调用服务端 brief 接口。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | Option<Vec<String>> | 是 | 股票代码列表,如 vec!["AAPL".to_string()] |
| include_hour_trading | Option<bool> | 否 | 是否包含盘前盘后 |
| sec_type | Option<String> | 否 | 证券类型 |
| lang | Option<String> | 否 | 语言 |
返回
Result<Vec<Brief>, TigerError>
每个 Brief 包含 symbol、latest_price、pre_close、change、change_rate、volume、open、high、low、ask_price / bid_price、latest_time 等字段。
示例
use tigeropen::model::quote_requests::BriefRequest;
let briefs = qc.get_brief(BriefRequest {
symbols: Some(vec!["AAPL".to_string(), "TSLA".to_string(), "00700".to_string()]),
..Default::default()
}).await?;
for b in &briefs {
println!("{} latest={:.2} change_rate={:.4}", b.symbol, b.latest_price, b.change_rate);
}数据示例
请求参数:
{ "symbols": ["AAPL", "TSLA"] }返回数据:
[
{
"symbol": "AAPL",
"latestPrice": 227.52,
"preClose": 225.01,
"change": 2.51,
"changeRate": 0.01115,
"volume": 62345678,
"open": 225.50,
"high": 228.10,
"low": 224.80,
"askPrice": 227.53,
"askSize": 300,
"bidPrice": 227.52,
"bidSize": 400,
"latestTime": 1735042800000
},
{
"symbol": "TSLA",
"latestPrice": 410.44,
"preClose": 403.84,
"change": 6.60,
"changeRate": 0.01634,
"volume": 98765432,
"open": 405.00,
"high": 415.20,
"low": 402.30,
"latestTime": 1735042800000
}
]get_kline 获取K线数据
qc.get_kline(symbol: &str, period: &str) -> Result<Vec<Kline>, TigerError>
说明
获取指定股票的历史 K 线数据,支持日线、周线、月线及分钟级别。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 股票代码,如 "AAPL" |
| period | &str | 是 | K 线周期:"day" / "week" / "month" / "year" / "1min" / "5min" / "15min" / "30min" / "60min" |
返回
Result<Vec<Kline>, TigerError>
每个 Kline 包含 symbol、period、next_page_token,以及 items: Vec<KlineItem>;KlineItem 含 time、open、high、low、close、volume、amount。
示例
// 获取日线
let klines = qc.get_kline("AAPL", "day").await?;
if let Some(k) = klines.first() {
println!("{} bars={}", k.symbol, k.items.len());
}
// 获取 5 分钟 K 线
let klines_5min = qc.get_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
}
]
}
]get_timeline 获取分时数据
qc.get_timeline(symbols: &[&str]) -> Result<Vec<Timeline>, TigerError>
说明
获取当日分时走势数据(逐分钟价格与成交量),用于绘制分时图。内部使用 v3.0 接口。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | &[&str] | 是 | 股票代码切片 |
返回
Result<Vec<Timeline>, TigerError>
每个 Timeline 包含 symbol、period、pre_close,以及 intraday / pre_hours / after_hours 三个可选 TimelineBucket;每个桶的 items 含 time、price、volume、avg_price 字段。
示例
let timeline = qc.get_timeline(&["AAPL", "TSLA"]).await?;
if let Some(t) = timeline.first() {
let points = t.intraday.as_ref().map(|b| b.items.len()).unwrap_or(0);
println!("{} intraday_points={} preClose={:.2}", t.symbol, points, t.pre_close);
}数据示例
请求参数:
{ "symbols": ["AAPL"] }返回数据:
[
{
"symbol": "AAPL",
"period": "day",
"preClose": 225.01,
"intraday": {
"items": [
{ "time": 1735020600000, "price": 225.50, "volume": 3021456, "avgPrice": 225.48 },
{ "time": 1735020660000, "price": 225.80, "volume": 1234567, "avgPrice": 225.55 }
]
}
}
]get_trade_tick 获取逐笔成交
async fn get_trade_tick(&self, req: TradeTickRequest) -> Result<Vec<TradeTick>, TigerError>
v0.4.0 Breaking:由位置参数
symbols: &[&str]改为TradeTickRequeststruct。
说明
获取最新逐笔成交记录,每一笔成交的价格、数量和方向(买/卖)。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | Option<Vec<String>> | 是 | 股票代码列表 |
| begin_index | Option<i32> | 否 | 起始序号 |
| end_index | Option<i32> | 否 | 结束序号 |
| limit | Option<i32> | 否 | 返回条数上限 |
| lang | Option<String> | 否 | 语言 |
返回
Result<Vec<TradeTick>, TigerError>
每个 TradeTick 含 symbol、begin_index、end_index、items;每条 items 包含 time、price、volume、type(方向字段,Rust 里为 r#type)。
示例
use tigeropen::model::quote_requests::TradeTickRequest;
let ticks = qc.get_trade_tick(TradeTickRequest {
symbols: Some(vec!["AAPL".to_string()]),
..Default::default()
}).await?;
if let Some(t) = ticks.first() {
println!("{} ticks={}", t.symbol, t.items.len());
}数据示例
请求参数:
{ "symbols": ["AAPL"] }返回数据:
[
{
"symbol": "AAPL",
"beginIndex": 0,
"endIndex": 1,
"items": [
{ "time": 1735042780000, "price": 227.52, "volume": 100, "type": "B" },
{ "time": 1735042781000, "price": 227.50, "volume": 200, "type": "S" }
]
}
]get_quote_depth 获取深度行情
async fn get_quote_depth(&self, req: DepthQuoteRequest) -> Result<Vec<Depth>, TigerError>
v0.4.0 Breaking:由位置参数
(symbol: &str, market: &str)改为DepthQuoteRequeststruct。
说明
获取买卖盘口深度数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | Option<Vec<String>> | 是 | 股票代码列表 |
| market | Option<String> | 是 | 市场代码,如 "US"、"HK" |
| lang | Option<String> | 否 | 语言 |
返回
Result<Vec<Depth>, TigerError>
每个 Depth 含 symbol、asks(卖盘)、bids(买盘),其中每档 DepthLevel 包含 price、count、volume 字段。
示例
use tigeropen::model::quote_requests::DepthQuoteRequest;
let depth = qc.get_quote_depth(DepthQuoteRequest {
symbols: Some(vec!["AAPL".to_string()]),
market: Some("US".to_string()),
..Default::default()
}).await?;
if let Some(d) = depth.first() {
println!("asks={} bids={}", d.asks.len(), d.bids.len());
}数据示例
请求参数:
{ "symbols": ["AAPL"], "market": "US" }返回数据:
[
{
"symbol": "AAPL",
"asks": [
{ "price": 227.53, "volume": 300, "count": 2 },
{ "price": 227.55, "volume": 500, "count": 4 }
],
"bids": [
{ "price": 227.52, "volume": 400, "count": 3 },
{ "price": 227.50, "volume": 600, "count": 5 }
]
}
]期权行情
get_option_expiration 获取期权到期日
qc.get_option_expiration(symbol: &str) -> Result<Vec<OptionExpiration>, TigerError>
说明
获取指定标的股票的所有期权到期日列表,用于构建期权链查询条件。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 标的股票代码,如 "AAPL" |
返回
Result<Vec<OptionExpiration>, TigerError>
每个元素含 symbol、dates("YYYY-MM-DD" 字符串数组)、timestamps(毫秒时间戳数组),以及可选的 option_symbols、periods、counts。
示例
let exps = qc.get_option_expiration("AAPL").await?;
if let Some(e) = exps.first() {
println!("dates={} first={}", e.dates.len(), e.dates.first().unwrap_or(&"".into()));
}数据示例
请求参数:
{ "symbols": ["AAPL"] }返回数据:
[
{
"symbol": "AAPL",
"dates": ["2025-01-17", "2025-02-21", "2025-03-21", "2025-06-20", "2025-09-19"],
"timestamps": [1737072000000, 1740096000000, 1742515200000, 1750377600000, 1758240000000]
}
]get_option_chain 获取期权链
qc.get_option_chain(symbol: &str, expiry: &str) -> Result<Vec<OptionChain>, TigerError>
说明
获取指定标的和到期日的完整期权链,包含所有行权价的认购和认沽期权信息。SDK 内部会把 "YYYY-MM-DD" 的 expiry 转换为 UTC 毫秒时间戳,并封装成 option_basic 数组(使用 v3.0 接口)。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 标的股票代码 |
| expiry | &str | 是 | 到期日,格式 "YYYY-MM-DD",如 "2025-01-17" |
返回
Result<Vec<OptionChain>, TigerError>
每个 OptionChain 包含 symbol、expiry(毫秒)、items: Vec<OptionChainRow>;每行 OptionChainRow 含 call 与 put 两个可选 OptionLeg,OptionLeg 含 identifier、strike、right、latest_price、bid_price / ask_price、implied_vol、delta、gamma、theta、vega、rho 等字段。
示例
let chain = qc.get_option_chain("AAPL", "2025-01-17").await?;
if let Some(row) = chain.first().and_then(|c| c.items.first()) {
let call_id = row.call.as_ref().map(|l| l.identifier.clone()).unwrap_or_default();
let put_id = row.put.as_ref().map(|l| l.identifier.clone()).unwrap_or_default();
println!("call={} put={}", call_id, put_id);
}数据示例
返回数据:
[
{
"symbol": "AAPL",
"expiry": 1737072000000,
"items": [
{
"call": {
"identifier": "AAPL 250117C00220000",
"strike": "220",
"right": "CALL",
"latestPrice": 9.50,
"impliedVol": 0.285,
"delta": 0.612
},
"put": {
"identifier": "AAPL 250117P00220000",
"strike": "220",
"right": "PUT",
"latestPrice": 2.10,
"impliedVol": 0.312
}
}
]
}
]get_option_brief 获取期权报价
qc.get_option_brief(identifiers: &[&str]) -> Result<Vec<OptionBrief>, TigerError>
说明
批量获取期权合约的实时报价;SDK 内部自动把 OCC 期权 identifier 解析为 symbol / expiry(毫秒) / right / strike 组成的 option_basic 数组(使用 v2.0 接口)。OptionBrief 为 Brief 的类型别名。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| identifiers | &[&str] | 是 | 期权合约 identifier 切片,美股格式:"AAPL 250117C00150000"(注意双空格) |
返回
Result<Vec<OptionBrief>, TigerError>
字段与 Brief 相同,包含 symbol、latest_price、pre_close、change、volume、open_interest、multiplier、expiry、strike、right、ask_price / bid_price 等。
示例
let opt_briefs = qc.get_option_brief(&["AAPL 250117C00150000"]).await?;
if let Some(b) = opt_briefs.first() {
println!("{} latest={:.4}", b.symbol, b.latest_price);
}数据示例
返回数据:
[
{
"symbol": "AAPL",
"expiry": "2025-01-17",
"strike": "150",
"right": "CALL",
"latestPrice": 9.50,
"preClose": 9.10,
"change": 0.40,
"openInterest": 12540,
"volume": 3820,
"multiplier": 100
}
]get_option_kline 获取期权K线
qc.get_option_kline(identifier: &str, period: &str) -> Result<Vec<OptionKline>, TigerError>
说明
获取指定期权合约的历史 K 线数据。SDK 内部自动解析 identifier 并以 option_query 数组形式发送(使用 v2.0 接口)。OptionKline 为 Kline 的类型别名。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| identifier | &str | 是 | 期权合约代码,如 "AAPL 250117C00150000" |
| period | &str | 是 | K 线周期,如 "day"、"1min" |
返回
Result<Vec<OptionKline>, TigerError>
结构与股票 K 线一致(symbol、period、items: Vec<KlineItem>)。
示例
let opt_kline = qc.get_option_kline("AAPL 250117C00150000", "day").await?;
if let Some(k) = opt_kline.first() {
println!("bars={}", k.items.len());
}数据示例
返回数据:
[
{
"symbol": "AAPL 250117C00150000",
"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 }
]
}
]期货行情
get_future_exchange 获取期货交易所列表
qc.get_future_exchange() -> Result<Vec<FutureExchange>, TigerError>
说明
获取平台支持的所有期货交易所列表。
参数
无参数。
返回
Result<Vec<FutureExchange>, TigerError>
每个元素包含 code(交易所代码,如 "CME")、name、zone_id。
示例
let exchanges = qc.get_future_exchange().await?;
for e in &exchanges {
println!("{} {} ({})", e.code, e.name, e.zone_id);
}数据示例
返回数据:
[
{ "code": "CME", "name": "Chicago Mercantile Exchange", "zoneId": "America/Chicago" },
{ "code": "CBOT", "name": "Chicago Board of Trade", "zoneId": "America/Chicago" },
{ "code": "NYMEX", "name": "New York Mercantile Exchange", "zoneId": "America/New_York" },
{ "code": "HKEX", "name": "Hong Kong Exchanges and Clearing", "zoneId": "Asia/Hong_Kong" }
]get_future_contracts 获取期货合约列表
qc.get_future_contracts(exchange_code: &str) -> Result<Vec<FutureContractInfo>, TigerError>
说明
获取指定交易所下所有可交易期货合约列表。方法名在服务端为 future_contract_by_exchange_code,请求键为 exchange_code。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| exchange_code | &str | 是 | 交易所代码,如 "CME"、"HKEX" |
返回
Result<Vec<FutureContractInfo>, TigerError>
每个元素包含 contract_code、name、type、contract_month、last_trading_date、currency、multiplier、min_tick、exchange 等字段。
示例
let contracts = qc.get_future_contracts("CME").await?;
if let Some(c) = contracts.first() {
println!("first contract={}", c.contract_code);
}数据示例
请求参数:
{ "exchange_code": "CME" }返回数据:
[
{
"contractCode": "ES2506",
"name": "E-mini S&P 500",
"type": "index",
"contractMonth": "202506",
"lastTradingDate": "2025-06-20",
"currency": "USD",
"multiplier": 50,
"minTick": 0.25,
"exchange": "CME"
},
{
"contractCode": "NQ2506",
"name": "E-mini NASDAQ-100",
"type": "index",
"contractMonth": "202506",
"currency": "USD",
"multiplier": 20,
"minTick": 0.25,
"exchange": "CME"
}
]get_future_real_time_quote 获取期货实时报价
async fn get_future_real_time_quote(&self, req: FutureBriefRequest) -> Result<Vec<FutureQuote>, TigerError>
v0.4.0 Breaking:由位置参数
contract_codes: &[&str]改为FutureBriefRequeststruct。
说明
批量获取期货合约的实时行情数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| contract_codes | Option<Vec<String>> | 是 | 期货合约代码列表,如 vec!["ES2506".to_string()] |
| lang | Option<String> | 否 | 语言 |
返回
Result<Vec<FutureQuote>, TigerError>
每个元素包含 contract_code、latest_price、bid_price / ask_price、volume、open_interest、open、high、low、settlement、limit_up / limit_down 等字段。
示例
use tigeropen::model::quote_requests::FutureBriefRequest;
let fut_quotes = qc.get_future_real_time_quote(FutureBriefRequest {
contract_codes: Some(vec!["ES2506".to_string(), "NQ2506".to_string()]),
..Default::default()
}).await?;
for q in &fut_quotes {
println!("{} latest={:.4}", q.contract_code, q.latest_price);
}数据示例
请求参数:
{ "contract_codes": ["ES2506", "NQ2506"] }返回数据:
[
{
"contractCode": "ES2506",
"latestPrice": 5920.50,
"latestTime": 1735042800000,
"bidPrice": 5920.25,
"askPrice": 5920.75,
"volume": 1234567,
"openInterest": 2345678,
"open": 5900.00,
"high": 5935.00,
"low": 5895.00,
"settlement": 5895.25
}
]get_future_kline 获取期货K线
qc.get_future_kline(req: FutureKlineRequest) -> Result<Vec<FutureKline>, TigerError>
说明
获取期货合约的历史 K 线数据。FutureKlineRequest 是结构化请求;若 begin_time / end_time 为 0,SDK 会自动填入 -1 表示不限制。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| req.contract_codes | Vec<String> | 是 | 期货合约代码列表,如 vec!["ES2506".into()] |
| req.period | String | 是 | K 线周期:"day" / "week" / "1min" / "5min" / "15min" / "30min" / "60min" |
| req.begin_time | i64 | 否 | 开始时间(毫秒),-1 或 0 表示不限 |
| req.end_time | i64 | 否 | 结束时间(毫秒),-1 或 0 表示不限 |
| req.limit | Option<i32> | 否 | 返回条数限制 |
| req.page_token | Option<String> | 否 | 分页令牌 |
返回
Result<Vec<FutureKline>, TigerError>
每个元素含 items: Vec<FutureKlineItem> 与 next_page_token;FutureKlineItem 含 time、open、high、low、close、volume、last_time、open_interest、settlement。
示例
use tigeropen::model::quote::FutureKlineRequest;
let fut_kline = qc.get_future_kline(FutureKlineRequest {
contract_codes: vec!["ES2506".into()],
period: "day".into(),
begin_time: -1,
end_time: -1,
limit: None,
page_token: None,
}).await?;
if let Some(k) = fut_kline.first() {
println!("bars={}", k.items.len());
}数据示例
返回数据:
[
{
"items": [
{
"time": 1734912000000,
"open": 5870.00,
"high": 5900.00,
"low": 5860.00,
"close": 5895.25,
"volume": 1023456,
"openInterest": 2340000,
"settlement": 5895.25
},
{
"time": 1734998400000,
"open": 5900.00,
"high": 5935.00,
"low": 5895.00,
"close": 5920.50,
"volume": 1234567
}
]
}
]基本面数据
get_financial_daily 获取财务日报
qc.get_financial_daily(req: FinancialDailyRequest) -> Result<Vec<FinancialDailyItem>, TigerError>
说明
获取股票的每日财务指标数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| req.symbols | Vec<String> | 是 | 股票代码列表 |
| req.market | String | 是 | 市场代码,如 "US" |
| req.fields | Vec<String> | 是 | 字段列表,如 vec!["shares_outstanding".into()] |
| req.begin_date | String | 是 | 起始日期,格式 "YYYY-MM-DD" |
| req.end_date | String | 是 | 截止日期,格式 "YYYY-MM-DD" |
返回
Result<Vec<FinancialDailyItem>, TigerError>
每个元素含 symbol、field、date、value。
示例
use tigeropen::model::quote::FinancialDailyRequest;
let daily = qc.get_financial_daily(FinancialDailyRequest {
symbols: vec!["AAPL".into()],
market: "US".into(),
fields: vec!["shares_outstanding".into()],
begin_date: "2026-05-05".into(),
end_date: "2026-05-06".into(),
}).await?;
println!("rows={}", daily.len());
get_financial_report/get_corporate_action/get_corporate_split/get_corporate_dividend/get_corporate_earnings_calendar属于高级接口,需要特殊权限,文档见高级接口目录。
资金流向
get_capital_flow 获取资金流向
qc.get_capital_flow(symbol: &str, market: &str, period: &str) -> Result<Option<CapitalFlow>, TigerError>
说明
获取股票的资金流向时间序列数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 股票代码 |
| market | &str | 是 | 市场代码,如 "US" |
| period | &str | 是 | 周期:"intraday" / "day" / "week" / "month" |
返回
Result<Option<CapitalFlow>, TigerError>
返回对象包含 symbol、period、items: Vec<CapitalFlowItem>,每条 items 含 time、timestamp、net_inflow。
示例
if let Some(cf) = qc.get_capital_flow("AAPL", "US", "day").await? {
println!("{} period={} rows={}", cf.symbol, cf.period, cf.items.len());
}数据示例
返回数据:
{
"symbol": "AAPL",
"period": "day",
"items": [
{ "time": "2025-05-05", "timestamp": 1746403200000, "netInflow": 111111101 },
{ "time": "2025-05-06", "timestamp": 1746489600000, "netInflow": -25430000 }
]
}get_capital_distribution 获取资金分布
qc.get_capital_distribution(symbol: &str, market: &str) -> Result<Option<CapitalDistribution>, TigerError>
说明
获取股票当前资金分布快照,按大单/中单/小单维度展示流入流出。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | &str | 是 | 股票代码 |
| market | &str | 是 | 市场代码,如 "US" |
返回
Result<Option<CapitalDistribution>, TigerError>
返回对象包含 symbol、net_inflow、in_all、in_big、in_mid、in_small、out_all、out_big、out_mid、out_small 等字段。
示例
if let Some(cd) = qc.get_capital_distribution("AAPL", "US").await? {
println!("{} netInflow={:.2}", cd.symbol, cd.net_inflow);
}数据示例
返回数据:
{
"symbol": "AAPL",
"netInflow": 1111111101,
"inAll": 8234567890,
"inBig": 5123456789,
"inMid": 2012345678,
"inSmall": 1098765432,
"outAll": 7123456789,
"outBig": 4012345678,
"outMid": 1800000000,
"outSmall": 1311111111
}选股器
market_scanner 选股器
qc.market_scanner(req: MarketScannerRequest) -> Result<Option<ScannerResult>, TigerError>
说明
根据自定义条件筛选符合要求的股票,支持按市值、涨跌幅、成交量、技术指标等多维度过滤(使用 v1.0 接口)。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| req.market | String | 是 | 市场代码,如 "US" |
| req.page | Option<i32> | 否 | 页码,从 0 开始 |
| req.page_size | Option<i32> | 否 | 每页条数 |
| req.cursor_id | Option<String> | 否 | 游标分页 ID |
| req.base_filter_list | Option<Vec<Value>> | 否 | 基础字段过滤条件数组 |
| req.accumulate_filter_list | Option<Vec<Value>> | 否 | 累计字段过滤条件数组 |
| req.financial_filter_list | Option<Vec<Value>> | 否 | 财务字段过滤条件数组 |
| req.multi_tags_filter_list | Option<Vec<Value>> | 否 | 多标签过滤条件数组 |
| req.sort_field_data | Option<Value> | 否 | 排序字段 |
| req.multi_tags_fields | Option<Vec<String>> | 否 | 多标签字段列表 |
返回
Result<Option<ScannerResult>, TigerError>
返回对象包含 page、total_page、total_count、page_size、cursor_id,以及 items: Vec<ScannerResultItem>(每项含 symbol、market 及分类数据列表)。
示例
use tigeropen::model::quote::MarketScannerRequest;
if let Some(r) = qc.market_scanner(MarketScannerRequest {
market: "US".into(),
page: Some(0),
page_size: Some(10),
..Default::default()
}).await? {
println!("page={}/{} items={}", r.page, r.total_page, r.items.len());
}数据示例
返回数据:
{
"page": 0,
"totalPage": 50,
"totalCount": 500,
"pageSize": 10,
"items": [
{
"symbol": "AAPL",
"market": "US",
"baseDataList": [
{ "index": 0, "name": "latest_price", "data": 227.52 }
]
},
{
"symbol": "NVDA",
"market": "US",
"baseDataList": [
{ "index": 0, "name": "latest_price", "data": 138.85 }
]
}
]
}行情权限
grab_quote_permission 获取行情权限
qc.grab_quote_permission() -> Result<Vec<QuotePermission>, TigerError>
说明
查询当前账户开通的行情权限列表,确认是否有权限访问实时行情数据。
参数
无参数。
返回
Result<Vec<QuotePermission>, TigerError>
每个元素包含 name(权限标识)、expire_at(毫秒时间戳)。
示例
let perms = qc.grab_quote_permission().await?;
for p in &perms {
println!("{} expire_at={}", p.name, p.expire_at);
}数据示例
返回数据:
[
{ "name": "US_BASIC", "expireAt": 1767225600000 },
{ "name": "HK_BASIC", "expireAt": 1767225600000 },
{ "name": "US_REALTIME", "expireAt": 1767225600000 }
]股票基础 (v0.4.0 新增)
get_symbols 查询股票代码列表 (v0.4.0 新增)
async fn get_symbols(&self, req: SymbolsRequest) -> Result<Vec<String>, TigerError>
查询指定市场/分类下的股票代码列表。
use tigeropen::model::quote_requests::SymbolsRequest;
let symbols = qc.get_symbols(SymbolsRequest { market: Some("US".to_string()), ..Default::default() }).await?;
println!("symbols={}", symbols.len());get_symbol_names 查询股票名称 (v0.4.0 新增)
async fn get_symbol_names(&self, req: SymbolNamesRequest) -> Result<Vec<SymbolName>, TigerError>
批量查询股票的中英文名称。
use tigeropen::model::quote_requests::SymbolNamesRequest;
let names = qc.get_symbol_names(SymbolNamesRequest {
symbols: Some(vec!["AAPL".to_string()]),
..Default::default()
}).await?;get_trade_metas 查询交易信息 (v0.4.0 新增)
async fn get_trade_metas(&self, req: TradeMetasRequest) -> Result<Vec<TradeMeta>, TigerError>
查询股票的交易属性(手数、最小变动价位、涨跌停等)。
use tigeropen::model::quote_requests::TradeMetasRequest;
let metas = qc.get_trade_metas(TradeMetasRequest {
symbols: Some(vec!["AAPL".to_string()]),
..Default::default()
}).await?;get_stock_delay_briefs 获取延迟行情 (v0.4.0 新增)
async fn get_stock_delay_briefs(&self, req: BriefRequest) -> Result<Vec<Brief>, TigerError>
获取股票延迟行情(不需要实时行情权限)。参数结构与 get_brief 相同。
use tigeropen::model::quote_requests::BriefRequest;
let delay = qc.get_stock_delay_briefs(BriefRequest {
symbols: Some(vec!["AAPL".to_string()]),
..Default::default()
}).await?;get_bars 获取 K 线(批量) (v0.4.0 新增)
async fn get_bars(&self, req: BarsRequest) -> Result<Vec<Kline>, TigerError>
批量查询多支股票的 K 线数据(支持分页)。
use tigeropen::model::quote_requests::BarsRequest;
let bars = qc.get_bars(BarsRequest {
symbols: Some(vec!["AAPL".to_string(), "TSLA".to_string()]),
period: Some("day".to_string()),
..Default::default()
}).await?;get_bars_by_page 分页获取 K 线 (v0.4.0 新增)
async fn get_bars_by_page(&self, req: BarsRequest) -> Result<Vec<Kline>, TigerError>
分页获取 K 线数据,适合历史数据量大的场景。
get_timeline_history 获取历史分时 (v0.4.0 新增)
async fn get_timeline_history(&self, req: TimelineHistoryRequest) -> Result<Vec<Timeline>, TigerError>
获取历史某日的分时数据。
use tigeropen::model::quote_requests::TimelineHistoryRequest;
let tl = qc.get_timeline_history(TimelineHistoryRequest {
symbols: Some(vec!["AAPL".to_string()]),
date: Some("2025-05-01".to_string()),
..Default::default()
}).await?;get_trade_rank 查询交易排行 (v0.4.0 新增)
async fn get_trade_rank(&self, req: TradeRankRequest) -> Result<Vec<TradeRankItem>, TigerError>
查询指定市场的成交量/额排行榜。
get_short_interest 查询做空兴趣 (v0.4.0 新增)
async fn get_short_interest(&self, req: ShortInterestRequest) -> Result<Vec<ShortInterest>, TigerError>
查询美股借空利率、可借空股数等。
get_stock_broker 查询券商席位 (v0.4.0 新增)
async fn get_stock_broker(&self, req: StockBrokerRequest) -> Result<Vec<StockBroker>, TigerError>
查询港股盘口委托的券商席位明细。
get_stock_industry 查询股票行业 (v0.4.0 新增)
async fn get_stock_industry(&self, req: StockIndustryRequest) -> Result<Vec<StockIndustry>, TigerError>
查询股票所属 GICS 行业分类。
get_kline_quota 查询 K 线配额 (v0.4.0 新增)
async fn get_kline_quota(&self) -> Result<KlineQuota, TigerError>
查询当前账户的分钟 K 线访问配额(已用 / 总量)。
期权行情 (v0.4.0 新增方法)
get_option_bars 期权 K 线 (v0.4.0 新增)
async fn get_option_bars(&self, req: OptionBarsRequest) -> Result<Vec<Kline>, TigerError>
批量获取期权合约的 K 线数据。
get_option_trade_ticks 期权逐笔成交 (v0.4.0 新增)
async fn get_option_trade_ticks(&self, req: OptionTradeTickRequest) -> Result<Vec<TradeTick>, TigerError>
get_option_timeline 期权分时 (v0.4.0 新增)
async fn get_option_timeline(&self, req: OptionTimelineRequest) -> Result<Vec<Timeline>, TigerError>
get_option_depth 期权深度 (v0.4.0 新增)
async fn get_option_depth(&self, req: OptionDepthRequest) -> Result<Vec<Depth>, TigerError>
get_option_symbols 期权代码列表 (v0.4.0 新增)
async fn get_option_symbols(&self, req: OptionSymbolsRequest) -> Result<Vec<String>, TigerError>
get_option_analysis 期权分析 (v0.4.0 新增)
async fn get_option_analysis(&self, req: OptionAnalysisRequest) -> Result<Vec<OptionAnalysis>, TigerError>
期货行情 (v0.4.0 新增方法)
get_future_contract 查询单个期货合约 (v0.4.0 新增)
async fn get_future_contract(&self, req: FutureContractRequest) -> Result<Option<FutureContractInfo>, TigerError>
get_all_future_contracts 查询全部期货合约 (v0.4.0 新增)
async fn get_all_future_contracts(&self, req: AllFutureContractsRequest) -> Result<Vec<FutureContractInfo>, TigerError>
get_current_future_contract 查询主力合约 (v0.4.0 新增)
async fn get_current_future_contract(&self, req: FutureContractRequest) -> Result<Option<FutureContractInfo>, TigerError>
get_future_continuous_contracts 查询连续合约 (v0.4.0 新增)
async fn get_future_continuous_contracts(&self, req: FutureContractsRequest) -> Result<Vec<FutureContractInfo>, TigerError>
get_future_history_main_contract 查询历史主力合约 (v0.4.0 新增)
async fn get_future_history_main_contract(&self, req: FutureHistoryRequest) -> Result<Vec<FutureContractInfo>, TigerError>
get_future_bars 期货 K 线 (v0.4.0 新增)
async fn get_future_bars(&self, req: FutureKlineRequest) -> Result<Vec<FutureKline>, TigerError>
get_future_bars_by_page 分页期货 K 线 (v0.4.0 新增)
async fn get_future_bars_by_page(&self, req: FutureKlineRequest) -> Result<Vec<FutureKline>, TigerError>
get_future_trade_ticks 期货逐笔成交 (v0.4.0 新增)
async fn get_future_trade_ticks(&self, req: FutureTradeTickRequest) -> Result<Vec<TradeTick>, TigerError>
get_future_depth 期货深度行情 (v0.4.0 新增)
async fn get_future_depth(&self, req: FutureDepthRequest) -> Result<Vec<Depth>, TigerError>
get_future_trading_times 期货交易时间 (v0.4.0 新增)
async fn get_future_trading_times(&self, req: FutureTradingTimesRequest) -> Result<Vec<FutureTradingTime>, TigerError>
基金行情 (v0.4.0 新增)
get_fund_symbols 基金代码列表 (v0.4.0 新增)
async fn get_fund_symbols(&self, req: FundSymbolsRequest) -> Result<Vec<String>, TigerError>
get_fund_contracts 基金合约信息 (v0.4.0 新增)
async fn get_fund_contracts(&self, req: FundContractsRequest) -> Result<Vec<FundContract>, TigerError>
get_fund_quote 基金实时报价 (v0.4.0 新增)
async fn get_fund_quote(&self, req: FundQuoteRequest) -> Result<Vec<FundQuote>, TigerError>
get_fund_history_quote 基金历史行情 (v0.4.0 新增)
async fn get_fund_history_quote(&self, req: FundHistoryQuoteRequest) -> Result<Vec<FundHistoryQuote>, TigerError>
窝轮行情 (v0.4.0 新增)
get_warrant_briefs 窝轮实时报价 (v0.4.0 新增)
async fn get_warrant_briefs(&self, req: WarrantBriefsRequest) -> Result<Vec<Brief>, TigerError>
get_warrant_filter 窝轮筛选 (v0.4.0 新增)
async fn get_warrant_filter(&self, req: WarrantFilterRequest) -> Result<Vec<WarrantFilterResult>, TigerError>
行业 (v0.4.0 新增)
get_industry_list 查询行业列表 (v0.4.0 新增)
async fn get_industry_list(&self, req: IndustryListRequest) -> Result<Vec<Industry>, TigerError>
查询 GICS 行业层级列表(IndustryLevel::GSECTOR / GGROUP / GIND / GSUBIND)。
use tigeropen::model::quote_requests::IndustryListRequest;
use tigeropen::model::enums::IndustryLevel;
let industries = qc.get_industry_list(IndustryListRequest {
level: Some("GSECTOR".to_string()),
..Default::default()
}).await?;get_industry_stocks 查询行业成分股 (v0.4.0 新增)
async fn get_industry_stocks(&self, req: IndustryStocksRequest) -> Result<Vec<String>, TigerError>
查询指定行业下的股票代码列表。
财务日历 (v0.4.0 新增)
get_financial_currency 查询财务货币 (v0.4.0 新增)
async fn get_financial_currency(&self, req: FinancialCurrencyRequest) -> Result<Vec<FinancialCurrency>, TigerError>
get_financial_exchange_rate 查询汇率 (v0.4.0 新增)
async fn get_financial_exchange_rate(&self, req: FinancialExchangeRateRequest) -> Result<Vec<FinancialExchangeRate>, TigerError>
get_trading_calendar 查询交易日历 (v0.4.0 新增)
async fn get_trading_calendar(&self, req: TradingCalendarRequest) -> Result<Vec<TradingCalendar>, TigerError>
查询指定市场的交易日历(哪些天开市 / 休市)。
use tigeropen::model::quote_requests::TradingCalendarRequest;
let calendar = qc.get_trading_calendar(TradingCalendarRequest {
market: Some("US".to_string()),
begin_date: Some("2025-01-01".to_string()),
end_date: Some("2025-12-31".to_string()),
..Default::default()
}).await?;选股器标签 (v0.4.0 新增)
get_market_scanner_tags 选股器标签 (v0.4.0 新增)
async fn get_market_scanner_tags(&self, req: MarketScannerTagsRequest) -> Result<Vec<ScannerTag>, TigerError>
查询选股器支持的过滤字段标签列表。
Updated 16 days ago
