skills/gate-exchange-spot

stars:4
forks:1
watches:4
last updated:2026-03-09 02:45:14

Resolving gate-cli (binary path)

Resolve gate-cli in order: (1) command -v gate-cli and gate-cli --version succeeds; (2) ${HOME}/.local/bin/gate-cli if executable; (3) ${HOME}/.openclaw/skills/bin/gate-cli if executable. Canonical rules: exchange-runtime-rules.md §4 (or gate-runtime-rules.md §4).

Gate Spot Trading Assistant

General Rules

⚠️ 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 ./references/gate-runtime-rules.md

  • Only use the gate-cli commands explicitly listed in this skill. Commands not documented here must NOT be run for these workflows, even if other interfaces expose them.

Skill Dependencies

This skill depends on the gate-cli binary and the documented subcommands below. Command strings align with gate-cli/cmd/cex/GATE_EXCHANGE_SKILLS_MCP_TO_GATE_CLI.md.

  • Before any gate-cli invocation: ensure gate-cli is installed. Let GATE_CLI_BIN="${GATE_OPENCLAW_SKILLS_BIN:-$HOME/.openclaw/skills/bin}/gate-cli". If [ ! -x "$GATE_CLI_BIN" ] (and command -v gate-cli also fails if you rely on PATH), run setup.sh (e.g. sh ./setup.sh from this skill directory), then re-check. Do not continue with trading or account reads that require auth until gate-cli runs successfully (e.g. gate-cli --version).
  • No MCP servers are required for this skill; execution is gate-cli only.

gate-cli commands used

Query Operations (Read-only)

  • gate-cli cex spot market currency
  • gate-cli cex spot market pair
  • gate-cli cex spot account get
  • gate-cli cex spot account batch-fee
  • gate-cli cex spot market candlesticks
  • gate-cli cex spot market orderbook
  • gate-cli cex spot price-trigger get
  • gate-cli cex spot market tickers
  • gate-cli cex spot account book
  • gate-cli cex spot order my-trades
  • gate-cli cex spot order list
  • gate-cli cex spot price-trigger list
  • gate-cli cex wallet market trade-fee

Execution Operations (Write)

  • gate-cli cex spot order batch-amend
  • gate-cli cex spot order amend
  • gate-cli cex spot order cancel
  • gate-cli cex spot order batch-cancel
  • gate-cli cex spot price-trigger cancel
  • gate-cli cex spot price-trigger cancel-all
  • gate-cli cex spot order batch-create
  • gate-cli cex spot order buy / gate-cli cex spot order sell
  • gate-cli cex spot price-trigger create

Authentication

  • Interactive file setup: when GATE_API_KEY and GATE_API_SECRET are not both set on the host, run gate-cli config init to complete the wizard for API key, secret, profiles, and defaults (see gate-cli).
  • Env / flags: gate-cli config init is not required when credentials are already supplied — e.g. both GATE_API_KEY and GATE_API_SECRET set on the host, or --api-key / --api-secret where supported — never ask the user to paste secrets into chat.
  • Permissions: Spot:Write, Wallet:Read on the key used by gate-cli.
  • Portal: create or rotate keys outside the chat: https://www.gate.com/myaccount/profile/api-key/manage

Installation Check

  • Required: gate-cli (install via setup.sh when missing, per Skill Dependencies).
  • GateClaw / OpenClaw: setup.sh installs to $HOME/.openclaw/skills/bin/gate-cli by default; add that directory to PATH if agents invoke gate-cli by name.
  • Credentials: When GATE_API_KEY and GATE_API_SECRET are both set (non-empty) for the host, do not require gate-cli config init — that is equivalent valid config for gate-cli. When both are unset or empty, remind the operator to run gate-cli config init or to configure GATE_API_KEY / GATE_API_SECRET in the matching skill from the skill library (never ask the user to paste secrets into chat).
  • Sanity check: Do not proceed with authenticated calls until the CLI behaves as expected for the setup (e.g. gate-cli cex spot market tickers); confirm credentials resolve before trades.

Execution mode

Read and strictly follow references/gate-cli.md, then execute this skill's routing/case logic.

  • SKILL.md remains the intent routing and scenario map.
  • references/gate-cli.md is the authoritative execution contract for gate-cli usage, pre-checks, confirmation gates, and degraded handling.

Domain Knowledge

Tool Mapping by Domain

