Getting Started with the CLI
Install the Keel CLI, inspect components, compose a strategy, and run a backtest.
Getting Started with the CLI
Install the Keel CLI and run the current compose -> backtest workflow.
See it working: Verified Keel backtest of a funding-carry strategy - Sharpe 2.17, +79.6% return, -9.7% max drawdown, 2024-08-15 -> 2026-04-30 on Hyperliquid perps.
Install
pipx install keel-trade
keel --version
# keel, version 0.4.2Requires Python 3.11+. pipx installs the keel CLI in an isolated
environment. uv tool install keel-trade also works.
Local discovery
Most component discovery and reference commands work without authentication.
keel components search momentum
keel components search --query "mean reversion oscillator"
keel components describe-batch ROC ForecastScaler ForecastWeightNormalizer
keel components compose-help ROC
keel help dsl_syntaxCompose a strategy
Create my_strategy.py:
Globals(target_timeframe="1d")
Universe(mode="top_volume", top_n=30, market="perp", resolved=[], resolved_at="")
Execution(rebalance="every_bar")
Pipeline([
PriceDataLoader(timeframe="15min"),
TargetTimeframeResampler(),
ROC(period=8),
ForecastScaler(avg_abs_target=10.0),
ForecastCapper(limit=20.0),
ForecastWeightNormalizer(target_leverage=1.0),
], name="my_momentum")Validate without saving:
keel strategy compose --source-file my_strategy.py --dry-run --format jsonSave it to the platform:
STRATEGY_ID=$(keel strategy compose \
--source-file my_strategy.py \
--name my_momentum \
--format json | jq -r '.strategy_id')keel strategy compose is the current create/update/validate entry point.
Use --dry-run first, then rerun without --dry-run when the source is ready.
Authenticate
Remote tools such as strategy save, backtest, accounts, sharing, and live deployment require authentication.
keel auth login
keel --format json auth whoami
keel status --format jsonFor CI, SSH, Codespaces, or WSL without browser forwarding:
keel auth login --key <token>
# Token from https://app.usekeel.io/settings?tab=api-keysFor live-trading scope, use keel auth login --scope live. Actual live
deployment also requires local arming with
keel arm live set --account <account_id>.
Run a backtest
BT_ID=$(keel backtest run "$STRATEGY_ID" \
--start-date 2025-06-01 \
--format json | jq -r '.run_id')
keel backtest watch "$BT_ID" --format json
keel backtest summarize "$BT_ID" --format jsonkeel backtest run waits by default for up to about 90 seconds and uses
today's UTC date when --end-date is omitted. If the run is still active, pass
run_id to keel backtest watch.
Deploy live
Live deployment defaults to preview mode and does not send orders:
keel live deploy str_abc123 --account-id acct_xyz789Actual deploys require all three gates:
keel auth login --scope live
keel arm live set --account acct_xyz789
keel live deploy str_abc123 --account-id acct_xyz789 --no-previewMonitor and control a deployment:
keel live monitor dep_123 --view overview
keel live monitor dep_123 --view positions
keel live control dep_123 --action pause
keel live control dep_123 --action stop --yeskeel live monitor includes freshness metadata. Use it to distinguish
on-demand Hyperliquid position snapshots from backend-recorded portfolio,
trade, order, execution, funding, stats, equity, and P&L views.
Output formats
Every outcome command supports --format:
keel components search ROC --format json
keel strategy search --query carry --format table
keel components search ROC --format tsv
keel help dsl_syntax --format humanThe CLI auto-detects common agent contexts and prefers structured output. Use
KEEL_AGENT_MODE=true to force agent mode or KEEL_AGENT_MODE=false to force
human mode.
Exit codes
| Code | Meaning | What to do |
|---|---|---|
| 0 | Success | Proceed |
| 1 | General failure | Check the structured error |
| 2 | Usage error | Fix arguments |
| 3 | Not found | Check the id or search first |
| 4 | Auth failed | Run keel auth login |
| 5 | Conflict | Inspect strategy status or retry with intent |
| 6 | Entitlement exceeded | Check keel status |
| 7 | Validation failed | Fix source, retry dry-run compose |
Next steps
- CLI Reference - Complete command documentation
- MCP Tool Reference - Generated tool schemas, safety annotations, and CLI equivalents
- Agent Setup - Configure Claude Code, Cursor, Codex, or a custom MCP client
- First Backtest CLI - End-to-end terminal walkthrough