Skills phemex-trade
Trade on Phemex (USDT-M futures, Coin-M futures, Spot) — place orders, manage positions, check balances, and query market data. Use when the user wants to (1) check crypto prices or market data on Phemex, (2) place, amend, or cancel orders, (3) view account balances or positions, (4) set leverage or switch position modes, (5) transfer funds between spot and futures wallets, or (6) any task involving the Phemex exchange.
git clone https://github.com/openclaw/skills
T=$(mktemp -d) && git clone --depth=1 https://github.com/openclaw/skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/bubble501/phemex-trade" ~/.claude/skills/openclaw-skills-phemex-trade && rm -rf "$T"
T=$(mktemp -d) && git clone --depth=1 https://github.com/openclaw/skills "$T" && mkdir -p ~/.openclaw/skills && cp -r "$T/skills/bubble501/phemex-trade" ~/.openclaw/skills/openclaw-skills-phemex-trade && rm -rf "$T"
skills/bubble501/phemex-trade/SKILL.mdPhemex Trading
Trade on Phemex via the phemex-cli tool. Supports USDT-M futures, Coin-M futures, and Spot markets.
What's New in v1.2.0
tool — Discover all available trading pairs, filtered by contract type. No more guessing symbol names.list_symbols- Config file (
) — Store API credentials persistently. No need to~/.phemexrc
env vars every session.export
for every tool — Run--help
to see parameters, defaults, and usage examples inline.phemex-cli <tool> --help- Friendly field names — API field suffixes (
,closeRp
) are mapped to readable names (fundingRateRr
,closePrice
). UsefundingRate
to get the original names.--raw - Enhanced error messages — Errors now include
andsuggestion
fields with actionable guidance instead of raw API codes.tip
Before you start
Ensure you have the latest version installed:
npm install -g phemex-trade-mcp@latest
How to call tools
phemex-cli <tool_name> --param1 value1 --param2 value2
Or with JSON args:
phemex-cli <tool_name> '{"param1":"value1","param2":"value2"}'
Output is always JSON. Credentials are loaded from environment variables or
~/.phemexrc (see Setup).
Tool help
Every tool supports
--help with full parameter docs and examples:
phemex-cli place_order --help
Output:
Usage: phemex-cli place_order [options] Place an order (Market, Limit, Stop, StopLimit) Required Parameters: --symbol <string> Trading pair (e.g. BTCUSDT) --side <string> Buy or Sell --orderQty <number> Quantity. linear: base amount (0.01 = 0.01 BTC). ... --ordType <string> Order type: Market, Limit, Stop, StopLimit Optional Parameters: --price <number> Limit price (required for Limit/StopLimit) --timeInForce <string> GoodTillCancel, PostOnly, ... [default: GoodTillCancel] --reduceOnly <boolean> Only reduce position [default: false] ... Examples: phemex-cli place_order --symbol BTCUSDT --side Buy --orderQty 0.01 --ordType Market phemex-cli place_order --symbol BTCUSDT --side Sell --orderQty 0.01 --ordType Limit --price 90000 --timeInForce PostOnly
More help examples:
phemex-cli get_ticker --help # see params for price ticker phemex-cli get_klines --help # see resolution values for candlesticks phemex-cli set_leverage --help # see leverage param format phemex-cli transfer_funds --help # see direction values phemex-cli list_symbols --help # see contractType filter
Friendly field names
By default, output uses readable field names:
phemex-cli get_ticker --symbol BTCUSDT
{ "closePrice": "70549.9", "openPrice": "70192.7", "highPrice": "70750", "lowPrice": "69160", "markPrice": "70549.9", "fundingRate": "-0.00003417", "volume": "5303.525", "turnover": "371204351.5978" }
Use
--raw to get original API field names (for scripts that depend on old format):
phemex-cli get_ticker --symbol BTCUSDT --raw
{ "closeRp": "70549.9", "openRp": "70192.7", "highRp": "70750", "lowRp": "69160", "markPriceRp": "70549.9", "fundingRateRr": "-0.00003417", "volumeRq": "5303.525", "turnoverRv": "371204351.5978" }
Field name mapping reference:
| Suffix | Meaning | Example | Mapped to |
|---|---|---|---|
| Real Price | | |
| Real Value | | |
| Real Rate | | |
| Real Quantity | | |
Contract types
Every tool accepts an optional
--contractType flag:
(default) — USDT-M perpetual futures. Symbols end in USDT (e.g. BTCUSDT).linear
— Coin-M perpetual futures. Symbols end in USD (e.g. BTCUSD).inverse
— Spot trading. Symbols end in USDT (e.g. BTCUSDT). The server auto-prefixesspot
for the API.s
Tools
Market data (no auth needed)
— 24hr price ticker. Example:get_tickerphemex-cli get_ticker --symbol BTCUSDT
— Order book (30 levels). Example:get_orderbookphemex-cli get_orderbook --symbol BTCUSDT
— Candlestick data. Example:get_klinesphemex-cli get_klines --symbol BTCUSDT --resolution 3600 --limit 100
— Recent trades. Example:get_recent_tradesphemex-cli get_recent_trades --symbol BTCUSDT
— Funding rate history. Example:get_funding_ratephemex-cli get_funding_rate --symbol .BTCFR8H --limit 20
Account (read-only, auth required)
— Balance and margin info. Example:get_accountphemex-cli get_account --currency USDT
— Spot wallet balances. Example:get_spot_walletphemex-cli get_spot_wallet
— Current positions with PnL. Example:get_positionsphemex-cli get_positions --currency USDT
— Open orders. Example:get_open_ordersphemex-cli get_open_orders --symbol BTCUSDT
— Closed/filled orders. Example:get_order_historyphemex-cli get_order_history --symbol BTCUSDT --limit 50
— Trade execution history. Example:get_tradesphemex-cli get_trades --symbol BTCUSDT --limit 50
Trading (auth required)
— Place an order (Market, Limit, Stop, StopLimit). Key params:place_order
,--symbol
(Buy/Sell),--side
,--orderQty
,--ordType
(Limit/StopLimit),--price
(Stop/StopLimit),--stopPx
(GoodTillCancel/PostOnly/ImmediateOrCancel/FillOrKill),--timeInForce
,--reduceOnly
(Long/Short/Merged),--posSide
,--stopLoss
,--takeProfit
(spot only). orderQty units differ by contract type:--qtyType
(USDT-M): orderQty = base currency amount (e.g.linear
= 0.01 BTC). To buy 10 USDT worth, calculate qty = 10 / current price.0.01
(Coin-M): orderQty = number of contracts as integer (e.g.inverse
= 10 contracts). Each contract has a fixed USD value (e.g. 1 USD/contract for BTCUSD).10
: depends onspot
.--qtyType
(default) = base currency (e.g.ByBase
= 0.01 BTC).0.01
= quote currency (e.g.ByQuote
= 50 USDT worth of BTC).50- Example:
phemex-cli place_order --symbol BTCUSDT --side Buy --orderQty 0.01 --ordType Market
— Modify an open order. Example:amend_orderphemex-cli amend_order --symbol BTCUSDT --orderID xxx --price 95000
— Cancel one order. Example:cancel_orderphemex-cli cancel_order --symbol BTCUSDT --orderID xxx
— Cancel all orders for a symbol. Example:cancel_all_ordersphemex-cli cancel_all_orders --symbol BTCUSDT
— Set leverage. Example:set_leveragephemex-cli set_leverage --symbol BTCUSDT --leverage 10
— Switch OneWay/Hedged. Example:switch_pos_modephemex-cli switch_pos_mode --symbol BTCUSDT --targetPosMode OneWay
Transfers (auth required)
— Move funds between spot and futures. Example:transfer_fundsphemex-cli transfer_funds --currency USDT --amount 100 --direction spot_to_futures
— Transfer history. Example:get_transfer_historyphemex-cli get_transfer_history --currency USDT --limit 20
Utility
— List all available trading symbols, grouped by contract type.list_symbols
# List all symbols (linear, inverse, spot) phemex-cli list_symbols # Only USDT-M perpetual futures phemex-cli list_symbols --contractType linear # Only Coin-M perpetual futures phemex-cli list_symbols --contractType inverse # Only spot pairs phemex-cli list_symbols --contractType spot
Example output:
{ "linear": ["BTCUSDT", "ETHUSDT", "SOLUSDT", "BNBUSDT", ...], "inverse": ["BTCUSD", "ETHUSD", ...], "spot": ["BTCUSDT", "ETHUSDT", ...] }
Use
list_symbols to discover valid symbol names before trading. This avoids "invalid symbol" errors.
Error messages
Errors return structured JSON with actionable guidance. Examples:
Invalid symbol:
phemex-cli get_ticker --symbol INVALIDXXX
{ "error": "Invalid symbol: INVALIDXXX", "code": 6001, "suggestion": "Symbol \"INVALIDXXX\" is not recognized. Check spelling and contract type.", "tip": "Run \"phemex-cli list_symbols\" to see all available symbols." }
Common typo (BTCUSD instead of BTCUSDT):
phemex-cli get_ticker --symbol BTCUSD
{ "error": "Invalid symbol: BTCUSD", "code": 6001, "suggestion": "Did you mean BTCUSDT? For USDT perpetuals, use symbols ending in USDT (e.g. BTCUSDT).", "tip": "Run \"phemex-cli list_symbols\" to see all available symbols." }
Order quantity too large:
{ "error": "Order quantity too large", "code": "TE_QTY_TOO_LARGE", "suggestion": "The order quantity exceeds the maximum allowed for BTCUSDT.", "tip": "Reduce --orderQty or check the symbol's max order size on Phemex." }
Other enhanced errors: insufficient balance, invalid API key, rate limiting, invalid leverage, order not found — all include
suggestion and tip fields.
Safety rules
- Always confirm before placing orders. Before calling
, show the user exactly what the order will do: symbol, side, quantity, type, price. Ask for confirmation.place_order - Always confirm before cancelling all orders. Before calling
, list the open orders first and confirm with the user.cancel_all_orders - Explain leverage changes. Before calling
, explain the implications (higher leverage = higher liquidation risk).set_leverage - Show context before trading. Before suggesting a trade, show current positions and account balance so the user can make an informed decision.
- Never auto-trade. Do not place orders without explicit user instruction.
Common workflows
Check a price
phemex-cli get_ticker --symbol BTCUSDT
Discover available symbols
phemex-cli list_symbols --contractType linear
Place a market buy (USDT-M futures)
phemex-cli place_order --symbol BTCUSDT --side Buy --orderQty 0.01 --ordType Market
Place a limit sell (Coin-M futures)
phemex-cli place_order --symbol BTCUSD --side Sell --orderQty 10 --ordType Limit --price 100000 --contractType inverse
Buy spot
phemex-cli place_order --symbol BTCUSDT --side Buy --orderQty 10 --ordType Market --contractType spot --qtyType ByQuote
Check positions
phemex-cli get_positions --currency USDT
Get help for any command
phemex-cli place_order --help
Setup
Option 1: Config file (recommended)
Create
~/.phemexrc — credentials persist across sessions without exporting env vars:
# ~/.phemexrc PHEMEX_API_KEY=your-api-key PHEMEX_API_SECRET=your-api-secret PHEMEX_API_URL=https://api.phemex.com # Optional: max order value limit (USD) PHEMEX_MAX_ORDER_VALUE=1000
That's it. All
phemex-cli commands will pick up these values automatically.
Option 2: Environment variables
export PHEMEX_API_KEY=your-api-key export PHEMEX_API_SECRET=your-api-secret export PHEMEX_API_URL=https://api.phemex.com
Configuration priority
Settings are loaded in this order (highest priority first):
- Command-line arguments
- Environment variables
config file~/.phemexrc- Defaults (testnet URL)
This means env vars always override the config file, so you can safely keep production creds in
~/.phemexrc and temporarily override with PHEMEX_API_URL=https://testnet-api.phemex.com phemex-cli ... for testing.
Steps
- Create a Phemex account at https://phemex.com
- Create an API key (Account → API Management)
- Save credentials to
or export as environment variables~/.phemexrc - Verify:
should return symbolsphemex-cli list_symbols --contractType linear - Optionally set
(defaults to testnetPHEMEX_API_URL
for safety; set tohttps://testnet-api.phemex.com
for real trading)https://api.phemex.com - Optionally set
to limit maximum order size (USD)PHEMEX_MAX_ORDER_VALUE