合约与订单
示例上下文
import { createClientConfig, TradeClient } from '@tigeropenapi/tigeropen';
const config = createClientConfig();
const tradeClient = TradeClient.fromConfig(config, config.account, config.secretKey);从配置创建
签名
static fromConfig(config: ClientConfig, account: string, secretKey?: string): TradeClient用途
从 ClientConfig 创建客户端。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
config | ClientConfig | 是 | None | — |
config.tigerId | string | 是 | 无 | — |
config.privateKey | string | 是 | 无 | — |
config.account | string | 是 | 无 | — |
config.secretKey | string | undefined | 否 | 无 | Institution secret key for trade authentication (institution accounts only) |
config.license | string | undefined | 否 | 无 | — |
config.language | string | 是 | 无 | — |
config.timezone | string | undefined | 否 | 无 | — |
config.timeout | number | 是 | 无 | — |
config.token | string | undefined | 否 | 无 | — |
config.tokenRefreshDuration | number | undefined | 否 | 无 | — |
config.tokenCheckInterval | number | undefined | 否 | 无 | 后台 token 检查间隔(毫秒),仅 tokenRefreshDuration > 0 时生效,默认 5 分钟 |
config.tokenLoader | 返回字符串或字符串 Promise 的可选函数 | 否 | 无 | 自定义 token 加载函数,替代默认的文件加载;精确类型见上方签名引用的 ClientConfig |
config.tokenWriter | ((token: string) => void) | undefined | 否 | 无 | token 刷新写入后的可选回调 |
config.serverUrl | string | 是 | 无 | — |
config.quoteServerUrl | string | 是 | 无 | Quote server URL for quote-specific requests; falls back to serverUrl |
config.deviceId | string | 是 | 无 | Device identifier (auto-detected MAC address) |
config.tigerPublicKey | string | 是 | 无 | — |
account | string | 是 | None | — |
secretKey | string | 否 | None | — |
返回
TradeClient
示例
const result = await TradeClient.fromConfig(config, config.account, config.secretKey);
console.log(result);返回示例
"TradeClient instance (not an API response payload)"获取合约
签名
async getContract(symbol: string, secType: string): Promise<Contract[]>用途
查询单个合约信息。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
symbol | string | 是 | None | — |
secType | string | 是 | None | — |
返回
Promise<Contract[]>
| 字段 | 类型 | 说明 |
|---|---|---|
| contractId | number | 合约 ID |
| symbol | string | 股票代码 |
| secType | string | 证券类型 |
| currency | string | 币种 |
| exchange | string | 交易所 |
| primaryExchange | string | 主交易所 |
| localSymbol | string | 本地代码 |
| tradingClass | string | 交易类 |
| expiry | string | 到期日 |
| strike | number | 行权价 |
| right | string | 期权方向 |
| multiplier | number | 合约乘数 |
| identifier | string | 标识符 |
| name | string | 名称 |
| market | string | 市场 |
| tradeable | boolean | 是否可交易 |
| conid | number | 合约序号 |
| status | number | 交易状态 |
| marginable | boolean | 是否可融资 |
| shortable | boolean | 是否可做空 |
| closeOnly | boolean | 是否仅可平仓 |
| isEtf | boolean | 是否 ETF |
| supportOvernightTrading | boolean | 是否支持隔夜交易 |
| supportFractionalShare | boolean | 是否支持碎股 |
| shortMargin | number | 空头保证金 |
| shortInitialMargin | number | 空头初始保证金 |
| shortMaintenanceMargin | number | 空头维持保证金 |
| longInitialMargin | number | 多头初始保证金 |
| longMaintenanceMargin | number | 多头维持保证金 |
| tickSizes | TickSize[] | 最小变动价位列表 |
| lotSize | number | 每手股数 |
示例
const result = await tradeClient.getContract('AAPL', 'STK');
console.log(result);返回示例
[
{
"contractId": 0,
"symbol": "string",
"secType": "string",
"currency": "string",
"exchange": "string",
"primaryExchange": "string",
"localSymbol": "string",
"tradingClass": "string",
"expiry": "string",
"strike": 0,
"right": "string",
"multiplier": 0,
"identifier": "string",
"name": "string",
"market": "string",
"tradeable": "boolean",
"conid": 0,
"status": 0,
"marginable": "boolean",
"shortable": "boolean",
"closeOnly": "boolean",
"isEtf": "boolean",
"supportOvernightTrading": "boolean",
"supportFractionalShare": "boolean",
"shortMargin": 0,
"shortInitialMargin": 0,
"shortMaintenanceMargin": 0,
"longInitialMargin": 0,
"longMaintenanceMargin": 0,
"tickSizes": [
"TickSize"
],
"lotSize": 0
}
]批量获取合约
签名
async getContracts(symbols: string[], secType: string): Promise<Contract[]>用途
查询合约列表。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
symbols | string[] | 是 | None | — |
secType | string | 是 | None | — |
返回
Promise<Contract[]>
| 字段 | 类型 | 说明 |
|---|---|---|
| contractId | number | 合约 ID |
| symbol | string | 股票代码 |
| secType | string | 证券类型 |
| currency | string | 币种 |
| exchange | string | 交易所 |
| primaryExchange | string | 主交易所 |
| localSymbol | string | 本地代码 |
| tradingClass | string | 交易类 |
| expiry | string | 到期日 |
| strike | number | 行权价 |
| right | string | 期权方向 |
| multiplier | number | 合约乘数 |
| identifier | string | 标识符 |
| name | string | 名称 |
| market | string | 市场 |
| tradeable | boolean | 是否可交易 |
| conid | number | 合约序号 |
| status | number | 交易状态 |
| marginable | boolean | 是否可融资 |
| shortable | boolean | 是否可做空 |
| closeOnly | boolean | 是否仅可平仓 |
| isEtf | boolean | 是否 ETF |
| supportOvernightTrading | boolean | 是否支持隔夜交易 |
| supportFractionalShare | boolean | 是否支持碎股 |
| shortMargin | number | 空头保证金 |
| shortInitialMargin | number | 空头初始保证金 |
| shortMaintenanceMargin | number | 空头维持保证金 |
| longInitialMargin | number | 多头初始保证金 |
| longMaintenanceMargin | number | 多头维持保证金 |
| tickSizes | TickSize[] | 最小变动价位列表 |
| lotSize | number | 每手股数 |
示例
const result = await tradeClient.getContracts(['AAPL'], 'STK');
console.log(result);返回示例
[
{
"contractId": 0,
"symbol": "string",
"secType": "string",
"currency": "string",
"exchange": "string",
"primaryExchange": "string",
"localSymbol": "string",
"tradingClass": "string",
"expiry": "string",
"strike": 0,
"right": "string",
"multiplier": 0,
"identifier": "string",
"name": "string",
"market": "string",
"tradeable": "boolean",
"conid": 0,
"status": 0,
"marginable": "boolean",
"shortable": "boolean",
"closeOnly": "boolean",
"isEtf": "boolean",
"supportOvernightTrading": "boolean",
"supportFractionalShare": "boolean",
"shortMargin": 0,
"shortInitialMargin": 0,
"shortMaintenanceMargin": 0,
"longInitialMargin": 0,
"longMaintenanceMargin": 0,
"tickSizes": [
"TickSize"
],
"lotSize": 0
}
]获取行情合约
签名
async getQuoteContract(symbol: string, secType: string, expiry: string): Promise<Contract[]>用途
查询行情合约信息。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
symbol | string | 是 | None | — |
secType | string | 是 | None | — |
expiry | string | 是 | None | — |
返回
Promise<Contract[]>
| 字段 | 类型 | 说明 |
|---|---|---|
| contractId | number | 合约 ID |
| symbol | string | 股票代码 |
| secType | string | 证券类型 |
| currency | string | 币种 |
| exchange | string | 交易所 |
| primaryExchange | string | 主交易所 |
| localSymbol | string | 本地代码 |
| tradingClass | string | 交易类 |
| expiry | string | 到期日 |
| strike | number | 行权价 |
| right | string | 期权方向 |
| multiplier | number | 合约乘数 |
| identifier | string | 标识符 |
| name | string | 名称 |
| market | string | 市场 |
| tradeable | boolean | 是否可交易 |
| conid | number | 合约序号 |
| status | number | 交易状态 |
| marginable | boolean | 是否可融资 |
| shortable | boolean | 是否可做空 |
| closeOnly | boolean | 是否仅可平仓 |
| isEtf | boolean | 是否 ETF |
| supportOvernightTrading | boolean | 是否支持隔夜交易 |
| supportFractionalShare | boolean | 是否支持碎股 |
| shortMargin | number | 空头保证金 |
| shortInitialMargin | number | 空头初始保证金 |
| shortMaintenanceMargin | number | 空头维持保证金 |
| longInitialMargin | number | 多头初始保证金 |
| longMaintenanceMargin | number | 多头维持保证金 |
| tickSizes | TickSize[] | 最小变动价位列表 |
| lotSize | number | 每手股数 |
示例
const result = await tradeClient.getQuoteContract('AAPL', 'STK', '20260619');
console.log(result);返回示例
[
{
"contractId": 0,
"symbol": "string",
"secType": "string",
"currency": "string",
"exchange": "string",
"primaryExchange": "string",
"localSymbol": "string",
"tradingClass": "string",
"expiry": "string",
"strike": 0,
"right": "string",
"multiplier": 0,
"identifier": "string",
"name": "string",
"market": "string",
"tradeable": "boolean",
"conid": 0,
"status": 0,
"marginable": "boolean",
"shortable": "boolean",
"closeOnly": "boolean",
"isEtf": "boolean",
"supportOvernightTrading": "boolean",
"supportFractionalShare": "boolean",
"shortMargin": 0,
"shortInitialMargin": 0,
"shortMaintenanceMargin": 0,
"longInitialMargin": 0,
"longMaintenanceMargin": 0,
"tickSizes": [
"TickSize"
],
"lotSize": 0
}
]获取衍生品合约
签名
async getDerivativeContracts(req: DerivativeContractsRequest): Promise<Contract[]>用途
查询衍生品合约。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
req | DerivativeContractsRequest | 是 | None | — |
req.account | string | undefined | 否 | TradeClient account when empty (client) | — |
req.secretKey | string | undefined | 否 | 无 | Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. |
req.symbols | string[] | 是 | 无 | — |
req.secType | string | 是 | 无 | — |
req.expiry | string | undefined | 否 | 无 | — |
req.lang | string | undefined | 否 | 无 | — |
返回
Promise<Contract[]>
| 字段 | 类型 | 说明 |
|---|---|---|
| contractId | number | 合约 ID |
| symbol | string | 股票代码 |
| secType | string | 证券类型 |
| currency | string | 币种 |
| exchange | string | 交易所 |
| primaryExchange | string | 主交易所 |
| localSymbol | string | 本地代码 |
| tradingClass | string | 交易类 |
| expiry | string | 到期日 |
| strike | number | 行权价 |
| right | string | 期权方向 |
| multiplier | number | 合约乘数 |
| identifier | string | 标识符 |
| name | string | 名称 |
| market | string | 市场 |
| tradeable | boolean | 是否可交易 |
| conid | number | 合约序号 |
| status | number | 交易状态 |
| marginable | boolean | 是否可融资 |
| shortable | boolean | 是否可做空 |
| closeOnly | boolean | 是否仅可平仓 |
| isEtf | boolean | 是否 ETF |
| supportOvernightTrading | boolean | 是否支持隔夜交易 |
| supportFractionalShare | boolean | 是否支持碎股 |
| shortMargin | number | 空头保证金 |
| shortInitialMargin | number | 空头初始保证金 |
| shortMaintenanceMargin | number | 空头维持保证金 |
| longInitialMargin | number | 多头初始保证金 |
| longMaintenanceMargin | number | 多头维持保证金 |
| tickSizes | TickSize[] | 最小变动价位列表 |
| lotSize | number | 每手股数 |
示例
const result = await tradeClient.getDerivativeContracts({ symbols: ['AAPL'], secType: 'STK' });
console.log(result);返回示例
[
{
"contractId": 0,
"symbol": "string",
"secType": "string",
"currency": "string",
"exchange": "string",
"primaryExchange": "string",
"localSymbol": "string",
"tradingClass": "string",
"expiry": "string",
"strike": 0,
"right": "string",
"multiplier": 0,
"identifier": "string",
"name": "string",
"market": "string",
"tradeable": "boolean",
"conid": 0,
"status": 0,
"marginable": "boolean",
"shortable": "boolean",
"closeOnly": "boolean",
"isEtf": "boolean",
"supportOvernightTrading": "boolean",
"supportFractionalShare": "boolean",
"shortMargin": 0,
"shortInitialMargin": 0,
"shortMaintenanceMargin": 0,
"longInitialMargin": 0,
"longMaintenanceMargin": 0,
"tickSizes": [
"TickSize"
],
"lotSize": 0
}
]下单
签名
async placeOrder(order: OrderRequest): Promise<PlaceOrderResult | undefined>用途
提交 order 请求。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
order | OrderRequest | 是 | None | — |
返回
Promise<PlaceOrderResult | undefined>
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | number |
| order_id | string | number |
| subIds | (string | number)[] |
| orders | Order[] | 订单列表 |
示例
const result = await tradeClient.placeOrder({ action: 'BUY', orderType: 'LMT', totalQuantity: 1, timeInForce: 'DAY', symbol: 'AAPL', secType: 'STK' });
console.log(result);返回示例
{
"id": "string | number",
"order_id": "string | number",
"subIds": [
"string | number"
],
"orders": [
{
"account": "string",
"id": "string | number",
"orderId": "string | number",
"externalId": "string",
"action": "string",
"orderType": "string",
"totalQuantity": 0,
"totalQuantityScale": 0,
"filledQuantity": 0,
"filledQuantityScale": 0,
"filledCashAmount": 0,
"limitPrice": 0,
"auxPrice": 0,
"trailingPercent": 0,
"status": "string",
"avgFillPrice": 0,
"timeInForce": "string",
"outsideRth": "boolean",
"orderLegs": [
"OrderLeg"
],
"algoParams": "AlgoParams",
"algoStrategy": "string",
"symbol": "string",
"secType": "string",
"market": "string",
"currency": "string",
"expiry": "string",
"strike": "string",
"right": "string",
"identifier": "string",
"name": "string",
"commission": 0,
"gst": 0,
"realizedPnl": 0,
"openTime": 0,
"updateTime": 0,
"latestTime": 0,
"latestPrice": 0,
"remark": "string",
"source": "string",
"userMark": "string",
"liquidation": "boolean",
"discount": 0,
"replaceStatus": "string",
"cancelStatus": "string",
"canModify": "boolean",
"canCancel": "boolean",
"isOpen": "boolean",
"orderDiscount": 0,
"tradingSessionType": "string",
"attrDesc": "string",
"attrList": [
"string"
]
}
]
}预览订单
签名
async previewOrder(order: OrderRequest): Promise<PreviewResult | undefined>用途
执行 preview order。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
order | OrderRequest | 是 | None | — |
返回
Promise<PreviewResult | undefined>
| 字段 | 类型 | 说明 |
|---|---|---|
| account | string | 账户 |
| isPass | boolean | 是否通过 |
| commission | number | 佣金 |
| commissionCurrency | string | 佣金币种 |
| marginCurrency | string | 保证金币种 |
| initMargin | number | 初始保证金 |
| initMarginBefore | number | 操作前初始保证金 |
| maintMargin | number | 维持保证金 |
| maintMarginBefore | number | 操作前维持保证金 |
| equityWithLoan | number | 含贷款的权益 |
| equityWithLoanBefore | number | 操作前含贷款的权益 |
| availableEE | number | 可用提前行权额度 |
| excessLiquidity | number | 超额流动性 |
| overnightLiquidation | number | 隔夜清算值 |
| gst | number | 商品服务税 |
| message | string | 消息 |
示例
const result = await tradeClient.previewOrder({ action: 'BUY', orderType: 'LMT', totalQuantity: 1, timeInForce: 'DAY', symbol: 'AAPL', secType: 'STK' });
console.log(result);返回示例
{
"account": "string",
"isPass": "boolean",
"commission": 0,
"commissionCurrency": "string",
"marginCurrency": "string",
"initMargin": 0,
"initMarginBefore": 0,
"maintMargin": 0,
"maintMarginBefore": 0,
"equityWithLoan": 0,
"equityWithLoanBefore": 0,
"availableEE": 0,
"excessLiquidity": 0,
"overnightLiquidation": 0,
"gst": 0,
"message": "string"
}改单
签名
async modifyOrder(id: number | string, order: OrderRequest): Promise<OrderIdResult | undefined>用途
修改 order。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
id | number | string | 是 | None | — |
order | OrderRequest | 是 | None | — |
返回
Promise<OrderIdResult | undefined>
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | number |
示例
const result = await tradeClient.modifyOrder(1, { action: 'BUY', orderType: 'LMT', totalQuantity: 1, timeInForce: 'DAY', symbol: 'AAPL', secType: 'STK' });
console.log(result);返回示例
{
"id": "string | number"
}撤单
签名
async cancelOrder(id: number | string, secretKey?: string): Promise<OrderIdResult | undefined>用途
取消 order。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
id | number | string | 是 | None | — |
secretKey | string | 否 | None | — |
返回
Promise<OrderIdResult | undefined>
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | number |
示例
const result = await tradeClient.cancelOrder(1, config.secretKey);
console.log(result);返回示例
{
"id": "string | number"
}获取订单列表
签名
async getOrders(req?: OrdersRequest): Promise<Order[]>用途
查询订单列表。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
req | OrdersRequest | 否 | None | — |
req.account | string | undefined | 否 | TradeClient account when empty (client) | — |
req.secretKey | string | undefined | 否 | 无 | Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. |
req.secType | string | undefined | 否 | 无 | — |
req.market | string | undefined | 否 | 无 | — |
req.symbol | string | undefined | 否 | 无 | — |
req.startDate | number | undefined | 否 | 无 | 毫秒时间戳 () |
req.endDate | number | undefined | 否 | 无 | 毫秒时间戳 () |
req.limit | number | undefined | 否 | 无 | — |
req.isBrief | boolean | undefined | 否 | 无 | — |
req.states | string[] | undefined | 否 | 无 | 订单状态过滤: Invalid / Initial / PendingCancel / Cancelled / Submitted / Filled / Inactive / PendingSubmit |
req.sortBy | string | undefined | 否 | 无 | LATEST_CREATED / LATEST_STATUS_UPDATED |
req.segType | string | undefined | 否 | 无 | — |
req.lang | string | undefined | 否 | 无 | — |
req.pageToken | string | undefined | 否 | 无 | — |
req.parentId | number | undefined | 否 | 无 | 仅 ActiveOrders 使用,按父订单 ID 过滤附加订单 |
返回
Promise<Order[]>
| 字段 | 类型 | 说明 |
|---|---|---|
| account | string | 账户 |
| id | string | number |
| orderId | string | number |
| externalId | string | 外部 ID |
| action | string | 交易方向(买/卖) |
| orderType | string | 订单类型 |
| totalQuantity | number | 总数量 |
| totalQuantityScale | number | 总数量精度 |
| filledQuantity | number | 成交数量 |
| filledQuantityScale | number | 成交数量精度 |
| filledCashAmount | number | 现金成交金额 |
| limitPrice | number | 限价 |
| auxPrice | number | 辅助价格 |
| trailingPercent | number | 追踪百分比 |
| status | string | 交易状态 |
| avgFillPrice | number | 平均成交价 |
| timeInForce | string | 订单有效期 |
| outsideRth | boolean | 盘前盘后交易 |
| orderLegs | OrderLeg[] | 组合腿列表 |
| algoParams | AlgoParams | 算法参数 |
| algoStrategy | string | 算法策略 |
| symbol | string | 股票代码 |
| secType | string | 证券类型 |
| market | string | 市场 |
| currency | string | 币种 |
| expiry | string | 到期日 |
| strike | string | 行权价 |
| right | string | 期权方向 |
| identifier | string | 标识符 |
| name | string | 名称 |
| commission | number | 佣金 |
| gst | number | 商品服务税 |
| realizedPnl | number | 已实现盈亏 |
| openTime | number | 开盘时间 |
| updateTime | number | 更新时间 |
| latestTime | number | 最新成交时间(毫秒时间戳) |
| latestPrice | number | 最新价 |
| remark | string | 备注 |
| source | string | 来源 |
| userMark | string | 用户标记 |
| liquidation | boolean | 清算值 |
| discount | number | 折扣 |
| replaceStatus | string | 替换状态 |
| cancelStatus | string | 撤单状态 |
| canModify | boolean | 是否可修改 |
| canCancel | boolean | 是否可撤单 |
| isOpen | boolean | 是否开仓 |
| orderDiscount | number | 订单折扣 |
| tradingSessionType | string | 交易时段类型 |
| attrDesc | string | 属性描述 |
| attrList | string[] | 属性列表 |
示例
const result = await tradeClient.getOrders({ market: 'US', secType: 'STK', limit: 100, sortBy: 'LATEST_CREATED' });
console.log(result);返回示例
[
{
"account": "string",
"id": "string | number",
"orderId": "string | number",
"externalId": "string",
"action": "string",
"orderType": "string",
"totalQuantity": 0,
"totalQuantityScale": 0,
"filledQuantity": 0,
"filledQuantityScale": 0,
"filledCashAmount": 0,
"limitPrice": 0,
"auxPrice": 0,
"trailingPercent": 0,
"status": "string",
"avgFillPrice": 0,
"timeInForce": "string",
"outsideRth": "boolean",
"orderLegs": [
"OrderLeg"
],
"algoParams": {
"algoStrategy": "string",
"startTime": "string",
"endTime": "string",
"participationRate": 0
},
"algoStrategy": "string",
"symbol": "string",
"secType": "string",
"market": "string",
"currency": "string",
"expiry": "string",
"strike": "string",
"right": "string",
"identifier": "string",
"name": "string",
"commission": 0,
"gst": 0,
"realizedPnl": 0,
"openTime": 0,
"updateTime": 0,
"latestTime": 0,
"latestPrice": 0,
"remark": "string",
"source": "string",
"userMark": "string",
"liquidation": "boolean",
"discount": 0,
"replaceStatus": "string",
"cancelStatus": "string",
"canModify": "boolean",
"canCancel": "boolean",
"isOpen": "boolean",
"orderDiscount": 0,
"tradingSessionType": "string",
"attrDesc": "string",
"attrList": [
"string"
]
}
]获取待成交订单
签名
async getActiveOrders(req?: OrdersRequest): Promise<Order[]>用途
查询 active orders。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
req | OrdersRequest | 否 | None | — |
req.account | string | undefined | 否 | TradeClient account when empty (client) | — |
req.secretKey | string | undefined | 否 | 无 | Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. |
req.secType | string | undefined | 否 | 无 | — |
req.market | string | undefined | 否 | 无 | — |
req.symbol | string | undefined | 否 | 无 | — |
req.startDate | number | undefined | 否 | 无 | 毫秒时间戳 () |
req.endDate | number | undefined | 否 | 无 | 毫秒时间戳 () |
req.limit | number | undefined | 否 | 无 | — |
req.isBrief | boolean | undefined | 否 | 无 | — |
req.states | string[] | undefined | 否 | 无 | 订单状态过滤: Invalid / Initial / PendingCancel / Cancelled / Submitted / Filled / Inactive / PendingSubmit |
req.sortBy | string | undefined | 否 | 无 | LATEST_CREATED / LATEST_STATUS_UPDATED |
req.segType | string | undefined | 否 | 无 | — |
req.lang | string | undefined | 否 | 无 | — |
req.pageToken | string | undefined | 否 | 无 | — |
req.parentId | number | undefined | 否 | 无 | 仅 ActiveOrders 使用,按父订单 ID 过滤附加订单 |
返回
Promise<Order[]>
| 字段 | 类型 | 说明 |
|---|---|---|
| account | string | 账户 |
| id | string | number |
| orderId | string | number |
| externalId | string | 外部 ID |
| action | string | 交易方向(买/卖) |
| orderType | string | 订单类型 |
| totalQuantity | number | 总数量 |
| totalQuantityScale | number | 总数量精度 |
| filledQuantity | number | 成交数量 |
| filledQuantityScale | number | 成交数量精度 |
| filledCashAmount | number | 现金成交金额 |
| limitPrice | number | 限价 |
| auxPrice | number | 辅助价格 |
| trailingPercent | number | 追踪百分比 |
| status | string | 交易状态 |
| avgFillPrice | number | 平均成交价 |
| timeInForce | string | 订单有效期 |
| outsideRth | boolean | 盘前盘后交易 |
| orderLegs | OrderLeg[] | 组合腿列表 |
| algoParams | AlgoParams | 算法参数 |
| algoStrategy | string | 算法策略 |
| symbol | string | 股票代码 |
| secType | string | 证券类型 |
| market | string | 市场 |
| currency | string | 币种 |
| expiry | string | 到期日 |
| strike | string | 行权价 |
| right | string | 期权方向 |
| identifier | string | 标识符 |
| name | string | 名称 |
| commission | number | 佣金 |
| gst | number | 商品服务税 |
| realizedPnl | number | 已实现盈亏 |
| openTime | number | 开盘时间 |
| updateTime | number | 更新时间 |
| latestTime | number | 最新成交时间(毫秒时间戳) |
| latestPrice | number | 最新价 |
| remark | string | 备注 |
| source | string | 来源 |
| userMark | string | 用户标记 |
| liquidation | boolean | 清算值 |
| discount | number | 折扣 |
| replaceStatus | string | 替换状态 |
| cancelStatus | string | 撤单状态 |
| canModify | boolean | 是否可修改 |
| canCancel | boolean | 是否可撤单 |
| isOpen | boolean | 是否开仓 |
| orderDiscount | number | 订单折扣 |
| tradingSessionType | string | 交易时段类型 |
| attrDesc | string | 属性描述 |
| attrList | string[] | 属性列表 |
示例
const result = await tradeClient.getActiveOrders({ market: 'US', secType: 'STK', symbol: 'AAPL' });
console.log(result);返回示例
[
{
"account": "string",
"id": "string | number",
"orderId": "string | number",
"externalId": "string",
"action": "string",
"orderType": "string",
"totalQuantity": 0,
"totalQuantityScale": 0,
"filledQuantity": 0,
"filledQuantityScale": 0,
"filledCashAmount": 0,
"limitPrice": 0,
"auxPrice": 0,
"trailingPercent": 0,
"status": "string",
"avgFillPrice": 0,
"timeInForce": "string",
"outsideRth": "boolean",
"orderLegs": [
"OrderLeg"
],
"algoParams": {
"algoStrategy": "string",
"startTime": "string",
"endTime": "string",
"participationRate": 0
},
"algoStrategy": "string",
"symbol": "string",
"secType": "string",
"market": "string",
"currency": "string",
"expiry": "string",
"strike": "string",
"right": "string",
"identifier": "string",
"name": "string",
"commission": 0,
"gst": 0,
"realizedPnl": 0,
"openTime": 0,
"updateTime": 0,
"latestTime": 0,
"latestPrice": 0,
"remark": "string",
"source": "string",
"userMark": "string",
"liquidation": "boolean",
"discount": 0,
"replaceStatus": "string",
"cancelStatus": "string",
"canModify": "boolean",
"canCancel": "boolean",
"isOpen": "boolean",
"orderDiscount": 0,
"tradingSessionType": "string",
"attrDesc": "string",
"attrList": [
"string"
]
}
]获取已撤销订单
签名
async getInactiveOrders(req?: OrdersRequest): Promise<Order[]>用途
查询 inactive orders。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
req | OrdersRequest | 否 | None | — |
req.account | string | undefined | 否 | TradeClient account when empty (client) | — |
req.secretKey | string | undefined | 否 | 无 | Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. |
req.secType | string | undefined | 否 | 无 | — |
req.market | string | undefined | 否 | 无 | — |
req.symbol | string | undefined | 否 | 无 | — |
req.startDate | number | undefined | 否 | 无 | 毫秒时间戳 () |
req.endDate | number | undefined | 否 | 无 | 毫秒时间戳 () |
req.limit | number | undefined | 否 | 无 | — |
req.isBrief | boolean | undefined | 否 | 无 | — |
req.states | string[] | undefined | 否 | 无 | 订单状态过滤: Invalid / Initial / PendingCancel / Cancelled / Submitted / Filled / Inactive / PendingSubmit |
req.sortBy | string | undefined | 否 | 无 | LATEST_CREATED / LATEST_STATUS_UPDATED |
req.segType | string | undefined | 否 | 无 | — |
req.lang | string | undefined | 否 | 无 | — |
req.pageToken | string | undefined | 否 | 无 | — |
req.parentId | number | undefined | 否 | 无 | 仅 ActiveOrders 使用,按父订单 ID 过滤附加订单 |
返回
Promise<Order[]>
| 字段 | 类型 | 说明 |
|---|---|---|
| account | string | 账户 |
| id | string | number |
| orderId | string | number |
| externalId | string | 外部 ID |
| action | string | 交易方向(买/卖) |
| orderType | string | 订单类型 |
| totalQuantity | number | 总数量 |
| totalQuantityScale | number | 总数量精度 |
| filledQuantity | number | 成交数量 |
| filledQuantityScale | number | 成交数量精度 |
| filledCashAmount | number | 现金成交金额 |
| limitPrice | number | 限价 |
| auxPrice | number | 辅助价格 |
| trailingPercent | number | 追踪百分比 |
| status | string | 交易状态 |
| avgFillPrice | number | 平均成交价 |
| timeInForce | string | 订单有效期 |
| outsideRth | boolean | 盘前盘后交易 |
| orderLegs | OrderLeg[] | 组合腿列表 |
| algoParams | AlgoParams | 算法参数 |
| algoStrategy | string | 算法策略 |
| symbol | string | 股票代码 |
| secType | string | 证券类型 |
| market | string | 市场 |
| currency | string | 币种 |
| expiry | string | 到期日 |
| strike | string | 行权价 |
| right | string | 期权方向 |
| identifier | string | 标识符 |
| name | string | 名称 |
| commission | number | 佣金 |
| gst | number | 商品服务税 |
| realizedPnl | number | 已实现盈亏 |
| openTime | number | 开盘时间 |
| updateTime | number | 更新时间 |
| latestTime | number | 最新成交时间(毫秒时间戳) |
| latestPrice | number | 最新价 |
| remark | string | 备注 |
| source | string | 来源 |
| userMark | string | 用户标记 |
| liquidation | boolean | 清算值 |
| discount | number | 折扣 |
| replaceStatus | string | 替换状态 |
| cancelStatus | string | 撤单状态 |
| canModify | boolean | 是否可修改 |
| canCancel | boolean | 是否可撤单 |
| isOpen | boolean | 是否开仓 |
| orderDiscount | number | 订单折扣 |
| tradingSessionType | string | 交易时段类型 |
| attrDesc | string | 属性描述 |
| attrList | string[] | 属性列表 |
示例
const result = await tradeClient.getInactiveOrders({ market: 'US', secType: 'STK', states: ['Cancelled'], limit: 50 });
console.log(result);返回示例
[
{
"account": "string",
"id": "string | number",
"orderId": "string | number",
"externalId": "string",
"action": "string",
"orderType": "string",
"totalQuantity": 0,
"totalQuantityScale": 0,
"filledQuantity": 0,
"filledQuantityScale": 0,
"filledCashAmount": 0,
"limitPrice": 0,
"auxPrice": 0,
"trailingPercent": 0,
"status": "string",
"avgFillPrice": 0,
"timeInForce": "string",
"outsideRth": "boolean",
"orderLegs": [
"OrderLeg"
],
"algoParams": {
"algoStrategy": "string",
"startTime": "string",
"endTime": "string",
"participationRate": 0
},
"algoStrategy": "string",
"symbol": "string",
"secType": "string",
"market": "string",
"currency": "string",
"expiry": "string",
"strike": "string",
"right": "string",
"identifier": "string",
"name": "string",
"commission": 0,
"gst": 0,
"realizedPnl": 0,
"openTime": 0,
"updateTime": 0,
"latestTime": 0,
"latestPrice": 0,
"remark": "string",
"source": "string",
"userMark": "string",
"liquidation": "boolean",
"discount": 0,
"replaceStatus": "string",
"cancelStatus": "string",
"canModify": "boolean",
"canCancel": "boolean",
"isOpen": "boolean",
"orderDiscount": 0,
"tradingSessionType": "string",
"attrDesc": "string",
"attrList": [
"string"
]
}
]获取已成交订单
签名
async getFilledOrders(req?: OrdersRequest): Promise<Order[]>用途
查询 filled orders。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
req | OrdersRequest | 否 | None | — |
req.account | string | undefined | 否 | TradeClient account when empty (client) | — |
req.secretKey | string | undefined | 否 | 无 | Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. |
req.secType | string | undefined | 否 | 无 | — |
req.market | string | undefined | 否 | 无 | — |
req.symbol | string | undefined | 否 | 无 | — |
req.startDate | number | undefined | 否 | 无 | 毫秒时间戳 () |
req.endDate | number | undefined | 否 | 无 | 毫秒时间戳 () |
req.limit | number | undefined | 否 | 无 | — |
req.isBrief | boolean | undefined | 否 | 无 | — |
req.states | string[] | undefined | 否 | 无 | 订单状态过滤: Invalid / Initial / PendingCancel / Cancelled / Submitted / Filled / Inactive / PendingSubmit |
req.sortBy | string | undefined | 否 | 无 | LATEST_CREATED / LATEST_STATUS_UPDATED |
req.segType | string | undefined | 否 | 无 | — |
req.lang | string | undefined | 否 | 无 | — |
req.pageToken | string | undefined | 否 | 无 | — |
req.parentId | number | undefined | 否 | 无 | 仅 ActiveOrders 使用,按父订单 ID 过滤附加订单 |
返回
Promise<Order[]>
| 字段 | 类型 | 说明 |
|---|---|---|
| account | string | 账户 |
| id | string | number |
| orderId | string | number |
| externalId | string | 外部 ID |
| action | string | 交易方向(买/卖) |
| orderType | string | 订单类型 |
| totalQuantity | number | 总数量 |
| totalQuantityScale | number | 总数量精度 |
| filledQuantity | number | 成交数量 |
| filledQuantityScale | number | 成交数量精度 |
| filledCashAmount | number | 现金成交金额 |
| limitPrice | number | 限价 |
| auxPrice | number | 辅助价格 |
| trailingPercent | number | 追踪百分比 |
| status | string | 交易状态 |
| avgFillPrice | number | 平均成交价 |
| timeInForce | string | 订单有效期 |
| outsideRth | boolean | 盘前盘后交易 |
| orderLegs | OrderLeg[] | 组合腿列表 |
| algoParams | AlgoParams | 算法参数 |
| algoStrategy | string | 算法策略 |
| symbol | string | 股票代码 |
| secType | string | 证券类型 |
| market | string | 市场 |
| currency | string | 币种 |
| expiry | string | 到期日 |
| strike | string | 行权价 |
| right | string | 期权方向 |
| identifier | string | 标识符 |
| name | string | 名称 |
| commission | number | 佣金 |
| gst | number | 商品服务税 |
| realizedPnl | number | 已实现盈亏 |
| openTime | number | 开盘时间 |
| updateTime | number | 更新时间 |
| latestTime | number | 最新成交时间(毫秒时间戳) |
| latestPrice | number | 最新价 |
| remark | string | 备注 |
| source | string | 来源 |
| userMark | string | 用户标记 |
| liquidation | boolean | 清算值 |
| discount | number | 折扣 |
| replaceStatus | string | 替换状态 |
| cancelStatus | string | 撤单状态 |
| canModify | boolean | 是否可修改 |
| canCancel | boolean | 是否可撤单 |
| isOpen | boolean | 是否开仓 |
| orderDiscount | number | 订单折扣 |
| tradingSessionType | string | 交易时段类型 |
| attrDesc | string | 属性描述 |
| attrList | string[] | 属性列表 |
示例
const result = await tradeClient.getFilledOrders({ market: 'US', secType: 'STK', startDate: Date.now() - 30 * 24 * 60 * 60 * 1000, endDate: Date.now(), limit: 100 });
console.log(result);返回示例
[
{
"account": "string",
"id": "string | number",
"orderId": "string | number",
"externalId": "string",
"action": "string",
"orderType": "string",
"totalQuantity": 0,
"totalQuantityScale": 0,
"filledQuantity": 0,
"filledQuantityScale": 0,
"filledCashAmount": 0,
"limitPrice": 0,
"auxPrice": 0,
"trailingPercent": 0,
"status": "string",
"avgFillPrice": 0,
"timeInForce": "string",
"outsideRth": "boolean",
"orderLegs": [
"OrderLeg"
],
"algoParams": {
"algoStrategy": "string",
"startTime": "string",
"endTime": "string",
"participationRate": 0
},
"algoStrategy": "string",
"symbol": "string",
"secType": "string",
"market": "string",
"currency": "string",
"expiry": "string",
"strike": "string",
"right": "string",
"identifier": "string",
"name": "string",
"commission": 0,
"gst": 0,
"realizedPnl": 0,
"openTime": 0,
"updateTime": 0,
"latestTime": 0,
"latestPrice": 0,
"remark": "string",
"source": "string",
"userMark": "string",
"liquidation": "boolean",
"discount": 0,
"replaceStatus": "string",
"cancelStatus": "string",
"canModify": "boolean",
"canCancel": "boolean",
"isOpen": "boolean",
"orderDiscount": 0,
"tradingSessionType": "string",
"attrDesc": "string",
"attrList": [
"string"
]
}
]获取订单详情
签名
async getOrder(req: GetOrderRequest): Promise<Order | undefined>用途
查询 order。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
req | GetOrderRequest | 是 | None | — |
req.account | string | undefined | 否 | TradeClient account when empty (client) | — |
req.secretKey | string | undefined | 否 | 无 | Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. |
req.id | number | undefined | 否 | 无 | — |
req.orderId | number | undefined | 否 | 无 | — |
req.isBrief | boolean | undefined | 否 | 无 | — |
req.showCharges | boolean | undefined | 否 | 无 | — |
req.lang | string | undefined | 否 | 无 | — |
返回
Promise<Order | undefined>
| 字段 | 类型 | 说明 |
|---|---|---|
| account | string | 账户 |
| id | string | number |
| orderId | string | number |
| externalId | string | 外部 ID |
| action | string | 交易方向(买/卖) |
| orderType | string | 订单类型 |
| totalQuantity | number | 总数量 |
| totalQuantityScale | number | 总数量精度 |
| filledQuantity | number | 成交数量 |
| filledQuantityScale | number | 成交数量精度 |
| filledCashAmount | number | 现金成交金额 |
| limitPrice | number | 限价 |
| auxPrice | number | 辅助价格 |
| trailingPercent | number | 追踪百分比 |
| status | string | 交易状态 |
| avgFillPrice | number | 平均成交价 |
| timeInForce | string | 订单有效期 |
| outsideRth | boolean | 盘前盘后交易 |
| orderLegs | OrderLeg[] | 组合腿列表 |
| algoParams | AlgoParams | 算法参数 |
| algoStrategy | string | 算法策略 |
| symbol | string | 股票代码 |
| secType | string | 证券类型 |
| market | string | 市场 |
| currency | string | 币种 |
| expiry | string | 到期日 |
| strike | string | 行权价 |
| right | string | 期权方向 |
| identifier | string | 标识符 |
| name | string | 名称 |
| commission | number | 佣金 |
| gst | number | 商品服务税 |
| realizedPnl | number | 已实现盈亏 |
| openTime | number | 开盘时间 |
| updateTime | number | 更新时间 |
| latestTime | number | 最新成交时间(毫秒时间戳) |
| latestPrice | number | 最新价 |
| remark | string | 备注 |
| source | string | 来源 |
| userMark | string | 用户标记 |
| liquidation | boolean | 清算值 |
| discount | number | 折扣 |
| replaceStatus | string | 替换状态 |
| cancelStatus | string | 撤单状态 |
| canModify | boolean | 是否可修改 |
| canCancel | boolean | 是否可撤单 |
| isOpen | boolean | 是否开仓 |
| orderDiscount | number | 订单折扣 |
| tradingSessionType | string | 交易时段类型 |
| attrDesc | string | 属性描述 |
| attrList | string[] | 属性列表 |
示例
const result = await tradeClient.getOrder({ orderId: 30854, showCharges: true });
console.log(result);返回示例
{
"account": "string",
"id": "string | number",
"orderId": "string | number",
"externalId": "string",
"action": "string",
"orderType": "string",
"totalQuantity": 0,
"totalQuantityScale": 0,
"filledQuantity": 0,
"filledQuantityScale": 0,
"filledCashAmount": 0,
"limitPrice": 0,
"auxPrice": 0,
"trailingPercent": 0,
"status": "string",
"avgFillPrice": 0,
"timeInForce": "string",
"outsideRth": "boolean",
"orderLegs": [
{
"legType": "string",
"price": 0,
"timeInForce": "string",
"quantity": 0
}
],
"algoParams": {
"algoStrategy": "string",
"startTime": "string",
"endTime": "string",
"participationRate": 0
},
"algoStrategy": "string",
"symbol": "string",
"secType": "string",
"market": "string",
"currency": "string",
"expiry": "string",
"strike": "string",
"right": "string",
"identifier": "string",
"name": "string",
"commission": 0,
"gst": 0,
"realizedPnl": 0,
"openTime": 0,
"updateTime": 0,
"latestTime": 0,
"latestPrice": 0,
"remark": "string",
"source": "string",
"userMark": "string",
"liquidation": "boolean",
"discount": 0,
"replaceStatus": "string",
"cancelStatus": "string",
"canModify": "boolean",
"canCancel": "boolean",
"isOpen": "boolean",
"orderDiscount": 0,
"tradingSessionType": "string",
"attrDesc": "string",
"attrList": [
"string"
]
}获取成交记录
签名
async getOrderTransactions(req: OrderTransactionsRequest): Promise<Transaction[]>用途
查询 order transactions。
参数、默认值与约束
| 参数 | 类型 | 必填 | SDK 默认值 | 约束 |
|---|---|---|---|---|
req | OrderTransactionsRequest | 是 | None | — |
req.account | string | undefined | 否 | TradeClient account when empty (client) | — |
req.secretKey | string | undefined | 否 | 无 | Institution account secret key. Overrides the default set in ClientConfig; omit to use the config default. |
req.orderId | number | undefined | 否 | 无 | — |
req.symbol | string | undefined | 否 | 无 | — |
req.secType | string | undefined | 否 | 无 | — |
req.startDate | number | undefined | 否 | 无 | 毫秒时间戳 |
req.endDate | number | undefined | 否 | 无 | 毫秒时间戳 |
req.limit | number | undefined | 否 | 无 | — |
req.expiry | string | undefined | 否 | 无 | — |
req.strike | number | undefined | 否 | 无 | — |
req.putCall | string | undefined | 否 | 无 | — |
req.lang | string | undefined | 否 | 无 | — |
req.pageToken | string | undefined | 否 | 无 | — |
返回
Promise<Transaction[]>
| 字段 | 类型 | 说明 |
|---|---|---|
| id | number | 订单 ID |
| orderId | number | 订单 ID |
| accountId | number | 账户 ID |
| account | string | 账户 |
| symbol | string | 股票代码 |
| secType | string | 证券类型 |
| market | string | 市场 |
| currency | string | 币种 |
| identifier | string | 标识符 |
| action | string | 交易方向(买/卖) |
| price | number | 价格 |
| filledPrice | number | 成交价格 |
| quantity | number | 数量 |
| filledQuantity | number | 成交数量 |
| filledQuantityScale | number | 成交数量精度 |
| amount | number | 成交额 |
| filledAmount | number | 成交金额 |
| commission | number | 佣金 |
| transactedAt | string | 交易时间 |
| transactionTime | number | 交易时间 |
| time | number | 时间(毫秒时间戳) |
示例
const result = await tradeClient.getOrderTransactions({ symbol: 'AAPL', secType: 'STK', limit: 100 });
console.log(result);返回示例
[
{
"id": 987654,
"orderId": 100234,
"accountId": 10001,
"account": "402901",
"symbol": "AAPL",
"secType": "STK",
"market": "US",
"currency": "USD",
"identifier": "AAPL",
"action": "BUY",
"price": 195.50,
"filledPrice": 195.48,
"quantity": 100,
"filledQuantity": 100,
"filledQuantityScale": 0,
"amount": 19550.0,
"filledAmount": 19548.0,
"commission": 1.99,
"transactedAt": "2025-06-24T15:30:01Z",
"transactionTime": 1719240601000,
"time": 1719240601000
}
]Updated 9 days ago