Groupgate-cli commands
Account and balancesgate-cli cex spot account get, gate-cli cex spot account book
Place/cancel/amend ordersgate-cli cex spot order buy / gate-cli cex spot order sell, gate-cli cex spot order batch-create, gate-cli cex spot order cancel, gate-cli cex spot order batch-cancel, gate-cli cex spot order amend, gate-cli cex spot order batch-amend
Trigger orders (price orders)gate-cli cex spot price-trigger create, gate-cli cex spot price-trigger list, gate-cli cex spot price-trigger get, gate-cli cex spot price-trigger cancel, gate-cli cex spot price-trigger cancel-all
Open orders and fillsgate-cli cex spot order list, gate-cli cex spot order my-trades
Market datagate-cli cex spot market tickers, gate-cli cex spot market orderbook, gate-cli cex spot market candlesticks
Trading rulesgate-cli cex spot market currency, gate-cli cex spot market pair
Feesgate-cli cex wallet market trade-fee, gate-cli cex spot account batch-fee

Key Trading Rules

  • Use BASE_QUOTE format for trading pairs, for example BTC_USDT.
  • Check quote-currency balance first before buy orders (for example USDT).
  • Amount-based buys must satisfy min_quote_amount (commonly 10U).
  • Quantity-based buys/sells must satisfy minimum size and precision (min_base_amount / amount_precision).
  • Condition requests may be implemented either as immediate limit-order drafting or as trigger orders, depending on user intent ("if price reaches X then place order").
  • Take-profit/stop-loss (TP/SL)-style requests are handled via spot price-trigger commands with explicit trigger and execution parameters.

Market Order Parameter Extraction Rules (Mandatory)

When calling gate-cli cex spot order buy / gate-cli cex spot order sell with type=market, fill amount by side:

sideamount meaningExample
buyQuote-currency amount (USDT)"Buy 100U BTC" -> amount="100"
sellBase-currency quantity (BTC/ETH, etc.)"Sell 0.01 BTC" -> amount="0.01"

Pre-check before execution:

  • buy market order: verify quote-currency balance can cover amount (USDT).
  • sell market order: verify base-currency available balance can cover amount (coin quantity).

Workflow

When the user asks for any spot trading operation, follow this sequence.

Step 1: Identify Task Type

Classify the request into one of these six categories:

  1. Buy (market/limit/full-balance buy)
  2. Sell (full-position sell/conditional sell)
  3. Account query (total assets, balance checks, tradability checks)
  4. Order management (list open orders, amend, cancel)
  5. Post-trade verification (filled or not, credited amount, current holdings)
  6. Combined actions (sell then buy, buy then place sell order, trend-based buy)

Step 2: Extract Parameters and Run Pre-checks

Extract key fields:

  • currency / currency_pair
  • side (buy/sell)
  • amount (coin quantity) or quote_amount (USDT amount)
  • price or price condition (for example "2% below current")
  • trigger condition (execute only when condition is met)

When type=market, normalize parameters as:

  • side=buy: amount = quote_amount (USDT amount)
  • side=sell: amount = base_amount (base-coin quantity)

Pre-check order:

  1. Trading pair/currency tradability status
  2. Minimum order amount/size and precision
  3. Available balance sufficiency
  4. User condition satisfaction (for example "buy only below 60000")

Step 3: Final User Confirmation Before Any Order Placement (Mandatory)

Before every gate-cli cex spot order buy / gate-cli cex spot order sell, gate-cli cex spot order batch-create, or gate-cli cex spot price-trigger create, always provide an Order Draft first, then wait for explicit confirmation.

Required execution flow:

  1. Send order draft (no trading call yet)
  2. Wait for explicit user approval
  3. Only after approval, submit the real order
  4. Without approval, perform query/estimation only, never execute trading
  5. Treat confirmation as single-use: after one execution, request confirmation again for any next order

Required confirmation fields:

  • trading pair (currency_pair)
  • side and order type (buy/sell, market/limit)
  • amount meaning and value
  • limit price (if applicable) or pricing basis
  • estimated fill / estimated cost or proceeds
  • main risk note (for example slippage)

Recommended draft wording:

  • Order Draft: BTC_USDT, buy, market, amount=100 USDT, estimated fill around current ask, risk: slippage in fast markets. Reply "Confirm order" to place it.

Allowed confirmation responses (examples):

  • Confirm order, Confirm, Proceed, Yes, place it

Hard blocking rules (non-bypassable):

  • NEVER call gate-cli cex spot order buy / gate-cli cex spot order sell, gate-cli cex spot order batch-create, or gate-cli cex spot price-trigger create unless the user explicitly confirms in the immediately previous turn.
  • If the conversation topic changes, parameters change, or multiple options are discussed, invalidate old confirmation and request a new one.
  • For multi-leg execution (for example case 15/22/33), require confirmation for each leg separately before each trading call.

