Keel Docs
SDK & CLI

Getting Started with the CLI

Install the Keel CLI and run your first command in under 60 seconds.

Getting Started

Install the Keel CLI and run your first command in under 60 seconds.

Install

pipx install keel-trade

Requires Python 3.11+. pipx installs the keel CLI in an isolated environment. If you don't have pipx: brew install pipx (macOS) or pip install pipx.

Alternatively, install in a virtual environment: pip install keel-trade

Verify the installation:

keel --version
# keel, version 0.1.0

keel --help

Local Tools (No API Key)

Most discovery and validation tools work locally — no account needed.

Search Components

# Find momentum indicators
keel components search --keyword momentum

# Natural language search
keel components search "mean reversion oscillator"

# Get full details for a component
keel components detail RSI

Validate a Strategy

Create a strategy file my_strategy.py:

Globals(target_timeframe="1d")

Universe(mode="top_volume", top_n=30, market="perp", resolved=[], resolved_at="")

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
keel strategy validate my_strategy.py

# Check if it's ready to backtest
keel strategy stage my_strategy.py

# Explain the pipeline structure
keel strategy explain my_strategy.py

Create from Template

# Create a new strategy from a template
keel strategy new my_strat --template momentum

# Available templates: basic, momentum, multi_factor, carry

Explore Examples

# Browse curated examples
keel strategy examples

# Search for specific patterns
keel strategy examples --query "carry"

# Get composition guidance
keel strategy patterns "momentum with proper sizing"

Remote Tools (API Key Required)

Backtesting, live trading, and platform features require authentication.

Authenticate

# Option 1: Environment variable (recommended for agents)
export KEEL_API_KEY=sk_org_xxx

# Option 2: Interactive login
keel auth login

# Verify
keel auth whoami

Get your API key from Settings → API Keys in the dashboard.

Run a Backtest

# Create strategy on platform
keel strategy create my_strategy.py

# Start backtest
keel backtest run str_abc123 --start-date 2025-01-01 --end-date 2025-12-31

# Check status
keel backtest status bt_xyz789

# Get results
keel backtest results bt_xyz789

Deploy Live

# Deploy (requires confirmation)
keel live deploy str_abc123 --confirm

# Monitor
keel live positions dep_123
keel live pnl dep_123
keel live equity dep_123

# Emergency stop
keel live pause dep_123
keel live stop dep_123

Output Formats

Every command supports --format:

# JSON (default in agent mode)
keel --format json components search --keyword ROC

# Table (default in terminal)
keel --format table backtest list

# TSV (half the tokens of JSON)
keel --format tsv components list

# Human-readable
keel --format human strategy explain my_strategy.py

The CLI auto-detects agent mode (JSON output, no prompts) when it sees CLAUDE_CODE, CURSOR_AGENT, AIDER, or KEEL_AGENT_MODE environment variables, or when stdout is not a TTY.

Exit Codes

CodeMeaningWhat to Do
0SuccessProceed
1General failureCheck error message
2Usage errorFix arguments
3Not foundRun keel <resource> list
4Auth failedRun keel auth login
5ConflictResource already exists
6Entitlement exceededCheck keel auth status
7Validation failedFix source, retry

Next Steps