hyperliquid

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Hyperliquid Trading

Hyperliquid 交易

Trade perpetual futures and spot tokens on Hyperliquid, a fully on-chain decentralized exchange. Orders are signed using this agent's EVM wallet and submitted directly to the Hyperliquid L1.
在完全链上的去中心化交易所Hyperliquid上交易永续期货和现货代币。订单通过该Agent的EVM钱包签名后直接提交至Hyperliquid L1。

Prerequisites

前置条件

Before trading, the wallet policy must be active. Load the wallet-policy skill and propose the standard wildcard policy (deny key export + allow
*
). This covers all Hyperliquid operations — USDC deposits, EIP-712 order signing, and withdrawals.
交易前,钱包策略必须处于激活状态。加载wallet-policy技能并提交标准通配符策略(禁止密钥导出 + 允许
*
)。该策略覆盖所有Hyperliquid操作——USDC存款、EIP-712订单签名和提款。

Available Tools

可用工具

Account & Market Info

账户与市场信息

ToolWhat it does
hl_total_balance
Check how much you can trade with (use this for balance checks!)
hl_account
See your open positions and PnL
hl_balances
See your token holdings (USDC, HYPE, etc.)
hl_market
Get current prices for crypto or stocks
hl_orderbook
Check order book depth and liquidity
hl_fills
See recent trade fills and execution prices
hl_candles
Get price charts (1m, 5m, 1h, 4h, 1d)
hl_funding
Check funding rates for perps
hl_open_orders
See pending orders
工具功能
hl_total_balance
查看可交易资金总量(请用此工具进行余额检查!)
hl_account
查看未平仓头寸和盈亏(PnL)
hl_balances
查看代币持仓(USDC、HYPE等)
hl_market
获取加密货币或股票的当前价格
hl_orderbook
查看订单簿深度和流动性
hl_fills
查看近期成交记录和执行价格
hl_candles
获取价格K线图(1分钟、5分钟、1小时、4小时、1天)
hl_funding
查看永续合约资金费率
hl_open_orders
查看挂单

Trading

交易操作

ToolWhat it does
hl_order
Buy or sell perps (crypto/stocks)
hl_spot_order
Buy or sell spot tokens
hl_tpsl_order
Place stop loss or take profit orders
hl_leverage
Set leverage (1x to asset max)
hl_cancel
Cancel a specific order
hl_cancel_all
Cancel all open orders
hl_modify
Change order price or size
工具功能
hl_order
买卖永续合约(加密货币/股票)
hl_spot_order
买卖现货代币
hl_tpsl_order
设置止损或止盈订单
hl_leverage
设置杠杆(1倍至资产上限)
hl_cancel
取消指定订单
hl_cancel_all
取消所有挂单
hl_modify
修改订单价格或数量

Funds

资金管理

ToolWhat it does
hl_deposit
Add USDC from Arbitrum (min $5)
hl_withdraw
Send USDC to Arbitrum (1 USDC fee, ~5 min)
hl_transfer_usd
Move USDC between spot/perp (rarely needed)

工具功能
hl_deposit
从Arbitrum转入USDC(最低5美元)
hl_withdraw
将USDC转出至Arbitrum(手续费1 USDC,约5分钟到账)
hl_transfer_usd
在现货/永续合约账户间划转USDC(极少需要)

Quick Start

快速开始

Just tell the agent what you want to trade - it handles everything automatically.
Examples:
User: "Buy $20 of Bitcoin with 5x leverage"
Agent: [checks balance → sets leverage → places order → reports fill]
Result: "✓ Bought 0.0002 BTC at $95,432 with 5x leverage. Position opened."

User: "Long NVIDIA with $50, 10x"
Agent: [auto-detects NVIDIA = xyz:NVDA → executes → verifies]
Result: "✓ Bought 0.25 NVDA at $198.50 with 10x leverage. Filled at $198.62."

User: "Sell my ETH position"
Agent: [checks position size → closes → reports PnL]
Result: "✓ Sold 0.5 ETH at $3,421. Realized PnL: +$12.50"
You don't need to:
  • Understand account modes or fund transfers
  • Check balances manually (agent does it)
  • Calculate position sizes (agent does it)
  • Verify fills (agent does it)
Just say what you want, the agent handles the rest.

只需告知Agent你想要进行的交易,它会自动处理所有流程。
示例:
用户:"用5倍杠杆买入20美元的比特币"
Agent: [检查余额 → 设置杠杆 → 下单 → 报告成交结果]
结果:"✓ 以95,432美元价格买入0.0002 BTC,使用5倍杠杆。已开仓。"

用户:"用50美元、10倍杠杆做多NVIDIA"
Agent: [自动识别NVIDIA = xyz:NVDA → 执行交易 → 验证结果]
结果:"✓ 以198.50美元价格买入0.25 NVDA,使用10倍杠杆,成交价格198.62美元。"

