CLI Reference
CLI Reference
Section titled “CLI Reference”Hydra provides a unified CLI with subcommands for different trading modes. The CLI is available as a pre-built binary or via bun run when running from source.
Unified CLI
Section titled “Unified CLI”hydra <command> [options]Commands
Section titled “Commands”| Command | Description |
|---|---|
run | Start the trading bot (paper/live/replay) |
trades | View trade history and statistics |
record | Record market data for later replay |
reset | Reset bot state (breaker, all) |
tui | Launch TUI dashboard |
latency | Check network latency to exchanges |
version | Show version information |
help | Show help message |
Global Options
Section titled “Global Options”| Option | Description |
|---|---|
--config, -c <path> | Path to config file |
Reset bot state to recover from kill switch or clear all state.
hydra reset [options]Options
Section titled “Options”| Option | Description | Default |
|---|---|---|
--breaker | Clear breaker/kill state only | - |
--all | Reset ALL state (dangerous) | - |
--mode, -m <mode> | Trading mode: paper or live | live |
--config, -c <path> | Path to config file | - |
--db <path> | Explicit path to state database | Auto-detected |
-y, --yes | Skip confirmation prompt | false |
Examples
Section titled “Examples”# Clear breaker state to allow bot restart (live mode)hydra reset --breaker
# Clear breaker state (paper mode)hydra reset --breaker --mode paper
# Clear breaker with specific confighydra reset --breaker --config ./my-config.yaml
# Full reset - clears ALL state (DANGEROUS)hydra reset --all
# Skip confirmation (for scripts)hydra reset --breaker -yWhen to Use
Section titled “When to Use”The bot persists its kill/breaker state to SQLite. When the breaker is triggered (via SIGINT, risk limit breach, or manual kill), the bot will refuse to trade on restart until the breaker state is cleared.
Use --breaker to:
- Recover after pressing Ctrl+C to stop the bot
- Resume after a risk limit triggered the kill switch
- Clear state after investigating a kill event
Use --all to:
- Start completely fresh (resets peak equity, P&L, cost basis)
- Warning: This will break P&L calculations if you have open positions!
Start the trading bot in paper, live, or replay mode.
hydra run [options]Options
Section titled “Options”| Option | Description | Default |
|---|---|---|
--mode, -m <mode> | Trading mode: paper, live, or replay | paper |
--verbose, -v | Enable verbose logging | false |
--config, -c <path> | Path to config file | ./config.example.yaml |
Environment Variables
Section titled “Environment Variables”| Variable | Description | Default |
|---|---|---|
BOT_CONFIG | Path to config file (alternative to —config) | ./config.example.yaml |
Examples
Section titled “Examples”# Binaryhydra run # Paper trading (default)hydra run --mode live # Live tradinghydra run --mode replay # Replay recorded sessionhydra run --config ./my-config.yaml # Custom confighydra run --verbose # Verbose logging
# From sourcebun run paper # Paper tradingbun run bot # Full bot (mode from config)BOT_CONFIG=./config.yaml bun run botOutput
Section titled “Output”Trading sessions create a directory under persistence.outDir:
out/└── run_1234567890/ └── events.jsonl # All events for replay/analysistrades
Section titled “trades”View trade history and statistics from the append-only trade ledger.
hydra trades [options]Options
Section titled “Options”| Option | Description | Default |
|---|---|---|
--mode, -m <mode> | Trade mode: paper or live | paper |
--limit, -n <count> | Limit number of trades shown | All |
--market <id> | Filter by market ID | None |
--side <side> | Filter by side: BUY or SELL | None |
--summary | Show summary statistics only | false |
--json | Output as JSON for parsing | false |
Examples
Section titled “Examples”# Binaryhydra trades # Show all paper tradeshydra trades --mode live # Show live tradeshydra trades -n 20 # Show last 20 tradeshydra trades --summary # Show trade statisticshydra trades --side SELL # Show only sellshydra trades --json # Output as JSON
# From sourcebun run tradesbun run trades -- --mode liverecord
Section titled “record”Record live market data for later replay.
hydra record [options]Options
Section titled “Options”| Option | Description |
|---|---|
--config, -c <path> | Path to config file |
Examples
Section titled “Examples”# Binaryhydra recordhydra record --config ./my-config.yaml
# From sourcebun run recordOutput
Section titled “Output”Recording creates JSONL files containing all market events:
out/└── record_1234567890/ └── recording.jsonl # All market data eventsReal-time monitoring dashboard for running bot instances.
hydra tui [options]Options
Section titled “Options”| Option | Description |
|---|---|
--config, -c <path> | Path to config file (for IPC connection settings) |
Keyboard Shortcuts
Section titled “Keyboard Shortcuts”| Key | Action |
|---|---|
q | Quit dashboard |
? | Toggle help modal |
a | Arm/disarm (required before control commands) |
k | Send kill command to bot (armed mode) |
p | Pause trading (armed mode) |
r | Resume trading (armed mode) |
c | Cancel all open orders (armed mode) |
↑/↓ | Navigate markets |
l | Toggle log format (raw/formatted) |
s | Toggle auto-scroll |
PgUp/PgDn | Scroll logs (when auto-scroll off) |
Example
Section titled “Example”# Start bot in one terminalhydra run# or from source: bun run paper
# Connect TUI in another terminalhydra tui# or from source: bun run tuilatency
Section titled “latency”Check network latency to exchange APIs and WebSockets.
hydra latency [options]Options
Section titled “Options”| Option | Description | Default |
|---|---|---|
-e, --exchange <name> | Specific exchange: binance, polymarket, coinbase | All |
-s, --samples <n> | Number of REST samples | 10 |
--ws-samples <n> | Number of WebSocket samples | 5 |
-h, --help | Show help |
Examples
Section titled “Examples”# Binaryhydra latency # Check all exchangeshydra latency -e binance # Check Binance onlyhydra latency --samples 20 # More samples for accuracy
# From sourcebun run latencyOutput
Section titled “Output”Provides latency statistics and deployment recommendations:
Binance: Best REST latency: 45.2ms Best WebSocket latency: 38.1ms
✅ Excellent Binance WebSocket latency (38.1ms) Your location is well-suited for latency arbitrage.version
Section titled “version”Show version and build information.
hydra versionOutput
Section titled “Output”Hydra v0.1.0 Build target: bun-linux-arm64 Build time: 2024-01-15T10:30:00.000ZIPC Commands
Section titled “IPC Commands”The bot exposes an IPC server for remote control. Commands can be sent via WebSocket or through the TUI.
Available Commands
Section titled “Available Commands”| Command | Description |
|---|---|
kill | Emergency stop - closes all positions and shuts down |
pause | Pause trading (keep connections alive) |
resume | Resume trading after pause |
cancel_all | Cancel all open orders |
WebSocket Example
Section titled “WebSocket Example”const ws = new WebSocket('ws://127.0.0.1:9876');
ws.onopen = () => { ws.send(JSON.stringify({ type: 'kill' }));};
ws.onmessage = (event) => { const snapshot = JSON.parse(event.data); console.log('State snapshot:', snapshot);};Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 | Clean shutdown (user requested or session complete) |
1 | Error (config error, connection failure, etc.) |
Signals
Section titled “Signals”| Signal | Behavior |
|---|---|
SIGINT (Ctrl+C) | Graceful shutdown - saves state, closes connections |
SIGTERM | Same as SIGINT |