diff --git a/docs/en/docs/trade/order/estimate_multileg_available_quantity.mdx b/docs/en/docs/trade/order/estimate_multileg_available_quantity.mdx
new file mode 100644
index 00000000..5f591f6a
--- /dev/null
+++ b/docs/en/docs/trade/order/estimate_multileg_available_quantity.mdx
@@ -0,0 +1,342 @@
+---
+slug: estimate_multileg_available_quantity
+sidebar_position: 12
+title: Estimate Multi-leg Option Trading Info
+language_tabs: false
+toc_footers: []
+includes: []
+search: true
+highlight_theme: ''
+headingLevel: 2
+---
+
+This API is used to estimate the maximum purchase quantity and the margin impact of a multi-leg option combination strategy before submitting the order.
+
+Constraints:
+
+- Only the US market is supported.
+- All legs must share the same underlying.
+- Each leg must be an option or the underlying stock itself.
+- Duplicate legs (the same symbol with the same side) are not allowed.
+- All legs must share the same settlement currency.
+
+
+longbridge estimate-multileg --side buy --strategy VerticalCallSpread --quantity 1 --leg QQQ260731C764000.US --leg QQQ260731C767000.US --price 1.5
+
+
+
+
+## Request
+
+
+
+| HTTP Method | POST |
+| HTTP URL | /v1/trade/estimate/multileg |
+
+
+
+### Parameters
+
+> Content-Type: application/json; charset=utf-8
+
+| Name | Type | Required | Description |
+| ------------------ | -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| side | string | YES | Order side of the combination
**Enum Value:**
`Buy`
`Sell` |
+| order_type | string | YES | [Order Type](../trade-definition#ordertype) |
+| submitted_price | string | NO | Estimated order price, example: `1.5`
Required for limit order types such as `LO` |
+| submitted_quantity | string | YES | Order quantity (number of combinations), example: `1` |
+| strategy | string | YES | Multi-leg strategy
**Enum Value:**
`CoveredCall` - Covered stock
`CoveredPut` - Covered stock
`VerticalCallSpread` - Vertical spread
`VerticalPutSpread` - Vertical spread
`Collar` - Collar
`Straddle` - Straddle
`Strangle` - Strangle
`CalendarCallSpread` - Calendar
`CalendarPutSpread` - Calendar |
+| legs | object[] | YES | Legs of the combination |
+| ∟ symbol | string | YES | Option or underlying stock symbol, use `ticker.region` format, example: `QQQ260731C764000.US` |
+| ∟ side | string | NO | Leg order side.
Reserved field, not in use for now.
**Enum Value:**
`Buy`
`Sell` |
+
+### Request Example
+
+
+
+
+```python
+from decimal import Decimal
+from longbridge.openapi import TradeContext, Config, OrderType, OrderSide, MultiLegStrategy, OAuthBuilder
+
+oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
+config = Config.from_oauth(oauth)
+
+# Create a context for trade APIs
+ctx = TradeContext(config)
+
+# Estimate multi-leg option trading info
+resp = ctx.estimate_multileg_available_quantity(
+ OrderSide.Buy,
+ OrderType.LO,
+ Decimal(1),
+ MultiLegStrategy.VerticalCallSpread,
+ ["QQQ260731C764000.US", "QQQ260731C767000.US"],
+ submitted_price=Decimal("1.5"),
+)
+print(resp)
+```
+
+
+
+
+```python
+import asyncio
+from decimal import Decimal
+from longbridge.openapi import AsyncTradeContext, Config, OrderType, OrderSide, MultiLegStrategy, OAuthBuilder
+
+async def main() -> None:
+ oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url))
+ config = Config.from_oauth(oauth)
+
+ # Create a context for trade APIs
+ ctx = AsyncTradeContext.create(config)
+
+ # Estimate multi-leg option trading info
+ resp = await ctx.estimate_multileg_available_quantity(
+ OrderSide.Buy,
+ OrderType.LO,
+ Decimal(1),
+ MultiLegStrategy.VerticalCallSpread,
+ ["QQQ260731C764000.US", "QQQ260731C767000.US"],
+ submitted_price=Decimal("1.5"),
+ )
+ print(resp)
+
+if __name__ == "__main__":
+ asyncio.run(main())
+```
+
+
+
+
+```javascript
+const { Config, TradeContext, Decimal, OrderType, OrderSide, MultiLegStrategy } = require('longbridge')
+
+const config = Config.fromEnv()
+const ctx = await TradeContext.new(config)
+const resp = await ctx.estimateMultilegAvailableQuantity({
+ side: OrderSide.Buy,
+ orderType: OrderType.LO,
+ submittedQuantity: new Decimal("1"),
+ strategy: MultiLegStrategy.VerticalCallSpread,
+ legs: [{ symbol: "QQQ260731C764000.US" }, { symbol: "QQQ260731C767000.US" }],
+ submittedPrice: new Decimal("1.5"),
+})
+console.log(resp.toString())
+```
+
+
+
+
+```java
+import com.longbridge.*;
+import com.longbridge.trade.*;
+import java.math.BigDecimal;
+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);
+ TradeContext ctx = TradeContext.create(config)) {
+ EstimateMultiLegAvailableQuantityOptions opts = new EstimateMultiLegAvailableQuantityOptions(
+ OrderSide.Buy,
+ OrderType.LO,
+ new BigDecimal("1"),
+ MultiLegStrategy.VerticalCallSpread,
+ new EstimateMultiLegOrderLeg[] {
+ new EstimateMultiLegOrderLeg("QQQ260731C764000.US"),
+ new EstimateMultiLegOrderLeg("QQQ260731C767000.US"),
+ })
+ .setSubmittedPrice(new BigDecimal("1.5"));
+ EstimateMultiLegAvailableQuantityResponse resp = ctx.estimateMultilegAvailableQuantity(opts).get();
+ System.out.println(resp);
+ }
+ }
+}
+```
+
+
+
+
+```rust
+use std::sync::Arc;
+use longbridge::{oauth::OAuthBuilder, trade::{EstimateMultiLegAvailableQuantityOptions, EstimateMultiLegOrderLeg, MultiLegStrategy, OrderSide, OrderType, TradeContext}, Config, Decimal, decimal};
+
+#[tokio::main]
+async fn main() -> Result<(), Box> {
+ 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, _) = TradeContext::new(config);
+ let opts = EstimateMultiLegAvailableQuantityOptions::new(
+ OrderSide::Buy,
+ OrderType::LO,
+ decimal!(1i32),
+ MultiLegStrategy::VerticalCallSpread,
+ [
+ EstimateMultiLegOrderLeg::new("QQQ260731C764000.US"),
+ EstimateMultiLegOrderLeg::new("QQQ260731C767000.US"),
+ ],
+ )
+ .submitted_price(decimal!(1.5));
+ let resp = ctx.estimate_multileg_available_quantity(opts).await?;
+ println!("{:?}", resp);
+ Ok(())
+}
+```
+
+
+
+
+```cpp
+#include
+#include
+
+#ifdef WIN32
+#include
+#endif
+
+using namespace longbridge;
+using namespace longbridge::trade;
+
+static void
+run(const OAuth& oauth)
+{
+ Config config = Config::from_oauth(oauth);
+ TradeContext ctx = TradeContext::create(config);
+
+ EstimateMultiLegAvailableQuantityOptions opts{
+ OrderSide::Buy,
+ OrderType::LO,
+ Decimal("1"),
+ MultiLegStrategy::VerticalCallSpread,
+ { EstimateMultiLegOrderLeg{"QQQ260731C764000.US"}, EstimateMultiLegOrderLeg{"QQQ260731C767000.US"} },
+ Decimal("1.5"),
+ };
+ ctx.estimate_multileg_available_quantity(opts, [](auto res) {
+ if (!res) { std::cout << "failed" << std::endl; return; }
+ std::cout << "max_open_qty: " << res->max_open_qty << std::endl;
+ });
+}
+
+int main(int argc, char const* argv[]) {
+#ifdef WIN32
+ SetConsoleOutputCP(CP_UTF8);
+#endif
+
+ 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: " << *res.status().message() << std::endl;
+ return;
+ }
+ run(*res);
+ });
+
+ std::cin.get();
+ return 0;
+}
+```
+
+
+
+
+```go
+package main
+
+import (
+ "context"
+ "fmt"
+ "log"
+
+ "github.com/longbridge/openapi-go/config"
+ "github.com/longbridge/openapi-go/oauth"
+ "github.com/longbridge/openapi-go/trade"
+ "github.com/shopspring/decimal"
+)
+
+func main() {
+ o := oauth.New("your-client-id").
+ OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) })
+ if err := o.Build(context.Background()); err != nil {
+ log.Fatal(err)
+ }
+ conf, err := config.New(config.WithOAuthClient(o))
+ if err != nil {
+ log.Fatal(err)
+ }
+ tctx, err := trade.NewFromCfg(conf)
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer tctx.Close()
+ resp, err := tctx.EstimateMultiLegAvailableQuantity(context.Background(), &trade.GetEstimateMultiLegAvailableQuantity{
+ Side: trade.OrderSideBuy,
+ OrderType: trade.OrderTypeLO,
+ SubmittedQuantity: decimal.RequireFromString("1"),
+ Strategy: trade.MultiLegStrategyVerticalCallSpread,
+ SubmittedPrice: decimal.RequireFromString("1.5"),
+ Legs: []trade.EstimateMultiLegOrderLeg{
+ {Symbol: "QQQ260731C764000.US"},
+ {Symbol: "QQQ260731C767000.US"},
+ },
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(resp)
+}
+```
+
+
+
+
+## Response
+
+### Response Headers
+
+- Content-Type: application/json
+
+### Response Example
+
+```json
+{
+ "code": 0,
+ "message": "success",
+ "data": {
+ "max_open_qty": "10",
+ "unit_margin": "1500.00",
+ "initial_margin_change": "15000.00",
+ "maintenance_margin_change": "12000.00"
+ }
+}
+```
+
+### Response Status
+
+| Status | Description | Schema |
+| ------ | -------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
+| 200 | Estimate Multi-leg Option Trading Info Success | [estimate_multileg_available_quantity_rsp](#schemaestimate_multileg_available_quantity_rsp) |
+| 400 | The query failed with an error in the request parameter. | None |
+
+
+
+## Schemas
+
+### estimate_multileg_available_quantity_rsp
+
+
+
+
+Estimated Multi-leg Option Trading Info
+
+| Name | Type | Required | Description |
+| ------------------------- | ------ | -------- | ---------------------------------------------------------------------------- |
+| max_open_qty | string | true | Maximum open quantity of the combination |
+| unit_margin | string | true | Margin required per combination unit |
+| initial_margin_change | string | true | Change of the initial margin after placing the order (after minus before) |
+| maintenance_margin_change | string | true | Change of the maintenance margin after placing the order (after minus before) |
diff --git a/docs/zh-CN/docs/trade/order/estimate_multileg_available_quantity.mdx b/docs/zh-CN/docs/trade/order/estimate_multileg_available_quantity.mdx
new file mode 100644
index 00000000..c9364fea
--- /dev/null
+++ b/docs/zh-CN/docs/trade/order/estimate_multileg_available_quantity.mdx
@@ -0,0 +1,342 @@
+---
+slug: estimate_multileg_available_quantity
+sidebar_position: 12
+title: 预估多腿期权可交易信息
+language_tabs: false
+toc_footers: []
+includes: []
+search: true
+highlight_theme: ''
+headingLevel: 2
+---
+
+该接口用于在提交多腿期权组合订单前,预估该组合策略的最大购买数量及保证金变化。
+
+限制条件:
+
+- 仅支持美股市场。
+- 所有腿必须属于同一标的。
+- 每条腿只能是期权或其正股。
+- 不允许重复腿(symbol 与买卖方向均相同)。
+- 所有腿的结算货币必须相同。
+
+
+longbridge estimate-multileg --side buy --strategy VerticalCallSpread --quantity 1 --leg QQQ260731C764000.US --leg QQQ260731C767000.US --price 1.5
+
+
+
+
+## Request
+
+
+
+| HTTP Method | POST |
+| HTTP URL | /v1/trade/estimate/multileg |
+
+
+
+### Parameters
+
+> Content-Type: application/json; charset=utf-8
+
+| Name | Type | Required | Description |
+| ------------------ | -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| side | string | YES | 组合买卖方向
**可选值:**
`Buy` - 买入
`Sell` - 卖出 |
+| order_type | string | YES | [订单类型](../trade-definition#ordertype) |
+| submitted_price | string | NO | 预估下单价格,例如:`1.5`
`LO` 等限价类型订单必填 |
+| submitted_quantity | string | YES | 下单数量(组合数量),例如:`1` |
+| strategy | string | YES | 多腿策略
**可选值:**
`CoveredCall` - 股票担保
`CoveredPut` - 股票担保
`VerticalCallSpread` - 垂直策略
`VerticalPutSpread` - 垂直策略
`Collar` - 领式策略
`Straddle` - 跨式策略
`Strangle` - 宽跨式策略
`CalendarCallSpread` - 日历策略
`CalendarPutSpread` - 日历策略 |
+| legs | object[] | YES | 组合的各腿 |
+| ∟ symbol | string | YES | 期权或正股 symbol,使用 `ticker.region` 格式,例如:`QQQ260731C764000.US` |
+| ∟ side | string | NO | 该腿的买卖方向。
预留字段,暂不使用。
**可选值:**
`Buy` - 买入
`Sell` - 卖出 |
+
+### Request Example
+
+
+
+
+```python
+from decimal import Decimal
+from longbridge.openapi import TradeContext, Config, OrderType, OrderSide, MultiLegStrategy, OAuthBuilder
+
+oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
+config = Config.from_oauth(oauth)
+
+# Create a context for trade APIs
+ctx = TradeContext(config)
+
+# Estimate multi-leg option trading info
+resp = ctx.estimate_multileg_available_quantity(
+ OrderSide.Buy,
+ OrderType.LO,
+ Decimal(1),
+ MultiLegStrategy.VerticalCallSpread,
+ ["QQQ260731C764000.US", "QQQ260731C767000.US"],
+ submitted_price=Decimal("1.5"),
+)
+print(resp)
+```
+
+
+
+
+```python
+import asyncio
+from decimal import Decimal
+from longbridge.openapi import AsyncTradeContext, Config, OrderType, OrderSide, MultiLegStrategy, OAuthBuilder
+
+async def main() -> None:
+ oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url))
+ config = Config.from_oauth(oauth)
+
+ # Create a context for trade APIs
+ ctx = AsyncTradeContext.create(config)
+
+ # Estimate multi-leg option trading info
+ resp = await ctx.estimate_multileg_available_quantity(
+ OrderSide.Buy,
+ OrderType.LO,
+ Decimal(1),
+ MultiLegStrategy.VerticalCallSpread,
+ ["QQQ260731C764000.US", "QQQ260731C767000.US"],
+ submitted_price=Decimal("1.5"),
+ )
+ print(resp)
+
+if __name__ == "__main__":
+ asyncio.run(main())
+```
+
+
+
+
+```javascript
+const { Config, TradeContext, Decimal, OrderType, OrderSide, MultiLegStrategy } = require('longbridge')
+
+const config = Config.fromEnv()
+const ctx = await TradeContext.new(config)
+const resp = await ctx.estimateMultilegAvailableQuantity({
+ side: OrderSide.Buy,
+ orderType: OrderType.LO,
+ submittedQuantity: new Decimal("1"),
+ strategy: MultiLegStrategy.VerticalCallSpread,
+ legs: [{ symbol: "QQQ260731C764000.US" }, { symbol: "QQQ260731C767000.US" }],
+ submittedPrice: new Decimal("1.5"),
+})
+console.log(resp.toString())
+```
+
+
+
+
+```java
+import com.longbridge.*;
+import com.longbridge.trade.*;
+import java.math.BigDecimal;
+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);
+ TradeContext ctx = TradeContext.create(config)) {
+ EstimateMultiLegAvailableQuantityOptions opts = new EstimateMultiLegAvailableQuantityOptions(
+ OrderSide.Buy,
+ OrderType.LO,
+ new BigDecimal("1"),
+ MultiLegStrategy.VerticalCallSpread,
+ new EstimateMultiLegOrderLeg[] {
+ new EstimateMultiLegOrderLeg("QQQ260731C764000.US"),
+ new EstimateMultiLegOrderLeg("QQQ260731C767000.US"),
+ })
+ .setSubmittedPrice(new BigDecimal("1.5"));
+ EstimateMultiLegAvailableQuantityResponse resp = ctx.estimateMultilegAvailableQuantity(opts).get();
+ System.out.println(resp);
+ }
+ }
+}
+```
+
+
+
+
+```rust
+use std::sync::Arc;
+use longbridge::{oauth::OAuthBuilder, trade::{EstimateMultiLegAvailableQuantityOptions, EstimateMultiLegOrderLeg, MultiLegStrategy, OrderSide, OrderType, TradeContext}, Config, Decimal, decimal};
+
+#[tokio::main]
+async fn main() -> Result<(), Box> {
+ 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, _) = TradeContext::new(config);
+ let opts = EstimateMultiLegAvailableQuantityOptions::new(
+ OrderSide::Buy,
+ OrderType::LO,
+ decimal!(1i32),
+ MultiLegStrategy::VerticalCallSpread,
+ [
+ EstimateMultiLegOrderLeg::new("QQQ260731C764000.US"),
+ EstimateMultiLegOrderLeg::new("QQQ260731C767000.US"),
+ ],
+ )
+ .submitted_price(decimal!(1.5));
+ let resp = ctx.estimate_multileg_available_quantity(opts).await?;
+ println!("{:?}", resp);
+ Ok(())
+}
+```
+
+
+
+
+```cpp
+#include
+#include
+
+#ifdef WIN32
+#include
+#endif
+
+using namespace longbridge;
+using namespace longbridge::trade;
+
+static void
+run(const OAuth& oauth)
+{
+ Config config = Config::from_oauth(oauth);
+ TradeContext ctx = TradeContext::create(config);
+
+ EstimateMultiLegAvailableQuantityOptions opts{
+ OrderSide::Buy,
+ OrderType::LO,
+ Decimal("1"),
+ MultiLegStrategy::VerticalCallSpread,
+ { EstimateMultiLegOrderLeg{"QQQ260731C764000.US"}, EstimateMultiLegOrderLeg{"QQQ260731C767000.US"} },
+ Decimal("1.5"),
+ };
+ ctx.estimate_multileg_available_quantity(opts, [](auto res) {
+ if (!res) { std::cout << "failed" << std::endl; return; }
+ std::cout << "max_open_qty: " << res->max_open_qty << std::endl;
+ });
+}
+
+int main(int argc, char const* argv[]) {
+#ifdef WIN32
+ SetConsoleOutputCP(CP_UTF8);
+#endif
+
+ 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: " << *res.status().message() << std::endl;
+ return;
+ }
+ run(*res);
+ });
+
+ std::cin.get();
+ return 0;
+}
+```
+
+
+
+
+```go
+package main
+
+import (
+ "context"
+ "fmt"
+ "log"
+
+ "github.com/longbridge/openapi-go/config"
+ "github.com/longbridge/openapi-go/oauth"
+ "github.com/longbridge/openapi-go/trade"
+ "github.com/shopspring/decimal"
+)
+
+func main() {
+ o := oauth.New("your-client-id").
+ OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) })
+ if err := o.Build(context.Background()); err != nil {
+ log.Fatal(err)
+ }
+ conf, err := config.New(config.WithOAuthClient(o))
+ if err != nil {
+ log.Fatal(err)
+ }
+ tctx, err := trade.NewFromCfg(conf)
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer tctx.Close()
+ resp, err := tctx.EstimateMultiLegAvailableQuantity(context.Background(), &trade.GetEstimateMultiLegAvailableQuantity{
+ Side: trade.OrderSideBuy,
+ OrderType: trade.OrderTypeLO,
+ SubmittedQuantity: decimal.RequireFromString("1"),
+ Strategy: trade.MultiLegStrategyVerticalCallSpread,
+ SubmittedPrice: decimal.RequireFromString("1.5"),
+ Legs: []trade.EstimateMultiLegOrderLeg{
+ {Symbol: "QQQ260731C764000.US"},
+ {Symbol: "QQQ260731C767000.US"},
+ },
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(resp)
+}
+```
+
+
+
+
+## Response
+
+### Response Headers
+
+- Content-Type: application/json
+
+### Response Example
+
+```json
+{
+ "code": 0,
+ "message": "success",
+ "data": {
+ "max_open_qty": "10",
+ "unit_margin": "1500.00",
+ "initial_margin_change": "15000.00",
+ "maintenance_margin_change": "12000.00"
+ }
+}
+```
+
+### Response Status
+
+| Status | Description | Schema |
+| ------ | ---------------------- | ------------------------------------------------------------------------------------------- |
+| 200 | 预估多腿期权可交易信息成功 | [estimate_multileg_available_quantity_rsp](#schemaestimate_multileg_available_quantity_rsp) |
+| 400 | 请求参数有误,查询失败 | None |
+
+
+
+## Schemas
+
+### estimate_multileg_available_quantity_rsp
+
+
+
+
+预估多腿期权可交易信息
+
+| Name | Type | Required | Description |
+| ------------------------- | ------ | -------- | ---------------------------------------- |
+| max_open_qty | string | true | 组合的最大可开仓数量 |
+| unit_margin | string | true | 每单位组合所需的保证金 |
+| initial_margin_change | string | true | 下单后初始保证金的变化量(下单后减去下单前) |
+| maintenance_margin_change | string | true | 下单后维持保证金的变化量(下单后减去下单前) |
diff --git a/docs/zh-HK/docs/trade/order/estimate_multileg_available_quantity.mdx b/docs/zh-HK/docs/trade/order/estimate_multileg_available_quantity.mdx
new file mode 100644
index 00000000..3ca0732a
--- /dev/null
+++ b/docs/zh-HK/docs/trade/order/estimate_multileg_available_quantity.mdx
@@ -0,0 +1,342 @@
+---
+slug: estimate_multileg_available_quantity
+sidebar_position: 12
+title: 預估多腿期權可交易信息
+language_tabs: false
+toc_footers: []
+includes: []
+search: true
+highlight_theme: ''
+headingLevel: 2
+---
+
+該接口用於在提交多腿期權組合訂單前,預估該組合策略的最大購買數量及保證金變化。
+
+限制條件:
+
+- 僅支持美股市場。
+- 所有腿必須屬於同一標的。
+- 每條腿只能是期權或其正股。
+- 不允許重複腿(symbol 與買賣方向均相同)。
+- 所有腿的結算貨幣必須相同。
+
+
+longbridge estimate-multileg --side buy --strategy VerticalCallSpread --quantity 1 --leg QQQ260731C764000.US --leg QQQ260731C767000.US --price 1.5
+
+
+
+
+## Request
+
+
+
+| HTTP Method | POST |
+| HTTP URL | /v1/trade/estimate/multileg |
+
+
+
+### Parameters
+
+> Content-Type: application/json; charset=utf-8
+
+| Name | Type | Required | Description |
+| ------------------ | -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| side | string | YES | 組合買賣方向
**可選值:**
`Buy` - 買入
`Sell` - 賣出 |
+| order_type | string | YES | [訂單類型](../trade-definition#ordertype) |
+| submitted_price | string | NO | 預估下單價格,例如:`1.5`
`LO` 等限價類型訂單必填 |
+| submitted_quantity | string | YES | 下單數量(組合數量),例如:`1` |
+| strategy | string | YES | 多腿策略
**可選值:**
`CoveredCall` - 股票擔保
`CoveredPut` - 股票擔保
`VerticalCallSpread` - 跨價期權
`VerticalPutSpread` - 跨價期權
`Collar` - 領式策略
`Straddle` - 馬鞍式策略
`Strangle` - 勒束式策略
`CalendarCallSpread` - 跨期期權策略
`CalendarPutSpread` - 跨期期權策略 |
+| legs | object[] | YES | 組合的各腿 |
+| ∟ symbol | string | YES | 期權或正股 symbol,使用 `ticker.region` 格式,例如:`QQQ260731C764000.US` |
+| ∟ side | string | NO | 該腿的買賣方向。
預留欄位,暫不使用。
**可選值:**
`Buy` - 買入
`Sell` - 賣出 |
+
+### Request Example
+
+
+
+
+```python
+from decimal import Decimal
+from longbridge.openapi import TradeContext, Config, OrderType, OrderSide, MultiLegStrategy, OAuthBuilder
+
+oauth = OAuthBuilder("your-client-id").build(lambda url: print("Visit:", url))
+config = Config.from_oauth(oauth)
+
+# Create a context for trade APIs
+ctx = TradeContext(config)
+
+# Estimate multi-leg option trading info
+resp = ctx.estimate_multileg_available_quantity(
+ OrderSide.Buy,
+ OrderType.LO,
+ Decimal(1),
+ MultiLegStrategy.VerticalCallSpread,
+ ["QQQ260731C764000.US", "QQQ260731C767000.US"],
+ submitted_price=Decimal("1.5"),
+)
+print(resp)
+```
+
+
+
+
+```python
+import asyncio
+from decimal import Decimal
+from longbridge.openapi import AsyncTradeContext, Config, OrderType, OrderSide, MultiLegStrategy, OAuthBuilder
+
+async def main() -> None:
+ oauth = await OAuthBuilder("your-client-id").build_async(lambda url: print("Visit:", url))
+ config = Config.from_oauth(oauth)
+
+ # Create a context for trade APIs
+ ctx = AsyncTradeContext.create(config)
+
+ # Estimate multi-leg option trading info
+ resp = await ctx.estimate_multileg_available_quantity(
+ OrderSide.Buy,
+ OrderType.LO,
+ Decimal(1),
+ MultiLegStrategy.VerticalCallSpread,
+ ["QQQ260731C764000.US", "QQQ260731C767000.US"],
+ submitted_price=Decimal("1.5"),
+ )
+ print(resp)
+
+if __name__ == "__main__":
+ asyncio.run(main())
+```
+
+
+
+
+```javascript
+const { Config, TradeContext, Decimal, OrderType, OrderSide, MultiLegStrategy } = require('longbridge')
+
+const config = Config.fromEnv()
+const ctx = await TradeContext.new(config)
+const resp = await ctx.estimateMultilegAvailableQuantity({
+ side: OrderSide.Buy,
+ orderType: OrderType.LO,
+ submittedQuantity: new Decimal("1"),
+ strategy: MultiLegStrategy.VerticalCallSpread,
+ legs: [{ symbol: "QQQ260731C764000.US" }, { symbol: "QQQ260731C767000.US" }],
+ submittedPrice: new Decimal("1.5"),
+})
+console.log(resp.toString())
+```
+
+
+
+
+```java
+import com.longbridge.*;
+import com.longbridge.trade.*;
+import java.math.BigDecimal;
+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);
+ TradeContext ctx = TradeContext.create(config)) {
+ EstimateMultiLegAvailableQuantityOptions opts = new EstimateMultiLegAvailableQuantityOptions(
+ OrderSide.Buy,
+ OrderType.LO,
+ new BigDecimal("1"),
+ MultiLegStrategy.VerticalCallSpread,
+ new EstimateMultiLegOrderLeg[] {
+ new EstimateMultiLegOrderLeg("QQQ260731C764000.US"),
+ new EstimateMultiLegOrderLeg("QQQ260731C767000.US"),
+ })
+ .setSubmittedPrice(new BigDecimal("1.5"));
+ EstimateMultiLegAvailableQuantityResponse resp = ctx.estimateMultilegAvailableQuantity(opts).get();
+ System.out.println(resp);
+ }
+ }
+}
+```
+
+
+
+
+```rust
+use std::sync::Arc;
+use longbridge::{oauth::OAuthBuilder, trade::{EstimateMultiLegAvailableQuantityOptions, EstimateMultiLegOrderLeg, MultiLegStrategy, OrderSide, OrderType, TradeContext}, Config, Decimal, decimal};
+
+#[tokio::main]
+async fn main() -> Result<(), Box> {
+ 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, _) = TradeContext::new(config);
+ let opts = EstimateMultiLegAvailableQuantityOptions::new(
+ OrderSide::Buy,
+ OrderType::LO,
+ decimal!(1i32),
+ MultiLegStrategy::VerticalCallSpread,
+ [
+ EstimateMultiLegOrderLeg::new("QQQ260731C764000.US"),
+ EstimateMultiLegOrderLeg::new("QQQ260731C767000.US"),
+ ],
+ )
+ .submitted_price(decimal!(1.5));
+ let resp = ctx.estimate_multileg_available_quantity(opts).await?;
+ println!("{:?}", resp);
+ Ok(())
+}
+```
+
+
+
+
+```cpp
+#include
+#include
+
+#ifdef WIN32
+#include
+#endif
+
+using namespace longbridge;
+using namespace longbridge::trade;
+
+static void
+run(const OAuth& oauth)
+{
+ Config config = Config::from_oauth(oauth);
+ TradeContext ctx = TradeContext::create(config);
+
+ EstimateMultiLegAvailableQuantityOptions opts{
+ OrderSide::Buy,
+ OrderType::LO,
+ Decimal("1"),
+ MultiLegStrategy::VerticalCallSpread,
+ { EstimateMultiLegOrderLeg{"QQQ260731C764000.US"}, EstimateMultiLegOrderLeg{"QQQ260731C767000.US"} },
+ Decimal("1.5"),
+ };
+ ctx.estimate_multileg_available_quantity(opts, [](auto res) {
+ if (!res) { std::cout << "failed" << std::endl; return; }
+ std::cout << "max_open_qty: " << res->max_open_qty << std::endl;
+ });
+}
+
+int main(int argc, char const* argv[]) {
+#ifdef WIN32
+ SetConsoleOutputCP(CP_UTF8);
+#endif
+
+ 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: " << *res.status().message() << std::endl;
+ return;
+ }
+ run(*res);
+ });
+
+ std::cin.get();
+ return 0;
+}
+```
+
+
+
+
+```go
+package main
+
+import (
+ "context"
+ "fmt"
+ "log"
+
+ "github.com/longbridge/openapi-go/config"
+ "github.com/longbridge/openapi-go/oauth"
+ "github.com/longbridge/openapi-go/trade"
+ "github.com/shopspring/decimal"
+)
+
+func main() {
+ o := oauth.New("your-client-id").
+ OnOpenURL(func(url string) { fmt.Println("Open this URL to authorize:", url) })
+ if err := o.Build(context.Background()); err != nil {
+ log.Fatal(err)
+ }
+ conf, err := config.New(config.WithOAuthClient(o))
+ if err != nil {
+ log.Fatal(err)
+ }
+ tctx, err := trade.NewFromCfg(conf)
+ if err != nil {
+ log.Fatal(err)
+ }
+ defer tctx.Close()
+ resp, err := tctx.EstimateMultiLegAvailableQuantity(context.Background(), &trade.GetEstimateMultiLegAvailableQuantity{
+ Side: trade.OrderSideBuy,
+ OrderType: trade.OrderTypeLO,
+ SubmittedQuantity: decimal.RequireFromString("1"),
+ Strategy: trade.MultiLegStrategyVerticalCallSpread,
+ SubmittedPrice: decimal.RequireFromString("1.5"),
+ Legs: []trade.EstimateMultiLegOrderLeg{
+ {Symbol: "QQQ260731C764000.US"},
+ {Symbol: "QQQ260731C767000.US"},
+ },
+ })
+ if err != nil {
+ log.Fatal(err)
+ }
+ fmt.Println(resp)
+}
+```
+
+
+
+
+## Response
+
+### Response Headers
+
+- Content-Type: application/json
+
+### Response Example
+
+```json
+{
+ "code": 0,
+ "message": "success",
+ "data": {
+ "max_open_qty": "10",
+ "unit_margin": "1500.00",
+ "initial_margin_change": "15000.00",
+ "maintenance_margin_change": "12000.00"
+ }
+}
+```
+
+### Response Status
+
+| Status | Description | Schema |
+| ------ | ---------------------- | ------------------------------------------------------------------------------------------- |
+| 200 | 預估多腿期權可交易信息成功 | [estimate_multileg_available_quantity_rsp](#schemaestimate_multileg_available_quantity_rsp) |
+| 400 | 請求參數有誤,查詢失敗 | None |
+
+
+
+## Schemas
+
+### estimate_multileg_available_quantity_rsp
+
+
+
+
+預估多腿期權可交易信息
+
+| Name | Type | Required | Description |
+| ------------------------- | ------ | -------- | ---------------------------------------- |
+| max_open_qty | string | true | 組合的最大可開倉數量 |
+| unit_margin | string | true | 每單位組合所需的保證金 |
+| initial_margin_change | string | true | 下單後初始保證金的變化量(下單後減去下單前) |
+| maintenance_margin_change | string | true | 下單後維持保證金的變化量(下單後減去下單前) |