合约与订单

示例上下文

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 默认值约束
configClientConfigNone
config.tigerIdstring
config.privateKeystring
config.accountstring
config.secretKeystring | undefinedInstitution secret key for trade authentication (institution accounts only)
config.licensestring | undefined
config.languagestring
config.timezonestring | undefined
config.timeoutnumber
config.tokenstring | undefined
config.tokenRefreshDurationnumber | undefined
config.tokenCheckIntervalnumber | undefined后台 token 检查间隔(毫秒),仅 tokenRefreshDuration > 0 时生效,默认 5 分钟
config.tokenLoader返回字符串或字符串 Promise 的可选函数自定义 token 加载函数,替代默认的文件加载;精确类型见上方签名引用的 ClientConfig
config.tokenWriter((token: string) => void) | undefinedtoken 刷新写入后的可选回调
config.serverUrlstring
config.quoteServerUrlstringQuote server URL for quote-specific requests; falls back to serverUrl
config.deviceIdstringDevice identifier (auto-detected MAC address)
config.tigerPublicKeystring
accountstringNone
secretKeystringNone

返回

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 默认值约束
symbolstringNone
secTypestringNone

返回

Promise<Contract[]>

字段类型说明
contractIdnumber合约 ID
symbolstring股票代码
secTypestring证券类型
currencystring币种
exchangestring交易所
primaryExchangestring主交易所
localSymbolstring本地代码
tradingClassstring交易类
expirystring到期日
strikenumber行权价
rightstring期权方向
multipliernumber合约乘数
identifierstring标识符
namestring名称
marketstring市场
tradeableboolean是否可交易
conidnumber合约序号
statusnumber交易状态
marginableboolean是否可融资
shortableboolean是否可做空
closeOnlyboolean是否仅可平仓
isEtfboolean是否 ETF
supportOvernightTradingboolean是否支持隔夜交易
supportFractionalShareboolean是否支持碎股
shortMarginnumber空头保证金
shortInitialMarginnumber空头初始保证金
shortMaintenanceMarginnumber空头维持保证金
longInitialMarginnumber多头初始保证金
longMaintenanceMarginnumber多头维持保证金
tickSizesTickSize[]最小变动价位列表
lotSizenumber每手股数

示例

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 默认值约束
symbolsstring[]None
secTypestringNone

返回

Promise<Contract[]>

字段类型说明
contractIdnumber合约 ID
symbolstring股票代码
secTypestring证券类型
currencystring币种
exchangestring交易所
primaryExchangestring主交易所
localSymbolstring本地代码
tradingClassstring交易类
expirystring到期日
strikenumber行权价
rightstring期权方向
multipliernumber合约乘数
identifierstring标识符
namestring名称
marketstring市场
tradeableboolean是否可交易
conidnumber合约序号
statusnumber交易状态
marginableboolean是否可融资
shortableboolean是否可做空
closeOnlyboolean是否仅可平仓
isEtfboolean是否 ETF
supportOvernightTradingboolean是否支持隔夜交易
supportFractionalShareboolean是否支持碎股
shortMarginnumber空头保证金
shortInitialMarginnumber空头初始保证金
shortMaintenanceMarginnumber空头维持保证金
longInitialMarginnumber多头初始保证金
longMaintenanceMarginnumber多头维持保证金
tickSizesTickSize[]最小变动价位列表
lotSizenumber每手股数

示例

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 默认值约束
symbolstringNone
secTypestringNone
expirystringNone

返回

Promise<Contract[]>

字段类型说明
contractIdnumber合约 ID
symbolstring股票代码
secTypestring证券类型
currencystring币种
exchangestring交易所
primaryExchangestring主交易所
localSymbolstring本地代码
tradingClassstring交易类
expirystring到期日
strikenumber行权价
rightstring期权方向
multipliernumber合约乘数
identifierstring标识符
namestring名称
marketstring市场
tradeableboolean是否可交易
conidnumber合约序号
statusnumber交易状态
marginableboolean是否可融资
shortableboolean是否可做空
closeOnlyboolean是否仅可平仓
isEtfboolean是否 ETF
supportOvernightTradingboolean是否支持隔夜交易
supportFractionalShareboolean是否支持碎股
shortMarginnumber空头保证金
shortInitialMarginnumber空头初始保证金
shortMaintenanceMarginnumber空头维持保证金
longInitialMarginnumber多头初始保证金
longMaintenanceMarginnumber多头维持保证金
tickSizesTickSize[]最小变动价位列表
lotSizenumber每手股数

