Skip to content

Latest commit

Β 

History

History
98 lines (67 loc) Β· 2.11 KB

File metadata and controls

98 lines (67 loc) Β· 2.11 KB

CCXT Skills Examples

Workflow examples for common market/account/admin/trade scenarios.

Initial Setup

Add Your First API Account

# Add API account (required for private account/trade actions)
ccxt-admin.account_add_api exchange=gate payload={alias:gate-main,apiKey:<API_KEY>,secret:<SECRET>} runtimeContext={password:<MASTER_PASSWORD>}

# Verify accounts
ccxt-admin.account_ls

Verify Exchange Support

ccxt-admin.check_sandbox gate
ccxt-admin.check_symbol_support gate BTC/USDT

Symbol Discovery First

Always resolve exact symbols before trading.

ccxt-market.list_markets gate 50

Use symbol exactly as listed by the exchange.


Market Data Workflow

ccxt-market.fetch_ticker gate BTC/USDT
ccxt-market.fetch_order_book gate BTC/USDT 20
ccxt-market.fetch_ohlcv gate BTC/USDT 1h 50

Account Read Workflow

ccxt-account.fetch_balance gate
ccxt-account.fetch_balance gate runtimeContext={accountAlias:gate-main,password:<MASTER_PASSWORD>}
ccxt-account.fetch_open_orders gate BTC/USDT
ccxt-account.fetch_orders gate BTC/USDT 20
ccxt-account.fetch_my_trades gate BTC/USDT 20
ccxt-account.fetch_positions gate

Trade Workflow

# 1) Validate order first
ccxt-trade.validate_order gate BTC/USDT limit buy 0.001 30000

# 2) Dry-run create order (safe path)
ccxt-trade.create_order gate BTC/USDT limit buy 0.001 30000 --dry-run

# 3) Real create order
ccxt-trade.create_order gate BTC/USDT limit buy 0.001 30000

# 4) Cancel order
ccxt-trade.cancel_order gate <ORDER_ID> BTC/USDT

# 5) Set leverage (derivatives/perps exchanges only)
ccxt-trade.set_leverage gate BTC/USDT 3

Common Troubleshooting

# Missing API account
ccxt-admin.account_ls

# Unsupported symbol / wrong symbol format
ccxt-market.list_markets gate 100

# Check exchange capabilities
ccxt-admin.exchange_capabilities gate BTC/USDT

Notes:

  • Private actions require an API account in local encrypted store (account_add_api).
  • Environment-variable credential mode is not used.
  • For market buy on some exchanges, a price may still be required to compute cost.