Skip to content

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.

Terminal window
hydra <command> [options]
CommandDescription
runStart the trading bot (paper/live/replay)
tradesView trade history and statistics
recordRecord market data for later replay
resetReset bot state (breaker, all)
tuiLaunch TUI dashboard
latencyCheck network latency to exchanges
versionShow version information
helpShow help message
OptionDescription
--config, -c <path>Path to config file

Reset bot state to recover from kill switch or clear all state.

Terminal window
hydra reset [options]
OptionDescriptionDefault
--breakerClear breaker/kill state only-
--allReset ALL state (dangerous)-
--mode, -m <mode>Trading mode: paper or livelive
--config, -c <path>Path to config file-
--db <path>Explicit path to state databaseAuto-detected
-y, --yesSkip confirmation promptfalse
Terminal window
# 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 config
hydra reset --breaker --config ./my-config.yaml
# Full reset - clears ALL state (DANGEROUS)
hydra reset --all
# Skip confirmation (for scripts)
hydra reset --breaker -y

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.

Terminal window
hydra run [options]
OptionDescriptionDefault
--mode, -m <mode>Trading mode: paper, live, or replaypaper
--verbose, -vEnable verbose loggingfalse
--config, -c <path>Path to config file./config.example.yaml
VariableDescriptionDefault
BOT_CONFIGPath to config file (alternative to —config)./config.example.yaml
Terminal window
# Binary
hydra run # Paper trading (default)
hydra run --mode live # Live trading
hydra run --mode replay # Replay recorded session
hydra run --config ./my-config.yaml # Custom config
hydra run --verbose # Verbose logging
# From source
bun run paper # Paper trading
bun run bot # Full bot (mode from config)
BOT_CONFIG=./config.yaml bun run bot

Trading sessions create a directory under persistence.outDir:

out/
└── run_1234567890/
└── events.jsonl # All events for replay/analysis

View trade history and statistics from the append-only trade ledger.

Terminal window
hydra trades [options]
OptionDescriptionDefault
--mode, -m <mode>Trade mode: paper or livepaper
--limit, -n <count>Limit number of trades shownAll
--market <id>Filter by market IDNone
--side <side>Filter by side: BUY or SELLNone
--summaryShow summary statistics onlyfalse
--jsonOutput as JSON for parsingfalse
Terminal window
# Binary
hydra trades # Show all paper trades
hydra trades --mode live # Show live trades
hydra trades -n 20 # Show last 20 trades
hydra trades --summary # Show trade statistics
hydra trades --side SELL # Show only sells
hydra trades --json # Output as JSON
# From source
bun run trades
bun run trades -- --mode live

Record live market data for later replay.

Terminal window
hydra record [options]
OptionDescription
--config, -c <path>Path to config file
Terminal window
# Binary
hydra record
hydra record --config ./my-config.yaml
# From source
bun run record

Recording creates JSONL files containing all market events:

out/
└── record_1234567890/
└── recording.jsonl # All market data events

Real-time monitoring dashboard for running bot instances.

Terminal window
hydra tui [options]
OptionDescription
--config, -c <path>Path to config file (for IPC connection settings)
KeyAction
qQuit dashboard
?Toggle help modal
aArm/disarm (required before control commands)
kSend kill command to bot (armed mode)
pPause trading (armed mode)
rResume trading (armed mode)
cCancel all open orders (armed mode)
↑/↓Navigate markets
lToggle log format (raw/formatted)
sToggle auto-scroll
PgUp/PgDnScroll logs (when auto-scroll off)
Terminal window
# Start bot in one terminal
hydra run
# or from source: bun run paper
# Connect TUI in another terminal
hydra tui
# or from source: bun run tui

Check network latency to exchange APIs and WebSockets.

Terminal window
hydra latency [options]
OptionDescriptionDefault
-e, --exchange <name>Specific exchange: binance, polymarket, coinbaseAll
-s, --samples <n>Number of REST samples10
--ws-samples <n>Number of WebSocket samples5
-h, --helpShow help
Terminal window
# Binary
hydra latency # Check all exchanges
hydra latency -e binance # Check Binance only
hydra latency --samples 20 # More samples for accuracy
# From source
bun run latency

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.

Show version and build information.

Terminal window
hydra version
Hydra v0.1.0
Build target: bun-linux-arm64
Build time: 2024-01-15T10:30:00.000Z

The bot exposes an IPC server for remote control. Commands can be sent via WebSocket or through the TUI.

CommandDescription
killEmergency stop - closes all positions and shuts down
pausePause trading (keep connections alive)
resumeResume trading after pause
cancel_allCancel all open orders
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);
};

CodeMeaning
0Clean shutdown (user requested or session complete)
1Error (config error, connection failure, etc.)

SignalBehavior
SIGINT (Ctrl+C)Graceful shutdown - saves state, closes connections
SIGTERMSame as SIGINT