perp-cli 0.4.8 → 0.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +44 -5
  2. package/dist/arb/reconcile.d.ts +28 -0
  3. package/dist/arb/reconcile.js +162 -0
  4. package/dist/commands/account.d.ts +1 -1
  5. package/dist/commands/account.js +300 -63
  6. package/dist/commands/agent.js +9 -5
  7. package/dist/commands/arb/index.js +243 -49
  8. package/dist/commands/arb-auto.js +67 -19
  9. package/dist/commands/arb.d.ts +2 -1
  10. package/dist/commands/arb.js +535 -131
  11. package/dist/commands/bot.js +207 -0
  12. package/dist/commands/funds.d.ts +4 -0
  13. package/dist/commands/funds.js +741 -0
  14. package/dist/commands/history.d.ts +2 -1
  15. package/dist/commands/history.js +508 -5
  16. package/dist/commands/manage.js +5 -3
  17. package/dist/commands/market.js +34 -1
  18. package/dist/commands/pnl.js +1 -1
  19. package/dist/commands/risk.d.ts +2 -0
  20. package/dist/commands/risk.js +56 -0
  21. package/dist/commands/settings.js +147 -0
  22. package/dist/commands/trade.d.ts +1 -1
  23. package/dist/commands/trade.js +241 -259
  24. package/dist/commands/wallet.d.ts +4 -0
  25. package/dist/commands/wallet.js +10 -0
  26. package/dist/config.d.ts +2 -2
  27. package/dist/config.js +11 -3
  28. package/dist/exchanges/hyperliquid-spot.d.ts +1 -0
  29. package/dist/exchanges/hyperliquid-spot.js +13 -21
  30. package/dist/exchanges/lighter-spot.js +13 -15
  31. package/dist/exchanges/lighter.js +82 -21
  32. package/dist/exchanges/pacifica.js +12 -0
  33. package/dist/execution-log.d.ts +1 -1
  34. package/dist/index.js +39 -123
  35. package/dist/mcp-server.js +43 -96
  36. package/dist/strategies/split-order.d.ts +49 -0
  37. package/dist/strategies/split-order.js +138 -0
  38. package/package.json +1 -1
  39. package/skills/perp-cli/SKILL.md +13 -26
  40. package/skills/perp-cli/references/agent-operations.md +19 -9
  41. package/skills/perp-cli/references/commands.md +38 -31
  42. package/skills/perp-cli/references/strategies.md +26 -16
  43. package/skills/perp-cli/scripts/funding-analysis.sh +2 -2
  44. package/skills/perp-cli/scripts/preflight.sh +1 -1
  45. package/skills/perp-cli/scripts/spot-perp-scan.sh +1 -1
@@ -12,11 +12,12 @@ perp --json market book <SYMBOL> # orderbook (bids/asks)
12
12
  perp --json market trades <SYMBOL> # recent trades
13
13
  perp --json market funding <SYMBOL> # funding rate history
14
14
  perp --json market kline <SYM> <INTERVAL> # OHLCV candles (1m,5m,15m,1h,4h,1d)
15
+ perp --json market hip3 # list HIP-3 deployed perp dexes (Hyperliquid only)
15
16
  ```
16
17
 
17
18
  ## Account (read-only, safe)
18
19
  ```bash
19
- perp --json account info # balance, equity, margin, PnL
20
+ perp --json account balance # perp balance + spot holdings + 24h funding (alias: account info)
20
21
  perp --json account positions # open positions
21
22
  perp --json account orders # open/pending orders
22
23
  perp --json account history # order history
@@ -24,7 +25,6 @@ perp --json account trades # trade fill history
24
25
  perp --json account funding-history # funding payments
25
26
  perp --json account pnl # profit & loss
26
27
  perp --json account margin <SYMBOL> # position margin info
27
- perp --json status # combined: balance + positions + orders
28
28
  perp --json portfolio # cross-exchange unified view
29
29
  ```
30
30
 
@@ -60,22 +60,29 @@ perp --json trade leverage <SYMBOL> <N> # set leverage
60
60
  # Advanced orders
61
61
  perp --json trade scale-tp <SYMBOL> --levels '<PRICE1>:<PCT>,<PRICE2>:<PCT>'
62
62
  perp --json trade scale-in <SYMBOL> <SIDE> --levels '<PRICE1>:<SIZE>,<PRICE2>:<SIZE>'
63
- perp --json trade trailing-stop <SYMBOL> # trailing stop with callback %
64
- perp --json trade twap <SYMBOL> <SIDE> <SIZE> <DURATION>
65
63
  perp --json trade pnl-track # real-time PnL tracker
64
+
65
+ # Split execution (orderbook-aware)
66
+ perp --json trade split <SYMBOL> <buy|sell> <USD> # split large order into depth-based slices
67
+ perp --json trade split <SYM> buy 5000 --max-slippage 0.5 --max-slices 5 --delay 2000 --min-slice 200
68
+ perp --json trade market <SYM> buy <SIZE> --split # split via market command flag
69
+ perp --json trade market <SYM> buy <SIZE> --split --max-slippage 0.5
66
70
  ```
67
71
 
68
- ## Deposit & Withdraw
72
+ ## Funds (Deposit, Withdraw, Transfer, Bridge)
69
73
  ```bash
70
- perp --json deposit pacifica <AMOUNT>
71
- perp --json deposit hyperliquid <AMOUNT>
72
- perp --json deposit lighter ethereum <AMOUNT> # L1 direct (min 1 USDC)
73
- perp --json deposit lighter cctp arbitrum <AMOUNT> # CCTP (min 5 USDC)
74
- perp --json deposit lighter info # all Lighter deposit routes
75
- perp --json withdraw pacifica <AMOUNT>
76
- perp --json withdraw hyperliquid <AMOUNT>
77
- perp --json deposit info # deposit instructions
78
- perp --json withdraw info # withdrawal instructions
74
+ perp --json funds deposit pacifica <AMOUNT>
75
+ perp --json funds deposit hyperliquid <AMOUNT>
76
+ perp --json funds deposit lighter ethereum <AMOUNT> # L1 direct (min 1 USDC)
77
+ perp --json funds deposit lighter cctp arbitrum <AMOUNT> # CCTP (min 5 USDC)
78
+ perp --json funds deposit lighter info # all Lighter deposit routes
79
+ perp --json funds withdraw pacifica <AMOUNT>
80
+ perp --json funds withdraw hyperliquid <AMOUNT>
81
+ perp --json funds withdraw lighter <AMOUNT>
82
+ perp --json funds transfer <AMOUNT> <ADDRESS> # HL internal transfer (instant)
83
+ perp --json funds bridge --from <CHAIN> --to <CHAIN> --amount <AMT> --recipient <ADDR> # CCTP bridge
84
+ perp --json funds bridge-status --hash <HASH> # check CCTP bridge status
85
+ perp --json funds info # combined deposit & withdrawal info
79
86
  ```
80
87
 
81
88
  ## Bridge (Cross-chain USDC)
@@ -105,10 +112,10 @@ perp --json arb spot-close <SYM> --spot-exch <hl|lt> # close spot+perp arb
105
112
  # HL spot uses U-tokens: BTC→UBTC, ETH→UETH, SOL→USOL (auto-resolved)
106
113
 
107
114
  # Other arb tools
108
- perp --json arb funding # detailed funding analysis
115
+ perp --json arb rates # funding rates across all DEXs (detailed)
116
+ perp --json arb prices # cross-exchange price gaps
109
117
  perp --json arb dex # HIP-3 cross-dex arb (Hyperliquid)
110
- perp --json gap show # cross-exchange price gaps
111
- # NOTE: 'arb rates' is deprecated — use 'arb scan' instead
118
+ # Deprecated: 'gap show' → use 'arb prices'; 'funding rates/spread' → use 'arb rates/scan'
112
119
  ```
113
120
 
114
121
  ## Wallet Management
@@ -130,30 +137,30 @@ perp --json risk liquidation-distance # % distance from liquidation for AL
130
137
  perp --json risk limits # view current risk limits
131
138
  perp --json risk limits --min-liq-distance 30 --max-leverage 5 # set risk limits
132
139
  perp --json risk check --notional 1000 --leverage 3 # pre-trade risk check
133
- perp --json health # exchange connectivity & latency
134
- perp --json analytics summary # trading performance
135
- perp --json analytics pnl # P&L breakdown
140
+ perp --json agent ping # exchange connectivity & latency
141
+ perp --json history summary # trading performance
142
+ perp --json history pnl # P&L breakdown by exchange
143
+ perp --json history funding # funding payment aggregation
144
+ perp --json history report # full performance report (summary + pnl + funding)
145
+ perp --json history perf --period daily # daily PnL breakdown (replaces daily-pnl)
146
+ perp --json history perf --period weekly # weekly PnL breakdown (replaces weekly-pnl)
147
+ perp --json history perf --period summary # performance summary stats
136
148
  perp --json history list # execution audit trail
137
149
  ```
138
150
 
139
- ## Automated Strategies
151
+ ## Automated Strategies (bot)
140
152
  ```bash
141
- perp --json run grid <SYMBOL> --range <PCT> --grids <N> --size <USD>
142
- perp --json run dca <SYMBOL> <SIDE> <AMOUNT> <INTERVAL>
143
- perp --json run funding-arb # auto funding arb
153
+ perp --json bot twap <SYMBOL> <SIDE> <SIZE> <DURATION> # TWAP execution
154
+ perp --json bot grid <SYMBOL> --range <PCT> --grids <N> --size <USD>
155
+ perp --json bot dca <SYMBOL> <SIDE> <AMOUNT> <INTERVAL>
156
+ perp --json bot trailing-stop <SYMBOL> # trailing stop with callback %
157
+ perp --json bot funding-arb # auto funding arb
144
158
  perp --json bot quick-grid <SYMBOL> # quick grid bot
145
159
  perp --json bot quick-arb # quick arb bot
146
160
  perp --json jobs list # list running jobs
147
161
  perp --json jobs stop <ID> # stop a job
148
162
  ```
149
163
 
150
- ## Alerts
151
- ```bash
152
- perp --json alert add # add price/funding/pnl/liquidation alert
153
- perp --json alert list # list active alerts
154
- perp --json alert remove <ID> # remove alert
155
- ```
156
-
157
164
  ## Command Discovery
158
165
  ```bash
159
166
  perp schema # Full CLI schema as JSON
@@ -202,19 +202,38 @@ perp --json -e <SHORT_EX> account positions # size must = X
202
202
  ```
203
203
  If sizes differ (partial fill, rounding), immediately adjust the larger position to match the smaller one.
204
204
 
205
- #### Step 3: Split Large Orders into Matched Chunks
205
+ #### Step 3: Split Large Orders with `trade split`
206
206
 
207
- If your desired size exceeds what the orderbooks can absorb at best ticks, split into chunks — but **every chunk must be a matched pair with identical size on both sides**:
207
+ For large orders, use the built-in orderbook-aware split execution instead of manual chunking:
208
208
 
209
+ ```bash
210
+ # Single exchange: split $5000 buy into depth-based slices
211
+ perp --json -e <EX> trade split <SYM> buy 5000
212
+
213
+ # With options
214
+ perp --json -e <EX> trade split <SYM> buy 5000 --max-slippage 0.5 --max-slices 5 --delay 2000
215
+
216
+ # Or use --split flag on market command
217
+ perp --json -e <EX> trade market <SYM> buy <SIZE> --split
209
218
  ```
