CLI Commands

horizon run, horizon presets, horizon version

Running the CLI

bash
PYTHONPATH=. python3 -m horizon.cli <command>

Or, after pip install -e .:

bash
horizon <command>

Commands

horizon run <preset>

Run a preset config. either a bundled preset by name or a .hz.toml file path.

bash
horizon run equity_mean_reversion
horizon run ./my_preset.hz.toml

Output:

backtest complete
  sharpe       = -0.456
  sortino      = -0.598
  total return = -3.988%
  max drawdown = 11.820%
  n trades     = 545
  equity start = 100000.00
  equity end   = 96011.70

horizon presets list

List bundled starter presets:

bash
$ horizon presets list
equity_mean_reversion
tech_momentum

horizon presets show <name>

Print the contents of a bundled preset:

bash
$ horizon presets show equity_mean_reversion
mode = "backtest"

[asset_classes]
classes = ["equity"]

[[universe]]
type = "static"
markets = ["AAPL", "MSFT", "NVDA", "GOOGL", "AMZN"]

...

Useful for copying a starter preset to modify:

bash
horizon presets show equity_mean_reversion > my_preset.hz.toml
# edit my_preset.hz.toml
horizon run ./my_preset.hz.toml

horizon version

bash
$ horizon version
horizon 0.1.0

Exit codes

  • 0: success
  • 2: preset not found or argument parse error
  • Non-zero: any other error

Useful in scripts:

bash
if horizon run my_preset; then
    echo "Backtest succeeded"
else
    echo "Backtest failed" >&2
    exit 1
fi

Planned additions

Planned CLI commands (not yet wired):

  • horizon strategy promote <name> --to shadow
  • horizon strategy demote <name> --reason "..."
  • horizon strategy status
  • horizon kill --reason "..."
  • horizon kill --reset --reason "..."
  • horizon walk-forward <preset> --train 2y --test 3m
  • horizon discover equity --sector Tech --market-cap-min 10B

The horizon.cli module is the entry point. add new commands there as needs arise.

Source

horizon/cli.py: built on stdlib argparse, no external dependencies.

Next