Longbridge Developers
Get Started

US Order History

Longbridge US Accounts

This method is only available for Longbridge US data-center accounts.

It is not available to accounts in other data centers (such as HK or SG), even when those accounts can trade US symbols. It is also not available to paper accounts (enable_papertrading = true): the Longbridge US desk (US DC) does not provide paper accounts at all, so the entire US region — every US-specific API, not just this one — is unavailable in a paper environment.

Calling it from an unsupported account returns an error rather than an empty result — do not treat the failure as “this account has no orders”. For a paper environment, use an AP account with the generic trade APIs instead.

Query historical and pending orders for US accounts with pagination and filtering.

>_ CLI
# List US orders
longbridge order
# Filter pending orders
longbridge order --status pending

Parameters

SDK method parameters.

NameTypeRequiredDescription
symbolstringNOFilter by symbol, e.g. AAPL.US
actionintNODirection filter: 0=all, 1=buy, 2=sell (default: 0)
start_atint64NOStart time (Unix seconds); 0 = last 90 days
end_atint64NOEnd time (Unix seconds); 0 = now
query_typeintNO0=all (incl. rejected), 1=pending, 2=filled only (default: 0)
pageintNOPage number, 1-based (default: 1)
limitintNOPage size (default: 20)

Request Example

from longbridge.openapi import TradeContext, Config, OAuthBuilder

oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = TradeContext(config)
# List all orders (all defaults)
resp = ctx.us_query_orders()
# Filter: buy orders for AAPL.US
resp = ctx.us_query_orders(symbol="AAPL.US", action=1)
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("Visit:", url))
    config = Config.from_oauth(oauth)
    ctx = AsyncTradeContext.create(config)
    resp = await ctx.us_query_orders()
    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('Open this URL to authorize: ' + url)
  })
  const config = Config.fromOAuth(oauth)
  const ctx = TradeContext.new(config)
  const resp = await ctx.usQueryOrders(null, 0, 0, 0, 0, 1, 20)
  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.getUsQueryOrders("", 0, 0L, 0L, 0, 1, 20).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!("Open: {url}")).await?;
    let config = Arc::new(Config::from_oauth(oauth));
    let ctx = TradeContext::new(config);
    let opts = longbridge::trade::GetUSHistoryOrders {
        symbol: None,
        side: longbridge::trade::OrderSide::Unknown,
        start_at: 0,
        end_at: 0,
    };
    let resp = ctx.us_query_orders(opts).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()
	page := int32(1)
	limit := int32(20)
	resp, err := c.QueryUSOrders(context.Background(), &trade.GetUSHistoryOrders{Page: page, Limit: limit})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%+v\n", resp)
}

Response

Response Example

{
  "orders": [
    {
      "id": "701276261045858304",
      "symbol": "AAPL.US",
      "action": "Buy",
      "order_type": "LO",
      "status": "Filled",
      "price": "185.00",
      "quantity": "10",
      "submitted_at": 1751866334,
      "updated_at": 1751866400
    }
  ],
  "total_count": 1
}

Response Status

StatusDescriptionSchema
200SuccessQueryUSOrdersResponse
400Bad requestNone

Schemas

QueryUSOrdersResponse

NameTypeRequiredDescription
ordersUSOrder[]trueList of orders matching the filter
total_countinttrueTotal number of matching orders

USOrder

NameTypeDescription
idstringOrder ID
symbolstringTrading symbol (e.g. AAPL.US)
actionstringDirection: Buy or Sell
order_typestringOrder type
statusstringOrder status
pricestringOrder price
quantitystringOrder quantity
submitted_atint64Submission time (Unix seconds)
updated_atint64Last update time (Unix seconds)