Longbridge Developers
Get Started

Today Orders

This API is used to get today order or get order by order id.

>_ CLI
longbridge order

Request

HTTP MethodGET
HTTP URL/v1/trade/order/today

Parameters

Content-Type: application/json; charset=utf-8

NameTypeRequiredDescription
symbolstringNOStock symbol, use ticker.region format, example: AAPL.US
statusstring[]NOOrder status

example: status=FilledStatus&status=NewStatus
sidestringNOOrder side

Enum Value:
Buy
Sell
marketstringNOMarket

Enum Value:
US - United States of America Market
HK - Hong Kong Market
order_idstringNOOrder ID, example: 701276261045858304
is_attachedboolNOWhether order_id refers to an attached order, returns the attached order information if true

Request Example

from longbridge.openapi import TradeContext, Config, OrderStatus, OrderSide, Market, OAuthBuilder

oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
config = Config.from_oauth(oauth)
ctx = TradeContext(config)

resp = ctx.today_orders(
    symbol = "700.HK",
    status = [OrderStatus.Filled, OrderStatus.New],
    side = OrderSide.Buy,
    market = Market.HK,
)
print(resp)
import asyncio
from longbridge.openapi import AsyncTradeContext, Config, OrderStatus, OrderSide, Market, 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.today_orders(
        symbol = "700.HK",
        status = [OrderStatus.Filled, OrderStatus.New],
        side = OrderSide.Buy,
        market = Market.HK,
    )
    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.todayOrders({})
  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)) {
            Order[] resp = ctx.getTodayOrders(null).get();
            for (Order o : resp) System.out.println(o);
        }
    }
}
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 this URL to authorize: {url}")).await?;
    let config = Arc::new(Config::from_oauth(oauth));
    let (ctx, _) = TradeContext::new(config);
    let resp = ctx.today_orders(None).await?;
    println!("{:?}", resp);
    Ok(())
}
#include &lt;iostream&gt;
#include <longbridge.hpp>

#ifdef WIN32
#include <windows.h>
#endif

using namespace longbridge;
using namespace longbridge::trade;

static void
run(const OAuth& oauth)
{
    Config config = Config::from_oauth(oauth);
    TradeContext ctx = TradeContext::create(config);

    ctx.today_orders(std::nullopt, [](auto res) {
        if (!res) { std::cout << "failed" << std::endl; return; }
        for (const auto& o : *res) std::cout << o.order_id << std::endl;
    });
}

int main(int argc, char const* argv[]) {
#ifdef WIN32
    SetConsoleOutputCP(CP_UTF8);
#endif

    const std::string client_id = "your-client-id";
    OAuthBuilder(client_id).build(
    [](const std::string& url) {
        std::cout << "Open this URL to authorize: " << url << std::endl;
    },
    [](auto res) {
        if (!res) {
            std::cout << "authorization failed: " << *res.status().message() << std::endl;
            return;
        }
        run(*res);
    });

    std::cin.get();
    return 0;
}
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)
	}
	tctx, err := trade.NewFromCfg(conf)
	if err != nil {
		log.Fatal(err)
	}
	defer tctx.Close()
	orders, err := tctx.TodayOrders(context.Background(), &trade.GetTodayOrders{})
	if err != nil {
		log.Fatal(err)
	}
	for _, o := range orders {
		fmt.Println(o.OrderId)
	}
}

Response

Response Headers

  • Content-Type: application/json

Response Example