If user confirmation is missing, ambiguous, or negative:

  • do not place the order
  • return a pending status and ask for explicit confirmation
  • continue with read-only actions only (balance checks, market quotes, fee estimation)

Step 4: Run commands by scenario

Use only the minimal gate-cli command set required for the task:

  • Balance and available funds: gate-cli cex spot account get
  • Rule validation: gate-cli cex spot market pair
  • Live price and moves: gate-cli cex spot market tickers
  • Order placement: gate-cli cex spot order buy / gate-cli cex spot order sell / gate-cli cex spot order batch-create
  • Trigger-order placement/query/cancel: gate-cli cex spot price-trigger create / gate-cli cex spot price-trigger list / gate-cli cex spot price-trigger get / gate-cli cex spot price-trigger cancel / gate-cli cex spot price-trigger cancel-all
  • Cancel/amend: gate-cli cex spot order cancel / gate-cli cex spot order batch-cancel / gate-cli cex spot order amend / gate-cli cex spot order batch-amend
  • Open order query: gate-cli cex spot order list (use status=open)
  • Fill verification: gate-cli cex spot order my-trades
  • Account change history: gate-cli cex spot account book
  • Batch fee query: gate-cli cex spot account batch-fee

Step 5: Return Actionable Result and Status

The response must include:

  • Whether execution succeeded (or why it did not execute)
  • Core numbers (price, quantity, amount, balance change)
  • If condition not met, clearly explain why no order is placed now

Case Routing Map (1-36)

A. Buy and Account Queries (1-8)

CaseUser IntentCore DecisionTool Sequence
1Market buyPlace market buy if USDT is sufficientgate-cli cex spot account getgate-cli cex spot order buy / gate-cli cex spot order sell
2Buy at target priceCreate a limit buy ordergate-cli cex spot account getgate-cli cex spot order buy / gate-cli cex spot order sell
3Buy with all balanceUse all available USDT balance to buygate-cli cex spot account getgate-cli cex spot order buy / gate-cli cex spot order sell
4Buy readiness checkCurrency status + min size + current unit pricegate-cli cex spot market currencygate-cli cex spot market pairgate-cli cex spot market tickers
5Asset summaryConvert all holdings to USDT valuegate-cli cex spot account getgate-cli cex spot market tickers
6Cancel all then check balanceCancel all open orders for the user’s pair (gate-cli cex spot order cancel with --all on that --pair) and return balancesgate-cli cex spot order cancelgate-cli cex spot account get
7Sell dustSell only if minimum size is metgate-cli cex spot account getgate-cli cex spot market pairgate-cli cex spot order buy / gate-cli cex spot order sell
8Balance + minimum buy checkPlace order only if account balance and min_quote_amount are both satisfiedgate-cli cex spot account getgate-cli cex spot market pairgate-cli cex spot order buy / gate-cli cex spot order sell

B. Smart Monitoring and Trading (9-16)

CaseUser IntentCore DecisionTool Sequence
9Buy 2% lowerPlace limit buy at current price -2%gate-cli cex spot market tickersgate-cli cex spot order buy / gate-cli cex spot order sell
10Sell at +500Place limit sell at current price +500gate-cli cex spot market tickersgate-cli cex spot order buy / gate-cli cex spot order sell
11Buy near today's lowBuy only if current price is near 24h lowgate-cli cex spot market tickersgate-cli cex spot order buy / gate-cli cex spot order sell
12Sell on 5% drop requestCalculate target drop price and place sell limit ordergate-cli cex spot market tickersgate-cli cex spot order buy / gate-cli cex spot order sell
13Buy top gainerAuto-pick highest 24h gainer and buygate-cli cex spot market tickersgate-cli cex spot order buy / gate-cli cex spot order sell
14Buy larger loserCompare BTC/ETH daily drop and buy the bigger losergate-cli cex spot market tickersgate-cli cex spot order buy / gate-cli cex spot order sell
15Buy then place sellMarket buy, then place sell at +2% reference pricegate-cli cex spot order buy / gate-cli cex spot order sellgate-cli cex spot order buy / gate-cli cex spot order sell
16Fee estimateEstimate total cost from fee rate and live pricegate-cli cex wallet market trade-feegate-cli cex spot market tickers

C. Order Management and Amendment (17-25)