示例

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 默认值约束
reqDerivativeContractsRequestNone
req.accountstring | undefinedTradeClient account when empty (client)
req.secretKeystring | undefinedInstitution account secret key. Overrides the default set in ClientConfig; omit to use the config default.
req.symbolsstring[]
req.secTypestring
req.expirystring | undefined
req.langstring | undefined

返回

Promise<Contract[]>

字段类型说明
contractIdnumber合约 ID
symbolstring股票代码
secTypestring证券类型
currencystring币种
exchangestring交易所
primaryExchangestring主交易所
localSymbolstring本地代码
tradingClassstring交易类
expirystring到期日
strikenumber行权价
rightstring期权方向
multipliernumber合约乘数
identifierstring标识符
namestring名称
marketstring市场
tradeableboolean是否可交易
conidnumber合约序号
statusnumber交易状态
marginableboolean是否可融资
shortableboolean是否可做空
closeOnlyboolean是否仅可平仓
isEtfboolean是否 ETF
supportOvernightTradingboolean是否支持隔夜交易
supportFractionalShareboolean是否支持碎股
shortMarginnumber空头保证金
shortInitialMarginnumber空头初始保证金
shortMaintenanceMarginnumber空头维持保证金
longInitialMarginnumber多头初始保证金
longMaintenanceMarginnumber多头维持保证金
tickSizesTickSize[]最小变动价位列表
lotSizenumber每手股数

示例

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 默认值约束
orderOrderRequestNone

返回

Promise<PlaceOrderResult | undefined>

字段类型说明
idstringnumber
order_idstringnumber
subIds(stringnumber)[]
ordersOrder[]订单列表

示例

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 默认值约束
orderOrderRequestNone

返回

Promise<PreviewResult | undefined>

字段类型说明
accountstring账户
isPassboolean是否通过
commissionnumber佣金
commissionCurrencystring佣金币种
marginCurrencystring保证金币种
initMarginnumber初始保证金
initMarginBeforenumber操作前初始保证金
maintMarginnumber维持保证金
maintMarginBeforenumber操作前维持保证金
equityWithLoannumber含贷款的权益
equityWithLoanBeforenumber操作前含贷款的权益
availableEEnumber可用提前行权额度
excessLiquiditynumber超额流动性
overnightLiquidationnumber隔夜清算值
gstnumber商品服务税
messagestring消息

示例

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 默认值约束
idnumber | stringNone
orderOrderRequestNone

返回

Promise<OrderIdResult | undefined>

字段类型说明
idstringnumber

示例

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 默认值约束
idnumber | stringNone
secretKeystringNone

返回

Promise<OrderIdResult | undefined>

字段类型说明
idstringnumber

示例

const result = await tradeClient.cancelOrder(1, config.secretKey);
console.log(result);

返回示例

{
  "id": "string | number"
}

获取订单列表

签名

async getOrders(req?: OrdersRequest): Promise<Order[]>

用途

查询订单列表。

参数、默认值与约束

参数类型必填SDK 默认值约束
reqOrdersRequestNone
req.accountstring | undefinedTradeClient account when empty (client)
req.secretKeystring | undefinedInstitution account secret key. Overrides the default set in ClientConfig; omit to use the config default.
req.secTypestring | undefined
req.marketstring | undefined
req.symbolstring | undefined
req.startDatenumber | undefined毫秒时间戳 ()
req.endDatenumber | undefined毫秒时间戳 ()
req.limitnumber | undefined
req.isBriefboolean | undefined
req.statesstring[] | undefined订单状态过滤: Invalid / Initial / PendingCancel / Cancelled / Submitted / Filled / Inactive / PendingSubmit
req.sortBystring | undefinedLATEST_CREATED / LATEST_STATUS_UPDATED
req.segTypestring | undefined
req.langstring | undefined
req.pageTokenstring | undefined
req.parentIdnumber | undefined仅 ActiveOrders 使用,按父订单 ID 过滤附加订单

