---
title: "CLI"
description: "Run strategies, query positions, and manage the engine from the command line."
icon: "terminal"
---

Horizon provides a full-featured CLI for trading, discovery, wallet analytics, fund management, and strategy execution.

<Note>
For the complete CLI reference with all commands, see the [CLI Integration Guide](/integrations/cli).
</Note>

## Install

<CodeGroup>

```bash pip
pip install horizon-sdk
```

```bash uv
uv pip install horizon-sdk
```

```bash Run without installing (uvx)
uvx horizon-sdk discover "election"
```

```bash Run without installing (bunx)
bunx horizon-sdk discover "election"
```

</CodeGroup>

## Running Strategies

```bash
horizon run <strategy_file> [OPTIONS]
```

| Flag | Values | Default | Description |
|------|--------|---------|-------------|
| `--mode` | `paper`, `live` | from strategy | Override trading mode |
| `--dashboard / --no-dashboard` | - | from strategy | Override dashboard setting |
| `--log-level` | `debug`, `info`, `warn`, `error` | `info` | Log level for Python + Rust |

CLI options always take priority over the strategy file's `hz.run()` arguments.

<CodeGroup>

```bash Paper with dashboard
horizon run examples/simple.py --dashboard
```

```bash Live with debug logging
horizon run examples/polymarket_mm.py --mode=live --log-level=debug
```

```bash Override dashboard off
horizon run examples/kalshi_mm.py --no-dashboard --log-level=warn
```

</CodeGroup>

## Trading from the CLI

```bash
# Search markets
horizon discover "bitcoin" --exchange polymarket

# Get Kelly-optimal size
horizon kelly --prob 0.65 --price 0.50 --bankroll 1000

# Submit an order
horizon submit --market-id will-btc-hit-100k --side buy --price 0.55 --size 10

# Check positions
horizon positions

# Cancel everything
horizon cancel-all
```

## Wallet Analytics

```bash
# Check wallet value
horizon wallet value 0x1234...abcd

# See trade history
horizon wallet trades 0x1234...abcd --limit 20

# Score trading performance
horizon wallet score 0x1234...abcd
```

## Fund Management

```bash
# Deploy a strategy
horizon fund deploy --name my-mm --markets will-btc-hit-100k

# Check fund status
horizon fund status

# View risk dashboard
horizon fund risk
```

## JSON Output

Every command supports `--json` for scripting:

```bash
horizon discover "election" --json | jq '.[0].slug'
horizon top-markets --json | jq '[.[] | {slug, yes_price}]'
```

## Database Commands

For offline analysis of persisted strategy data:

```bash
# Show fills from database
horizon db fills --path ./horizon.db --limit 20

# Show positions
horizon db positions --path ./horizon.db

# Show orders
horizon db orders --path ./horizon.db --all
```

## How CLI Overrides Work

When running strategies, the CLI sets overrides in the `_cli_overrides` dictionary before loading the strategy module:

1. CLI parses `--mode` and `--dashboard` flags
2. Overrides are stored in `horizon.strategy._cli_overrides`
3. The strategy file is loaded and executed
4. When `hz.run()` is called, it reads `_cli_overrides` and applies them

This means `hz.run()` in the strategy file always runs. The CLI just changes its arguments.

## All Commands

Run `horizon --help` for the full command list, or see the [CLI Integration Guide](/integrations/cli) for detailed documentation of all 40+ commands.
