hyperliquid

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Hyperliquid Trading Skill

Hyperliquid交易技能

Full trading and portfolio management for Hyperliquid perpetual futures exchange.
为Hyperliquid永续期货交易所提供完整的交易和投资组合管理功能。

Prerequisites

前置条件

Install dependencies once:
bash
cd skills/hyperliquid/scripts && npm install
只需安装一次依赖:
bash
cd skills/hyperliquid/scripts && npm install

Authentication

身份验证

For read-only operations (balance, positions, prices):
  • Set
    HYPERLIQUID_ADDRESS
    environment variable
  • No private key needed
For trading operations:
  • Set
    HYPERLIQUID_PRIVATE_KEY
    environment variable
  • Address derived automatically from private key
Testnet:
  • Set
    HYPERLIQUID_TESTNET=1
    to use testnet
用于只读操作(余额、持仓、价格):
  • 设置
    HYPERLIQUID_ADDRESS
    环境变量
  • 无需私钥
用于交易操作:
  • 设置
    HYPERLIQUID_PRIVATE_KEY
    环境变量
  • 地址会自动从私钥派生
测试网:
  • 设置
    HYPERLIQUID_TESTNET=1
    以使用测试网

Core Operations

核心操作

Portfolio Monitoring

投资组合监控

Check balance:
bash
HYPERLIQUID_ADDRESS=0x... node scripts/hyperliquid.mjs balance
View positions with P&L:
bash
HYPERLIQUID_ADDRESS=0x... node scripts/hyperliquid.mjs positions
Check open orders:
bash
HYPERLIQUID_ADDRESS=0x... node scripts/hyperliquid.mjs orders
View trade history:
bash
HYPERLIQUID_ADDRESS=0x... node scripts/hyperliquid.mjs fills
Get price for a coin:
bash
node scripts/hyperliquid.mjs price BTC
查看余额:
bash
HYPERLIQUID_ADDRESS=0x... node scripts/hyperliquid.mjs balance
查看带盈亏的持仓:
bash
HYPERLIQUID_ADDRESS=0x... node scripts/hyperliquid.mjs positions
查看挂单:
bash
HYPERLIQUID_ADDRESS=0x... node scripts/hyperliquid.mjs orders
查看交易历史:
bash
HYPERLIQUID_ADDRESS=0x... node scripts/hyperliquid.mjs fills
查询币种价格:
bash
node scripts/hyperliquid.mjs price BTC

Trading Operations

交易操作

All trading commands require
HYPERLIQUID_PRIVATE_KEY
.
Place limit orders:
bash
undefined
所有交易命令都需要
HYPERLIQUID_PRIVATE_KEY
挂限价单:
bash
undefined

Buy 0.1 BTC at $45,000

以45,000美元买入0.1 BTC

HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs buy BTC 0.1 45000
HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs buy BTC 0.1 45000

Sell 1 ETH at $3,000

以3,000美元卖出1 ETH

HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs sell ETH 1 3000

**Market orders (with 5% slippage protection):**
```bash
HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs sell ETH 1 3000

**市价单(带5%滑点保护):**
```bash

Market buy 0.5 BTC

市价买入0.5 BTC

HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs market-buy BTC 0.5
HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs market-buy BTC 0.5

Market sell 2 ETH

市价卖出2 ETH

HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs market-sell ETH 2

**Cancel orders:**
```bash
HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs market-sell ETH 2

**撤单:**
```bash

Cancel specific order

撤销指定订单

HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs cancel BTC 12345
HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs cancel BTC 12345

Cancel all orders

撤销所有订单

HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs cancel-all
HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs cancel-all

Cancel all orders for specific coin

撤销指定币种的所有订单

HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs cancel-all BTC
undefined
HYPERLIQUID_PRIVATE_KEY=0x... node scripts/hyperliquid.mjs cancel-all BTC
undefined

Output Formatting

输出格式

All commands output JSON. Parse and format for chat display:
For balance/portfolio:
  • Show total equity, available balance
  • List positions with size, entry price, unrealized P&L
  • Summarize open orders
For trade execution:
  • Confirm order details before executing
  • Report order ID and status after execution
  • Show filled price if immediately executed
所有命令均输出JSON格式数据,可解析后用于聊天展示:
针对余额/投资组合:
  • 显示总权益、可用余额
  • 列出持仓的规模、入场价、未实现盈亏
  • 汇总当前挂单情况
针对交易执行:
  • 执行前确认交易参数
  • 执行后反馈订单ID和状态
  • 若立即成交则显示成交价格

Safety Guidelines

安全指南

Before executing trades:
  1. Confirm trade parameters with user (coin, size, direction, price)
  2. Show current price and position for context
  3. Calculate estimated cost/proceeds