返回

Promise<Order[]>

字段类型说明
accountstring账户
idstringnumber
orderIdstringnumber
externalIdstring外部 ID
actionstring交易方向(买/卖)
orderTypestring订单类型
totalQuantitynumber总数量
totalQuantityScalenumber总数量精度
filledQuantitynumber成交数量
filledQuantityScalenumber成交数量精度
filledCashAmountnumber现金成交金额
limitPricenumber限价
auxPricenumber辅助价格
trailingPercentnumber追踪百分比
statusstring交易状态
avgFillPricenumber平均成交价
timeInForcestring订单有效期
outsideRthboolean盘前盘后交易
orderLegsOrderLeg[]组合腿列表
algoParamsAlgoParams算法参数
algoStrategystring算法策略
symbolstring股票代码
secTypestring证券类型
marketstring市场
currencystring币种
expirystring到期日
strikestring行权价
rightstring期权方向
identifierstring标识符
namestring名称
commissionnumber佣金
gstnumber商品服务税
realizedPnlnumber已实现盈亏
openTimenumber开盘时间
updateTimenumber更新时间
latestTimenumber最新成交时间(毫秒时间戳)
latestPricenumber最新价
remarkstring备注
sourcestring来源
userMarkstring用户标记
liquidationboolean清算值
discountnumber折扣
replaceStatusstring替换状态
cancelStatusstring撤单状态
canModifyboolean是否可修改
canCancelboolean是否可撤单
isOpenboolean是否开仓
orderDiscountnumber订单折扣
tradingSessionTypestring交易时段类型
attrDescstring属性描述
attrListstring[]属性列表

示例

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 默认值约束
reqOrdersRequestNone
req.accountstring | undefinedTradeClient account when empty (client)
req.secretKeystring | undefinedInstitution account secret key. Overrides the default set in ClientConfig; omit to use the config default.
req.secTypestring | undefined
req.marketstring | undefined
req.symbolstring | undefined
req.startDatenumber | undefined毫秒时间戳 ()
req.endDatenumber | undefined毫秒时间戳 ()
req.limitnumber | undefined
req.isBriefboolean | undefined
req.statesstring[] | undefined订单状态过滤: Invalid / Initial / PendingCancel / Cancelled / Submitted / Filled / Inactive / PendingSubmit
req.sortBystring | undefinedLATEST_CREATED / LATEST_STATUS_UPDATED
req.segTypestring | undefined
req.langstring | undefined
req.pageTokenstring | undefined
req.parentIdnumber | undefined仅 ActiveOrders 使用,按父订单 ID 过滤附加订单

返回

Promise<Order[]>

字段类型说明
accountstring账户
idstringnumber
orderIdstringnumber
externalIdstring外部 ID
actionstring交易方向(买/卖)
orderTypestring订单类型
totalQuantitynumber总数量
totalQuantityScalenumber总数量精度
filledQuantitynumber成交数量
filledQuantityScalenumber成交数量精度
filledCashAmountnumber现金成交金额
limitPricenumber限价
auxPricenumber辅助价格
trailingPercentnumber追踪百分比
statusstring交易状态
avgFillPricenumber平均成交价
timeInForcestring订单有效期
outsideRthboolean盘前盘后交易
orderLegsOrderLeg[]组合腿列表
algoParamsAlgoParams算法参数
algoStrategystring算法策略
symbolstring股票代码
secTypestring证券类型
marketstring市场
currencystring币种
expirystring到期日
strikestring行权价
rightstring期权方向
identifierstring标识符
namestring名称
commissionnumber佣金
gstnumber商品服务税
realizedPnlnumber已实现盈亏
openTimenumber开盘时间
updateTimenumber更新时间
latestTimenumber最新成交时间(毫秒时间戳)
latestPricenumber最新价
remarkstring备注
sourcestring来源
userMarkstring用户标记
liquidationboolean清算值
discountnumber折扣
replaceStatusstring替换状态
cancelStatusstring撤单状态
canModifyboolean是否可修改
canCancelboolean是否可撤单
isOpenboolean是否开仓
orderDiscountnumber订单折扣
tradingSessionTypestring交易时段类型
attrDescstring属性描述
attrListstring[]属性列表

