Longbridge Developers
Get Started

Query Grid Orders by IDs

Query specific grid orders by their IDs.

>_ CLI
# Query specific grid orders by ID
longbridge grid --ids 764609681686573056 764609681686573057

Request

HTTP MethodPOST
HTTP URL/v1/gridtrading/list

Parameters

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

NameTypeRequiredDescription
order_idsstring[]YESGrid order IDs to query

Request Example

from longbridge.openapi import GridContext, Config, OAuthBuilder

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

# Grid REST calls go through the standalone GridContext
ctx = GridContext(config)

resp = ctx.list_by_ids(["764609681686573056"])
print(resp)
const { Config, GridContext, 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 = GridContext.new(config)
  const resp = await ctx.listByIds({ orderIds: ['764609681686573056'] })
  console.log(resp)
}
main().catch(console.error)
import com.longbridge.*;
import com.longbridge.grid.*;

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);
             GridContext ctx = GridContext.create(config)) {
            GridOrder[] orders = ctx.listByIds(new String[]{"764609681686573056"}).get();
            for (GridOrder order : orders) {
                System.out.println(order);
            }
        }
    }
}
use std::sync::Arc;
use longbridge::{
    Config,
    grid::{GridContext, GetGridOrdersByIdsOptions},
    oauth::OAuthBuilder,
};

#[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 = GridContext::new(config);

    let resp = ctx.list_by_ids(GetGridOrdersByIdsOptions::new(["764609681686573056"])).await?;
    println!("{:?}", resp);
    Ok(())
}
#include &lt;iostream&gt;
#include <longbridge.hpp>

using namespace longbridge;
using namespace longbridge::grid;

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

    GetGridOrdersByIdsOptions opts;
    opts.order_ids = { "764609681686573056" };

    ctx.list_by_ids(opts, [](auto res) {
        if (!res) {
            std::cout << "failed" << std::endl;
            return;
        }
        std::cout << "grid orders: " << res->count << std::endl;
    });
}

int main(int argc, char const* argv[]) {
    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" << std::endl;
            return;
        }
        run(*res);
    });

    std::cin.get();
    return 0;
}

Response

Response Headers

  • Content-Type: application/json

Response Example

{
  "code": 0,
  "message": "success",
  "data": {
    "grid_order": [
      {
        "order_id": "764609681686573056",
        "symbol": "700.HK",
        "stock_name": "TENCENT",
        "market": "HK",
        "status": "Performing",
        "grid_status": "Performing",
        "submitted_base_price": "300.000",
        "current_base_price": "300.000",
        "pre_trigger_base_price": "300.000",
        "post_trigger_base_price": "306.000",
        "upper_limit_price": "360.000",
        "lower_limit_price": "240.000",
        "trigger_price_type": 2,
        "trigger_spread_up": "",
        "trigger_spread_down": "",
        "trigger_percent_up": "2",
        "trigger_percent_down": "2",
        "pullback_percent": "",
        "pullback_spread": "",
        "rebound_percent": "",
        "rebound_spread": "",
        "trigger_sell_order_type": "GMO",
        "trigger_buy_order_type": "GMO",
        "trigger_sell_depth": 0,
        "trigger_buy_depth": 0,
        "trigger_quantity": "100",
        "trigger_sell_quantity": "100",
        "trigger_buy_quantity": "100",
        "upper_limit_quantity": "200",
        "lower_limit_quantity": "100",
        "upper_limit_event": 1,
        "lower_limit_event": 1,
        "multiple_trigger": false,
        "trigger_times": 3,
        "total_buy_quantity": "300",
        "total_sell_quantity": "200",
        "total_profit_balance": "1250.00",
        "settlement_currency": "HKD",
        "time_in_force": 1,
        "gtd": "",
        "created_at": "2025-01-15T09:30:00+08:00",
        "rth": 0,
        "support_shortsell": false,
        "grid_order_type_up": "GMO",
        "grid_order_type_down": "GMO"
      }
    ]
  }
}

Response Status