Position sizing:
  • Warn if trade is >20% of account equity
  • Suggest appropriate sizes based on account balance
Price checks:
  • For limit orders, compare limit price to current market price
  • Warn if limit price is >5% away from market (likely mistake)
执行交易前:
  1. 与用户确认交易参数(币种、规模、方向、价格)
  2. 展示当前价格和持仓作为参考
  3. 计算预估成本/收益
持仓规模:
  • 若交易金额占账户权益的比例>20%则发出警告
  • 根据账户余额建议合适的交易规模
价格检查:
  • 对于限价单,将限价与当前市价进行对比
  • 若限价与市价偏差>5%则发出警告(可能是操作失误)

Error Handling

错误处理

Common errors:
  • "Address required" → Set HYPERLIQUID_ADDRESS or HYPERLIQUID_PRIVATE_KEY
  • "Private key required" → Trading needs HYPERLIQUID_PRIVATE_KEY
  • "Unknown coin" → Check available coins with
    meta
    command
  • HTTP errors → Check network connection and API status
When errors occur:
  • Show the error message to user
  • Suggest fixes (set env vars, check coin names, verify balance)
  • Don't retry trades automatically
常见错误:
  • "Address required" → 设置
    HYPERLIQUID_ADDRESS
    HYPERLIQUID_PRIVATE_KEY
  • "Private key required" → 交易操作需要
    HYPERLIQUID_PRIVATE_KEY
  • "Unknown coin" → 使用
    meta
    命令查询可用币种
  • HTTP错误 → 检查网络连接和API状态
发生错误时:
  • 向用户展示错误信息
  • 建议修复方案(设置环境变量、检查币种名称、验证余额)
  • 不要自动重试交易

Workflow Examples

工作流示例

"How's my Hyperliquid portfolio?"
  1. Run
    balance
    to get total equity
  2. Run
    positions
    to get open positions
  3. Format summary: equity, positions with P&L, total unrealized P&L
"Buy 0.5 BTC on Hyperliquid"
  1. Run
    price BTC
    to get current price
  2. Run
    balance
    to verify sufficient funds
  3. Confirm with user: "Buy 0.5 BTC at market? Current price: $X. Estimated cost: $Y"
  4. Execute
    market-buy BTC 0.5
  5. Report order result
"What's the current BTC price on Hyperliquid?"
  1. Run
    price BTC
  2. Format response: "BTC: $X on Hyperliquid"
"Close my ETH position"
  1. Run
    positions
    to get current ETH position size
  2. If long → market-sell, if short → market-buy
  3. Execute with position size
  4. Report result
“我的Hyperliquid投资组合情况如何?”
  1. 运行
    balance
    命令获取总权益
  2. 运行
    positions
    命令获取当前持仓
  3. 格式化汇总信息:权益、带盈亏的持仓、总未实现盈亏
“在Hyperliquid上买入0.5 BTC”
  1. 运行
    price BTC
    命令获取当前价格
  2. 运行
    balance
    命令验证资金是否充足
  3. 与用户确认:“以市价买入0.5 BTC?当前价格:$X。预估成本:$Y”
  4. 执行
    market-buy BTC 0.5
    命令
  5. 反馈订单结果
“Hyperliquid上当前BTC的价格是多少?”
  1. 运行
    price BTC
    命令
  2. 格式化回复:“Hyperliquid上BTC的价格为:$X”
“平仓我的ETH持仓”
  1. 运行
    positions
    命令获取当前ETH持仓规模
  2. 若为多头则执行市价卖出,若为空头则执行市价买入
  3. 以持仓规模执行交易
  4. 反馈结果

Advanced Features

高级功能

List all available coins:
bash
node scripts/hyperliquid.mjs meta
Query other addresses:
bash
undefined
列出所有可用币种:
bash
node scripts/hyperliquid.mjs meta
查询其他地址的信息:
bash
undefined

Check someone else's positions (read-only, public data)

查看他人的持仓(只读,公开数据)

node scripts/hyperliquid.mjs positions 0x1234...
undefined
node scripts/hyperliquid.mjs positions 0x1234...
undefined

Notes

注意事项

  • All sizes are in base currency (BTC, ETH, etc.)
  • Prices are in USD
  • Market orders use limit orders with 5% slippage protection
  • Hyperliquid uses perpetual futures, not spot trading
  • Check references/api.md for full API documentation
  • 所有规模均以基础币种(BTC、ETH等)为单位
  • 价格以美元为单位
  • 市价单使用带5%滑点保护的限价单实现
  • Hyperliquid采用永续期货,不支持现货交易
  • 查看references/api.md获取完整API文档