> ## Documentation Index
> Fetch the complete documentation index at: https://mathematicalcompany.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Run strategies, query positions, and manage the engine from the command line.

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 theme={null}
  pip install horizon-sdk
  ```

  ```bash uv theme={null}
  uv pip install horizon-sdk
  ```

  ```bash Run without installing (uvx) theme={null}
  uvx horizon-sdk discover "election"
  ```

  ```bash Run without installing (bunx) theme={null}
  bunx horizon-sdk discover "election"
  ```
</CodeGroup>

## Running Strategies

```bash theme={null}
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 theme={null}
  horizon run examples/simple.py --dashboard
  ```

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

  ```bash Override dashboard off theme={null}
  horizon run examples/kalshi_mm.py --no-dashboard --log-level=warn
  ```
</CodeGroup>

## Trading from the CLI

```bash theme={null}
# Search markets
horizon discover "bitcoin" --exchange polymarket

# Discover equities
horizon discover "AAPL" --exchange alpaca

# 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 theme={null}
# 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 theme={null}
# 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
```

## Equity & Options

```bash theme={null}
# Stock quote
horizon equity quote AAPL

# Search stocks
horizon equity search "apple"

# Options chain
horizon equity options-chain AAPL --expiry 2026-04-17

# Greek exposure
horizon equity greeks SPY

# IV term structure
horizon equity iv-surface TSLA

# Stock screener
horizon equity screener --sector tech
```

## JSON Output

Every command supports `--json` for scripting:

```bash theme={null}
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 theme={null}
# 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 50+ commands.