CaseUser IntentCore DecisionTool Sequence
17Raise price for unfilled orderConfirm how much to raise (or target price), locate unfilled buy orders, confirm which order to amend if multiple, then amend limit pricegate-cli cex spot order list(status=open) → gate-cli cex spot order amend
18Verify fill and holdingsLast buy fill quantity + current total holdingsgate-cli cex spot order my-tradesgate-cli cex spot account get
19Cancel if not filledIf still open, cancel and then recheck balancegate-cli cex spot order list(status=open) → gate-cli cex spot order cancelgate-cli cex spot account get
20Rebuy at last priceUse last fill price, check balance, then place limit buygate-cli cex spot order my-tradesgate-cli cex spot account getgate-cli cex spot order buy / gate-cli cex spot order sell
21Sell at break-even or betterSell only if current price is above cost basisgate-cli cex spot order my-tradesgate-cli cex spot market tickersgate-cli cex spot order buy / gate-cli cex spot order sell
22Asset swapEstimate value, if >=10U then sell then buygate-cli cex spot account getgate-cli cex spot market tickersgate-cli cex spot order buy / gate-cli cex spot order sell(sell) → gate-cli cex spot order buy / gate-cli cex spot order sell(buy)
23Buy if price condition metBuy only when current < 60000, then report balancegate-cli cex spot market tickersgate-cli cex spot order buy / gate-cli cex spot order sellgate-cli cex spot account get
24Buy on trend conditionBuy only if 3 of last 4 hourly candles are bullishgate-cli cex spot market candlesticksgate-cli cex spot order buy / gate-cli cex spot order sell
25Fast-fill limit buyUse best opposite-book price for fast executiongate-cli cex spot market orderbookgate-cli cex spot order buy / gate-cli cex spot order sell

D. Advanced Spot Utilities (26-31)

CaseUser IntentCore DecisionTool Sequence
26Filter and batch-cancel selected open ordersVerify target order ids exist in open orders, show candidate list, cancel only after user verificationgate-cli cex spot order list(status=open) → gate-cli cex spot order batch-cancel
27Market slippage simulationSimulate average fill from order-book asks for a notional buy, compare to last pricegate-cli cex spot market orderbookgate-cli cex spot market tickers
28Batch buy placementCheck total required quote amount vs available balance, then place multi-order basketgate-cli cex spot account getgate-cli cex spot order batch-create
29Fee-rate comparison across pairsCompare fee tiers and translate fee impact into estimated costgate-cli cex spot account batch-feegate-cli cex spot market tickers
30Account-book audit + current balanceShow recent ledger changes for a coin and current remaining balancegate-cli cex spot account bookgate-cli cex spot account get
31Batch amend open buy orders by +1%Filter open orders by pair, select up to 5 target buy orders, reprice and batch amend after user verificationgate-cli cex spot order list(status=open) → gate-cli cex spot order batch-amend

E. Trigger Orders and TP/SL Automation (32-36)

CaseUser IntentCore DecisionTool Sequence
32Conditional buy trigger orderRead current BTC price, compute 5% drop trigger, place buy trigger after confirmationgate-cli cex spot market tickersgate-cli cex spot price-trigger create
33Dual TP/SL trigger placementCheck ETH available balance, build TP and SL trigger legs, confirm then place bothgate-cli cex spot account getgate-cli cex spot price-trigger creategate-cli cex spot price-trigger create
34Single trigger order progress queryRead trigger-order detail and compare against live market price to compute distance to triggergate-cli cex spot price-trigger getgate-cli cex spot market tickers
35Batch cancel BTC buy trigger ordersList open trigger orders, filter BTC buy side, confirm scope, then batch cancelgate-cli cex spot price-trigger list(status=open) → gate-cli cex spot price-trigger cancel-all
36Single trigger/TP-SL order cancelVerify one target trigger order is active, then cancel after confirmationgate-cli cex spot price-trigger getgate-cli cex spot price-trigger cancel

Judgment Logic Summary

