Longbridge Developers
立即開始

網格訂單詳情

查詢單個網格訂單的完整詳情,包括網格規則、分頁的成交子訂單(grid_sub_orders)以及分頁的生命週期歷史(grid_order_history)。

>_ CLI
# 查看網格訂單的規則、子訂單與歷史
longbridge grid detail 764609681686573056

Request

HTTP MethodGET
HTTP URL/v1/gridtrading/detail

Parameters

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

NameTypeRequiredDescription
order_idstringYES網格訂單 ID,例如:764609681686573056
history_idstringNO生命週期歷史的分頁游標,傳入某頁最後一條的 history_id 以獲取更早的記錄
limitint32NOgrid_sub_orders 與 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)

# 網格 REST 調用通過獨立的 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
200網格訂單詳情返回成功。grid_order_detail_rsp
400請求被拒絕,請求參數錯誤。None

Schemas

grid_order_detail_rsp

NameTypeRequiredDescription
order_idstringtrue網格訂單 ID
symbolstringtrue標的代碼,ticker.region 格式
stock_namestringtrue標的名稱
statusstringtrue網格訂單狀態,例如:Performing / Suspended
grid_statusstringtrue網格詳細運行狀態
suspend_reasonstringtrue網格被暫停的原因,運行中時為空
sleeping_reasonstringtrue網格休眠的原因,活躍時為空
submitted_base_pricestringtrue提交時網格錨定的基準價
current_base_pricestringtrue觸發後的當前基準價
upper_limit_pricestringtrue價格上界
lower_limit_pricestringtrue價格下界
trigger_price_typeint32true觸發閾值的計價方式

枚舉值:
1 - 價差(絕對值)
2 - 百分比
trigger_spread_upstringtrue向上觸發價差(當 trigger_price_type 為 1 時)
trigger_spread_downstringtrue向下觸發價差(當 trigger_price_type 為 1 時)
trigger_percent_upstringtrue向上觸發百分比(當 trigger_price_type 為 2 時)
trigger_percent_downstringtrue向下觸發百分比(當 trigger_price_type 為 2 時)
pullback_percentstringtrue回落百分比
pullback_spreadstringtrue回落價差
rebound_percentstringtrue反彈百分比
rebound_spreadstringtrue反彈價差
multiple_triggerbooleantrue單個網格檔位是否可多次觸發
time_in_forceint32true訂單有效期

枚舉值:
0 - 當日有效
1 - GTC
6 - GTD
trigger_quantitystringtrue每次觸發的數量
trigger_sell_quantitystringtrue賣出方向累計觸發數量
trigger_buy_quantitystringtrue買入方向累計觸發數量
upper_limit_quantitystringtrue觸及上界時處理的數量
lower_limit_quantitystringtrue觸及下界時處理的數量
upper_limit_eventint32true觸及上界時的動作

枚舉值:
1 - 忽略
2 - 按最新價平倉
lower_limit_eventint32true觸及下界時的動作

枚舉值:
1 - 忽略
2 - 按最新價平倉
trigger_sell_depthint32true賣出方向盤口深度(-5 ~ 5)。0 = 使用 grid_order_type_up
trigger_buy_depthint32true買入方向盤口深度(-5 ~ 5)。0 = 使用 grid_order_type_down
created_atstringtrue創建時間,RFC3339 格式
updated_atstringtrue最後更新時間,RFC3339 格式
settlement_currencystringtrue結算貨幣,例如:HKD
expire_timestringtrue過期時間,RFC3339 格式(當 time_in_force 為 GTD 時)
gtdstringtrueGood-Til-Date,YYYY-MM-DD 格式
grid_sub_ordersobject[]false該網格已成交的子訂單
∟ idstringtrue子訂單 ID
∟ pricestringtrue訂單價格
∟ order_typestringtrue訂單類型
∟ quantitystringtrue訂單數量
∟ executed_qtystringtrue已成交數量
∟ actionint32true買賣方向
∟ statusstringtrue子訂單狀態
∟ submitted_atstringtrue提交時間,RFC3339 格式
∟ rthint32true盤中交易時段標識(0 / 1 / 2)
sub_has_morebooleantrue是否還有更多子訂單可分頁
grid_order_historyobject[]false生命週期歷史記錄
∟ history_idstringtrue歷史記錄 ID,同時用作分頁游標
∟ created_atstringtrue事件時間,RFC3339 格式
∟ statusstringtrue事件後的網格狀態
∟ suspend_reasonstringtrue暫停原因(如適用)
∟ reasonstringtrue事件的可讀描述
history_has_morebooleantrue是否可通過 history_id 分頁獲取更多歷史記錄
support_shortsellbooleantrue是否允許賣空
rthint32true盤中交易時段標識(0 / 1 / 2)
grid_order_type_upstringtruetrigger_sell_depth 為 0 時的賣出方向訂單類型

枚舉值:
GMO / GLO / GTG
grid_order_type_downstringtruetrigger_buy_depth 為 0 時的買入方向訂單類型

枚舉值:
GMO / GLO / GTG