{
  "code": 0,
  "message": "success",
  "data": {
    "orders": [
      {
        "currency": "HKD",
        "executed_price": "0.000",
        "executed_quantity": "0",
        "expire_date": "",
        "last_done": "",
        "limit_offset": "",
        "msg": "",
        "order_id": "706388312699592704",
        "order_type": "ELO",
        "outside_rth": "UnknownOutsideRth",
        "price": "11.900",
        "quantity": "200",
        "side": "Buy",
        "status": "RejectedStatus",
        "stock_name": "Bank of East Asia Ltd/The",
        "submitted_at": "1651644897",
        "symbol": "23.HK",
        "tag": "Normal",
        "time_in_force": "Day",
        "trailing_amount": "",
        "trailing_percent": "",
        "trigger_at": "0",
        "trigger_price": "",
        "trigger_status": "NOT_USED",
        "updated_at": "1651644898",
        "remark": "",
        "limit_depth_level": 0,
        "monitor_price": "",
        "trigger_count": 1,
        "attached_orders": [
          {
            "order_id": "706388312699592705",
            "attached_type_display": 2,
            "trigger_price": "10.500",
            "quantity": "200",
            "executed_qty": "0",
            "status": "NewStatus",
            "updated_at": "1651644898",
            "withdrawn": false,
            "gtd": "",
            "time_in_force": "Day",
            "counter_id": "",
            "trigger_status": 0,
            "executed_amount": "0",
            "tag": 0,
            "submitted_at": "1651644897",
            "executed_price": "0.000",
            "force_only_rth": "RTH_ONLY",
            "reviewed": false,
            "activate_order_type": "MIT",
            "activate_rth": "RTH_ONLY",
            "submit_price": ""
          }
        ],
        "multi_leg": {
          "strategy": "2",
          "strategy_name": "Vertical spread",
          "multileg_id": "Spread_QQQ20260731C764/767",
          "code": "QQQ 260731 764/767 Vertical spread",
          "legs": [
            {
              "symbol": "QQQ260731C764000.US",
              "side": "Buy",
              "position": "LONG",
              "ratio_quantity": "1",
              "strike_price": "764",
              "expire_date": "20260731",
              "contract_direction": "C"
            },
            {
              "symbol": "QQQ260731C767000.US",
              "side": "Sell",
              "position": "SHORT",
              "ratio_quantity": "1",
              "strike_price": "767",
              "expire_date": "20260731",
              "contract_direction": "C"
            }
          ]
        }
      }
    ]
  }
}

Response Status

StatusDescriptionSchema
200Get Today Orders Successtoday_orders_rsp
400The query failed with an error in the request parameter.None

Schemas

today_orders_rsp

NameTypeRequiredDescription
ordersobject[]falseOrder Detail
∟ order_idstringtrueOrder ID
∟ statusstringtrueOrder Status
∟ stock_namestringtrueStock Name
∟ quantitystringtrueSubmitted Quantity
∟ executed_quantitystringtrueExecuted Quantity.

when the order is not filled, value is 0
∟ pricestringtrueSubmitted Price.

when market condition order is not triggered, value is empty string
∟ executed_pricestringtrueExecuted Price.

when the order is not filled, value is 0
∟ submitted_atstringtrueSubmitted Time
∟ sidestringtrueOrder Side

Enum Value:
Buy
Sell
∟ symbolstringtrueStock symbol, use ticker.region format, example: AAPL.US
∟ order_typestringtrueOrder Type
∟ last_donestringtrueLast done.

when the order is not filled, value is empty string
∟ trigger_pricestringtrueLIT / MIT Order Trigger Price.

When the order is not LIT / MIT order, value is empty string
∟ msgstringtrueRejected message or remark, default value is empty string.
∟ tagstringtrueOrder tag

Enum Value
Normal - Normal Order
Gtc - Long term Order
Grey - Grey Order
∟ time_in_forcestringtrueTime in force Type

Enum Value:
Day - Day Order
GTC - Good Til Canceled Order
GTD - Good Til Date Order
∟ expire_datestringtrueLong term order expire date, format: YYYY-MM-DD, example: 2022-12-05.

When not a long term order, default value is empty string
∟ updated_atstringtrueLast updated time, formatted as a timestamp (second)
∟ trigger_atstringtrueConditional order trigger time. formatted as a timestamp (second)
∟ trailing_amountstringtrueTSLPAMT order trailing amount.

When the order is not TSLPAMT order, value is empty string
∟ trailing_percentstringtrueTSLPPCT order trailing percent.