用户:"卖出我的ETH头寸"
Agent: [检查头寸规模 → 平仓 → 报告盈亏]
结果:"✓ 以3,421美元价格卖出0.5 ETH,已实现盈亏:+$12.50"
你无需:
  • 理解账户模式或资金划转规则
  • 手动检查余额(Agent会自动处理)
  • 计算头寸规模(Agent会自动处理)
  • 验证成交结果(Agent会自动处理)
只需说出你的需求,其余交给Agent即可。

Agent Behavior Guidelines

Agent行为准则

🤖 As the agent, you should ALWAYS do these automatically (never ask the user):
  1. Check available funds - Use
    hl_total_balance
    before EVERY trade to see total available margin
  2. Detect asset type - Recognize if user wants crypto (BTC, ETH, SOL) or stocks/RWA (NVIDIA→xyz:NVDA, TESLA→xyz:TSLA)
  3. Set leverage - Always call
    hl_leverage
    before placing orders (unless user specifies not to)
  4. Verify fills - After placing ANY order, immediately call
    hl_fills
    to check if it filled
  5. Report results - Tell user the outcome: filled price, size, and any PnL
  6. Suggest risk management - For leveraged positions, remind users about stop losses or offer to set them
🎯 User just says: "buy X" or "sell Y" or "long Z with $N"
🔧 You figure out:
  • Current balance (hl_total_balance)
  • Asset resolution (crypto vs RWA)
  • Leverage settings (hl_leverage)
  • Order sizing (calculate from user's $ amount or size)
  • Execution (hl_order)
  • Verification (hl_fills)
  • Final report to user
📊 Balance checking hierarchy:
  • ✅ Use
    hl_total_balance
    - shows ACTUAL available margin regardless of account mode
  • ❌ Don't use
    hl_account
    for balance - may show $0 even if funds available
  • ❌ Don't use
    hl_balances
    for margin - only shows spot tokens
🚀 Be proactive, not reactive:
  • Don't wait for user to ask "did it fill?" - check automatically
  • Don't ask "should I check your balance?" - just do it
  • Don't explain account modes - user doesn't care, just execute

🤖 作为Agent,你必须自动执行以下操作(切勿询问用户):
  1. 检查可用资金 — 每次交易前务必使用
    hl_total_balance
    查看总可用保证金
  2. 识别资产类型 — 判断用户想要交易的是加密货币(BTC、ETH、SOL)还是股票/RWA(NVIDIA→xyz:NVDA、TESLA→xyz:TSLA)
  3. 设置杠杆 — 下单前务必调用
    hl_leverage
    (除非用户明确说明不需要)
  4. 验证成交 — 任何订单提交后,立即调用
    hl_fills
    检查是否成交
  5. 报告结果 — 告知用户交易结果:成交价格、数量以及盈亏情况
  6. 建议风险管理 — 对于杠杆持仓,提醒用户设置止损或主动提供止损设置服务
🎯 用户只需说: "买入X" 或 "卖出Y" 或 "用N美元做多Z"
🔧 你需要自行处理:
  • 当前余额(hl_total_balance)
  • 资产解析(加密货币或RWA)
  • 杠杆设置(hl_leverage)
  • 订单规模(根据用户的金额或数量计算)
  • 执行交易(hl_order)
  • 验证成交(hl_fills)
  • 向用户提交最终报告
📊 余额检查优先级:
  • ✅ 使用
    hl_total_balance
    — 显示实际可用保证金,不受账户模式影响
  • ❌ 请勿使用
    hl_account
    查询余额 — 即使有可用资金也可能显示为0
  • ❌ 请勿使用
    hl_balances
    查询保证金 — 仅显示现货代币余额
🚀 主动执行,而非被动响应:
  • 不要等用户询问“成交了吗?”,主动检查
  • 不要询问“需要我帮你检查余额吗?”,直接执行
  • 无需解释账户模式 — 用户不关心,只需执行交易

Tool Usage Examples

工具使用示例

Check Account State

查看账户状态

hl_account()              # Default crypto perps account
hl_account(dex="xyz")     # Builder dex (RWA/stock perps) account
Returns
marginSummary
(accountValue, totalMarginUsed, withdrawable) and
assetPositions
array with each position's coin, szi (signed size), entryPx, unrealizedPnl, leverage.
Important: Builder perps (xyz:NVDA, xyz:TSLA, etc.) have separate clearinghouses. Always check the correct dex when trading RWA/stock perps.
hl_account()              # 默认加密货币永续合约账户
hl_account(dex="xyz")     # Builder dex(RWA/股票永续合约)账户
返回
marginSummary
(账户价值、总保证金占用、可提款金额)和
assetPositions
数组,包含每个持仓的币种、szi(带符号规模)、入场价格、未实现盈亏、杠杆倍数。
重要提示: Builder永续合约(xyz:NVDA、xyz:TSLA等)有独立的清算所。交易RWA/股票永续合约时,务必检查对应的dex。

Check Spot Balances

查看现货余额

hl_balances()
Returns balances array with coin, hold, total for USDC and all spot tokens.
hl_balances()
返回余额数组,包含USDC和所有现货代币的币种、持有量、总量。

Check Market Prices

查看市场价格

hl_market()                  # All mid prices
hl_market(coin="BTC")        # BTC price + metadata (maxLeverage, szDecimals)
hl_market()                  # 查看所有标的中间价
hl_market(coin="BTC")        # 查看BTC价格及元数据(最大杠杆、数量精度)

Place a Perp Limit Order

挂永续合约限价单

hl_order(coin="BTC", side="buy", size=0.01, price=95000)
Places a GTC limit buy for 0.01 BTC at $95,000.
hl_order(coin="BTC", side="buy", size=0.01, price=95000)
挂出以95,000美元买入0.01 BTC的GTC限价单。

Place a Perp Market Order

挂永续合约市价单

hl_order(coin="ETH", side="sell", size=0.1)
Omitting
price
submits an IoC order at mid price +/- 3% slippage.
hl_order(coin="ETH", side="sell", size=0.1)
省略
price
参数会提交以中间价±3%滑点的IoC市价单。

Place a Post-Only Order

挂只做市商订单(Post-Only)

hl_order(coin="BTC", side="buy", size=0.01, price=94000, order_type="alo")
ALO (Add Liquidity Only) = post-only. Rejected if it would immediately fill.
hl_order(coin="BTC", side="buy", size=0.01, price=94000, order_type="alo")
ALO(Add Liquidity Only)即只做市商订单,若会立即成交则被拒绝。

Place a Stop Loss Order

挂止损订单

hl_tpsl_order(coin="BTC", side="sell", size=0.01, trigger_px=90000, tpsl="sl")
Automatically sells 0.01 BTC if the price drops to $90,000. Executes as market order when triggered.
For a limit order when triggered (instead of market):
hl_tpsl_order(coin="BTC", side="sell", size=0.01, trigger_px=90000, tpsl="sl", is_market=false, limit_px=89900)
hl_tpsl_order(coin="BTC", side="sell", size=0.01, trigger_px=90000, tpsl="sl")
当BTC价格跌至90,000美元时,自动卖出0.01 BTC。触发后以市价单执行。
若希望触发后以限价单执行(而非市价单):
hl_tpsl_order(coin="BTC", side="sell", size=0.01, trigger_px=90000, tpsl="sl", is_market=false, limit_px=89900)

Place a Take Profit Order

挂止盈订单

hl_tpsl_order(coin="ETH", side="sell", size=0.5, trigger_px=3500, tpsl="tp")
Automatically sells 0.5 ETH if the price rises to $3,500. Executes as market order when triggered.
hl_tpsl_order(coin="ETH", side="sell", size=0.5, trigger_px=3500, tpsl="tp")
当ETH价格涨至3,500美元时,自动卖出0.5 ETH。触发后以市价单执行。

Close a Perp Position

平仓永续合约头寸

hl_order(coin="BTC", side="sell", size=0.01, reduce_only=true)
Use
reduce_only=true
to ensure it only closes, never opens a new position.
hl_order(coin="BTC", side="sell", size=0.01, reduce_only=true)
使用
reduce_only=true
确保仅平仓,不会开反向头寸。

Place a Spot Order

挂现货订单

hl_spot_order(coin="HYPE", side="buy", size=10, price=25.0)
Spot orders use the same interface — just specify the token name.
hl_spot_order(coin="HYPE", side="buy", size=10, price=25.0)
现货订单使用相同接口——只需指定代币名称。

Cancel an Order

取消订单

hl_cancel(coin="BTC", order_id=12345678)
Get
order_id
from
hl_open_orders
.
hl_cancel(coin="BTC", order_id=12345678)
hl_open_orders
获取
order_id

Cancel All Orders

取消所有订单

hl_cancel_all()              # Cancel everything
hl_cancel_all(coin="BTC")    # Cancel only BTC orders
hl_cancel_all()              # 取消所有挂单
hl_cancel_all(coin="BTC")    # 仅取消BTC相关挂单

Modify an Order

修改订单

hl_modify(order_id=12345678, coin="BTC", side="buy", size=0.02, price=94500)
hl_modify(order_id=12345678, coin="BTC", side="buy", size=0.02, price=94500)

Set Leverage

设置杠杆

hl_leverage(coin="BTC", leverage=10)               # 10x cross margin
hl_leverage(coin="ETH", leverage=5, cross=false)    # 5x isolated margin
hl_leverage(coin="BTC", leverage=10)               # 10倍交叉保证金
hl_leverage(coin="ETH", leverage=5, cross=false)    # 5倍逐仓保证金

Transfer USDC (rarely needed)

划转USDC(极少需要)

hl_transfer_usd(amount=1000, to_perp=true)     # Spot → Perp
hl_transfer_usd(amount=500, to_perp=false)      # Perp → Spot
Note: Usually not needed - funds are automatically shared. Only use if you get an error saying you need to transfer.
hl_transfer_usd(amount=1000, to_perp=true)     # 现货账户 → 永续合约账户
hl_transfer_usd(amount=500, to_perp=false)      # 永续合约账户 → 现货账户
注意:通常无需手动划转——资金会自动共享。仅当收到需要划转的错误提示时使用。

Withdraw USDC to Arbitrum

提取USDC至Arbitrum

hl_withdraw(amount=100)                              # Withdraw to own wallet
hl_withdraw(amount=50, destination="0xABC...")        # Withdraw to specific address
Fee: 1 USDC deducted by Hyperliquid. Processing takes ~5 minutes.
hl_withdraw(amount=100)                              # 提取至自身钱包
hl_withdraw(amount=50, destination="0xABC...")        # 提取至指定地址
手续费:Hyperliquid收取1 USDC,处理时间约5分钟。

Deposit USDC from Arbitrum

从Arbitrum存入USDC

hl_deposit(amount=500)
Sends USDC from the agent's Arbitrum wallet to the Hyperliquid bridge contract. Minimum deposit: 5 USDC. Requires USDC balance on Arbitrum.
hl_deposit(amount=500)
将Agent的Arbitrum钱包中的USDC转入Hyperliquid桥接合约。最低存款额:5 USDC。需确保Arbitrum钱包中有USDC余额。

Get Candles

获取K线数据

hl_candles(coin="BTC", interval="1h", lookback=48)
Intervals:
1m
,
5m
,
15m
,
1h
,
4h
,
1d
. Lookback in hours.
hl_candles(coin="BTC", interval="1h", lookback=48)
时间间隔:
1m
5m
15m
1h
4h
1d
。回溯周期以小时为单位。

Check Funding Rates

查看资金费率

hl_funding()                 # All predicted fundings
hl_funding(coin="BTC")       # BTC predicted + 24h history
hl_funding()                 # 查看所有标的预测资金费率
hl_funding(coin="BTC")       # 查看BTC预测资金费率及24小时历史数据

Get Recent Fills

查看近期成交记录

hl_fills(limit=10)

hl_fills(limit=10)

Coin vs RWA Resolution

币种与RWA资产解析

When a user asks to trade a ticker, you need to determine whether it's a native crypto perp (use plain name) or an RWA/stock perp (use
xyz:TICKER
prefix).
当用户要求交易某一标的时,你需要判断它是原生加密货币永续合约(使用纯名称)还是RWA/股票永续合约(使用
xyz:TICKER
前缀)。