示例

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 默认值约束
reqOrdersRequestNone
req.accountstring | undefinedTradeClient account when empty (client)
req.secretKeystring | undefinedInstitution account secret key. Overrides the default set in ClientConfig; omit to use the config default.
req.secTypestring | undefined
req.marketstring | undefined
req.symbolstring | undefined
req.startDatenumber | undefined毫秒时间戳 ()
req.endDatenumber | undefined毫秒时间戳 ()
req.limitnumber | undefined
req.isBriefboolean | undefined
req.statesstring[] | undefined订单状态过滤: Invalid / Initial / PendingCancel / Cancelled / Submitted / Filled / Inactive / PendingSubmit
req.sortBystring | undefinedLATEST_CREATED / LATEST_STATUS_UPDATED
req.segTypestring | undefined
req.langstring | undefined
req.pageTokenstring | undefined
req.parentIdnumber | undefined仅 ActiveOrders 使用,按父订单 ID 过滤附加订单

返回

Promise<Order[]>

字段类型说明
accountstring账户
idstringnumber
orderIdstringnumber
externalIdstring外部 ID
actionstring交易方向(买/卖)
orderTypestring订单类型
totalQuantitynumber总数量
totalQuantityScalenumber总数量精度
filledQuantitynumber成交数量
filledQuantityScalenumber成交数量精度
filledCashAmountnumber现金成交金额
limitPricenumber限价
auxPricenumber辅助价格
trailingPercentnumber追踪百分比
statusstring交易状态
avgFillPricenumber平均成交价
timeInForcestring订单有效期
outsideRthboolean盘前盘后交易
orderLegsOrderLeg[]组合腿列表
algoParamsAlgoParams算法参数
algoStrategystring算法策略
symbolstring股票代码
secTypestring证券类型
marketstring市场
currencystring币种
expirystring到期日
strikestring行权价
rightstring期权方向
identifierstring标识符
namestring名称
commissionnumber佣金
gstnumber商品服务税
realizedPnlnumber已实现盈亏
openTimenumber开盘时间
updateTimenumber更新时间
latestTimenumber最新成交时间(毫秒时间戳)
latestPricenumber最新价
remarkstring备注
sourcestring来源
userMarkstring用户标记
liquidationboolean清算值
discountnumber折扣
replaceStatusstring替换状态
cancelStatusstring撤单状态
canModifyboolean是否可修改
canCancelboolean是否可撤单
isOpenboolean是否开仓
orderDiscountnumber订单折扣
tradingSessionTypestring交易时段类型
attrDescstring属性描述
attrListstring[]属性列表

示例

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 默认值约束
reqOrdersRequestNone
req.accountstring | undefinedTradeClient account when empty (client)
req.secretKeystring | undefinedInstitution account secret key. Overrides the default set in ClientConfig; omit to use the config default.
req.secTypestring | undefined
req.marketstring | undefined
req.symbolstring | undefined
req.startDatenumber | undefined毫秒时间戳 ()
req.endDatenumber | undefined毫秒时间戳 ()
req.limitnumber | undefined
req.isBriefboolean | undefined
req.statesstring[] | undefined订单状态过滤: Invalid / Initial / PendingCancel / Cancelled / Submitted / Filled / Inactive / PendingSubmit
req.sortBystring | undefinedLATEST_CREATED / LATEST_STATUS_UPDATED
req.segTypestring | undefined
req.langstring | undefined
req.pageTokenstring | undefined
req.parentIdnumber | undefined仅 ActiveOrders 使用,按父订单 ID 过滤附加订单

返回

Promise<Order[]>

