⚠️ STOP — You MUST read and strictly follow the shared runtime rules before proceeding. Do NOT select or call any tool until all rules are read. These rules have the highest priority. → Read gate-runtime-rules.md
MCP ServerStatusGate (main)✅ Required
Query Operations (Read-only)
Execution Operations (Write)
gate-mcp-cursor-installergate-mcp-codex-installergate-mcp-claude-installergate-mcp-openclaw-installerRead and strictly follow references/mcp.md, then execute module-specific routes in this SKILL.md.
SKILL.md keeps routing logic (Open/Close/Cancel/Amend/TP-SL/Conditional/Manage).references/mcp.md is the authoritative MCP execution layer for tool contracts, mode switching safeguards, confirmation gates, and degraded handling.ModuleDescriptionTrigger keywordsOpenLimit/market open long or short, cross/isolated mode, top gainer/loser orderlong, short, buy, sell, open, top gainer, top loserCloseFull close, partial close, reverse positionclose, close all, reverseCancelCancel one or many orderscancel, revokeAmendChange order price or sizeamend, modifyTP/SLAttach take-profit or stop-loss to an existing position; fires a close/reduce order when price is reachedtake profit, stop loss, TP, SL, 止盈, 止损Conditional OpenPlace a pending open order that triggers when price hits a levelconditional order, when price reaches, breakout buy, dip buy, 条件单, 触价开仓Manage TriggersList, cancel, or amend open price-triggered orderslist triggers, cancel TP, cancel SL, amend trigger, 查询条件单, 取消止盈止损
IntentExample phrasesRoute toOpen position"BTC long 1 contract", "market short ETH", "10x leverage long", "top gainer long 10U"Read references/open-position.mdClose position"close all BTC", "close half", "reverse to short", "close everything"Read references/close-position.mdCancel orders"cancel that buy order", "cancel all orders", "list my orders"Read references/cancel-order.mdAmend order"change price to 60000", "change order size"Read references/amend-order.mdSet TP/SL"Set BTC TP at 70000", "SL at 58000 for my long", "止损60000"Read references/tp-sl.mdConditional open"Buy BTC when it drops to 60000", "Open short if price breaks above 68000", "条件单做多"Read references/conditional.mdManage triggered orders"List my TP/SL orders", "Cancel that stop loss", "Amend trigger price", "查询条件单"Read references/manage.mdUnclear"help with futures", "show my position"Clarify: query position/orders, then guide user
#ToolPurpose1cex_fx_get_fx_tickersGet all futures tickers (for top gainer/loser sorting)2cex_fx_get_fx_contractGet single contract info (precision, multiplier, etc.)3cex_fx_get_fx_order_bookGet contract order book (best bid/ask)4cex_fx_get_fx_accountsGet futures account (position mode: single/dual)5cex_fx_list_fx_positionsList positions (dual mode)6cex_fx_get_fx_dual_positionGet dual-mode position for a contract7cex_fx_get_fx_positionGet single-mode position for a contract8cex_fx_update_fx_dual_position_cross_modeSwitch margin mode (cross/isolated)9cex_fx_update_fx_position_cross_modeSwitch margin mode in single mode (do NOT use in dual)10cex_fx_update_fx_dual_position_leverageSet leverage (dual mode)11cex_fx_update_fx_position_leverageSet leverage (single mode, do NOT use in dual)12cex_fx_create_fx_orderPlace order (open/close/reverse)13cex_fx_list_fx_ordersList orders14cex_fx_get_fx_orderGet single order detail15cex_fx_cancel_fx_orderCancel single order16cex_fx_cancel_all_fx_ordersCancel all orders for a contract17cex_fx_amend_fx_orderAmend order (price/size)
contract, side, size, price, leverage (for Open/Close); trigger_price, trigger_rule, order_size, order_price, order_tif (for TP/SL/Conditional).cex_fx_get_fx_tickers(settle="usdt"), sort by changePercentage (descending for gainer, ascending for loser), pick the top contract. Then continue the open flow with that contract.Contract: call cex_fx_get_fx_contract to ensure contract exists and is tradeable.
Account: check balance and conflicting positions (e.g. when switching margin mode).
Risk: do not pre-calculate valid limit price from order_price_deviate (actual deviation limit depends on risk_limit_tier). On PRICE_TOO_DEVIATED, show the valid range from the error message.
Settle currency: always usdt unless user explicitly specifies BTC-settled contract.
Margin mode vs position mode (only when user explicitly requested a margin mode and it differs from current): call cex_fx_get_fx_accounts(settle) to get position mode. From response position_mode: single = single position mode, dual = dual (hedge) position mode. Margin mode from position: use position query per dual/single above → pos_margin_mode (cross/isolated). If user did not specify margin mode, do not switch; place order in current mode.
position_mode === "single"): do not interrupt. Prompt user: "You already have a {currency} position; switching margin mode will apply to this position too. Continue?" (e.g. currency from contract: BTC_USDT → BTC). Wait for user confirmation, then continue.position_mode === "dual"): interrupt flow. Tell user: "Please close the position first, then open a new one."Dual mode vs single mode (API choice): call cex_fx_get_fx_accounts(settle) first. If position_mode === "dual" (or in_dual_mode === true):
cex_fx_list_fx_positions(settle, holding=true) or cex_fx_get_fx_dual_position(settle, contract). Do not use cex_fx_get_fx_position in dual mode (API returns an array and causes parse error).cex_fx_update_fx_dual_position_cross_mode(settle, contract, mode) (do not use cex_fx_update_fx_position_cross_mode in dual mode).cex_fx_update_fx_dual_position_leverage(settle, contract, leverage) (do not use cex_fx_update_fx_position_leverage in dual mode; it returns array and causes parse error).
If single mode: use cex_fx_get_fx_position(settle, contract) for position; cex_fx_update_fx_position_cross_mode for mode switch; cex_fx_update_fx_position_leverage for leverage.Unit conversion: if user does not specify size in contracts, distinguish between USDT cost ("spend 100U") and USDT value ("100U worth"), get quanto_multiplier from cex_fx_get_fx_contract and best bid/ask from cex_fx_get_fx_order_book(settle, contract, limit=1):
contracts = cost / (0.0015 + 1/leverage) / quanto_multiplier / order_price; open short: contracts = cost / (0.0015 + 1.00075/leverage) / quanto_multiplier / max(order_price, best_bid). order_price: limit → specified price; market → best ask (long) or best bid (short). leverage must come from the current position query (step 5); do not assume a default.contracts = usdt_value / price / quanto_multiplier; sell/open short: contracts = usdt_value / max(best_bid, order_price) / quanto_multiplier. price: limit → specified price; market → best ask (buy) or best bid (sell).order_size_min.Mode: Switch margin mode only when the user explicitly requests it: switch to isolated only when user explicitly asks for isolated (e.g. "isolated"); switch to cross only when user explicitly asks for cross (e.g. "cross"). If the user does not specify margin mode, do not switch — place the order in the current margin mode (from position pos_margin_mode). If user explicitly wants isolated, check leverage.
Mode switch: only when user explicitly requested a margin mode and it differs from current (current from position: pos_margin_mode), then before calling cex_fx_update_fx_dual_position_cross_mode/ cex_fx_update_fx_position_cross_mode: get position mode via cex_fx_get_fx_accounts(settle) → position_mode (single/dual); if position_mode === "single", show prompt "You already have a {currency} position; switching margin mode will apply to this position too. Continue?" and continue only after user confirms; if position_mode === "dual", do not switch—interrupt and tell user "Please close the position first, then open a new one."
Mode switch (no conflict): only when user explicitly requested cross or isolated and that target differs from current: if no position, or single position and user confirmed, call cex_fx_update_fx_dual_position_cross_mode (dual) or cex_fx_update_fx_position_cross_mode (single) with mode "cross" or "isolated". Do not switch if the user did not explicitly request a margin mode.
Leverage: if user specified leverage and it differs from current (from position query per dual/single above), call cex_fx_update_fx_dual_position_leverage in dual mode or cex_fx_update_fx_position_leverage in single mode first, then proceed. If user did not specify leverage, do not change it — use the current leverage from the position query for all calculations (e.g. USDT cost formula). Do not default to any value (e.g. 10x or 20x).
Pre-order confirmation: get current leverage from position query (dual: cex_fx_list_fx_positions or cex_fx_get_fx_dual_position; single: cex_fx_get_fx_position) for contract + side. Show final order summary (contract, side, size, price or market, mode, leverage, estimated margin/liq price). Ask user to confirm (e.g. "Reply 'confirm' to place the order."). Only after user confirms, place order.
Place order: call cex_fx_create_fx_order (market: tif=ioc, price=0).
Verify: confirm position via position query (dual: cex_fx_list_fx_positions(holding=true) or cex_fx_get_fx_dual_position; single: cex_fx_get_fx_position).
size and side via position query (dual: cex_fx_list_fx_positions(settle, holding=true) or cex_fx_get_fx_dual_position(settle, contract); single: cex_fx_get_fx_position(settle, contract)).cex_fx_create_fx_order reduce_only); reverse (close then open opposite in two steps).cex_fx_list_fx_orders and let user choose.cex_fx_cancel_fx_order only (no batch cancel).finish_as == cancelled.open.cex_fx_amend_fx_order to update price or size.Read references/tp-sl.md for full logic. Key points:
Position check: get current position to confirm side and size (dual/single mode rules from pre-flight checks apply).
Trigger rule auto-selection:
trigger_rule = ">=" (price rises to TP level)trigger_rule = "<=" (price falls to SL level)trigger_rule = "<=" (price falls to TP level)trigger_rule = ">=" (price rises to SL level)Close flags ( close, auto_size, and order_type depend on position mode and side):
order_type = "close-long-position", close = true, no auto_size, order_reduce_only = true.order_type = "close-short-position", close = true, no auto_size, order_reduce_only = true.order_type = "plan-close-long-position", close = false, no auto_size, order_reduce_only = true.order_type = "plan-close-short-position", close = false, no 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, no auto_size, order_reduce_only = true.order_type = "plan-close-short-position", close = false, no auto_size, order_reduce_only = true.Size: if user says "close all" or does not specify size, use full close (size = 0) with mode-appropriate flags above; if partial, compute size and set order_reduce_only = true.
Market vs limit: if user does not specify execution price, use market ( order_price = "0", order_tif = "ioc"); otherwise limit ( order_tif = "gtc").
Confirmation: show summary (contract, side, trigger price, trigger rule, execution type, size or "close all") and ask user to confirm before calling cex_fx_create_fx_price_triggered_order.
Read references/conditional.md for full logic. Key points:
trigger_rule = "<=", "buy when breaks above X" → trigger_rule = ">=".cex_fx_get_fx_contract for quanto_multiplier and cex_fx_get_fx_order_book for best bid/ask. For cost-based conversion, use trigger_price as reference order_price when user has not specified an execution limit price.Read references/manage.md for full logic. Supports:
cex_fx_list_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_orderAmend limitation: only TP/SL orders (order_type contains plan-close-* or has reduce_only/ close flag) support direct amendment via cex_fx_update_fx_price_triggered_order. Conditional open orders created via API return APIOrderNotSupportUpdateTouchOrder and cannot be amended — must cancel and re-create instead.
After each operation, output a short standardized result.
For price-triggered orders:
text
✓ [Operation] [Contract]
Trigger: [rule] [trigger_price]
Execute: [market/limit price] × [size or "close all"] [reduce_only/close]
Order ID: [id]
quanto_multiplier units of the base asset (e.g. 0.001 BTC).cex_fx_create_fx_order. Do not add text about mark price vs limit price, order_price_deviate, or suggesting to adjust price. Example: "Reply 'confirm' to place the order."Gate order IDs are 64-bit integers that exceed Number.MAX_SAFE_INTEGER (2^53-1). Standard JSON parsers silently corrupt them.
order_id as a string (e.g. "728451920374819843", not 728451920374819843).CodeActionBALANCE_NOT_ENOUGHSuggest deposit or lower leverage/size.PRICE_TOO_DEVIATEDExtract actual valid price range from the error message and show to user (do not rely on contract order_price_deviate; actual limit depends on risk_limit_tier).POSITION_HOLDING (mode switch)API returns this (not POSITION_NOT_EMPTY). Ask user to close position first.CONTRACT_NOT_FOUNDContract invalid or not tradeable. Confirm contract name (e.g. BTC_USDT) and settle; suggest listing contracts.ORDER_NOT_FOUNDOrder already filled, triggered, cancelled, or wrong order_id. Suggest checking order history or listing triggered orders.APIOrderNotSupportUpdateTouchOrderAPI-created conditional open orders cannot be amended. Cancel and re-create instead. TP/SL orders are not affected and can be amended normally.SIZE_TOO_LARGEOrder size exceeds limit. Suggest reducing size or check contract order_size_max.ORDER_FOKFOK order could not be filled entirely. Suggest different price/size or use GTC/IOC.ORDER_POCPOC order would have taken liquidity; exchange rejected. Suggest different price for maker-only.INVALID_PARAM_VALUEOften in dual mode when wrong API or params used (e.g. cex_fx_update_fx_position_cross_mode or cex_fx_update_fx_position_leverage in dual). Use dual-mode APIs: cex_fx_update_fx_dual_position_cross_mode, cex_fx_update_fx_dual_position_leverage; for position use cex_fx_list_fx_positions or cex_fx_get_fx_dual_position. For price-triggered orders: check trigger_rule, order_size sign, order_price format.