重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
gate-exchange-futures by gate/gate-skills
npx skills add https://github.com/gate/gate-skills --skill gate-exchange-futures请首先阅读并遵循 exchange-runtime-rules.md。
此技能是 Gate USDT 永续期货的唯一入口。它支持七种操作:开仓、平仓、取消订单、修改订单、止盈/止损(TP/SL)、条件开仓以及价格触发订单管理。用户意图将被路由到匹配的工作流程。
| 模块 | 描述 | 触发关键词 |
|---|---|---|
| 开仓 | 限价/市价开多或开空,全仓/逐仓模式,涨幅榜/跌幅榜订单 | long, short, buy, sell, open, , |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
top gainertop loser| 平仓 | 全部平仓、部分平仓、反向持仓 | close, close all, reverse |
| 取消 | 取消一个或多个订单 | cancel, revoke |
| 修改 | 更改订单价格或数量 | amend, modify |
| 止盈/止损 | 为现有持仓附加止盈或止损;当价格达到时触发平仓/减仓订单 | take profit, stop loss, TP, SL, 止盈, 止损 |
| 条件开仓 | 放置一个待触发的开仓订单,当价格达到某个水平时触发 | conditional order, when price reaches, breakout buy, dip buy, 条件单, 触价开仓 |
| 管理触发单 | 列出、取消或修改已设置的价格触发订单 | list triggers, cancel TP, cancel SL, amend trigger, 查询条件单, 取消止盈止损 |
| 意图 | 示例短语 | 路由至 |
|---|---|---|
| 开仓 | "BTC long 1 contract", "market short ETH", "10x leverage long", "top gainer long 10U" | 阅读 references/open-position.md |
| 平仓 | "close all BTC", "close half", "reverse to short", "close everything" | 阅读 references/close-position.md |
| 取消订单 | "cancel that buy order", "cancel all orders", "list my orders" | 阅读 references/cancel-order.md |
| 修改订单 | "change price to 60000", "change order size" | 阅读 references/amend-order.md |
| 设置止盈/止损 | "Set BTC TP at 70000", "SL at 58000 for my long", "止损60000" | 阅读 references/tp-sl.md |
| 条件开仓 | "Buy BTC when it drops to 60000", "Open short if price breaks above 68000", "条件单做多" | 阅读 references/conditional.md |
| 管理触发订单 | "List my TP/SL orders", "Cancel that stop loss", "Amend trigger price", "查询条件单" | 阅读 references/manage.md |
| 意图不明确 | "help with futures", "show my position" | 澄清:查询持仓/订单,然后引导用户 |
---|---|---
1 | cex_fx_get_fx_tickers | 获取所有期货交易对信息(用于涨幅榜/跌幅榜排序)
2 | cex_fx_get_fx_contract | 获取单个合约信息(精度、乘数等)
3 | cex_fx_get_fx_order_book | 获取合约订单簿(最佳买卖价)
4 | cex_fx_get_fx_accounts | 获取期货账户(持仓模式:单向/双向)
5 | cex_fx_list_fx_positions | 列出持仓(双向模式)
6 | cex_fx_get_fx_dual_position | 获取合约的双向模式持仓
7 | cex_fx_get_fx_position | 获取合约的单向模式持仓
8 | cex_fx_update_fx_dual_position_cross_mode | 切换保证金模式(全仓/逐仓)
9 | cex_fx_update_fx_position_cross_mode | 在单向模式中切换保证金模式(切勿在双向模式中使用)
10 | cex_fx_update_fx_dual_position_leverage | 设置杠杆(双向模式)
11 | cex_fx_update_fx_position_leverage | 设置杠杆(单向模式,切勿在双向模式中使用)
12 | cex_fx_create_fx_order | 下单(开仓/平仓/反向)
13 | cex_fx_list_fx_orders | 列出订单
14 | cex_fx_get_fx_order | 获取单个订单详情
15 | cex_fx_cancel_fx_order | 取消单个订单
16 | cex_fx_cancel_all_fx_orders | 取消某个合约的所有订单
17 | cex_fx_amend_fx_order | 修改订单(价格/数量)
contract, side, size, price, leverage(用于开仓/平仓);trigger_price, trigger_rule, order_size, order_price, order_tif(用于止盈止损/条件单)。cex_fx_get_fx_tickers(settle="usdt"),按 changePercentage 排序(涨幅榜降序,跌幅榜升序),选择排名第一的合约。然后使用该合约继续开仓流程。cex_fx_get_fx_contract 以确保合约存在且可交易。order_price_deviate 预先计算有效的限价价格(实际偏差限制取决于 risk_limit_tier)。在出现 PRICE_TOO_DEVIATED 错误时,从错误消息中显示有效价格范围。usdt,除非用户明确指定了 BTC 结算的合约。cex_fx_get_fx_accounts(settle) 以获取持仓模式。从响应 position_mode 中:single = 单向持仓模式,dual = 双向(对冲)持仓模式。从持仓中获取保证金模式:根据上述的双向/单向模式使用持仓查询 → pos_margin_mode(全仓/逐仓)。如果用户未指定保证金模式,则不要切换;在当前模式下下单。
position_mode === "single"):不要中断。提示用户:"您已持有 {currency} 持仓;切换保证金模式也将应用于此持仓。是否继续?"(例如,从合约中获取 currency:BTC_USDT → BTC)。等待用户确认,然后继续。position_mode === "dual"):中断流程。告知用户:"请先平仓,然后再开新仓。"cex_fx_get_fx_accounts(settle)。如果 position_mode === "dual"(或 in_dual_mode === true):
cex_fx_list_fx_positions(settle, holding=true) 或 cex_fx_get_fx_dual_position(settle, contract)。不要在双向模式中使用 cex_fx_get_fx_position(API 返回数组并导致解析错误)。cex_fx_update_fx_dual_position_cross_mode(settle, contract, mode)(不要在双向模式中使用 cex_fx_update_fx_position_cross_mode)。cex_fx_get_fx_contract 获取 quanto_multiplier,并从 cex_fx_get_fx_order_book(settle, contract, limit=1) 获取最佳买卖价:
contracts = cost / (0.0015 + 1/leverage) / quanto_multiplier / order_price;开空:contracts = cost / (0.0015 + 1.00075/leverage) / quanto_multiplier / max(order_price, best_bid)。order_price:限价 → 指定价格;市价 → 最佳卖价(开多)或最佳买价(开空)。leverage 必须来自当前持仓查询(步骤 5);不要假设默认值。contracts = usdt_value / price / quanto_multiplier;卖出/开空:contracts = usdt_value / max(best_bid, order_price) / quanto_multiplier。price:限价 → 指定价格;市价 → 最佳卖价(买入)或最佳买价(卖出)。order_size_min。pos_margin_mode 获取)。如果用户明确想要逐仓,请检查杠杆。pos_margin_mode),在调用 cex_fx_update_fx_dual_position_cross_mode/cex_fx_update_fx_position_cross_mode 之前:通过 cex_fx_get_fx_accounts(settle) → position_mode 获取持仓模式(单向/双向);如果 position_mode === "single",显示提示 "您已持有 {currency} 持仓;切换保证金模式也将应用于此持仓。是否继续?" 并仅在用户确认后继续;如果 position_mode === "dual",不要切换 — 中断并告知用户 "请先平仓,然后再开新仓。"cex_fx_update_fx_dual_position_cross_mode(双向)或 cex_fx_update_fx_position_cross_mode(单向),参数 mode 为 "cross" 或 "isolated"。如果用户未明确请求保证金模式,则不要切换。cex_fx_update_fx_dual_position_leverage 或单向模式下的 cex_fx_update_fx_position_leverage,然后继续。如果用户未指定杠杆,则不要更改它 — 使用持仓查询中获取的当前杠杆进行所有计算(例如 USDT 成本公式)。不要默认使用任何值(例如 10 倍或 20 倍)。cex_fx_list_fx_positions 或 cex_fx_get_fx_dual_position;单向:cex_fx_get_fx_position)获取合约 + 方向的当前杠杆。显示最终订单摘要(合约、方向、数量、价格或市价、模式、杠杆、预估保证金/强平价)。要求用户确认(例如:"回复 'confirm' 以下单。")。仅在用户确认后下单。cex_fx_create_fx_order(市价:tif=ioc, price=0)。cex_fx_list_fx_positions(holding=true) 或 cex_fx_get_fx_dual_position;单向:cex_fx_get_fx_position)确认持仓。cex_fx_list_fx_positions(settle, holding=true) 或 cex_fx_get_fx_dual_position(settle, contract);单向:cex_fx_get_fx_position(settle, contract))获取当前 size 和方向。cex_fx_create_fx_order reduce_only);反向持仓(分两步:平仓然后开立相反方向)。cex_fx_list_fx_orders 让用户选择。cex_fx_cancel_fx_order(无批量取消)。finish_as == cancelled。open。cex_fx_amend_fx_order 更新价格或数量。阅读 references/tp-sl.md 获取完整逻辑。要点:
trigger_rule = ">="(价格上涨至止盈水平)trigger_rule = "<="(价格下跌至止损水平)trigger_rule = "<="(价格下跌至止盈水平)trigger_rule = ">="(价格上涨至止损水平)close, auto_size, 和 order_type 取决于持仓模式和方向):
order_type = "close-long-position", close = true, 无 auto_size, order_reduce_only = true。order_type = "close-short-position", close = true, 无 auto_size, order_reduce_only = true。order_type = "plan-close-long-position", close = false, 无 auto_size, order_reduce_only = true。order_type = "plan-close-short-position", close = false, 无 auto_size, order_reduce_only = true。order_type = "close-long-position", close = false, auto_size = "close_long", order_reduce_only = true。order_type = "close-short-position", close = false, auto_size = "close_short", order_reduce_only = true。order_type = "plan-close-long-position", close = false, 无 auto_size, order_reduce_only = true。order_type = "plan-close-short-position", close = false, 无 auto_size, order_reduce_only = true。order_reduce_only = true。order_price = "0", order_tif = "ioc");否则使用限价(order_tif = "gtc")。cex_fx_create_fx_price_triggered_order 之前要求用户确认。阅读 references/conditional.md 获取完整逻辑。要点:
trigger_rule = "<=", "buy when breaks above X" → trigger_rule = ">="。cex_fx_get_fx_contract 获取 quanto_multiplier,使用 cex_fx_get_fx_order_book 获取最佳买卖价。对于基于成本的转换,当用户未指定执行限价时,使用 trigger_price 作为参考 order_price。阅读 references/manage.md 获取完整逻辑。支持:
cex_fx_list_fx_price_triggered_orderscex_fx_get_fx_price_triggered_ordercex_fx_cancel_fx_price_triggered_ordercex_fx_cancel_fx_price_triggered_order_listcex_fx_update_fx_price_triggered_order修改限制:只有止盈/止损订单(order_type 包含 plan-close-* 或具有 reduce_only/close 标志)支持通过 cex_fx_update_fx_price_triggered_order 直接修改。通过 API 创建的条件开仓订单会返回 APIOrderNotSupportUpdateTouchOrder 并且无法修改 — 必须取消并重新创建。
每次操作后,输出一个简短的标准化结果。
对于价格触发订单:
✓ [操作] [合约]
触发: [规则] [触发价格]
执行: [市价/限价] × [数量或"全部平仓"] [reduce_only/close]
订单 ID: [id]
quanto_multiplier 单位的标的资产(例如 0.001 BTC)。cex_fx_create_fx_order 之前要求确认。不要添加关于标记价格与限价价格、order_price_deviate 或建议调整价格的文本。示例:"回复 'confirm' 以下单。"Gate 订单 ID 是 64 位整数,可能超过 Number.MAX_SAFE_INTEGER(2^53-1)。标准的 JSON 解析器会静默地损坏它们。
order_id 作为字符串传递(例如 "728451920374819843",而不是 728451920374819843)。| 代码 | 操作 |
|---|---|
BALANCE_NOT_ENOUGH | 建议充值或降低杠杆/数量。 |
PRICE_TOO_DEVIATED | 从错误消息中提取实际有效的价格范围并显示给用户(不要依赖合约的 order_price_deviate;实际限制取决于 risk_limit_tier)。 |
POSITION_HOLDING(模式切换) | API 返回此错误(而非 POSITION_NOT_EMPTY)。要求用户先平仓。 |
CONTRACT_NOT_FOUND | 合约无效或不可交易。确认合约名称(例如 BTC_USDT)和结算货币;建议列出合约。 |
ORDER_NOT_FOUND | 订单已成交、已触发、已取消或 order_id 错误。建议检查订单历史或列出触发订单。 |
APIOrderNotSupportUpdateTouchOrder | 通过 API 创建的条件开仓订单无法修改。请取消并重新创建。止盈/止损订单不受影响,可以正常修改。 |
SIZE_TOO_LARGE | 订单数量超过限制。建议减少数量或检查合约的 order_size_max。 |
ORDER_FOK | FOK 订单无法全部成交。建议使用不同的价格/数量或使用 GTC/IOC。 |
ORDER_POC | POC 订单将消耗流动性;交易所拒绝。建议使用不同的价格以成为纯挂单。 |
INVALID_PARAM_VALUE | 通常在双向模式下使用了错误的 API 或参数时发生(例如在双向模式下使用了 cex_fx_update_fx_position_cross_mode 或 cex_fx_update_fx_position_leverage)。请使用双向模式 API:cex_fx_update_fx_dual_position_cross_mode, cex_fx_update_fx_dual_position_leverage;对于持仓查询,使用 cex_fx_list_fx_positions 或 cex_fx_get_fx_dual_position。对于价格触发订单:检查 trigger_rule, order_size 符号, order_price 格式。 |
每周安装数
64
代码库
GitHub 星标数
12
首次出现
2026年3月7日
安全审计
安装于
kimi-cli63
gemini-cli63
amp63
cline63
github-copilot63
codex63
通过 LiteLLM 代理让 Claude Code 对接 GitHub Copilot 运行 | 高级变通方案指南
46,900 周安装
cex_fx_update_fx_dual_position_leverage(settle, contract, leverage)(不要在双向模式中使用 cex_fx_update_fx_position_leverage;它返回数组并导致解析错误)。如果为单向模式:使用 cex_fx_get_fx_position(settle, contract) 查询持仓;使用 cex_fx_update_fx_position_cross_mode 切换模式;使用 cex_fx_update_fx_position_leverage 设置杠杆。