ConditionAction
User asks to check balance before buyingMust call gate-cli cex spot account get first; place order only if sufficient
User specifies buy/sell at target priceUse type=limit at user-provided price
User asks for fastest fill at current marketPrefer market; if "fast limit" is requested, use best book price
Market buy (buy)Fill amount with USDT quote amount, not base quantity
Market sell (sell)Fill amount with base-coin quantity, not USDT amount
User requests take-profit/stop-lossUse trigger-order workflow: validate position size, draft TP+SL legs, then place after explicit confirmation
Any order placement requestRequire explicit final user confirmation before gate-cli cex spot order buy / gate-cli cex spot order sell
User has not replied with clear confirmationKeep order as draft; no trading execution
Confirmation is stale or not from the immediately previous turnInvalidate it and require a fresh confirmation
Multi-leg trading flowRequire per-leg confirmation before each gate-cli cex spot order buy / gate-cli cex spot order sell
User asks to amend an unfilled buy orderConfirm price increase amount or exact target price before gate-cli cex spot order amend
Multiple open buy orders match amendment requestAsk user to choose which order to amend before executing
User requests selected-order batch cancellationVerify each order id exists/open, present list, and run gate-cli cex spot order batch-cancel only after user verification
User requests batch amend for open ordersFilter target pair open buy orders (max 5), compute repriced levels, and run gate-cli cex spot order batch-amend only after user verification
User requests trigger-order progressRead one trigger order and compare current ticker price to trigger condition; return numeric distance
User requests trigger-order batch cancellationFilter trigger orders by pair+side, present cancellation scope, then call gate-cli cex spot price-trigger cancel-all after confirmation
User requests single trigger-order cancellationVerify order is active/matching intent, then call gate-cli cex spot price-trigger cancel after confirmation
User requests market slippage simulationUse order-book depth simulation and compare weighted fill vs ticker last price
User requests multi-coin one-click buyValidate summed quote requirement, then use gate-cli cex spot order batch-create
User requests fee comparison for multiple pairsUse gate-cli cex spot account batch-fee and convert to cost impact with latest prices
User requests account flow for a coinUse gate-cli cex spot account book and then reconcile with gate-cli cex spot account get
User amount is too smallCheck min_quote_amount; if not met, ask user to increase amount
User requests all-in buy/sellUse available balance, then trim by minimum trade rules
Trigger condition not metDo not place order; return current vs target price gap

Report Template

## Execution Result

| Item | Value |
|------|-----|
| Scenario | {case_name} |
| Pair | {currency_pair} |
| Action | {action} |
| Status | {status} |
| Key Metrics | {key_metrics} |

{decision_text}

Example decision_text:

  • ✅ Condition met. Your order has been placed.
  • 📝 Order draft ready. Reply "Confirm order" to execute.
  • ⏸️ No order placed yet: current price is 60200, above your target 60000.
  • ❌ Not executed: minimum order amount is 10U, your input is 5U.

Error Handling

Error TypeTypical CauseHandling Strategy
Insufficient balanceNot enough available USDT/coinsReturn shortfall and suggest reducing order size
Minimum trade constraintBelow minimum amount/sizeReturn threshold and suggest increasing order size
Trigger-order parameter mismatchTrigger rule/price/side is inconsistent with user intentReturn normalized trigger draft and require user reconfirmation
Missing final confirmationUser has not clearly approved final order summaryKeep order pending and request explicit confirmation
Stale confirmationConfirmation does not match the current draft or is not in the previous turnReject execution and ask for reconfirmation
Draft-only modeUser has not confirmed yetOnly run query/estimation tools; do not call gate-cli cex spot order buy / gate-cli cex spot order sell, gate-cli cex spot order batch-create, or gate-cli cex spot price-trigger create
Ambiguous amendment targetMultiple candidate open buy ordersKeep pending and ask user to confirm order ID/row
Batch-cancel ambiguitySome requested order ids are missing/not-openReturn matched vs unmatched ids and request reconfirmation
Batch-amend ambiguityCandidate order set is unclear or exceeds max selectionAsk user to confirm exact order ids (up to 5) before execution
Order missing/already filledAmendment/cancellation target is invalidAsk user to refresh open orders and retry
Market condition not metTrigger condition is not satisfiedReturn current price, target price, and difference
Pair unavailableCurrency suspended or abnormal statusClearly state pair is currently not tradable

Cross-Skill Workflows

Workflow A: Buy Then Amend

  1. Place order with gate-exchange-spot (Case 2/9/23)
  2. If still unfilled, amend price (Case 17)

Workflow B: Cancel Then Rebuy

  1. Cancel all open orders to release funds (Case 6)
  2. Re-enter with updated strategy (Case 1/2/9)

Safety Rules

  • For all-in/full-balance/one-click requests, restate key amount and symbol before execution.
  • For condition-based requests, explicitly show how the trigger threshold is calculated.
  • For TP/SL-style requests on spot, use the price-trigger workflow in this skill; do not imply unsupported CEX features—draft trigger legs and confirm before gate-cli cex spot price-trigger create.
  • Before any order placement, always request explicit final user confirmation.
  • Without explicit confirmation, stay in draft/query/estimation mode and never execute trade placement.
  • Do not reuse old confirmations; if anything changes, re-draft and re-confirm.
  • For fast-fill requests, warn about possible slippage or order-book depth limits.
  • For chained actions (sell then buy), report step-by-step results clearly.
  • If any condition is not met, do not force execution; explain and provide alternatives.
    Good AI Tools