字段类型说明
accountstring账户
idstringnumber
orderIdstringnumber
externalIdstring外部 ID
actionstring交易方向(买/卖)
orderTypestring订单类型
totalQuantitynumber总数量
totalQuantityScalenumber总数量精度
filledQuantitynumber成交数量
filledQuantityScalenumber成交数量精度
filledCashAmountnumber现金成交金额
limitPricenumber限价
auxPricenumber辅助价格
trailingPercentnumber追踪百分比
statusstring交易状态
avgFillPricenumber平均成交价
timeInForcestring订单有效期
outsideRthboolean盘前盘后交易
orderLegsOrderLeg[]组合腿列表
algoParamsAlgoParams算法参数
algoStrategystring算法策略
symbolstring股票代码
secTypestring证券类型
marketstring市场
currencystring币种
expirystring到期日
strikestring行权价
rightstring期权方向
identifierstring标识符
namestring名称
commissionnumber佣金
gstnumber商品服务税
realizedPnlnumber已实现盈亏
openTimenumber开盘时间
updateTimenumber更新时间
latestTimenumber最新成交时间(毫秒时间戳)
latestPricenumber最新价
remarkstring备注
sourcestring来源
userMarkstring用户标记
liquidationboolean清算值
discountnumber折扣
replaceStatusstring替换状态
cancelStatusstring撤单状态
canModifyboolean是否可修改
canCancelboolean是否可撤单
isOpenboolean是否开仓
orderDiscountnumber订单折扣
tradingSessionTypestring交易时段类型
attrDescstring属性描述
attrListstring[]属性列表

示例

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 默认值约束
reqGetOrderRequestNone
req.accountstring | undefinedTradeClient account when empty (client)
req.secretKeystring | undefinedInstitution account secret key. Overrides the default set in ClientConfig; omit to use the config default.
req.idnumber | undefined
req.orderIdnumber | undefined
req.isBriefboolean | undefined
req.showChargesboolean | undefined
req.langstring | undefined

返回

Promise<Order | undefined>

字段类型说明
accountstring账户
idstringnumber
orderIdstringnumber
externalIdstring外部 ID
actionstring交易方向(买/卖)
orderTypestring订单类型
totalQuantitynumber总数量
totalQuantityScalenumber总数量精度
filledQuantitynumber成交数量
filledQuantityScalenumber成交数量精度
filledCashAmountnumber现金成交金额
limitPricenumber限价
auxPricenumber辅助价格
trailingPercentnumber追踪百分比
statusstring交易状态
avgFillPricenumber平均成交价
timeInForcestring订单有效期
outsideRthboolean盘前盘后交易
orderLegsOrderLeg[]组合腿列表
algoParamsAlgoParams算法参数
algoStrategystring算法策略
symbolstring股票代码
secTypestring证券类型
marketstring市场
currencystring币种
expirystring到期日
strikestring行权价
rightstring期权方向
identifierstring标识符
namestring名称
commissionnumber佣金
gstnumber商品服务税
realizedPnlnumber已实现盈亏
openTimenumber开盘时间
updateTimenumber更新时间
latestTimenumber最新成交时间(毫秒时间戳)
latestPricenumber最新价
remarkstring备注
sourcestring来源
userMarkstring用户标记
liquidationboolean清算值
discountnumber折扣
replaceStatusstring替换状态
cancelStatusstring撤单状态
canModifyboolean是否可修改
canCancelboolean是否可撤单
isOpenboolean是否开仓
orderDiscountnumber订单折扣
tradingSessionTypestring交易时段类型
attrDescstring属性描述
attrListstring[]属性列表

示例

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 默认值约束
reqOrderTransactionsRequestNone
req.accountstring | undefinedTradeClient account when empty (client)
req.secretKeystring | undefinedInstitution account secret key. Overrides the default set in ClientConfig; omit to use the config default.
req.orderIdnumber | undefined
req.symbolstring | undefined
req.secTypestring | undefined
req.startDatenumber | undefined毫秒时间戳
req.endDatenumber | undefined毫秒时间戳
req.limitnumber | undefined
req.expirystring | undefined
req.strikenumber | undefined
req.putCallstring | undefined
req.langstring | undefined
req.pageTokenstring | undefined

返回

Promise<Transaction[]>

字段类型说明
idnumber订单 ID
orderIdnumber订单 ID
accountIdnumber账户 ID
accountstring账户
symbolstring股票代码
secTypestring证券类型
marketstring市场
currencystring币种
identifierstring标识符
actionstring交易方向(买/卖)
pricenumber价格
filledPricenumber成交价格
quantitynumber数量
filledQuantitynumber成交数量
filledQuantityScalenumber成交数量精度
amountnumber成交额
filledAmountnumber成交金额
commissionnumber佣金
transactedAtstring交易时间
transactionTimenumber交易时间
timenumber时间(毫秒时间戳)

示例

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
  }
]

Did this page help you?