From d8435cc21c5f3de4619e06926380660b53eedb18 Mon Sep 17 00:00:00 2001 From: Sunli Date: Tue, 8 Sep 2026 10:41:16 +0800 Subject: [PATCH] feat: add calendar spreads to MultiLegStrategy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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. --- CHANGELOG.md | 1 + c/csrc/include/longbridge.h | 8 ++++++++ c/src/trade_context/enum_types.rs | 6 ++++++ cpp/include/types.hpp | 4 ++++ cpp/src/convert.hpp | 8 ++++++++ .../java/com/longbridge/trade/MultiLegStrategy.java | 4 ++++ java/src/types/enum_types.rs | 4 +++- nodejs/index.d.ts | 6 +++++- nodejs/src/trade/types.rs | 4 ++++ python/pysrc/longbridge/openapi.pyi | 10 ++++++++++ python/src/trade/types.rs | 4 ++++ rust/src/trade/types.rs | 6 ++++++ 12 files changed, 63 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23ede6a26..1a382638b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- **All languages:** `MultiLegStrategy` gains `CalendarCallSpread` (`7`) and `CalendarPutSpread` (`8`) — calendar (horizontal) spreads, accepted by `TradeContext.submit_multileg` and reported back on the `multi_leg` field of order queries and the order-changed push. Both are appended after `Strangle`, so the discriminants of the existing variants are unchanged. Added across Rust, C, C++, Java, Node.js, and Python. Documented in longbridge/developers#1251 - **Rust:** `Signal.status` is now a `SignalStatus` enum (pending / active / deleted / ai-failed / filtered-by-manual / ai-submit-failed), `SignalsResponse.total` is `i32` to match the wire contract, and the `risk_level` / `display_control` fields were dropped — neither is part of the API contract nor served in production - **Rust:** `SignalContext.security_facts` now returns a typed `SecurityFact` instead of raw JSON — fact id / type / direction, the securities it is about, the factors behind it (with their anomaly test and groups), the data sources, and the natural-language `nl_info`. Adds the `FactType` and `FactDirection` enums, and `FactNlInfo::summary_tags()` / `invest_anal_tags()` / `eli_explain_tags()` for the `{tag, value}` entries the API carries as JSON inside a string - **Rust:** add `SignalContext` — strategy signals and the catalyst facts behind them. `signals` (`GET /v1/signals`) queries signals with symbol / strategy / catalyst / time-range filters and paging; `signal` (`GET /v1/signals/{signal_id}`) returns one signal including the full strategy analysis in `json_data`; `security_facts` (`GET /v1/facts/security_facts`) lists a security's fact (catalyst) events. Bindings for the other languages are not wired up yet diff --git a/c/csrc/include/longbridge.h b/c/csrc/include/longbridge.h index a458d19b9..40319b22a 100644 --- a/c/csrc/include/longbridge.h +++ b/c/csrc/include/longbridge.h @@ -1343,6 +1343,14 @@ typedef enum CMultiLegStrategy { * Strangle */ MultiLegStrategyStrangle, + /** + * Calendar call spread + */ + MultiLegStrategyCalendarCallSpread, + /** + * Calendar put spread + */ + MultiLegStrategyCalendarPutSpread, } CMultiLegStrategy; /** diff --git a/c/src/trade_context/enum_types.rs b/c/src/trade_context/enum_types.rs index dc7260af3..8ab96821a 100644 --- a/c/src/trade_context/enum_types.rs +++ b/c/src/trade_context/enum_types.rs @@ -353,6 +353,12 @@ pub enum CMultiLegStrategy { /// Strangle #[c(remote = "Strangle")] MultiLegStrategyStrangle, + /// Calendar call spread + #[c(remote = "CalendarCallSpread")] + MultiLegStrategyCalendarCallSpread, + /// Calendar put spread + #[c(remote = "CalendarPutSpread")] + MultiLegStrategyCalendarPutSpread, } /// Multi-leg position direction diff --git a/cpp/include/types.hpp b/cpp/include/types.hpp index 81fb3eabd..fb7d59011 100644 --- a/cpp/include/types.hpp +++ b/cpp/include/types.hpp @@ -1653,6 +1653,10 @@ enum class MultiLegStrategy Straddle, /// Strangle Strangle, + /// Calendar call spread + CalendarCallSpread, + /// Calendar put spread + CalendarPutSpread, }; /// Multi-leg position direction diff --git a/cpp/src/convert.hpp b/cpp/src/convert.hpp index f18c05ff9..cefb8eecc 100644 --- a/cpp/src/convert.hpp +++ b/cpp/src/convert.hpp @@ -1495,6 +1495,10 @@ convert(CMultiLegStrategy strategy) return MultiLegStrategy::Straddle; case MultiLegStrategyStrangle: return MultiLegStrategy::Strangle; + case MultiLegStrategyCalendarCallSpread: + return MultiLegStrategy::CalendarCallSpread; + case MultiLegStrategyCalendarPutSpread: + return MultiLegStrategy::CalendarPutSpread; default: return MultiLegStrategy::Unknown; } @@ -1520,6 +1524,10 @@ convert(MultiLegStrategy strategy) return MultiLegStrategyStraddle; case MultiLegStrategy::Strangle: return MultiLegStrategyStrangle; + case MultiLegStrategy::CalendarCallSpread: + return MultiLegStrategyCalendarCallSpread; + case MultiLegStrategy::CalendarPutSpread: + return MultiLegStrategyCalendarPutSpread; default: return MultiLegStrategyUnknown; } diff --git a/java/javasrc/src/main/java/com/longbridge/trade/MultiLegStrategy.java b/java/javasrc/src/main/java/com/longbridge/trade/MultiLegStrategy.java index 7e58e4b8b..7997455e5 100644 --- a/java/javasrc/src/main/java/com/longbridge/trade/MultiLegStrategy.java +++ b/java/javasrc/src/main/java/com/longbridge/trade/MultiLegStrategy.java @@ -20,4 +20,8 @@ public enum MultiLegStrategy { Straddle, /** Strangle */ Strangle, + /** Calendar call spread */ + CalendarCallSpread, + /** Calendar put spread */ + CalendarPutSpread, } diff --git a/java/src/types/enum_types.rs b/java/src/types/enum_types.rs index 38ceb4fca..b4bc9804b 100644 --- a/java/src/types/enum_types.rs +++ b/java/src/types/enum_types.rs @@ -470,7 +470,9 @@ impl_java_enum!( VerticalPutSpread, Collar, Straddle, - Strangle + Strangle, + CalendarCallSpread, + CalendarPutSpread ] ); diff --git a/nodejs/index.d.ts b/nodejs/index.d.ts index e40e0e025..2ae18b355 100644 --- a/nodejs/index.d.ts +++ b/nodejs/index.d.ts @@ -6002,7 +6002,11 @@ export declare const enum MultiLegStrategy { /** Straddle */ Straddle = 6, /** Strangle */ - Strangle = 7 + Strangle = 7, + /** Calendar call spread */ + CalendarCallSpread = 8, + /** Calendar put spread */ + CalendarPutSpread = 9 } /** Options for listing topics created by the current authenticated user */ diff --git a/nodejs/src/trade/types.rs b/nodejs/src/trade/types.rs index b251bc9c7..ccaf76ac8 100644 --- a/nodejs/src/trade/types.rs +++ b/nodejs/src/trade/types.rs @@ -291,6 +291,10 @@ pub enum MultiLegStrategy { Straddle, /// Strangle Strangle, + /// Calendar call spread + CalendarCallSpread, + /// Calendar put spread + CalendarPutSpread, } /// Multi-leg position direction diff --git a/python/pysrc/longbridge/openapi.pyi b/python/pysrc/longbridge/openapi.pyi index 09c16f65d..00abe9d2d 100644 --- a/python/pysrc/longbridge/openapi.pyi +++ b/python/pysrc/longbridge/openapi.pyi @@ -6266,6 +6266,16 @@ class MultiLegStrategy: Strangle """ + class CalendarCallSpread(MultiLegStrategy): + """ + Calendar call spread + """ + + class CalendarPutSpread(MultiLegStrategy): + """ + Calendar put spread + """ + class MultiLegPosition: """ Multi-leg position direction diff --git a/python/src/trade/types.rs b/python/src/trade/types.rs index 0baefd345..0cdd0ef39 100644 --- a/python/src/trade/types.rs +++ b/python/src/trade/types.rs @@ -417,6 +417,10 @@ pub(crate) enum MultiLegStrategy { Straddle, /// Strangle Strangle, + /// Calendar call spread + CalendarCallSpread, + /// Calendar put spread + CalendarPutSpread, } /// Multi-leg position direction diff --git a/rust/src/trade/types.rs b/rust/src/trade/types.rs index 46f079c17..fbd7b0ce5 100644 --- a/rust/src/trade/types.rs +++ b/rust/src/trade/types.rs @@ -341,6 +341,12 @@ pub enum MultiLegStrategy { /// Strangle #[strum(to_string = "Strangle", serialize = "6")] Strangle, + /// Calendar call spread + #[strum(to_string = "CalendarCallSpread", serialize = "7")] + CalendarCallSpread, + /// Calendar put spread + #[strum(to_string = "CalendarPutSpread", serialize = "8")] + CalendarPutSpread, } /// Multi-leg position direction