行情查询
TypeScript SDK 通过 QuoteClient 提供全部行情接口,所有方法均返回 Promise,需使用 async/await 或 .then() 调用。以下为完整可运行示例:
import { ClientConfig } from '@tigeropenapi/tigeropen';
import { QuoteClient } from '@tigeropenapi/tigeropen';
async function main() {
const config = ClientConfig.fromPropertiesFile('tiger_openapi_config.properties');
const qc = new QuoteClient(config);
// 获取市场状态
const states = await qc.marketState('US');
console.log('美股市场状态:', states);
// 获取实时报价
const briefs = await qc.quoteRealTime(['AAPL', 'TSLA']);
console.log('实时报价:', briefs);
// 获取 K 线数据
const klines = await qc.kline('AAPL', 'day');
console.log('K 线数据:', klines);
}
main().catch(console.error);基础行情
marketState 获取市场状态
qc.marketState(market: string): Promise<unknown>
说明
查询指定市场(美股、港股等)的当前交易状态,包括是否开盘、下次开盘时间等。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| market | string | 是 | 市场代码,如 'US'(美股)、'HK'(港股)、'CN'(A股) |
返回
Promise<unknown>
返回市场状态数组,每个元素包含 market、status(trading / closed 等)、openTime 等字段。
示例
const states = await qc.marketState('US');
console.log(states);
// 查询港股市场状态
const hkStates = await qc.marketState('HK');数据示例
请求参数:
{ "market": "US" }返回数据:
[
{
"market": "US",
"status": "trading",
"openTime": 1735020600000,
"closeTime": 1735044000000,
"timezone": "America/New_York"
}
]quoteRealTime 获取实时报价
qc.quoteRealTime(symbols: string[]): Promise<unknown>
说明
批量获取股票的实时快照行情,包括最新价、涨跌幅、成交量等核心字段。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | string[] | 是 | 股票代码列表,如 ['AAPL', 'TSLA'];港股如 ['00700'] |
返回
Promise<unknown>
返回行情快照数组,每个元素包含 symbol、latestPrice、preClose、change、changePercentage、volume、amount 等字段。
示例
const briefs = await qc.quoteRealTime(['AAPL', 'TSLA', '00700']);
console.log(briefs);数据示例
请求参数:
{ "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: string, period: string): Promise<unknown>
说明
获取指定股票的历史 K 线数据,支持日线、周线、月线及分钟级别。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | string | 是 | 股票代码,如 'AAPL' |
| period | string | 是 | K 线周期:'day' / 'week' / 'month' / 'year' / '1min' / '5min' / '15min' / '30min' / '60min' |
返回
Promise<unknown>
返回 K 线数组,每条记录包含 time、open、high、low、close、volume 字段。
示例
// 获取日线
const klines = await qc.kline('AAPL', 'day');
console.log(klines);
// 获取 5 分钟 K 线
const klines5min = await qc.kline('AAPL', '5min');数据示例
请求参数:
{ "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: string[]): Promise<unknown>
说明
获取当日分时走势数据(逐分钟价格与成交量),用于绘制分时图。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | string[] | 是 | 股票代码列表 |
返回
Promise<unknown>
每个 symbol 返回分时数据数组,包含 time、price、volume、avgPrice 等字段。
示例
const timeline = await qc.timeline(['AAPL', 'TSLA']);
console.log(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
}
]
}tradeTick 获取逐笔成交
qc.tradeTick(symbols: string[]): Promise<unknown>
说明
获取最新逐笔成交记录,每一笔成交的价格、数量和方向(买/卖)。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | string[] | 是 | 股票代码列表 |
返回
Promise<unknown>
返回逐笔成交数组,每条包含 time、price、volume、direction 字段。
示例
const ticks = await qc.tradeTick(['AAPL']);
console.log(ticks);数据示例
请求参数:
{ "symbols": ["AAPL"] }返回数据:
{
"symbol": "AAPL",
"items": [
{
"time": 1735042780000,
"price": 227.52,
"volume": 100,
"direction": "BUY"
},
{
"time": 1735042781000,
"price": 227.50,
"volume": 200,
"direction": "SELL"
}
]
}quoteDepth 获取深度行情
qc.quoteDepth(symbol: string): Promise<unknown>
说明
获取买卖五档盘口深度数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | string | 是 | 股票代码 |
返回
Promise<unknown>
返回 askList(卖盘)和 bidList(买盘),每档包含 price、volume、orderCount 字段。
示例
const depth = await qc.quoteDepth('AAPL');
console.log(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 }
]
}期权行情
optionExpiration 获取期权到期日
qc.optionExpiration(symbol: string): Promise<unknown>
说明
获取指定标的股票的所有期权到期日列表,用于构建期权链查询条件。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | string | 是 | 标的股票代码,如 'AAPL' |
返回
Promise<unknown>
返回到期日字符串列表,格式为 'YYYY-MM-DD'。
示例
const expDates = await qc.optionExpiration('AAPL');
console.log(expDates);数据示例
请求参数:
{ "symbols": ["AAPL"] }返回数据:
["2025-01-17", "2025-02-21", "2025-03-21", "2025-06-20", "2025-09-19", "2025-12-19", "2026-01-16"]optionChain 获取期权链
qc.optionChain(symbol: string, expiry: string): Promise<unknown>
说明
获取指定标的和到期日的完整期权链,包含所有行权价的认购和认沽期权信息。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | string | 是 | 标的股票代码 |
| expiry | string | 是 | 到期日,格式 'YYYY-MM-DD',如 '2025-01-17' |
返回
Promise<unknown>
返回期权链列表,每条包含 strike、callSymbol、putSymbol、callLatestPrice、putLatestPrice 等字段。
示例
const chain = await qc.optionChain('AAPL', '2025-01-17');
console.log(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
}
]optionBrief 获取期权报价
qc.optionBrief(identifiers: string[]): Promise<unknown>
说明
批量获取期权合约的实时报价,包含 Greeks(Delta、Gamma、Theta、Vega)等数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| identifiers | string[] | 是 | 期权合约代码列表,美股格式:'AAPL 250117C00150000'(注意双空格) |
返回
Promise<unknown>
返回期权报价列表,包含 latestPrice、impliedVolatility、delta、gamma、theta、vega 等字段。
示例
const optBriefs = await qc.optionBrief(['AAPL 250117C00150000']);
console.log(optBriefs);数据示例
请求参数:
{ "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
}
]optionKline 获取期权K线
qc.optionKline(identifier: string, period: string): Promise<unknown>
说明
获取指定期权合约的历史 K 线数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| identifier | string | 是 | 期权合约代码 |
| period | string | 是 | K 线周期,如 'day'、'1min' |
返回
Promise<unknown>
返回 K 线数组,字段同股票 K 线。
示例
const optKline = await qc.optionKline('AAPL 250117C00150000', 'day');
console.log(optKline);数据示例
请求参数:
{ "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
}
]
}期货行情
futureExchange 获取期货交易所列表
qc.futureExchange(): Promise<unknown>
说明
获取平台支持的所有期货交易所列表。
参数
无参数。
返回
Promise<unknown>
返回交易所列表,每个元素包含 exchange(如 'CME')及交易所名称。
示例
const exchanges = await qc.futureExchange();
console.log(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" }
]futureContracts 获取期货合约列表
qc.futureContracts(exchange: string): Promise<unknown>
说明
获取指定交易所下所有可交易期货合约列表。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| exchange | string | 是 | 交易所代码,如 'CME'、'HKEX' |
返回
Promise<unknown>
返回期货合约列表,包含 symbol、name、contractMultiplier、currency 等字段。
示例
const contracts = await qc.futureContracts('CME');
console.log(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"
}
]futureRealTimeQuote 获取期货实时报价
qc.futureRealTimeQuote(symbols: string[]): Promise<unknown>
说明
批量获取期货合约的实时行情数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbols | string[] | 是 | 期货合约代码列表,如 ['ES2506', 'NQ2506'] |
返回
Promise<unknown>
返回期货行情列表,包含 symbol、latestPrice、change、volume、openInterest 等字段。
示例
const futQuotes = await qc.futureRealTimeQuote(['ES2506', 'NQ2506']);
console.log(futQuotes);数据示例
请求参数:
{ "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
}
]futureKline 获取期货K线
qc.futureKline(symbol: string, period: string): Promise<unknown>
说明
获取期货合约的历史 K 线数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | string | 是 | 期货合约代码,如 'ES2506' |
| period | string | 是 | K 线周期:'day' / 'week' / '1min' / '5min' / '15min' / '30min' / '60min' |
返回
Promise<unknown>
返回 K 线数组,字段同股票 K 线。
示例
const futKline = await qc.futureKline('ES2506', 'day');
console.log(futKline);数据示例
请求参数:
{ "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
}
]
}基本面数据
financialDaily 获取财务日报
qc.financialDaily(symbol: string): Promise<unknown>
说明
获取股票的每日财务指标数据,如市盈率(PE)、市净率(PB)、股息率等。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | string | 是 | 股票代码 |
返回
Promise<unknown>
返回财务日报列表,包含 date、pe、pb、eps、dividendYield 等字段。
示例
const daily = await qc.financialDaily('AAPL');
console.log(daily);数据示例
请求参数:
{ "symbol": "AAPL" }返回数据:
[
{
"date": "2024-12-24",
"pe": 38.5,
"pb": 58.2,
"eps": 6.52,
"dividendYield": 0.0044,
"marketCap": 3420000000000
}
]financialReport 获取财务报告
qc.financialReport(symbol: string): Promise<unknown>
说明
获取股票的季度/年度财务报告数据,包含利润表、资产负债表、现金流量表等核心数据。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | string | 是 | 股票代码 |
返回
Promise<unknown>
返回财务报告列表,包含 revenue、netIncome、totalAssets、totalLiabilities、cashFlow 等字段。
示例
const report = await qc.financialReport('AAPL');
console.log(report);数据示例
请求参数:
{ "symbol": "AAPL" }返回数据:
[
{
"period": "2024Q4",
"periodType": "quarterly",
"revenue": 124300000000,
"netIncome": 36330000000,
"totalAssets": 352583000000,
"totalLiabilities": 308030000000,
"cashFlow": 29943000000,
"eps": 2.40
}
]corporateAction 获取公司行动
qc.corporateAction(symbol: string): Promise<unknown>
说明
获取股票的公司行动记录,包括分红、股票拆分(拆股/合股)、配股等事件。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | string | 是 | 股票代码 |
返回
Promise<unknown>
返回公司行动列表,每条包含 actionType(dividend / split 等)、exDate、amount、ratio 等字段。
示例
const actions = await qc.corporateAction('AAPL');
console.log(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 股票拆分"
}
]资金流向
capitalFlow 获取资金流向
qc.capitalFlow(symbol: string): Promise<unknown>
说明
获取股票的资金流向数据,区分大单/中单/小单的流入流出情况,帮助判断主力资金动向。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | string | 是 | 股票代码 |
返回
Promise<unknown>
返回资金流向数据,包含 inflow、outflow、netInflow、largeOrderInflow、smallOrderOutflow 等字段。
示例
const flow = await qc.capitalFlow('AAPL');
console.log(flow);数据示例
请求参数:
{ "symbol": "AAPL" }返回数据:
{
"symbol": "AAPL",
"inflow": 8234567890,
"outflow": 7123456789,
"netInflow": 1111111101,
"largeOrderInflow": 5123456789,
"largeOrderOutflow": 4012345678,
"mediumOrderInflow": 2012345678,
"smallOrderInflow": 1098765432,
"timestamp": 1735042800000
}capitalDistribution 获取资金分布
qc.capitalDistribution(symbol: string): Promise<unknown>
说明
获取股票当前资金分布快照,按散户/机构/大户等维度展示持仓比例。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| symbol | string | 是 | 股票代码 |
返回
Promise<unknown>
返回资金分布数据,包含各类投资者的 buyRatio、sellRatio、holdRatio 等字段。
示例
const dist = await qc.capitalDistribution('AAPL');
console.log(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
}选股器
marketScanner 选股器
qc.marketScanner(params: Record<string, unknown>): Promise<unknown>
说明
根据自定义条件筛选符合要求的股票,支持按市值、涨跌幅、成交量、技术指标等多维度过滤。
参数
| 参数名 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| params | object | 是 | 筛选条件,包含 market(市场)、filter(过滤条件数组)等字段 |
filter 数组中每个元素:
| 字段 | 类型 | 描述 |
|---|---|---|
| fieldName | string | 筛选字段名,如 'marketCap'、'changePercentage' |
| filterMin | number | 最小值(可选) |
| filterMax | number | 最大值(可选) |
返回
Promise<unknown>
返回符合条件的股票列表。
示例
const scanResult = await qc.marketScanner({
market: 'US',
filter: [
{ fieldName: 'marketCap', filterMin: 1000000000 },
{ fieldName: 'changePercentage', filterMin: 2.0 },
],
});
console.log(scanResult);数据示例
请求参数:
{
"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
}
]grabQuotePermission 获取行情权限
qc.grabQuotePermission(): Promise<unknown>
说明
查询当前账户开通的行情权限列表,确认是否有权限访问实时行情数据。
参数
无参数。
返回
Promise<unknown>
返回已开通的行情权限列表。
示例
const perm = await qc.grabQuotePermission();
console.log(perm);数据示例
返回数据:
["US_BASIC", "HK_BASIC", "US_REALTIME"]Updated 7 days ago