When the order is not TSLPPCT order, value is empty string
∟ limit_offsetstringtrueTSLPAMT / TSLPPCT order limit offset amount.

When the order is not TSLPAMT / TSLPPCT order, value is empty string
∟ trigger_statusstringtrueConditional Order Trigger Status
When an order is not a conditional order or a conditional order is not triggered, the trigger status is NOT_USED

Enum Value
NOT_USED
DEACTIVE
ACTIVE
RELEASED
∟ currencystringtrueCurrency
∟ outside_rthstringtrueEnable or disable outside regular trading hours
Default is UnknownOutsideRth when the order is not a US stock

Enum Value:
RTH_ONLY - Regular trading hour only
ANY_TIME - Any time
OVERNIGHT - Overnight”
∟ remarkstringtrueRemark
∟ limit_depth_levelint32trueSpecifies the bid/ask depth level
∟ monitor_pricestringtrueMonitoring price
∟ trigger_countint32trueNumber of triggers
∟ attached_ordersobject[]falseList of attached order details
∟∟ order_idstringtrueAttached order ID
∟∟ attached_type_displayint32trueAttached order type.

Enum Value:
1 - Take Profit
2 - Stop Loss
∟∟ trigger_pricestringtrueTrigger price
∟∟ quantitystringtrueOrder quantity
∟∟ executed_qtystringtrueExecuted quantity
∟∟ statusstringtrueOrder status
∟∟ updated_atstringtrueLast updated time, formatted as a timestamp (second)
∟∟ withdrawnbooleantrueWhether the order has been withdrawn
∟∟ gtdstringtrueGTD expiration date, format: YYYY-MM-DD
∟∟ time_in_forcestringtrueTime in force Type

Enum Value:
Day - Day Order
GTC - Good Til Canceled Order
GTD - Good Til Date Order
∟∟ counter_idstringtrueCounter order ID
∟∟ trigger_statusint32trueConditional order trigger status after the attached order is activated.
0 - Not activated
1 - Monitoring
2 - Cancelled
4 - Triggered
∟∟ executed_amountstringtrueExecuted amount
∟∟ tagint32trueOrder tag
∟∟ submitted_atstringtrueSubmitted time, formatted as a timestamp (second)
∟∟ executed_pricestringtrueExecuted price
∟∟ force_only_rthstringtrueWhether execution is restricted to regular trading hours only
∟∟ reviewedbooleantrueWhether the order has been reviewed
∟∟ activate_order_typestringtrueOrder type submitted after triggering, e.g. LIT (limit-if-touched) or MIT (market-if-touched)
∟∟ activate_rthstringtrueWhether the order submitted after triggering allows pre/post market trading
∟∟ submit_pricestringtrueSubmitted price
∟ multi_legobjectfalseMulti-leg strategy information. Only returned for multi-leg option combination orders; otherwise not returned.
∟∟ strategystringfalseMulti-leg strategy

Enum Value:
0 - CoveredCall (Covered stock)
1 - CoveredPut (Covered stock)
2 - VerticalCallSpread (Vertical spread)
3 - VerticalPutSpread (Vertical spread)
4 - Collar
5 - Straddle
6 - Strangle
∟∟ strategy_namestringfalseStrategy name
∟∟ multileg_idstringfalseMulti-leg combination ID
∟∟ codestringfalseMulti-leg combination code
∟∟ legsobject[]falseLegs of the combination order
∟∟∟ symbolstringfalseOption symbol, use ticker.region format, example: QQQ260731C764000.US
∟∟∟ sidestringfalseOrder Side

Enum Value:
Buy
Sell
∟∟∟ positionstringfalsePosition direction

Enum Value:
LONG
SHORT
∟∟∟ ratio_quantitystringfalseLeg ratio quantity
∟∟∟ strike_pricestringfalseStrike price
∟∟∟ expire_datestringfalseOption expiry date, format: YYYYMMDD
∟∟∟ contract_directionstringfalseContract type

Enum Value:
C - Call
P - Put