StatusDescriptionSchema
200The grid orders were returned successfully.list_grid_orders_by_ids_rsp
400The request was rejected with an incorrect request parameter.None

Schemas

list_grid_orders_by_ids_rsp

NameTypeRequiredDescription
grid_orderobject[]falseGrid orders
∟ order_idstringtrueGrid order ID
∟ symbolstringtrueStock symbol, use ticker.region format, example: AAPL.US
∟ stock_namestringtrueStock name
∟ marketstringtrueMarket
∟ statusstringtrueGrid order status
∟ grid_statusstringtrueGrid running status
∟ submitted_base_pricestringtrueSubmitted base price the grid is anchored to
∟ current_base_pricestringtrueCurrent base price
∟ pre_trigger_base_pricestringtrueBase price before the last trigger
∟ post_trigger_base_pricestringtrueBase price after the last trigger
∟ upper_limit_pricestringtrueUpper price bound
∟ lower_limit_pricestringtrueLower price bound
∟ trigger_price_typeint32trueTrigger price type

Enum Value:
1 - Spread
2 - Percent
∟ trigger_spread_upstringtrueUpward trigger spread, used when trigger_price_type is 1
∟ trigger_spread_downstringtrueDownward trigger spread, used when trigger_price_type is 1
∟ trigger_percent_upstringtrueUpward trigger percent, used when trigger_price_type is 2
∟ trigger_percent_downstringtrueDownward trigger percent, used when trigger_price_type is 2
∟ pullback_percentstringtruePullback percent
∟ pullback_spreadstringtruePullback spread
∟ rebound_percentstringtrueRebound percent
∟ rebound_spreadstringtrueRebound spread
∟ trigger_sell_order_typestringtrueSell-side grid order type

Enum Value:
GMO - Grid market order
GLO - Grid limit order
GTG - Grid touch-to-go
∟ trigger_buy_order_typestringtrueBuy-side grid order type

Enum Value:
GMO - Grid market order
GLO - Grid limit order
GTG - Grid touch-to-go
∟ trigger_sell_depthint32trueSell-side order-book depth, range -5..5; 0 means use trigger_sell_order_type
∟ trigger_buy_depthint32trueBuy-side order-book depth, range -5..5; 0 means use trigger_buy_order_type
∟ trigger_quantitystringtrueQuantity per trigger
∟ trigger_sell_quantitystringtrueSell-side trigger quantity
∟ trigger_buy_quantitystringtrueBuy-side trigger quantity
∟ upper_limit_quantitystringtrueQuantity handled at the upper bound
∟ lower_limit_quantitystringtrueQuantity handled at the lower bound
∟ upper_limit_eventint32trueEvent when the upper bound is reached

Enum Value:
1 - Ignore (keep grid running)
2 - Close position at last price
∟ lower_limit_eventint32trueEvent when the lower bound is reached

Enum Value:
1 - Ignore (keep grid running)
2 - Close position at last price
∟ multiple_triggerbooleantrueWhether a single grid level can trigger multiple times
∟ trigger_timesint32trueNumber of times the grid has triggered
∟ total_buy_quantitystringtrueTotal bought quantity
∟ total_sell_quantitystringtrueTotal sold quantity
∟ total_profit_balancestringtrueTotal profit balance
∟ settlement_currencystringtrueSettlement currency
∟ time_in_forceint32trueTime in force type

Enum Value:
0 - Day
1 - Good-Til-Canceled
6 - Good-Til-Date
∟ gtdstringtrueGood-Til-Date expiry date, format: YYYY-MM-DD
∟ created_atstringtrueCreation time, formatted as RFC3339
∟ rthint32trueRegular trading hours flag

Enum Value:
0
1
2
∟ support_shortsellbooleantrueWhether short selling is allowed
∟ grid_order_type_upstringtrueSell-side order type when depth is 0

Enum Value:
GMO - Grid market order
GLO - Grid limit order
GTG - Grid touch-to-go
∟ grid_order_type_downstringtrueBuy-side order type when depth is 0

Enum Value:
GMO - Grid market order
GLO - Grid limit order
GTG - Grid touch-to-go