Longbridge Developers
立即开始

美股委托详情

Longbridge US 账户

此方法仅适用于 Longbridge 美国数据中心账户。

其他数据中心的账户(如香港、新加坡)不支持该方法,即便这些账户可以交易美股;模拟账户(enable_papertrading = true)同样不支持Longbridge US 柜台(US DC)未提供模拟账户功能,因此整个 US region——所有美股专用接口,而不只是本接口——在模拟环境下均不可用。

使用不受支持的账户调用时会返回错误,而不是空结果——请勿将该失败理解为“此委托不存在”。如需模拟环境,请改用 AP 账户与通用交易接口。

获取美股指定委托的详情,包括成交历史,可选获取关联子委托。

>_ CLI
# 查看美股委托详情
longbridge order detail 701276261045858304

Parameters

SDK 方法参数。

名称类型必填描述
order_idstring委托 ID

Request Example

from longbridge.openapi import TradeContext, Config, OAuthBuilder

oauth = OAuthBuilder("your-client-id").build(lambda url: print("请访问:", url))
config = Config.from_oauth(oauth)
ctx = TradeContext(config)
resp = ctx.us_order_detail("701276261045858304")
print(resp)
import asyncio
from longbridge.openapi import AsyncTradeContext, Config, OAuthBuilder

async def main() -> None:
    oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("请访问:", url))
    config = Config.from_oauth(oauth)
    ctx = AsyncTradeContext.create(config)
    resp = await ctx.us_order_detail("701276261045858304")
    print(resp)

if __name__ == "__main__":
    asyncio.run(main())
const { Config, TradeContext, OAuth } = require('longbridge')

async function main() {
  const oauth = await OAuth.build('your-client-id', (_, url) => {
    console.log('请访问此 URL 授权:' + url)
  })
  const config = Config.fromOAuth(oauth)
  const ctx = TradeContext.new(config)
  const resp = await ctx.usOrderDetail("701276261045858304")
  console.log(resp)
}
main().catch(console.error)
import com.longbridge.*;
import com.longbridge.trade.*;

class Main {
    public static void main(String[] args) throws Exception {
        try (OAuth oauth = new OAuthBuilder("your-client-id").build(url -> System.out.println("Open to authorize: " + url)).get();
             Config config = Config.fromOAuth(oauth);
             TradeContext ctx = TradeContext.create(config)) {
            var resp = ctx.getUsOrderDetail("701276261045858304").get();
            System.out.println(resp);
        }
    }
}
use std::sync::Arc;
use longbridge::{oauth::OAuthBuilder, trade::TradeContext, Config};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let oauth = OAuthBuilder::new("your-client-id").build(|url| println!("请访问:{url}")).await?;
    let config = Arc::new(Config::from_oauth(oauth));
    let ctx = TradeContext::new(config);
    let resp = ctx.us_order_detail("701276261045858304").await?;
    println!("{:?}", resp);
    Ok(())
}
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/longbridge/openapi-go/config"
	"github.com/longbridge/openapi-go/oauth"
	"github.com/longbridge/openapi-go/trade"
)

func main() {
	o := oauth.New("your-client-id").
		OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) })
	if err := o.Build(context.Background()); err != nil {
		log.Fatal(err)
	}
	conf, err := config.New(config.WithOAuthClient(o))
	if err != nil {
		log.Fatal(err)
	}
	c, err := trade.NewFromCfg(conf)
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()
	resp, err := c.USOrderDetail(context.Background(), "701276261045858304")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", resp)
}

Response

Response Example

{
  "order": {
    "id": "701276261045858304",
    "symbol": "AAPL.US",
    "action": "Buy",
    "order_type": "LO",
    "status": "Filled",
    "price": "185.00",
    "quantity": "10",
    "executed_qty": "10",
    "executed_price": "184.95",
    "executed_amount": "1849.50",
    "currency": "USD",
    "submitted_at": "1751866334",
    "done_at": "1751866400",
    "time_in_force": 0,
    "msg": ""
  },
  "current_attached_order": null,
  "current_millisecond": "1751866400000"
}

Response Status

状态码描述结构
200成功USOrderDetailResponse
400请求错误None

USOrderDetailResponse

名称类型必填描述
orderUSOrderDetail | null完整委托详情,未找到时为 null
current_attached_orderUSOrderDetail | null关联子委托(括号单/OCO)
current_millisecondstring服务器时间戳(毫秒)

USOrderDetail

核心字段(完整响应包含 50+ 个字段,涵盖费用、触发条件和结算详情):

名称类型描述
idstring委托 ID
symbolstring交易标的,如 AAPL.US
actionint方向:1=买入,2=卖出
order_typestring委托类型
statusstring委托状态
pricestring委托价格
quantitystring委托数量
executed_qtystring已成交数量
executed_pricestring平均成交价格
executed_amountstring成交总金额
currencystring货币代码
submitted_atstring提交时间
done_atstring完成时间
time_in_forceint有效期类型
trigger_pricestring触发价格(止损/止盈单)
msgstring状态消息
order_historiesUSOrderHistory[]委托状态变更历史
attached_ordersUSAttachedOrder[]关联子委托列表
button_controlUSButtonControl可用操作按钮状态
charge_detailUSChargeDetail | null费用明细

USOrderHistory

名称类型描述
exec_typeint执行类型
statusstring当前节点委托状态
pricestring价格
qtystring数量
timestring时间戳
msgstring消息