feat(trade): Add grid trading APIs (Rust core + all bindings) - #563
Draft
hogan-yuan wants to merge 3 commits into
Draft
feat(trade): Add grid trading APIs (Rust core + all bindings)#563hogan-yuan wants to merge 3 commits into
hogan-yuan wants to merge 3 commits into
Conversation
- 11 REST methods on TradeContext: submit / replace / list (GET) / list-by-ids (POST) / detail / trigger-history / cancel / suspend / restart / strategy-questionnaire / order-info - Security is passed and returned via `symbol` (700.HK) across all request and response fields, matching the OpenAPI convention - Response types mirror the live gateway payload; datetime fields are exposed as RFC3339 (unix-seconds in, RFC3339 out) like other trade types; includes grid_status / pullback+rebound / trigger_buy+sell_ quantity / trigger_times / total_* / paging flags; order-info nests channel_infos + bid_sizes - Response types derive Serialize for consumer convenience - GridTradeRule request params follow the gridtrading proto - PushEvent::GridOrderChanged for the grid master-order WS push - grid_trading example Verified end-to-end against the test environment: all 11 endpoints succeed with correct field parsing. trigger_price_type: 1 = spread, 2 = percent.
Mirror the 11 grid trading methods and all grid types from the Rust core into each language binding, following existing trade patterns: - Python (pyo3): sync + async TradeContext methods, PyObject/PyEnum mirrors - Node.js (napi): TradeContext methods, JsObject remote mirrors - Java (JNI + javasrc): JNI wrappers + Java POJOs + TradeContext methods - C / C++: repr(C) FFI structs + extern C fns + C++ wrapper Each adds submit/replace/list(GET)/list-by-ids(POST)/detail/trigger-history/ cancel/suspend/restart/strategy-questionnaire/order-info plus the GridOrderChanged push event.
Move grid trading out of the trade module/context into its own `grid` module, mirroring how DCA is structured: - Core: standalone REST-only `GridContext` (async) + `GridContextSync` (blocking); grid types/options/responses under `longbridge::grid::*`. - All bindings (Python/Node.js/Java/C+C++): grid exposed as its own context class (`GridContext.create(config)` etc.), separate from the trade context. - The WS push (`GridOrderChanged`) stays on `TradeContext` since it travels on the trade private topic. - Drop the redundant `grid_`/`grid_order_` prefix from method names (submit / replace / list / list_by_ids / detail / trigger_history / cancel / suspend / restart / order_info), matching DCAContext's unprefixed methods. Types keep the `Grid` prefix.
hogan-yuan
marked this pull request as draft
August 11, 2026 05:50
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds grid trading support to the Longbridge OpenAPI SDK — the Rust core plus all four language bindings (Python, Node.js, Java, C/C++).
Endpoints (11)
submit·replace·list(GET) ·list-by-ids(POST) ·detail·trigger-history·cancel·suspend·restart·strategy-questionnaire·order-info, plus theGridOrderChangedWebSocket push event.Commits
TradeContext(async) +TradeContextSync(blocking) methods, request/response types,PushEvent::GridOrderChanged.Conventions
symbol(700.HK) across all fields.trigger_price_type:1= spread,2= percent.Verification
cargo build(whole workspace) +cargo clippy -p longbridge: clean.mvn compile, C++-fsyntax-only: pass.trigger-historyreturns empty because the test grids never triggered —TriggerOrderfields follow the proto and are pending real-response confirmation (needs aForceTriggeron the backend).🤖 Generated with Claude Code