hyperliquid
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHyperliquid 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
账户与市场信息
| Tool | What it does |
|---|---|
| Check how much you can trade with (use this for balance checks!) |
| See your open positions and PnL |
| See your token holdings (USDC, HYPE, etc.) |
| Get current prices for crypto or stocks |
| Check order book depth and liquidity |
| See recent trade fills and execution prices |
| Get price charts (1m, 5m, 1h, 4h, 1d) |
| Check funding rates for perps |
| See pending orders |
| 工具 | 功能 |
|---|---|
| 查看可交易资金总量(请用此工具进行余额检查!) |
| 查看未平仓头寸和盈亏(PnL) |
| 查看代币持仓(USDC、HYPE等) |
| 获取加密货币或股票的当前价格 |
| 查看订单簿深度和流动性 |
| 查看近期成交记录和执行价格 |
| 获取价格K线图(1分钟、5分钟、1小时、4小时、1天) |
| 查看永续合约资金费率 |
| 查看挂单 |
Trading
交易操作
| Tool | What it does |
|---|---|
| Buy or sell perps (crypto/stocks) |
| Buy or sell spot tokens |
| Place stop loss or take profit orders |
| Set leverage (1x to asset max) |
| Cancel a specific order |
| Cancel all open orders |
| Change order price or size |
| 工具 | 功能 |
|---|---|
| 买卖永续合约(加密货币/股票) |
| 买卖现货代币 |
| 设置止损或止盈订单 |
| 设置杠杆(1倍至资产上限) |
| 取消指定订单 |
| 取消所有挂单 |
| 修改订单价格或数量 |
Funds
资金管理
| Tool | What it does |
|---|---|
| Add USDC from Arbitrum (min $5) |
| Send USDC to Arbitrum (1 USDC fee, ~5 min) |
| Move USDC between spot/perp (rarely needed) |
| 工具 | 功能 |
|---|---|
| 从Arbitrum转入USDC(最低5美元) |
| 将USDC转出至Arbitrum(手续费1 USDC,约5分钟到账) |
| 在现货/永续合约账户间划转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):
- Check available funds - Use before EVERY trade to see total available margin
hl_total_balance - Detect asset type - Recognize if user wants crypto (BTC, ETH, SOL) or stocks/RWA (NVIDIA→xyz:NVDA, TESLA→xyz:TSLA)
- Set leverage - Always call before placing orders (unless user specifies not to)
hl_leverage - Verify fills - After placing ANY order, immediately call to check if it filled
hl_fills - Report results - Tell user the outcome: filled price, size, and any PnL
- 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 - shows ACTUAL available margin regardless of account mode
hl_total_balance - ❌ Don't use for balance - may show $0 even if funds available
hl_account - ❌ Don't use for margin - only shows spot tokens
hl_balances
🚀 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,你必须自动执行以下操作(切勿询问用户):
- 检查可用资金 — 每次交易前务必使用查看总可用保证金
hl_total_balance - 识别资产类型 — 判断用户想要交易的是加密货币(BTC、ETH、SOL)还是股票/RWA(NVIDIA→xyz:NVDA、TESLA→xyz:TSLA)
- 设置杠杆 — 下单前务必调用(除非用户明确说明不需要)
hl_leverage - 验证成交 — 任何订单提交后,立即调用检查是否成交
hl_fills - 报告结果 — 告知用户交易结果:成交价格、数量以及盈亏情况
- 建议风险管理 — 对于杠杆持仓,提醒用户设置止损或主动提供止损设置服务
🎯 用户只需说: "买入X" 或 "卖出Y" 或 "用N美元做多Z"
🔧 你需要自行处理:
- 当前余额(hl_total_balance)
- 资产解析(加密货币或RWA)
- 杠杆设置(hl_leverage)
- 订单规模(根据用户的金额或数量计算)
- 执行交易(hl_order)
- 验证成交(hl_fills)
- 向用户提交最终报告
📊 余额检查优先级:
- ✅ 使用— 显示实际可用保证金,不受账户模式影响
hl_total_balance - ❌ 请勿使用查询余额 — 即使有可用资金也可能显示为0
hl_account - ❌ 请勿使用查询保证金 — 仅显示现货代币余额
hl_balances
🚀 主动执行,而非被动响应:
- 不要等用户询问“成交了吗?”,主动检查
- 不要询问“需要我帮你检查余额吗?”,直接执行
- 无需解释账户模式 — 用户不关心,只需执行交易
Tool Usage Examples
工具使用示例
Check Account State
查看账户状态
hl_account() # Default crypto perps account
hl_account(dex="xyz") # Builder dex (RWA/stock perps) accountReturns (accountValue, totalMarginUsed, withdrawable) and array with each position's coin, szi (signed size), entryPx, unrealizedPnl, leverage.
marginSummaryassetPositionsImportant: 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/股票永续合约)账户返回(账户价值、总保证金占用、可提款金额)和数组,包含每个持仓的币种、szi(带符号规模)、入场价格、未实现盈亏、杠杆倍数。
marginSummaryassetPositions重要提示: 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 submits an IoC order at mid price +/- 3% slippage.
pricehl_order(coin="ETH", side="sell", size=0.1)省略参数会提交以中间价±3%滑点的IoC市价单。
pricePlace 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 to ensure it only closes, never opens a new position.
reduce_only=truehl_order(coin="BTC", side="sell", size=0.01, reduce_only=true)使用确保仅平仓,不会开反向头寸。
reduce_only=truePlace 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 from .
order_idhl_open_ordershl_cancel(coin="BTC", order_id=12345678)从获取。
hl_open_ordersorder_idCancel All Orders
取消所有订单
hl_cancel_all() # Cancel everything
hl_cancel_all(coin="BTC") # Cancel only BTC ordershl_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 marginhl_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 → SpotNote: 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 addressFee: 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: , , , , , . Lookback in hours.
1m5m15m1h4h1dhl_candles(coin="BTC", interval="1h", lookback=48)时间间隔:、、、、、。回溯周期以小时为单位。
1m5m15m1h4h1dCheck Funding Rates
查看资金费率
hl_funding() # All predicted fundings
hl_funding(coin="BTC") # BTC predicted + 24h historyhl_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 prefix).
xyz:TICKER当用户要求交易某一标的时,你需要判断它是原生加密货币永续合约(使用纯名称)还是RWA/股票永续合约(使用前缀)。
xyz:TICKERDecision Workflow
判断流程
- Known crypto → use plain name: ,
"BTC","ETH","SOL","DOGE", etc."HYPE" - Known stock/commodity/forex → use prefix:
xyz:,"xyz:NVDA","xyz:TSLA", etc."xyz:GOLD" - Unsure → resolve with tool calls:
- First try — if it returns a price, it's a crypto perp
hl_market(coin="X") - If not found, try to list all RWA markets and search the results
hl_market(dex="xyz") - Use whichever returns a match
- First try
- 已知加密货币 → 使用纯名称:、
"BTC"、"ETH"、"SOL"、"DOGE"等。"HYPE" - 已知股票/商品/外汇 → 使用前缀:
xyz:、"xyz:NVDA"、"xyz:TSLA"等。"xyz:GOLD" - 不确定 → 通过工具调用解析:
- 首先尝试—— 若返回价格,则为加密货币永续合约
hl_market(coin="X") - 若未找到,尝试列出所有RWA市场并搜索结果
hl_market(dex="xyz") - 使用返回匹配结果的方式
- 首先尝试
Common RWA Categories (all use xyz:
prefix)
xyz:常见RWA类别(均使用xyz:
前缀)
xyz:| Category | Examples |
|---|---|
| US Stocks | |
| Commodities | |
| Indices | |
| Forex | |
If a user says "buy NVDA" or "trade GOLD", use/xyz:NVDA. These are real-world assets, not crypto.xyz:GOLD
| 类别 | 示例 |
|---|---|
| 美股 | |
| 商品 | |
| 指数 | |
| 外汇 | |
若用户说“买入NVIDIA”或“交易GOLD”,请使用/xyz:NVDA。这些是现实世界资产,并非加密货币。xyz:GOLD
Prefixed Name — Same Tools
带前缀名称的工具使用
All existing tools work with — just pass the prefixed coin name:
xyz:TICKERhl_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:TICKERhl_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”
- Recognize NVIDIA = stock → use
xyz:NVDA - — Check current price, leverage limits
hl_market(coin="xyz:NVDA") - — Set leverage (builder perps use isolated margin)
hl_leverage(coin="xyz:NVDA", leverage=3) - — Place limit buy
hl_order(coin="xyz:NVDA", side="buy", size=0.5, price=188) - — Check if filled
hl_fills()
- 识别NVIDIA为股票 → 使用
xyz:NVDA - —— 查看当前价格、杠杆限制
hl_market(coin="xyz:NVDA") - —— 设置杠杆(Builder永续合约使用逐仓保证金)
hl_leverage(coin="xyz:NVDA", leverage=3) - —— 挂限价单
hl_order(coin="xyz:NVDA", side="buy", size=0.5, price=188) - —— 检查是否成交
hl_fills()
Notes
注意事项
- Builder perps (HIP-3) use isolated margin only — handles this automatically
hl_leverage - The prefix (e.g.
dex) identifies which builder deployed the perpxyz - All tools (candles, orderbook, funding, etc.) work the same way with prefixed names
- Builder永续合约(HIP-3)仅支持逐仓保证金 —— 会自动处理此设置
hl_leverage - 前缀(如
dex)标识该永续合约由哪个Builder部署xyz - 所有工具(K线、订单簿、资金费率等)对带前缀名称的使用方式完全相同
Common Workflows
常见工作流
Trade Crypto Perps (BTC, ETH, SOL, etc.)
交易加密货币永续合约(BTC、ETH、SOL等)
User: "Buy BTC" or "Long ETH with 5x"
Agent workflow:
- → Check available funds
hl_total_balance() - → Set leverage
hl_leverage(coin="BTC", leverage=5) - → Place order
hl_order(...) - → Verify fill and report result
hl_fills()
用户:“买入BTC”或“用5倍杠杆做多ETH”
Agent工作流:
- → 检查可用资金
hl_total_balance() - → 设置杠杆
hl_leverage(coin="BTC", leverage=5) - → 下单
hl_order(...) - → 验证成交并报告结果
hl_fills()
Trade Stocks/RWA (NVIDIA, TESLA, GOLD, etc.)
交易股票/RWA资产(NVIDIA、TESLA、GOLD等)
User: "Buy NVIDIA" or "Short TESLA"
Agent workflow:
- Detect asset type → Convert "NVIDIA" to "xyz:NVDA"
- → Check available funds
hl_total_balance() - → Set leverage
hl_leverage(coin="xyz:NVDA", leverage=10) - → Place order
hl_order(coin="xyz:NVDA", ...) - → Verify fill and report result
hl_fills()
用户:“买入NVIDIA”或“做空TESLA”
Agent工作流:
- 识别资产类型 → 将“NVIDIA”转换为“xyz:NVDA”
- → 检查可用资金
hl_total_balance() - → 设置杠杆
hl_leverage(coin="xyz:NVDA", leverage=10) - → 下单
hl_order(coin="xyz:NVDA", ...) - → 验证成交并报告结果
hl_fills()
Close Positions
平仓头寸
User: "Close my BTC position"
Agent workflow:
- → Get current position size
hl_account() - → Close position
hl_order(coin="BTC", side="sell", size=X, reduce_only=true) - → Report PnL
hl_fills()
用户:“平仓我的BTC头寸”
Agent工作流:
- → 获取当前头寸规模
hl_account() - → 平仓
hl_order(coin="BTC", side="sell", size=X, reduce_only=true) - → 报告盈亏
hl_fills()
Spot Trading
现货交易
User: "Buy 100 HYPE tokens"
Agent workflow:
- → Check available USDC
hl_total_balance() - → Buy tokens
hl_spot_order(coin="HYPE", side="buy", size=100) - → Verify purchase
hl_balances()
用户:“买入100个HYPE代币”
Agent工作流:
- → 检查可用USDC
hl_total_balance() - → 买入代币
hl_spot_order(coin="HYPE", side="buy", size=100) - → 验证买入结果
hl_balances()
Deposit/Withdraw Funds
存款/提款
Deposit:
User: "Deposit $500 USDC to Hyperliquid"
Agent: → Done
hl_deposit(amount=500)Withdraw:
User: "Withdraw $100 to my Arbitrum wallet"
Agent: → Done (5 min, 1 USDC fee)
hl_withdraw(amount=100)存款:
用户:“向Hyperliquid存入500美元USDC”
Agent: → 完成
hl_deposit(amount=500)提款:
用户:“提取100美元至我的Arbitrum钱包”
Agent: → 完成(约5分钟到账,手续费1 USDC)
hl_withdraw(amount=100)Order Types
订单类型
| Type | Parameter | Behavior |
|---|---|---|
| Limit (GTC) | | Rests on book until filled or cancelled |
| Market (IoC) | omit | Immediate-or-Cancel at mid +/- 3% slippage |
| Post-Only (ALO) | | Rejected if it would cross the spread |
| Fill-or-Kill | | Fill immediately at price or cancel |
| Stop Loss | | Triggers when price drops to limit losses |
| Take Profit | | Triggers when price rises to lock gains |
| 类型 | 参数 | 行为 |
|---|---|---|
| 限价单(GTC) | | 挂单直至成交或取消 |
| 市价单(IoC) | 省略 | 立即成交或取消,滑点为中间价±3% |
| 只做市商单(ALO) | | 若会吃单则被拒绝 |
| 立即成交或取消单(Fill-or-Kill) | | 立即以指定价格成交或取消 |
| 止损单(SL) | | 价格下跌至触发价时执行,限制亏损 |
| 止盈单(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
工作原理
- Order Placement: Place a dormant trigger order with a trigger price
- Monitoring: Order sits inactive, watching the market price
- Trigger: When market price reaches , order activates
trigger_px - Execution: Order executes immediately (as market or limit order)
- 下单:挂出休眠状态的触发订单,设置触发价格
- 监控:订单处于非激活状态,持续监控市场价格
- 触发:当市场价格达到时,订单激活
trigger_px - 执行:订单立即执行(市价单或限价单)
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 parameter:
sideStop 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
最佳实践
- Always use (default) - ensures TP/SL only closes positions, never opens new ones
reduce_only=true - Match size to position - TP/SL size should equal or be less than your position size
- Set both TP and SL - protect both upside (take profit) and downside (stop loss)
- Account for volatility - don't set stops too tight or they'll trigger on normal price swings
- Check open orders - use to verify TP/SL orders are active
hl_open_orders
- 始终使用(默认设置)- 确保止盈/止损仅平仓,不会开反向头寸
reduce_only=true - 头寸规模匹配 - 止盈/止损订单的规模应等于或小于你的头寸规模
- 同时设置止盈和止损 - 既保护盈利(止盈)又限制亏损(止损)
- 考虑波动性 - 不要设置过紧的止损,否则会因正常价格波动被触发
- 检查挂单 - 使用验证止盈/止损订单是否已激活
hl_open_orders
Common Mistakes
常见错误
| Mistake | Problem | Solution |
|---|---|---|
| Wrong side | SL buys instead of sells | Long position → |
| Size too large | TP/SL opens new position | Set |
| Trigger = limit | Confusion about prices | |
| No SL on leverage | Liquidation risk | Always set stop loss on leveraged positions |
| 错误 | 问题 | 解决方案 |
|---|---|---|
| 方向错误 | 止损单买入而非卖出 | 多头头寸 → 止盈/止损使用 |
| 规模过大 | 止盈/止损开反向头寸 | 设置 |
| 触发价与限价混淆 | 对价格参数理解错误 | |
| 杠杆头寸未设止损 | 面临爆仓风险 | 杠杆头寸务必设置止损 |
Perps vs Spot
永续合约与现货对比
| Aspect | Perps | Spot |
|---|---|---|
| Tool | | |
| Leverage | Yes (up to asset max) | No |
| Funding | Paid/received every hour | None |
| Short selling | Yes (native) | Must own tokens to sell |
| Check positions | | |
| 维度 | 永续合约 | 现货 |
|---|---|---|
| 工具 | | |
| 杠杆 | 支持(最高至资产上限) | 不支持 |
| 资金费率 | 每小时收取/发放 | 无 |
| 卖空 | 原生支持 | 需持有代币才能卖出 |
| 头寸查询 | | |
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
常见错误
| Error | Fix |
|---|---|
| "Unknown perp asset" | Check coin name. Crypto: "BTC", "ETH". Stocks: "xyz:NVDA", "xyz:TSLA" |
| "Insufficient margin" | Use |
| "Order must have minimum value of $10" | Increase size. Formula: |
| "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 |
| "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" | 使用 |
| "Order must have minimum value of $10" | 增加订单规模。计算公式: |
| "Size too small" | BTC最小订单规模通常为0.001。查看资产的szDecimals |
| "Order would cross" | ALO订单被拒绝。改用普通限价单 |
| "User or wallet does not exist" | 先使用 |
| "Minimum deposit is 5 USDC" | Hyperliquid要求每次存款至少5美元 |
| "Policy violation" | 加载wallet-policy技能并提交通配符策略 |
| "Action disabled when unified account is active" | 统一账户模式下禁止划转(默认设置)。直接下单即可 |