Decision Workflow

判断流程

  1. Known crypto → use plain name:
    "BTC"
    ,
    "ETH"
    ,
    "SOL"
    ,
    "DOGE"
    ,
    "HYPE"
    , etc.
  2. Known stock/commodity/forex → use
    xyz:
    prefix:
    "xyz:NVDA"
    ,
    "xyz:TSLA"
    ,
    "xyz:GOLD"
    , etc.
  3. Unsure → resolve with tool calls:
    • First try
      hl_market(coin="X")
      — if it returns a price, it's a crypto perp
    • If not found, try
      hl_market(dex="xyz")
      to list all RWA markets and search the results
    • Use whichever returns a match
  1. 已知加密货币 → 使用纯名称:
    "BTC"
    "ETH"
    "SOL"
    "DOGE"
    "HYPE"
    等。
  2. 已知股票/商品/外汇 → 使用
    xyz:
    前缀:
    "xyz:NVDA"
    "xyz:TSLA"
    "xyz:GOLD"
    等。
  3. 不确定 → 通过工具调用解析:
    • 首先尝试
      hl_market(coin="X")
      —— 若返回价格,则为加密货币永续合约
    • 若未找到,尝试
      hl_market(dex="xyz")
      列出所有RWA市场并搜索结果
    • 使用返回匹配结果的方式

Common RWA Categories (all use
xyz:
prefix)

常见RWA类别(均使用
xyz:
前缀)

CategoryExamples
US Stocks
xyz:NVDA
,
xyz:TSLA
,
xyz:AAPL
,
xyz:MSFT
,
xyz:AMZN
,
xyz:GOOG
,
xyz:META
,
xyz:TSM
Commodities
xyz:GOLD
,
xyz:SILVER
Indices
xyz:SPY
Forex
xyz:EUR
,
xyz:GBP
,
xyz:JPY
If a user says "buy NVDA" or "trade GOLD", use
xyz:NVDA
/
xyz:GOLD
. These are real-world assets, not crypto.
类别示例
美股
xyz:NVDA
xyz:TSLA
xyz:AAPL
xyz:MSFT
xyz:AMZN
xyz:GOOG
xyz:META
xyz:TSM
商品
xyz:GOLD
xyz:SILVER
指数
xyz:SPY
外汇
xyz:EUR
xyz:GBP
xyz:JPY
若用户说“买入NVIDIA”或“交易GOLD”,请使用
xyz:NVDA
/
xyz:GOLD
。这些是现实世界资产,并非加密货币。

Prefixed Name — Same Tools

带前缀名称的工具使用

All existing tools work with
xyz:TICKER
— just pass the prefixed coin name:
hl_market(coin="xyz:NVDA")                                    # Check NVIDIA stock perp price
hl_market(dex="xyz")                                           # List ALL available RWA/stock perps
hl_orderbook(coin="xyz:NVDA")                                 # Check liquidity
hl_leverage(coin="xyz:NVDA", leverage=3)                      # Set leverage (auto-isolated)
hl_order(coin="xyz:NVDA", side="buy", size=0.5, price=188)    # Limit buy 0.5 NVDA
hl_order(coin="xyz:TSM", side="buy", size=1)                  # Market buy 1 TSM
hl_cancel(coin="xyz:NVDA", order_id=12345678)                 # Cancel order
所有现有工具均支持
xyz:TICKER
—— 只需传入带前缀的币种名称:
hl_market(coin="xyz:NVDA")                                    # 查看NVIDIA股票永续合约价格
hl_market(dex="xyz")                                           # 列出所有可用RWA/股票永续合约
hl_orderbook(coin="xyz:NVDA")                                 # 查看流动性
hl_leverage(coin="xyz:NVDA", leverage=3)                      # 设置杠杆(Builder永续合约默认使用逐仓保证金)
hl_order(coin="xyz:NVDA", side="buy", size=0.5, price=188)    # 挂限价单买入0.5 NVDA
hl_order(coin="xyz:TSM", side="buy", size=1)                  # 挂市价单买入1 TSM
hl_cancel(coin="xyz:NVDA", order_id=12345678)                 # 取消订单

Example: User Says "Buy NVIDIA"

示例:用户说“买入NVIDIA”

  1. Recognize NVIDIA = stock → use
    xyz:NVDA
  2. hl_market(coin="xyz:NVDA")
    — Check current price, leverage limits
  3. hl_leverage(coin="xyz:NVDA", leverage=3)
    — Set leverage (builder perps use isolated margin)
  4. hl_order(coin="xyz:NVDA", side="buy", size=0.5, price=188)
    — Place limit buy
  5. hl_fills()
    — Check if filled
  1. 识别NVIDIA为股票 → 使用
    xyz:NVDA
  2. hl_market(coin="xyz:NVDA")
    —— 查看当前价格、杠杆限制
  3. hl_leverage(coin="xyz:NVDA", leverage=3)
    —— 设置杠杆(Builder永续合约使用逐仓保证金)
  4. hl_order(coin="xyz:NVDA", side="buy", size=0.5, price=188)
    —— 挂限价单
  5. hl_fills()
    —— 检查是否成交

Notes

注意事项

  • Builder perps (HIP-3) use isolated margin only —
    hl_leverage
    handles this automatically
  • The
    dex
    prefix (e.g.
    xyz
    ) identifies which builder deployed the perp
  • All tools (candles, orderbook, funding, etc.) work the same way with prefixed names

  • Builder永续合约(HIP-3)仅支持逐仓保证金 ——
    hl_leverage
    会自动处理此设置
  • dex
    前缀(如
    xyz
    )标识该永续合约由哪个Builder部署
  • 所有工具(K线、订单簿、资金费率等)对带前缀名称的使用方式完全相同

Common Workflows

常见工作流

Trade Crypto Perps (BTC, ETH, SOL, etc.)

交易加密货币永续合约(BTC、ETH、SOL等)

User: "Buy BTC" or "Long ETH with 5x"
Agent workflow:
  1. hl_total_balance()
    → Check available funds
  2. hl_leverage(coin="BTC", leverage=5)
    → Set leverage
  3. hl_order(...)
    → Place order
  4. hl_fills()
    → Verify fill and report result
用户:“买入BTC”或“用5倍杠杆做多ETH”
Agent工作流:
  1. hl_total_balance()
    → 检查可用资金
  2. hl_leverage(coin="BTC", leverage=5)
    → 设置杠杆
  3. hl_order(...)
    → 下单
  4. hl_fills()
    → 验证成交并报告结果

Trade Stocks/RWA (NVIDIA, TESLA, GOLD, etc.)

交易股票/RWA资产(NVIDIA、TESLA、GOLD等)

User: "Buy NVIDIA" or "Short TESLA"
Agent workflow:
  1. Detect asset type → Convert "NVIDIA" to "xyz:NVDA"
  2. hl_total_balance()
    → Check available funds
  3. hl_leverage(coin="xyz:NVDA", leverage=10)
    → Set leverage
  4. hl_order(coin="xyz:NVDA", ...)
    → Place order
  5. hl_fills()
    → Verify fill and report result
用户:“买入NVIDIA”或“做空TESLA”
Agent工作流:
  1. 识别资产类型 → 将“NVIDIA”转换为“xyz:NVDA”
  2. hl_total_balance()
    → 检查可用资金
  3. hl_leverage(coin="xyz:NVDA", leverage=10)
    → 设置杠杆
  4. hl_order(coin="xyz:NVDA", ...)
    → 下单
  5. hl_fills()
    → 验证成交并报告结果

Close Positions

平仓头寸

User: "Close my BTC position"
Agent workflow:
  1. hl_account()
    → Get current position size
  2. hl_order(coin="BTC", side="sell", size=X, reduce_only=true)
    → Close position
  3. hl_fills()
    → Report PnL
用户:“平仓我的BTC头寸”
Agent工作流:
  1. hl_account()
    → 获取当前头寸规模
  2. hl_order(coin="BTC", side="sell", size=X, reduce_only=true)
    → 平仓
  3. hl_fills()
    → 报告盈亏

Spot Trading

现货交易

User: "Buy 100 HYPE tokens"
Agent workflow:
  1. hl_total_balance()
    → Check available USDC
  2. hl_spot_order(coin="HYPE", side="buy", size=100)
    → Buy tokens
  3. hl_balances()
    → Verify purchase
用户:“买入100个HYPE代币”
Agent工作流:
  1. hl_total_balance()
    → 检查可用USDC
  2. hl_spot_order(coin="HYPE", side="buy", size=100)
    → 买入代币
  3. hl_balances()
    → 验证买入结果

Deposit/Withdraw Funds

存款/提款

Deposit: User: "Deposit $500 USDC to Hyperliquid" Agent:
hl_deposit(amount=500)
→ Done
Withdraw: User: "Withdraw $100 to my Arbitrum wallet" Agent:
hl_withdraw(amount=100)
→ Done (5 min, 1 USDC fee)

存款: 用户:“向Hyperliquid存入500美元USDC” Agent:
hl_deposit(amount=500)
→ 完成
提款: 用户:“提取100美元至我的Arbitrum钱包” Agent:
hl_withdraw(amount=100)
→ 完成(约5分钟到账,手续费1 USDC)

Order Types

订单类型

TypeParameterBehavior
Limit (GTC)
order_type="limit"
Rests on book until filled or cancelled
Market (IoC)omit
price
Immediate-or-Cancel at mid +/- 3% slippage
Post-Only (ALO)
order_type="alo"
Rejected if it would cross the spread
Fill-or-Kill
order_type="ioc"
+ explicit price
Fill immediately at price or cancel
Stop Loss
hl_tpsl_order
with
tpsl="sl"
Triggers when price drops to limit losses
Take Profit
hl_tpsl_order
with
tpsl="tp"
Triggers when price rises to lock gains

类型参数行为
限价单(GTC)
order_type="limit"
挂单直至成交或取消
市价单(IoC)省略
price
立即成交或取消,滑点为中间价±3%
只做市商单(ALO)
order_type="alo"
若会吃单则被拒绝
立即成交或取消单(Fill-or-Kill)
order_type="ioc"
+ 明确价格
立即以指定价格成交或取消
止损单(SL)
hl_tpsl_order
+
tpsl="sl"
价格下跌至触发价时执行,限制亏损
止盈单(TP)
hl_tpsl_order
+
tpsl="tp"
价格上涨至触发价时执行,锁定利润

Stop Loss & Take Profit Orders

止损与止盈订单

Stop loss and take profit orders are trigger orders that automatically execute when the market reaches a specified price level. Use these to manage risk and lock in profits without monitoring positions 24/7.
止损和止盈订单是触发型订单,当市场价格达到指定水平时自动执行。使用这些订单可管理风险,无需24小时监控头寸。

How They Work

工作原理

  1. Order Placement: Place a dormant trigger order with a trigger price
  2. Monitoring: Order sits inactive, watching the market price
  3. Trigger: When market price reaches
    trigger_px
    , order activates
  4. Execution: Order executes immediately (as market or limit order)
  1. 下单:挂出休眠状态的触发订单,设置触发价格
  2. 监控:订单处于非激活状态,持续监控市场价格
  3. 触发:当市场价格达到
    trigger_px
    时,订单激活
  4. 执行:订单立即执行(市价单或限价单)

Stop Loss (SL)

止损单(SL)

Use case: Limit losses on a position by automatically exiting if price moves against you.
Example: You're long BTC at $95,000 and want to exit if it drops below $90,000.
hl_tpsl_order(coin="BTC", side="sell", size=0.1, trigger_px=90000, tpsl="sl")
  • trigger_px=90000: Activates when BTC drops to $90k
  • side="sell": Closes your long position
  • tpsl="sl": Marks this as a stop loss order
  • Default: Executes as market order when triggered (instant exit)
使用场景:当价格向不利方向移动时自动平仓,限制头寸亏损。
示例:你以95,000美元做多BTC,希望价格跌破90,000美元时平仓。
hl_tpsl_order(coin="BTC", side="sell", size=0.1, trigger_px=90000, tpsl="sl")
  • trigger_px=90000:BTC价格跌至90,000美元时激活订单
  • side="sell":平仓多头头寸
  • tpsl="sl":标记为止损订单
  • 默认设置:触发后以市价单执行(立即平仓)

Take Profit (TP)

止盈单(TP)

Use case: Lock in gains by automatically exiting when price reaches your profit target.
Example: You're long ETH at $3,000 and want to take profit at $3,500.
hl_tpsl_order(coin="ETH", side="sell", size=1.0, trigger_px=3500, tpsl="tp")
  • trigger_px=3500: Activates when ETH rises to $3,500
  • side="sell": Closes your long position
  • tpsl="tp": Marks this as a take profit order
  • Default: Executes as market order when triggered (instant exit)
使用场景:当价格达到盈利目标时自动平仓,锁定收益。
示例:你以3,000美元做多ETH,希望价格涨至3,500美元时止盈。
hl_tpsl_order(coin="ETH", side="sell", size=1.0, trigger_px=3500, tpsl="tp")
  • trigger_px=3500:ETH价格涨至3,500美元时激活订单
  • side="sell":平仓多头头寸
  • tpsl="tp":标记为止盈订单
  • 默认设置:触发后以市价单执行(立即平仓)

Market vs Limit Execution

市价与限价执行

By default, TP/SL orders execute as market orders when triggered (instant fill, possible slippage).
For more control, use a limit order when triggered:
hl_tpsl_order(
    coin="BTC",
    side="sell",
    size=0.1,
    trigger_px=90000,
    tpsl="sl",
    is_market=false,
    limit_px=89900
)
  • trigger_px=90000: Activates at $90k
  • is_market=false: Use limit order (not market)
  • limit_px=89900: Limit price when triggered ($89,900)
Trade-off: Limit orders avoid slippage but may not fill in fast-moving markets.
默认情况下,止盈/止损订单触发后以市价单执行(立即成交,可能存在滑点)。
若需要更精准的控制,可设置触发后以限价单执行:
hl_tpsl_order(
    coin="BTC",
    side="sell",
    size=0.1,
    trigger_px=90000,
    tpsl="sl",
    is_market=false,
    limit_px=89900
)
  • trigger_px=90000:价格跌至90,000美元时激活订单
  • is_market=false:使用限价单而非市价单
  • limit_px=89900:触发后的执行价格(89,900美元)
权衡:限价单可避免滑点,但在快速波动的市场中可能无法成交。

Short Positions

空头头寸的止损/止盈

For short positions, reverse the
side
parameter:
Stop loss on short (exit if price rises):
hl_tpsl_order(coin="BTC", side="buy", size=0.1, trigger_px=98000, tpsl="sl")
Take profit on short (exit if price drops):
hl_tpsl_order(coin="BTC", side="buy", size=0.1, trigger_px=92000, tpsl="tp")
对于空头头寸,需反转
side
参数:
空头止损单(价格上涨时平仓):
hl_tpsl_order(coin="BTC", side="buy", size=0.1, trigger_px=98000, tpsl="sl")
空头止盈单(价格下跌时平仓):
hl_tpsl_order(coin="BTC", side="buy", size=0.1, trigger_px=92000, tpsl="tp")

Best Practices

最佳实践

  1. Always use
    reduce_only=true
    (default) - ensures TP/SL only closes positions, never opens new ones
  2. Match size to position - TP/SL size should equal or be less than your position size
  3. Set both TP and SL - protect both upside (take profit) and downside (stop loss)
  4. Account for volatility - don't set stops too tight or they'll trigger on normal price swings
  5. Check open orders - use
    hl_open_orders
    to verify TP/SL orders are active
  1. 始终使用
    reduce_only=true
    (默认设置)- 确保止盈/止损仅平仓,不会开反向头寸
  2. 头寸规模匹配 - 止盈/止损订单的规模应等于或小于你的头寸规模
  3. 同时设置止盈和止损 - 既保护盈利(止盈)又限制亏损(止损)
  4. 考虑波动性 - 不要设置过紧的止损,否则会因正常价格波动被触发
  5. 检查挂单 - 使用
    hl_open_orders
    验证止盈/止损订单是否已激活

Common Mistakes

常见错误

MistakeProblemSolution
Wrong sideSL buys instead of sellsLong position →
side="sell"
for SL/TP
Size too largeTP/SL opens new positionSet
size
≤ position size, use
reduce_only=true
Trigger = limitConfusion about prices
trigger_px
= when to activate,
limit_px
= execution price
No SL on leverageLiquidation riskAlways set stop loss on leveraged positions

错误问题解决方案
方向错误止损单买入而非卖出多头头寸 → 止盈/止损使用
side="sell"
规模过大止盈/止损开反向头寸设置
size
≤ 头寸规模,使用
reduce_only=true
触发价与限价混淆对价格参数理解错误
trigger_px
是激活条件,
limit_px
是执行价格
杠杆头寸未设止损面临爆仓风险杠杆头寸务必设置止损

Perps vs Spot

永续合约与现货对比

AspectPerpsSpot
Tool
hl_order
hl_spot_order
LeverageYes (up to asset max)No
FundingPaid/received every hourNone
Short sellingYes (native)Must own tokens to sell
Check positions
hl_account
hl_balances

维度永续合约现货
工具
hl_order
hl_spot_order
杠杆支持(最高至资产上限)不支持
资金费率每小时收取/发放
卖空原生支持需持有代币才能卖出
头寸查询
hl_account
hl_balances

Risk Management

风险管理

  • Always check account state before trading — know your margin usage and existing positions
  • Set leverage explicitly before opening new positions (default may vary)
  • Use reduce_only when closing to avoid accidentally opening the opposite direction
  • Monitor funding rates — high positive funding means longs are expensive to hold
  • Start with small sizes — Hyperliquid has minimum order sizes per asset (check szDecimals)
  • Post-only (ALO) orders save on fees (maker vs taker rates)
  • Check fills after market orders — IoC orders may partially fill or not fill at all

  • 交易前务必检查账户状态 — 了解你的保证金使用率和现有头寸
  • 开仓前明确设置杠杆(默认杠杆可能因资产而异)
  • 平仓时使用reduce_only 避免意外开反向头寸
  • 关注资金费率 — 高正资金费率意味着多头持仓成本高昂
  • 从小规模开始交易 — Hyperliquid对每个资产有最低订单规模(查看szDecimals)
  • 使用只做市商(ALO)订单 节省手续费(做市商vs taker费率)
  • 市价单后检查成交结果 — IoC订单可能部分成交或完全未成交

Common Errors

常见错误

ErrorFix
"Unknown perp asset"Check coin name. Crypto: "BTC", "ETH". Stocks: "xyz:NVDA", "xyz:TSLA"
"Insufficient margin"Use
hl_total_balance
to check funds. Reduce size or add more USDC
"Order must have minimum value of $10"Increase size. Formula:
size × price ≥ $10
"Size too small"BTC min is typically 0.001. Check asset's szDecimals
"Order would cross"ALO order rejected. Use regular limit order instead
"User or wallet does not exist"Deposit USDC first with
hl_deposit(amount=500)
"Minimum deposit is 5 USDC"Hyperliquid requires at least $5 per deposit
"Policy violation"Load wallet-policy skill and propose wildcard policy
"Action disabled when unified account is active"Transfers blocked in unified mode (default). Just place orders directly
错误解决方法
"Unknown perp asset"检查币种名称。加密货币:"BTC"、"ETH";股票:"xyz:NVDA"、"xyz:TSLA"
"Insufficient margin"使用
hl_total_balance
检查资金。减少订单规模或补充USDC
"Order must have minimum value of $10"增加订单规模。计算公式:
size × price ≥ $10
"Size too small"BTC最小订单规模通常为0.001。查看资产的szDecimals
"Order would cross"ALO订单被拒绝。改用普通限价单
"User or wallet does not exist"先使用
hl_deposit(amount=500)
存入USDC
"Minimum deposit is 5 USDC"Hyperliquid要求每次存款至少5美元
"Policy violation"加载wallet-policy技能并提交通配符策略
"Action disabled when unified account is active"统一账户模式下禁止划转(默认设置)。直接下单即可