Longbridge Developers
Get Started

Grid Order Detail

Query the full detail of a single grid order, including its rule, paged executed sub-orders (grid_sub_orders), and paged lifecycle history (grid_order_history).

>_ CLI
# Rule, sub-orders and history of a grid order
longbridge grid detail 764609681686573056

Request

HTTP MethodGET
HTTP URL/v1/gridtrading/detail

Parameters

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

NameTypeRequiredDescription
order_idstringYESGrid order ID, example: 764609681686573056
history_idstringNOCursor for paging the lifecycle history. Pass the last history_id of a page to fetch older entries.
limitint32NOPage size for grid_sub_orders and grid_order_history

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.detail("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.detail({ orderId: '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)) {
            GridOrderDetail resp = ctx.detail(new GetGridOrderDetailOptions("764609681686573056")).get();
            System.out.println(resp);
        }
    }
}
use std::sync::Arc;
use longbridge::{
    Config,
    grid::{GridContext, GetGridOrderDetailOptions},
    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.detail(GetGridOrderDetailOptions::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);

    GetGridOrderDetailOptions opts{ "764609681686573056" };
    ctx.detail(opts, [](auto res) {
        if (!res) {
            std::cout << "failed" << std::endl;
            return;
        }
        std::cout << "order_id: " << res->order_id << 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": {
    "order_id": "764609681686573056",
    "symbol": "700.HK",
    "stock_name": "TENCENT",
    "status": "Performing",
    "grid_status": "Performing",
    "suspend_reason": "",
    "sleeping_reason": "",
    "submitted_base_price": "300",
    "current_base_price": "300",
    "upper_limit_price": "360",
    "lower_limit_price": "240",
    "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": "",
    "multiple_trigger": false,
    "time_in_force": 1,
    "trigger_quantity": "100",
    "trigger_sell_quantity": "0",
    "trigger_buy_quantity": "0",
    "upper_limit_quantity": "200",
    "lower_limit_quantity": "100",
    "upper_limit_event": 1,
    "lower_limit_event": 1,
    "trigger_sell_depth": 0,
    "trigger_buy_depth": 0,
    "created_at": "2024-08-12T10:30:00+08:00",
    "updated_at": "2024-08-12T10:30:00+08:00",
    "settlement_currency": "HKD",
    "expire_time": "",
    "gtd": "",
    "grid_sub_orders": [],
    "sub_has_more": false,
    "grid_order_history": [
      {
        "history_id": "764609681686573100",
        "created_at": "2024-08-12T10:30:00+08:00",
        "status": "Performing",
        "suspend_reason": "",
        "reason": "Grid order started"
      }
    ],
    "history_has_more": false,
    "support_shortsell": false,
    "rth": 0,
    "grid_order_type_up": "GMO",
    "grid_order_type_down": "GMO"
  }
}

Response Status

StatusDescriptionSchema
200The grid order detail was returned successfully.grid_order_detail_rsp
400The request was rejected with an incorrect parameter.None

Schemas

grid_order_detail_rsp

NameTypeRequiredDescription
order_idstringtrueGrid order ID
symbolstringtrueSecurity symbol, ticker.region format
stock_namestringtrueSecurity name
statusstringtrueGrid order status, example: Performing / Suspended
grid_statusstringtrueDetailed grid running status
suspend_reasonstringtrueReason the grid is suspended, empty when running
sleeping_reasonstringtrueReason the grid is dormant, empty when active
submitted_base_pricestringtrueBase price the grid was anchored to at submission
current_base_pricestringtrueCurrent base price after triggers
upper_limit_pricestringtrueUpper price bound
lower_limit_pricestringtrueLower price bound
trigger_price_typeint32trueHow trigger thresholds are interpreted

Enum Value:
1 - spread (absolute)
2 - percent
trigger_spread_upstringtrueUpward trigger spread (when trigger_price_type is 1)
trigger_spread_downstringtrueDownward trigger spread (when trigger_price_type is 1)
trigger_percent_upstringtrueUpward trigger percent (when trigger_price_type is 2)
trigger_percent_downstringtrueDownward trigger percent (when trigger_price_type is 2)
pullback_percentstringtruePullback percent
pullback_spreadstringtruePullback spread
rebound_percentstringtrueRebound percent
rebound_spreadstringtrueRebound spread
multiple_triggerbooleantrueWhether a single grid level may trigger multiple times
time_in_forceint32trueTime in force

Enum Value:
0 - Day
1 - GTC
6 - GTD
trigger_quantitystringtrueQuantity per trigger
trigger_sell_quantitystringtrueCumulative quantity triggered on the sell side
trigger_buy_quantitystringtrueCumulative quantity triggered on the buy side
upper_limit_quantitystringtrueQuantity handled when the upper bound is reached
lower_limit_quantitystringtrueQuantity handled when the lower bound is reached
upper_limit_eventint32trueAction at the upper bound

Enum Value:
1 - ignore
2 - close position at last price
lower_limit_eventint32trueAction at the lower bound

Enum Value:
1 - ignore
2 - close position at last price
trigger_sell_depthint32trueSell-side order-book depth (-5 ~ 5). 0 = use grid_order_type_up
trigger_buy_depthint32trueBuy-side order-book depth (-5 ~ 5). 0 = use grid_order_type_down
created_atstringtrueCreation time, RFC3339 format
updated_atstringtrueLast update time, RFC3339 format
settlement_currencystringtrueSettlement currency, example: HKD
expire_timestringtrueExpiry time, RFC3339 format (when time_in_force is GTD)
gtdstringtrueGood-Til-Date, YYYY-MM-DD format
grid_sub_ordersobject[]falseExecuted sub-orders for this grid
∟ idstringtrueSub-order ID
∟ pricestringtrueOrder price
∟ order_typestringtrueOrder type
∟ quantitystringtrueOrder quantity
∟ executed_qtystringtrueExecuted quantity
∟ actionint32trueBuy/sell direction
∟ statusstringtrueSub-order status
∟ submitted_atstringtrueSubmission time, RFC3339 format
∟ rthint32trueRegular-trading-hours flag (0 / 1 / 2)
sub_has_morebooleantrueWhether more sub-orders can be paged
grid_order_historyobject[]falseLifecycle history entries
∟ history_idstringtrueHistory entry ID, also used as the paging cursor
∟ created_atstringtrueEvent time, RFC3339 format
∟ statusstringtrueGrid status after the event
∟ suspend_reasonstringtrueSuspend reason, when applicable
∟ reasonstringtrueHuman-readable description of the event
history_has_morebooleantrueWhether more history entries can be paged via history_id
support_shortsellbooleantrueWhether short selling is allowed
rthint32trueRegular-trading-hours flag (0 / 1 / 2)
grid_order_type_upstringtrueSell-side order type when trigger_sell_depth is 0

Enum Value:
GMO / GLO / GTG
grid_order_type_downstringtrueBuy-side order type when trigger_buy_depth is 0

Enum Value:
GMO / GLO / GTG