Skip to content

feat(trade): add attached-order depth levels - #607

Merged
hogan-yuan merged 3 commits into
mainfrom
feat/attached-order-depth-level
Oct 15, 2026
Merged

hogan-yuan merged 3 commits into
mainfrom
feat/attached-order-depth-level

Conversation

@hogan-yuan

@hogan-yuan hogan-yuan commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Follows longbridge/developers#1189, which documents depth levels for attached (take-profit / stop-loss) orders.

Changes

Spec SDK
Submit / replace order attached_params.profit_taker_depth_level / stop_loss_depth_level (int32, valid when activate_order_type is LIT) SubmitAttachedParams / ReplaceAttachedParams gain both fields; omitted from the request when unset
today_orders / history_orders / order_detail attached_orders[].limit_depth_level (int32) AttachedOrderDetail.limit_depth_level; 0, null or a missing field read as unset, matching Order.limit_depth_level

All six layers, per the checklist in CLAUDE.md:

  • Rust: profit_taker_depth_level(i32) / stop_loss_depth_level(i32) builders and AttachedOrderDetail.limit_depth_level: Option<i32>. A small int32_opt_null_or_0_is_none deserializer keeps the new response field tolerant of null.
  • C: const int32_t * fields appended at the end of CSubmitAttachedParams, CReplaceAttachedParams and CAttachedOrderDetail (header regenerated by cbindgen).
  • C++: std::optional<int32_t> on the three types plus both conversion directions.
  • Java: setProfitTakerDepthLevel(Integer) / setStopLossDepthLevel(Integer) on both params classes and AttachedOrderDetail.getLimitDepthLevel(), with the JNI layer to match.
  • Node.js: profitTakerDepthLevel? / stopLossDepthLevel? and get limitDepthLevel(): number | null. index.d.ts was regenerated; index.js is unchanged.
  • Python: profit_taker_depth_level / stop_loss_depth_level keyword arguments on both params classes and AttachedOrderDetail.limit_depth_level, plus the openapi.pyi stub.

Go SDK counterpart: longbridge/openapi-go#132.

Verification

  • cargo test -p longbridge --lib: 73 passed. New tests cover the request serialization of both params types (omitted when unset), and limit_depth_level for 0, 3, null and a missing field.
  • cargo clippy --all --all-features: no new warnings. cargo +nightly fmt --all was applied.
  • cargo build -p longbridge-c, clang++ -fsyntax-only on cpp/src/trade_context.cpp, cargo build -p longbridge-java + mvn compile, cargo check -p longbridge-python, and npm run build:debug.
  • Not verified against a live order with attached orders.

Note: possible docs/SDK mismatch, out of scope here

The docs example in #1189 (and the existing docs) shows attached_type_display, trigger_status and tag in attached_orders as integers, e.g. "attached_type_display": 2. Both the Rust and Go SDKs parse these as strings (STOP_LOSS, NOT_USED, Normal), and the docs example fails to deserialize as written. One of them is wrong. It should be checked against a real response that has attached orders.

🤖 Generated with Claude Code

Documented in longbridge/developers#1189.

- SubmitAttachedParams / ReplaceAttachedParams gain
  profit_taker_depth_level / stop_loss_depth_level (int32): the bid/ask
  depth level for the take-profit / stop-loss limit order submitted
  price, valid when activate_order_type is LIT.
- AttachedOrderDetail gains limit_depth_level, read from
  attached_orders[].limit_depth_level; 0, null or a missing field read
  as unset.
- Mirrored across C (fields appended at the end of the structs; header
  regenerated), C++, Java, Node.js (index.d.ts regenerated) and Python
  (+ openapi.pyi).
Accept an integer or a numeric string; null, 0 or an invalid value read
as unset instead of failing the whole order response. CHANGELOG: note
that the C option structs grow.
hogan-yuan added a commit to longbridge/openapi-go that referenced this pull request Oct 15, 2026
hogan-yuan added a commit to longbridge/openapi-go that referenced this pull request Oct 15, 2026
Ports longbridge/openapi#607, which follows
[longbridge/developers#1189](longbridge/developers#1189).

## Changes

- `SubmitAttachedParams` and `ReplaceAttachedParams` gain
`ProfitTakerDepthLevel` and `StopLossDepthLevel` (`int32`, not sent when
`0`). Each is the bid/ask depth level used for the take-profit or
stop-loss limit order's submitted price, and only applies when
`ActivateOrderType` is `LIT`.
- `AttachedOrderDetail` gains `LimitDepthLevel` (`int32`, `0` when not
set), read from `attached_orders[].limit_depth_level` in `TodayOrders`,
`HistoryOrders` and `OrderDetail`. A JSON `null` reads as `0`.

## Verification

- `go build ./...`, `go vet ./trade/...` and `go test ./trade/...` pass.
- `trade/attached_depth_level_test.go` goes through the real `util.Copy`
and `encoding/json` path. It checks:
- the depth levels reach `attached_params` on submit and replace, and
are omitted when zero
  - `limit_depth_level` values of `3`, `0` and `null` on a response

## Note

The docs examples show `attached_type_display`, `trigger_status` and
`tag` in `attached_orders` as integers. This SDK, like the Rust core,
reads them as strings, so one of the two is wrong. See the note on
longbridge/openapi#607.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@hogan-yuan
hogan-yuan merged commit 9c918cb into main Oct 15, 2026
56 checks passed
@hogan-yuan
hogan-yuan deleted the feat/attached-order-depth-level branch October 15, 2026 05:38
hogan-yuan added a commit to longbridge/openapi-go that referenced this pull request Oct 16, 2026
Cut **v0.29.2** — closes out the `[Unreleased]` CHANGELOG section as
`[v0.29.2] - 2026-10-16`.

## Included since v0.29.1
- **Added — attached-order depth levels** (#132): `SubmitAttachedParams`
/ `ReplaceAttachedParams` gain `ProfitTakerDepthLevel` /
`StopLossDepthLevel` (`int32`, not sent when `0`, valid when
`ActivateOrderType` is `LIT`), and `AttachedOrderDetail` gains
`LimitDepthLevel`. Ports longbridge/openapi#607
(longbridge/developers#1189).

Only `CHANGELOG.md` changes. The `v0.29.2` tag is created after merge.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
hogan-yuan added a commit that referenced this pull request Oct 16, 2026
Release **v5.2.2**. Bumps workspace `5.2.1` → `5.2.2`.

### New since v5.2.1
- **Added:** attached (take-profit / stop-loss) orders gain bid/ask
depth levels (longbridge/developers#1189). `SubmitAttachedParams` /
`ReplaceAttachedParams` gain `profit_taker_depth_level` /
`stop_loss_depth_level` (int32, valid when `activate_order_type` is
`LIT`), and `AttachedOrderDetail` gains `limit_depth_level`. Across
Rust, C, C++, Java, Node.js and Python (the Go SDK ships separately,
openapi-go#132) (#607)

### Release pipeline (no SDK changes)
- Java: bump `central-publishing-maven-plugin` to 0.12.0 so Maven
Central accepts bundles built with Maven 3.10 (#606)
- Node.js: skip npm publish when the version is already published, so
re-running the Release workflow no longer fails with E403 (#608)
- Lower the Linux gnu glibc baseline for the Node.js & Python SDKs
(#609)

Only `Cargo.toml` (workspace version + internal dep reqs) and
`CHANGELOG.md` change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant