High-performance terminal for trading on Hyperliquid, built in Rust.
BTC ETH SOL HYPE mainnet | ws:connected
+--------------------------+ +---------------------------+
| Candlestick Chart (1m-1D)| | Account Summary |
| with S/R levels | | Equity, margin, P&L |
+--------------------------+ +---------------------------+
| Orderbook (top of book) |
| asks/bids with depth |
+--------------------------+
| Positions |
| Open Orders |
+---------------------------------------------------------------+
:command [?] help
This is the open-source infrastructure skeleton of hl-cli. It includes the full TUI framework, API client, WebSocket streaming, EIP-712 signing, trailing stops, and Claude AI agent integration. The proprietary trading strategy (momentum scanner, regime detection, adaptive sizing) lives in a private repository.
# Demo mode — streams live market data, no keys needed
cargo run -- --demo
# Full mode — requires a Hyperliquid private key
export HL_PRIVATE_KEY=0x...
cargo run
# Testnet
cargo run -- --testnet
# Read-only (view positions, no trading)
cargo run -- --readonly| Module | Lines | Description |
|---|---|---|
src/api/ |
1,600 | REST client, EIP-712 signing (phantom agent pattern), WebSocket manager |
src/ui/ |
2,600 | Ratatui TUI: candlestick chart, orderbook, positions, P&L, order modals |
src/trading/ |
1,000 | Trailing stops (ATR/percent/fixed), position tracking, circuit breaker, adaptive sizing |
src/agent/ |
760 | Claude AI agent with 10 tools (positions, orders, candles, funding, R:R calc) |
src/app.rs |
1,400 | Async state machine, tokio event loop, command dispatch |
src/hotkeys.rs |
190 | Configurable key mapping engine |
Total: ~8,500 lines across 35 files
+-----------+
| main.rs | CLI parsing, logging, config
+-----+-----+
|
+-----v-----+
| app.rs | State machine + tokio::select! event loop
+-----+-----+
|
+------------------+------------------+
| | |
+------v------+ +------v------+ +------v------+
| api/ | | ui/ | | trading/ |
| REST client | | Ratatui TUI | | Trailing |
| EIP-712 sig | | Chart, Book | | stops, risk |
| WebSocket | | Modals | | management |
+-------------+ +-------------+ +-------------+
|
+------v------+
| agent/ |
| Claude AI |
| Tool loop |
+-------------+
- EIP-712 signing uses the "phantom agent" pattern:
msgpack(action) -> keccak256 -> Agent typed data -> sign. Built with alloy crates, no SDK dependency. rust_decimal::Decimalfor all financial math (prices, sizes, PnL). Indicators usef64.- WebSocket manager runs as a separate tokio task with automatic reconnection and subscription management.
- Async event loop uses
tokio::select!with biased polling — keyboard input is always prioritized over WebSocket/refresh events for zero-lag response.
The full version adds a momentum trading strategy on top of this infrastructure:
- Multi-timeframe momentum scanner — ADX, ATR, volume surge, trend scoring across 7 timeframes
- Regime detection — classifies markets as Breakout, Trending, Ranging, Choppy
- Style profiling — analyzes trade history to build a "winning pattern" fingerprint
- Adaptive position sizing — equity x risk x regime x streak x liquidation tier
- Circuit breaker — liquidation-aware cooldowns, daily loss limits, streak tracking
- Session scheduling — configurable trading windows per asset class
- Semi-auto mode — signals require manual confirmation before execution
Config lives at ~/.hl-cli/config.toml. A default file is created on first run.
[account]
private_key_env = "HL_PRIVATE_KEY"
network = "mainnet"
[defaults]
asset = "BTC"
leverage = 5
slippage_bps = 10
[risk]
max_position_usd = 50000
max_daily_loss_usd = 5000
[favorites]
assets = ["BTC", "ETH", "SOL", "HYPE"]
[agent]
api_key_env = "ANTHROPIC_API_KEY"
model = "claude-sonnet-4-6"| Key | Action |
|---|---|
q |
Quit |
b / s |
Buy / Sell modal |
j / k |
Select position |
t / T |
Attach / Remove trailing stop |
x |
Cancel selected orders |
Ctrl-x |
Flatten selected position |
Tab |
Cycle favorite assets |
/ |
Search all assets |
@ |
Claude agent mode |
[ / ] |
Chart timeframe |
: |
Command mode |
? |
Help overlay |
- Rust (async, tokio runtime)
- ratatui + crossterm (TUI framework)
- alloy crates (EIP-712 signing, Ethereum types)
- reqwest + tokio-tungstenite (HTTP + WebSocket)
- rust_decimal (fixed-point financial math)
MIT