210
- Chunk 1: buy 0.3 on Exchange A → sell 0.3 on Exchange B → verify both
211
- Chunk 2: buy 0.3 on Exchange A → sell 0.3 on Exchange B → verify both
212
- ... repeat until full size is executed
219
+
220
+ How it works:
221
+ 1. Fetches fresh orderbook before each slice
222
+ 2. Walks levels via `computeExecutableSize` to find fillable amount at target slippage
223
+ 3. Places IOC limit at worst acceptable price within slippage tolerance
224
+ 4. Waits for book to refresh, repeats until target filled or max slices reached
225
+
226
+ **For arb, both legs must still match.** Use `trade split` on each side independently with the same total USD, then verify sizes match:
227
+
228
+ ```
229
+ Leg A: perp --json -e <LONG_EX> trade split <SYM> buy 5000
230
+ Leg B: perp --json -e <SHORT_EX> trade split <SYM> sell 5000
231
+ → Verify positions, adjust if sizes differ
213
232
  ```
214
233
 
215
234
  **Rules:**
216
- 1. Re-check orderbook depth between chunks — liquidity changes
217
- 2. Each chunk: same size on both sides, no exceptions
235
+ 1. Each chunk re-checks orderbook depth — liquidity changes between slices
236
+ 2. For arb: same total USD on both sides, verify matched sizes after execution
218
237
  3. If one leg fails → STOP immediately, do NOT continue
219
238
  4. Assess exposure: retry the failed leg, or unwind the completed leg
220
239
  5. NEVER execute multiple orders on one side without matching the other
@@ -418,15 +437,6 @@ Or use TP/SL together:
418
437
  perp --json -e <EX> trade tp-sl <SYM> --tp <PRICE> --sl <PRICE>
419
438
  ```
420
439
 
421
- ### Monitoring Alerts
422
-
423
- Set up alerts so you get notified of dangerous conditions without polling:
424
- ```bash
425
- perp --json alert add -t margin --margin-pct 70 # alert when margin usage > 70%
426
- perp --json alert add -t price -s BTC --below 50000 --above 80000 # price boundaries
427
- perp --json alert add -t funding -s ETH --spread 50 # funding spread alert
428
- ```
429
-
430
440
  ### What to Track Over Time
431
441
  As you operate, build awareness of:
432
442
  - Which symbols consistently have the best funding spreads
@@ -62,7 +62,7 @@ EOF
62
62
  else
63
63
  # All symbols scan
64
64
  SCAN=$($PERP --json arb scan --mode all --min 0 2>/dev/null || echo '{"ok":false}')
65
- FUNDING_DETAIL=$($PERP --json arb funding 2>/dev/null || echo '{"ok":false}')
65
+ FUNDING_DETAIL=$($PERP --json arb rates 2>/dev/null || echo '{"ok":false}')
66
66
 
67
67
  if $JSON_MODE; then
68
68
  cat <<EOF
@@ -71,7 +71,7 @@ else
71
71
  "timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
72
72
  "topN": $TOP,
73
73
  "allOpportunities": $SCAN,
74
- "fundingDetail": $FUNDING_DETAIL
74
+ "ratesDetail": $FUNDING_DETAIL
75
75
  }
76
76
  EOF
77
77
  else
@@ -42,7 +42,7 @@ else
42
42
  fi
43
43
 
44
44
  # 3. Exchange connectivity
45
- HEALTH_OUT=$($PERP --json health 2>/dev/null || echo '{"ok":false}')
45
+ HEALTH_OUT=$($PERP --json agent ping 2>/dev/null || echo '{"ok":false}')
46
46
  if echo "$HEALTH_OUT" | grep -q '"ok":true'; then
47
47
  add_check "connectivity" "pass" "Exchanges reachable"
48
48
  else
@@ -39,7 +39,7 @@ fi
39
39
  SCAN_RESULT=$($PERP --json arb scan --mode "$MODE" --min "$MIN_SPREAD" 2>/dev/null || echo '{"ok":false}')
40
40
 
41
41
  # 3. Get exchange health for context
42
- HEALTH=$($PERP --json health 2>/dev/null || echo '{"ok":false}')
42
+ HEALTH=$($PERP --json agent ping 2>/dev/null || echo '{"ok":false}')
43
43
 
44
44
  if $JSON_MODE; then
45
45
  cat <<EOF