Keel Docs
SDK & CLI

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.2

Requires 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_syntax

Compose 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 json

Save 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 json

For CI, SSH, Codespaces, or WSL without browser forwarding:

keel auth login --key <token>
# Token from https://app.usekeel.io/settings?tab=api-keys

For 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 json

keel 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_xyz789

Actual 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-preview

Monitor 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 --yes

keel 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 human

The 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

CodeMeaningWhat to do
0SuccessProceed
1General failureCheck the structured error
2Usage errorFix arguments
3Not foundCheck the id or search first
4Auth failedRun keel auth login
5ConflictInspect strategy status or retry with intent
6Entitlement exceededCheck keel status
7Validation failedFix source, retry dry-run compose

Next steps