Skip to content

feat: add calendar spreads to MultiLegStrategy - #589

Open
sunli829 wants to merge 1 commit into
mainfrom
feat/multileg-calendar-spread
Open

feat: add calendar spreads to MultiLegStrategy#589
sunli829 wants to merge 1 commit into
mainfrom
feat/multileg-calendar-spread

Conversation

@sunli829

@sunli829 sunli829 commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Follows longbridge/developers#1251, which documents two new values on the multi-leg strategy enum.

MultiLegStrategy gains:

  • CalendarCallSpread — wire value 7
  • CalendarPutSpread — wire value 8

Calendar (horizontal) spreads. Accepted by TradeContext.submit_multileg, and reported back on the multi_leg field of today_orders / history_orders / order_detail and the order-changed push.

Both variants are appended after Strangle, so the discriminants of the existing variants are unchanged — this is additive, not a breaking change. Without them the SDK parsed the two new server values as Unknown and had no way to submit either strategy.

Layers touched

Layer Files
Rust core rust/src/trade/types.rs (with the #[strum(to_string = …, serialize = "7"/"8")] mapping)
C c/src/trade_context/enum_types.rs
C++ cpp/include/types.hpp, cpp/src/convert.hpp (both convert() directions)
Java java/src/types/enum_types.rs, java/javasrc/…/trade/MultiLegStrategy.java
Node.js nodejs/src/trade/types.rs
Python python/src/trade/types.rs, python/pysrc/longbridge/openapi.pyi
Generated c/csrc/include/longbridge.h, nodejs/index.d.ts

Verification

  • cargo clippy --all --all-features and cargo +nightly fmt --all — clean (only the pre-existing longbridge-nodejs warnings)
  • cargo build -p longbridge-c / -p longbridge-java / -p longbridge-python — pass
  • npm run build:debug — pass; index.d.ts regenerated
  • C++: syntax-checked a TU including convert.hpp (g++ -std=c++17 -fsyntax-only); both convert() overloads resolve the new variants. Full CMake build not run.
  • strum round-trip checked with a throwaway cargo test: "7"/"8" and "CalendarCallSpread"/"CalendarPutSpread" parse to the new variants, and to_string() yields the string names. The temporary test file is not part of this PR.

java/javasrc was not compiled — no JDK on this machine. The change there is two enum constants; the Rust JNI half does build.

🤖 Generated with Claude Code

`MultiLegStrategy` gains `CalendarCallSpread` (`7`) and `CalendarPutSpread`
(`8`) — calendar (horizontal) spreads, accepted by
`TradeContext.submit_multileg` and reported back on the `multi_leg` field of
`today_orders` / `history_orders` / `order_detail` and the order-changed push.

Both variants are appended after `Strangle`, so the discriminants of the
existing variants are unchanged. Without them the SDK parsed the two new
server values as `Unknown` and could not submit either strategy.

Propagated to all six layers: Rust, C, C++ (incl. both `convert()`
directions), Java (JNI + `MultiLegStrategy.java`), Node.js, and Python (incl.
the `openapi.pyi` stub). `longbridge.h` and `index.d.ts` regenerated.

Documented in longbridge/developers#1251.
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