gate-exchange-options
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseResolving gate-cli
(binary path)
gate-cli解析gate-cli
(二进制文件路径)
gate-cliResolve in order: (1) and succeeds; (2) if executable; (3) if executable. Canonical rules: §4 (or §4).
gate-clicommand -v gate-cligate-cli --version${HOME}/.local/bin/gate-cli${HOME}/.openclaw/skills/bin/gate-cliexchange-runtime-rules.mdgate-runtime-rules.mdRead and follow exchange-runtime-rules.md first.
按以下顺序解析****:(1) **和**执行成功;(2) 若可执行则使用该路径;(3) 若可执行则使用该路径。标准规则参见:第4节(或第4节)。
gate-clicommand -v gate-cligate-cli --version${HOME}/.local/bin/gate-cli${HOME}/.openclaw/skills/bin/gate-cliexchange-runtime-rules.mdgate-runtime-rules.md请先阅读并遵循exchange-runtime-rules.md中的内容。
Gate Options Trading
Gate期权交易
This skill is the single entry for Gate options. It supports five operation types: place order (market/limit), place order (mark IV), close/reduce position, cancel open orders, amend open orders. User intent is routed to the matching workflow.
此Skill是Gate期权交易的唯一入口,支持五种操作类型:下单(市价/限价)、基于mark IV下单、平仓/减仓、取消未成交订单、修改未成交订单。用户的意图会被路由至匹配的工作流。
Case coverage (5 cases)
场景覆盖(5种场景)
| Case | Description | Example triggers (EN) | Example output (EN) |
|---|---|---|---|
| Case 1 | Market/limit place order | "Market buy 1 BTC call, strike at current price, expire in one week" / "Sell 1000U weekly BTC call at 70k strike" / "Open long 1 SOL weekly option at market" / "Use half of account to buy BTC call expiring in 3 days" | "Order submitted! You have placed a {buy/sell} order on {underlying} at {market/limit price}, strike {xxx}, expiration {xxx}, option type {call/put}, size {xxx} contracts." |
| Case 2 | Mark IV place order | "Mark IV order: buy 1 BTC call, one week expiry" / "Sell 1000U weekly BTC call at 70k strike, mark IV" / "Open long 1 SOL weekly option, mark IV" | Same as Case 1, but price is derived from mark IV or IV-to-price backend. |
| Case 3 | Market/limit close or reduce position | "Market close my BTC call, expiry 03/18, strike 70000" / "Close half of my ETH put at market" / "Close all profitable option positions" / "Market close all options with loss over 50%" | "Close order submitted! As requested, you have closed {size} of your {long/short} position on {underlying} at {market/limit price}." |
| Case 4 | Cancel open orders | "Cancel the BTC call order at 70k strike, expiry 03/18" / "Cancel all SOL call buy orders" / "Cancel all open orders" / "One-click cancel" | "Cancel successful! Your {specified/all} open order(s) have been cancelled. A total of {N} order(s) were cancelled, releasing {xxx} USDT margin." |
| Case 5 | Amend open orders | "Change my BTC call order at 70k strike, expiry 03/18, price to 0.05" / "Halve the size of my SOL put at strike 70, expiry 03/20" | "Amend confirmed! Your open order on {underlying} has been updated: price is now {new price}, size is now {new size}. Waiting for fill." |
| 场景 | 描述 | 触发示例(英文) | 输出示例(英文) |
|---|---|---|---|
| 场景1 | 市价/限价下单 | "Market buy 1 BTC call, strike at current price, expire in one week" / "Sell 1000U weekly BTC call at 70k strike" / "Open long 1 SOL weekly option at market" / "Use half of account to buy BTC call expiring in 3 days" | "Order submitted! You have placed a {buy/sell} order on {underlying} at {market/limit price}, strike {xxx}, expiration {xxx}, option type {call/put}, size {xxx} contracts." |
| 场景2 | 基于mark IV下单 | "Mark IV order: buy 1 BTC call, one week expiry" / "Sell 1000U weekly BTC call at 70k strike, mark IV" / "Open long 1 SOL weekly option, mark IV" | 与场景1输出一致,但价格由mark IV或IV转价格的后端服务生成。 |
| 场景3 | 市价/限价平仓或减仓 | "Market close my BTC call, expiry 03/18, strike 70000" / "Close half of my ETH put at market" / "Close all profitable option positions" / "Market close all options with loss over 50%" | "Close order submitted! As requested, you have closed {size} of your {long/short} position on {underlying} at {market/limit price}." |
| 场景4 | 取消未成交订单 | "Cancel the BTC call order at 70k strike, expiry 03/18" / "Cancel all SOL call buy orders" / "Cancel all open orders" / "One-click cancel" | "Cancel successful! Your {specified/all} open order(s) have been cancelled. A total of {N} order(s) were cancelled, releasing {xxx} USDT margin." |
| 场景5 | 修改未成交订单 | "Change my BTC call order at 70k strike, expiry 03/18, price to 0.05" / "Halve the size of my SOL put at strike 70, expiry 03/20" | "Amend confirmed! Your open order on {underlying} has been updated: price is now {new price}, size is now {new size}. Waiting for fill." |
Module overview
模块概述
| Module | Description | Trigger keywords |
|---|---|---|
| Place order (market/limit) | Buy or sell options at market or limit price | market buy, limit sell, open long, buy call, sell put, spend X on option |
| Place order (mark IV) | Place order by implied volatility (mark IV) | mark IV, IV order |
| Close/reduce position | Market/limit close or partial close | close position, flat, reduce half, close all profitable, close losing |
| Cancel orders | Cancel one or all open option orders | cancel order, revoke, cancel all, one-click cancel |
| Amend orders | Change price or size of open order | amend, modify price, change size |
| 模块 | 描述 | 触发关键词 |
|---|---|---|
| 下单(市价/限价) | 以市价或限价买卖期权 | market buy, limit sell, open long, buy call, sell put, spend X on option |
| 基于mark IV下单 | 基于隐含波动率(mark IV)下单 | mark IV, IV order |
| 平仓/减仓 | 市价/限价平仓或部分平仓 | close position, flat, reduce half, close all profitable, close losing |
| 取消订单 | 取消单个或全部未成交期权订单 | cancel order, revoke, cancel all, one-click cancel |
| 修改订单 | 修改未成交订单的价格或数量 | amend, modify price, change size |
Routing rules
路由规则
| Intent | Example phrases | Route to |
|---|---|---|
| Place order (market/limit) | "Market buy 1 BTC call, strike at current price, expire in one week" / "Sell 1000U of weekly BTC call at 70k strike" / "Open long 1 SOL weekly option at market" / "Use half of account to buy BTC call expiring in 3 days" | Read |
| Place order (mark IV) | "Mark IV order: buy 1 BTC call, one week expiry" / "Sell 1000U weekly BTC call at 70k strike, mark IV" / "Open long 1 SOL weekly option, mark IV" | Read |
| Close/reduce position | "Market close my BTC call, expiry MM/DD, strike XXXX" / "Close half of ETH put at market" / "Close all BTC call long when price hits 60000" / "Market close all profitable option positions" | Read |
| Cancel orders | "Cancel the BTC call order at 70k strike, expiry MM/DD" / "Cancel all SOL call buy orders" / "Cancel all open orders" | Read |
| Amend orders | "Change my BTC call order at 70k strike, expiry MM/DD, price to XXXX" / "Halve the size of my SOL put at strike 70, expiry MM/DD" | Read |
| Unclear | "Help with options", "Show my option positions" | Clarify: query positions/orders, then guide user |
| 意图 | 示例短语 | 路由至 |
|---|---|---|
| 下单(市价/限价) | "Market buy 1 BTC call, strike at current price, expire in one week" / "Sell 1000U of weekly BTC call at 70k strike" / "Open long 1 SOL weekly option at market" / "Use half of account to buy BTC call expiring in 3 days" | 阅读 |
| 基于mark IV下单 | "Mark IV order: buy 1 BTC call, one week expiry" / "Sell 1000U weekly BTC call at 70k strike, mark IV" / "Open long 1 SOL weekly option, mark IV" | 阅读 |
| 平仓/减仓 | "Market close my BTC call, expiry MM/DD, strike XXXX" / "Close half of ETH put at market" / "Close all BTC call long when price hits 60000" / "Market close all profitable option positions" | 阅读 |
| 取消订单 | "Cancel the BTC call order at 70k strike, expiry MM/DD" / "Cancel all SOL call buy orders" / "Cancel all open orders" | 阅读 |
| 修改订单 | "Change my BTC call order at 70k strike, expiry MM/DD, price to XXXX" / "Halve the size of my SOL put at strike 70, expiry MM/DD" | 阅读 |
| 意图不明确 | "Help with options", "Show my option positions" | 澄清:查询仓位/订单,然后引导用户 |
Tool mapping
工具映射
All options tools use the prefix. See gate-mcp tools.
cex_options_| Group | MCP tools |
|---|---|
| Underlying & contracts | |
| Market data | |
| Account & positions | |
| Orders | |
| Amend | |
| Trades | |
所有期权工具均使用前缀,详情参见gate-mcp tools。
cex_options_| 分组 | MCP工具 |
|---|---|
| 标的与合约 | |
| 市场数据 | |
| 账户与仓位 | |
| 订单 | |
| 修改订单 | |
| 交易记录 | |
Authentication
身份验证
- Interactive file setup: when and
GATE_API_KEYare not both set on the host, runGATE_API_SECRETto complete the wizard for API key, secret, profiles, and defaults (see gate-cli).gate-cli config init - Env / flags: is not required when credentials are already supplied — e.g. both
gate-cli config initandGATE_API_KEYset on the host, orGATE_API_SECRET/--api-keywhere supported — never ask the user to paste secrets into chat.--api-secret - Permissions: Options:Write (and reads as required for quotes/positions); use least privilege consistent with this skill.
- Portal: create or rotate keys outside the chat: https://www.gate.com/myaccount/profile/api-key/manage
- 交互式文件配置:当主机上未同时设置**和
GATE_API_KEY时,运行GATE_API_SECRET**完成API密钥、密钥、配置文件及默认设置的向导配置(参见gate-cli)。gate-cli config init - 环境变量/参数:若已提供凭证,则无需运行**——例如主机上已同时设置
gate-cli config init和GATE_API_KEY,或在支持的情况下使用GATE_API_SECRET** / **--api-key**参数——切勿要求用户在聊天中粘贴密钥。--api-secret - 权限:期权交易需具备Options:Write权限(以及获取报价/仓位所需的读取权限);遵循最小权限原则。
- 门户:在聊天外创建或轮换密钥:https://www.gate.com/myaccount/profile/api-key/manage
Installation Check
安装检查
- Required: (install from gate-cli releases or via a Gate MCP / skills installer for your environment).
gate-cli - Add the directory containing to
gate-cliwhen invoking by name.PATH - Credentials: When and
GATE_API_KEYare both set (non-empty) for the host, do not requireGATE_API_SECRET. When both are unset or empty, remind the operator to rungate-cli config initor to configuregate-cli config init/GATE_API_KEYin the matching skill from the skill library (never ask the user to paste secrets into chat).GATE_API_SECRET - Sanity check: Do not proceed with authenticated or mutating calls until the CLI works as expected (e.g. or
gate-cli cex options market tickers); confirm credentials resolve before orders.gate-cli --version
- 必需组件:(从gate-cli releases下载安装,或通过适用于您环境的Gate MCP / Skill安装程序安装)。
gate-cli - 调用时,需将包含**
gate-cli的目录添加至gate-cli**环境变量。PATH - 凭证检查:当主机上的**和
GATE_API_KEY均已设置(非空)时,无需要求运行GATE_API_SECRET。当两者均未设置或为空时,提醒操作人员运行gate-cli config init,或从Skill库中的对应Skill配置gate-cli config init** /GATE_API_KEY——切勿要求用户在聊天中粘贴密钥。GATE_API_SECRET - 完整性检查:在执行需身份验证或变更操作的调用前,确保CLI可正常工作(例如执行**或
gate-cli cex options market tickers**);下单前确认凭证已解析成功。gate-cli --version
Execution workflow
执行工作流
1. Intent and parameters
1. 意图与参数提取
- Determine module (Place / Close / Cancel / Amend).
- Extract: underlying, expiration, strike, call/put → resolve to exact contract name. Contract format is (e.g.
{underlying}-{expiration}-{strike}-{C|P}). UseBTC_USDT-20210916-50000-Corlist_options_contracts.get_options_contract - Missing: if required params missing (e.g. strike or expiration), ask user (clarify mode).
- 确定模块(下单/平仓/取消/修改)。
- 提取:标的、到期日、行权价、看涨/看跌期权 → 解析为准确的合约名称。合约格式为(例如
{underlying}-{expiration}-{strike}-{C|P})。使用BTC_USDT-20210916-50000-C或list_options_contracts工具。get_options_contract - 参数缺失:若必填参数缺失(如行权价或到期日),询问用户(澄清模式)。
2. Unit conversion (place order only)
2. 单位转换(仅下单场景)
When the user does not specify size in contracts, convert to contracts before placing the order.
| User phrase | Intent | How to get size (contracts) |
|---|---|---|
| Contracts | Explicit contract count | "1 contract", "buy 3 contracts" → size = 1, 3 |
| Base notional | Notional in underlying | "0.1 BTC call", "1 BTC put" → contracts = base_amount / multiplier (from |
| Quote (USDT) | Premium / cost in USDT | "1000U", "spend 500 USDT", "half of account" → contracts = usdt_amount / price_per_contract (from order book/ticker) |
- Base notional → contracts: . Multiplier = face value of one contract in underlying units (from
contracts = base_amount / multiplier).get_options_contract - Quote (USDT) → contracts: . For "half of account", use
contracts = usdt_amount / price_per_contractthen half of available balance.list_options_account - Default: When user says "X BTC" or "X ETH" without "contract(s)", treat as base notional and convert. Use explicit "X contracts" for contract count.
- Precision: Floor to integer; must satisfy from
order_size_min. If result < order_size_min, inform user.get_options_contract
当用户未以合约数指定数量时,需先转换为合约数再下单。
| 用户表述 | 意图 | 如何计算合约数 |
|---|---|---|
| 合约数 | 明确指定合约数量 | "1 contract", "buy 3 contracts" → 数量=1、3 |
| 标的名义价值 | 以标的资产计价的名义价值 | "0.1 BTC call", "1 BTC put" → 合约数=标的金额 / 乘数(来自 |
| 计价货币(USDT) | 以USDT计价的权利金/成本 | "1000U", "spend 500 USDT", "half of account" → 合约数=USDT金额 / 每份合约价格(来自订单簿/行情数据) |
- 标的名义价值→合约数:。乘数为每份合约对应的标的资产面值(来自
合约数 = 标的金额 / 乘数)。get_options_contract - 计价货币(USDT)→合约数:。对于“half of account”,使用
合约数 = USDT金额 / 每份合约价格获取账户可用余额后取一半计算。list_options_account - 默认规则:当用户表述为“X BTC”或“X ETH”且未提及“contract(s)”时,视为标的名义价值并进行转换。需明确使用“X contracts”来指定合约数量。
- 精度处理:向下取整为整数;需满足返回的
get_options_contract要求。若结果小于order_size_min,告知用户。order_size_min
3. Pre-flight checks
3. 前置检查
- Contract: call (or resolve via
get_options_contract) to ensure contract exists.list_options_contracts - Account: for buy, check balance (and for quote-based size, check price_per_contract from order book/ticker).
- Close/reduce: verify position exists and close size does not exceed position. Full close: ,
close: true; partial:size: 0and size (negative for long, positive for short).reduce_only: true - Disambiguation: If "one week" or "3 days" matches multiple expirations, pick nearest or list and ask. If "strike at current price", use underlying index price and pick nearest strike.
- 合约验证:调用(或通过
get_options_contract解析)确保合约存在。list_options_contracts - 账户余额检查:买入时检查余额(若为基于计价货币的数量,需从订单簿/行情数据获取每份合约价格)。
- 平仓/减仓检查:验证仓位存在且平仓数量不超过仓位规模。全额平仓:,
close: true;部分平仓:size: 0并指定数量(多头为负,空头为正)。reduce_only: true - 歧义处理:若“one week”或“3 days”匹配多个到期日,选择最近的到期日或列出所有匹配项询问用户。若“strike at current price”,使用标的指数价格并选择最接近的行权价。
4. Confirmation
4. 确认环节
- Place order: show final order summary (contract, side, size in contracts, price or market, strike, expiration, call/put). Optionally show equivalent base notional or USDT when size was converted. "Reply 'confirm' to place the order." Only after user confirms, call .
create_options_order - Close / cancel / amend: show scope and ask for confirmation before executing.
- 下单:展示最终订单摘要(合约、方向、合约数、价格类型、行权价、到期日、期权类型)。若数量是从标的名义价值或USDT转换而来,可附加说明如“(相当于1 BTC名义价值)”或“(相当于xxx USDT)”。提示:*"回复'confirm'以确认下单。"*仅在用户确认后调用。
create_options_order - 平仓/取消/修改:展示操作范围并在执行前请求用户确认。
5. Call tools and output
5. 调用工具与输出
- Call tools in the order specified in the reference.
- Output using the response template for that case.
- 按照参考文档中指定的顺序调用工具。
- 使用对应场景的响应模板输出结果。
Report template
报告模板
After each operation, output a short standardized result (see Response templates below).
每次操作后,输出简短的标准化结果(参见下方响应模板)。
Response templates
响应模板
Use the English templates below for standardized output.
使用以下英文模板进行标准化输出。
Place order (Case 1 & 2)
下单(场景1&2)
Order submitted! You have placed a {buy/sell} order on {underlying} at {market/limit price / mark IV}, strike {xxx}, expiration {xxx}, option type {call/put}, size {xxx} contracts.When size was converted from base notional or USDT, optionally add e.g. " (equiv. 1 BTC notional)" or " (equiv. xxx USDT)".
Order submitted! You have placed a {buy/sell} order on {underlying} at {market/limit price / mark IV}, strike {xxx}, expiration {xxx}, option type {call/put}, size {xxx} contracts.若数量是从标的名义价值或USDT转换而来,可附加说明如“ (equiv. 1 BTC notional)”或“ (equiv. xxx USDT)”。
Close/reduce position (Case 3)
平仓/减仓(场景3)
Close order submitted! As requested, you have closed {size} of your {long/short} position on {underlying} at {market/limit price}.Close order submitted! As requested, you have closed {size} of your {long/short} position on {underlying} at {market/limit price}.Cancel orders (Case 4)
取消订单(场景4)
Tools:
- Cancel all open option orders (one-click / all underlyings): with no params.
gate-cli cex options order cancel-all - Cancel a single order: .
gate-cli cex options order cancel - List open orders (to find order_id / confirm scope): .
gate-cli cex options order list
Cancel successful! Your {specified/all} open order(s) have been cancelled. A total of {N} order(s) were cancelled, releasing {xxx} USDT margin.工具:
- 一键取消全部未成交期权订单(所有标的):不带参数运行。
gate-cli cex options order cancel-all - 取消单个订单:运行。
gate-cli cex options order cancel - 查询未成交订单(获取order_id/确认范围):运行。
gate-cli cex options order list
Cancel successful! Your {specified/all} open order(s) have been cancelled. A total of {N} order(s) were cancelled, releasing {xxx} USDT margin.Amend order (Case 5)
修改订单(场景5)
Amend confirmed! Your open order on {underlying} has been updated: price is now {new price}, size is now {new size}. Waiting for fill.Amend confirmed! Your open order on {underlying} has been updated: price is now {new price}, size is now {new size}. Waiting for fill.Safety rules
安全规则
Confirmation
确认要求
- Place order: show final order summary (contract, side, size in contracts, price/market, strike, expiration, call/put), then ask for confirmation before . Example: "Reply 'confirm' to place the order."
create_options_order - Close / cancel / amend (including single-order cancel): show exact scope (contract/order_id, side, size/price where applicable) and ask for confirmation before executing any action that creates/amends/cancels orders.
- 下单:展示最终订单摘要(合约、方向、合约数、价格类型、行权价、到期日、期权类型),然后请求用户确认后再调用。示例:"Reply 'confirm' to place the order."
create_options_order - 平仓/取消/修改(包括单个订单取消):展示明确的操作范围(合约/order_id、方向、相关数量/价格),并在执行任何创建/修改/取消订单的操作前请求用户确认。
Errors
错误处理
| Code / situation | Action |
|---|---|
| Insufficient balance | Suggest depositing or reducing size. |
Size below | Inform user; do not submit. |
| Contract not found | Confirm underlying, expiration, strike, call/put; suggest listing contracts. |
| Order not found | Order may be filled, cancelled, or wrong id; suggest checking order history. |
| 代码/场景 | 处理方式 |
|---|---|
| 余额不足 | 建议充值或减少订单数量。 |
数量小于 | 告知用户;不提交订单。 |
| 合约不存在 | 确认标的、到期日、行权价、期权类型;建议列出可用合约。 |
| 订单不存在 | 订单可能已成交、取消或ID错误;建议查询订单历史。 |
Other
其他规则
- Resolve underlying, expiration, strike, call/put to a single contract before create/cancel/amend.
- Mark IV orders: use backend IV-to-price conversion when available; otherwise clarify with user.
- Precision: Respect and
order_size_minfromorder_price_round; round price toget_options_contract.order_price_round
- 在创建/取消/修改订单前,需将标的、到期日、行权价、看涨/看跌期权解析为单个合约。
- 基于mark IV的订单:若后端支持IV转价格则使用该服务;否则向用户澄清。
- 精度要求:遵循返回的
get_options_contract和order_size_min;将价格四舍五入至order_price_round指定的精度。order_price_round