介绍
# Open Broker - Hyperliquid Trading CLI
在 Hyperliquid DEX 上执行交易操作,支持 builder 费用。
## 安装
```bash npm install -g openbroker ```
## 快速开始
```bash # 1. Setup (generates wallet, creates config, approves builder fee) openbroker setup
# 2. Fund your wallet with USDC on Arbitrum, then deposit at https://app.hyperliquid.xyz/
# 3. Start trading openbroker account openbroker buy --coin ETH --size 0.1 ```
## 命令参考
### 设置 ```bash openbroker setup # One-command setup (wallet + config + builder approval) openbroker approve-builder --check # Check builder fee status (for troubleshooting) ```
`setup` 命令处理所有事项: 1. 生成新钱包或使用现有私钥 2. 将配置保存到 `~/.openbroker/.env` 3. 自动批准 builder 费用(交易必需)
### 账户信息 ```bash openbroker account # Balance, equity, margin openbroker account --orders # Include open orders openbroker positions # Open positions with PnL openbroker positions --coin ETH # Specific coin ```
### 资金费率 ```bash openbroker funding --top 20 # Top 20 by funding rate openbroker funding --coin ETH # Specific coin ```
### 市场 ```bash openbroker markets --top 30 # Top 30 main perps openbroker markets --coin BTC # Specific coin ```
### 所有市场(永续 + 现货 + HIP-3) ```bash openbroker all-markets # Show all markets openbroker all-markets --type perp # Main perps only openbroker all-markets --type hip3 # HIP-3 perps only openbroker all-markets --type spot # Spot markets only openbroker all-markets --top 20 # Top 20 by volume ```
### 搜索市场(跨提供商查找资产) ```bash openbroker search --query GOLD # Find all GOLD markets openbroker search --query BTC # Find BTC across all providers openbroker search --query ETH --type perp # ETH perps only ```
### 现货市场 ```bash openbroker spot # Show all spot markets openbroker spot --coin PURR # Show PURR market info openbroker spot --balances # Show your spot balances openbroker spot --top 20 # Top 20 by volume ```
## 交易命令
### 市价单(快速) ```bash openbroker buy --coin ETH --size 0.1 openbroker sell --coin BTC --size 0.01 openbroker buy --coin SOL --size 5 --slippage 100 # Custom slippage (bps) ```
### 市价单(完整) ```bash openbroker market --coin ETH --side buy --size 0.1 openbroker market --coin BTC --side sell --size 0.01 --slippage 100 ```
### 限价单 ```bash openbroker limit --coin ETH --side buy --size 1 --price 3000 openbroker limit --coin SOL --side sell --size 10 --price 200 --tif ALO ```
### 为现有持仓设置止盈/止损 ```bash # Set take profit at $40, stop loss at $30 openbroker tpsl --coin HYPE --tp 40 --sl 30
# Set TP at +10% from entry, SL at entry (breakeven) openbroker tpsl --coin HYPE --tp +10% --sl entry
# Set only stop loss at -5% from entry openbroker tpsl --coin ETH --sl -5%
# Partial position TP/SL openbroker tpsl --coin ETH --tp 4000 --sl 3500 --size 0.5 ```
### 触发委托(独立止盈/止损) ```bash # Take profit: sell when price rises to $40 openbroker trigger --coin HYPE --side sell --size 0.5 --trigger 40 --type tp
# Stop loss: sell when price drops to $30 openbroker trigger --coin HYPE --side sell --size 0.5 --trigger 30 --type sl ```
### 撤销委托 ```bash openbroker cancel --all # Cancel all orders openbroker cancel --coin ETH # Cancel ETH orders only openbroker cancel --oid 123456 # Cancel specific order ```
## 高级执行
### TWAP(时间加权平均价格) ```bash # Execute 1 ETH buy over 1 hour (auto-calculates slices) openbroker twap --coin ETH --side buy --size 1 --duration 3600
# Custom intervals with randomization openbroker twap --coin BTC --side sell --size 0.5 --duration 1800 --intervals 6 --randomize 20 ```
### 分批买入/卖出(网格委托) ```bash # Place 5 buy orders ranging 2% below current price openbroker scale --coin ETH --side buy --size 1 --levels 5 --range 2
# Scale out with exponential distribution openbroker scale --coin BTC --side sell --size 0.5 --levels 4 --range 3 --distribution exponential --reduce ```
### 盈利委托(开仓 + 止盈 + 止损) ```bash # Long ETH with 3% take profit and 1.5% stop loss openbroker bracket --coin ETH --side buy --size 0.5 --tp 3 --sl 1.5
# Short with limit entry openbroker bracket --coin BTC --side sell --size 0.1 --entry limit --price 100000 --tp 5 --sl 2 ```
### 追单(跟随价格) ```bash # Chase buy with ALO orders until filled openbroker chase --coin ETH --side buy --size 0.5 --timeout 300
# Aggressive chase with tight offset openbroker chase --coin SOL --side buy --size 10 --offset 2 --timeout 60 ```
## 交易策略
### 资金费率套利 ```bash # Collect funding on ETH if rate > 25% annualized openbroker funding-arb --coin ETH --size 5000 --min-funding 25
# Run for 24 hours, check every 30 minutes openbroker funding-arb --coin BTC --size 10000 --duration 24 --check 30 --dry ```
### 网格交易 ```bash # ETH grid from $3000-$4000 with 10 levels, 0.1 ETH per level openbroker grid --coin ETH --lower 3000 --upper 4000 --grids 10 --size 0.1
# Accumulation grid (buys only) openbroker grid --coin BTC --lower 90000 --upper 100000 --grids 5 --size 0.01 --mode long ```
### DCA(定投) ```bash # Buy $100 of ETH every hour for 24 hours openbroker dca --coin ETH --amount 100 --interval 1h --count 24
# Invest $5000 in BTC over 30 days with daily purchases openbroker dca --coin BTC --total 5000 --interval 1d --count 30 ```
### 做市价差 ```bash # Market make ETH with 0.1 size, 10bps spread openbroker mm-spread --coin ETH --size 0.1 --spread 10
# Tighter spread with position limit openbroker mm-spread --coin BTC --size 0.01 --spread 5 --max-position 0.1 ```
### 仅挂单做市(ALO 委托) ```bash # Market make using ALO (post-only) orders - guarantees maker rebates openbroker mm-maker --coin HYPE --size 1 --offset 1
# Wider offset for volatile assets openbroker mm-maker --coin ETH --size 0.1 --offset 2 --max-position 0.5 ```
## 委托类型
### 限价单 vs 触发委托
**限价单** (`openbroker limit`): - 价格满足时立即执行 - 挂在订单簿上直到成交或撤销 - 低于当前价格的限价卖单会立即成交(taker) - 不适合用于止损
**触发委托** (`openbroker trigger`, `openbroker tpsl`): - 在达到触发价格前保持休眠状态 - 仅在价格触及触发水平时激活 - 设置止损和止盈的正确方式 - 不会提前成交
### 何时使用哪种方式
| 场景 | 命令 | |----------|---------| | 以低于市场的特定价格买入 | `openbroker limit` | | 以高于市场的特定价格卖出 | `openbroker limit` | | 止损(价格下跌时退出) | `openbroker trigger --type sl` | | 止盈(在目标价格退出) | `openbroker trigger --type tp` | | 为现有持仓添加止盈/止损 | `openbroker tpsl` |
## 通用参数
所有命令都支持 `--dry` 进行模拟运行(预览但不执行)。
| 参数 | 描述 | |----------|-------------| | `--coin` | 资产代码(ETH, BTC, SOL, HYPE 等) | | `--side` | 委托方向:`buy` 或 `sell` | | `--size` | 以基础资产计价的委托数量 | | `--price` | 限价 | | `--dry` | 预览而不执行 | | `--help` | 显示命令帮助 |
### 委托参数 | 参数 | 描述 | |----------|-------------| | `--trigger` | 触发价格(用于触发委托) | | `--type` | 触发类型:`tp` 或 `sl` | | `--slippage` | 滑点容忍度,单位为 bps(用于市价单) | | `--tif` | 订单有效期:GTC, IOC, ALO | | `--reduce` | 只减仓委托 |
### 止盈/止损 价格格式 | 格式 | 示例 | 描述 | |--------|---------|-------------| | 绝对值 | `--tp 40` | 价格为 40 美元 | | 向上百分比 | `--tp +10%` | 比入场价高 10% | | 向下百分比 | `--sl -5%` | 比入场价低 5% | | 入场价 | `--sl entry` | 盈亏平衡止损 |
## 配置
配置按优先级顺序从以下位置加载: 1. 环境变量 2. 当前目录下的 `.env` 3. `~/.openbroker/.env`(全局配置)
运行 `openbroker setup` 以交互方式创建全局配置。
| 变量 | 必填 | 描述 | |----------|----------|-------------| | `HYPERLIQUID_PRIVATE_KEY` | 是 | 钱包私钥(0x...) | | `HYPERLIQUID_NETWORK` | 否 | `mainnet`(默认)或 `testnet` | | `HYPERLIQUID_ACCOUNT_ADDRESS` | 否 | 用于 API 钱包 |
## 风险警告
- 始终先使用 `--dry` 预览委托 - 在测试网上从小额数量开始(`HYPERLIQUID_NETWORK=testnet`) - 监控持仓和平仓价格 - 使用 `--reduce` 仅用于平仓