CLI Commands Reference
Complete option reference for the pyne Click CLI: check, format, lint, compile, run, optimize, prewarm, data, info, and more.
This page
CLI Commands Reference
Abstract
Machine-oriented reference for every command on the preferred pyne Click group
(alias pynescript; src/pynescript/__main__.py). Install via hoox-pyne
(pip install hoox-pyne). For workflows see the CLI guide.
The language server is a separate console script (pyne-lsp; alias pynescript-lsp).
Version option: pyne --version / -V reports pynescript.__about__.__version__
(e.g. 0.3.14). Global --no-color honors NO_COLOR.
Command index
| Command | Aliases | Purpose |
|---|---|---|
check | Parse-only validation (CI-friendly exit codes) | |
format | fmt | Parse → unparse (structural format) |
convert | Rewrite older Pine toward v5 or v6 | |
parse-and-dump | dump, ast | AST dump |
parse-and-unparse | unparse | Round-trip source |
lint | Static diagnostics (JSON / fail-on) | |
compile | Transpile or compile-check (Numba path) | |
prewarm | Warm Numba builtins / script IR caches (H2) | |
run | Compile + execute on synthetic OHLCV | |
optimize | Search input.* values over N interpret Runtime runs | |
data | Fetch market bars | |
runner | Hosted scripts on the Pro API (deploy / tick / list) | |
info | ls | Version + optional extras |
pyne --help
pyne --version
pyne <command> -h
# alias: pynescript …
pyne check
Validate that path(s) parse as Pine Script.
| Kind | Name | Default | Description |
|---|---|---|---|
| argument | PATHS… | (optional) | Files and/or directories; omit or - → stdin |
| option | --encoding | utf-8 | Text encoding |
| option | -q, --quiet | off | Exit code only |
| option | --ext | .pine | When PATH is a directory, only this suffix |
pyne check script.pine
pyne check scripts/ --ext .pyne
pyne check -q strategy.pine # exit 0/1 only
cat x.pine | pyne check -
Exit: 0 all ok; 1 any parse failure.
pyne format (fmt)
Canonicalize Pine by parse → unparse (structural, not a full style formatter).
| Kind | Name | Default | Description |
|---|---|---|---|
| argument | PATH | required | File or - (stdin) |
| option | --encoding | utf-8 | |
| option | -w, --write | off | Write back to PATH (not for stdin) |
| option | --check | off | Exit 1 if format would change (no write) |
| option | -o, --output-file | - | Output when not using --write |
pyne format script.pine # stdout
pyne fmt script.pine -w
pyne format script.pine --check # CI drift gate
pyne convert
Rewrite older Pine toward v5 or v6. --to 6 converts any older version
(missing //@version counts as v1): color / n / timeframe idents, ta.* /
math.* / request.* namespaces, study( → indicator(, typed input.*(),
iff / offset. Not a semantic v6 migrator (bool-as-int, na).
| Kind | Name | Default | Description |
|---|---|---|---|
| argument | PATH | required | File or - (stdin) |
| option | --to | required | 5 / 6 / v5 / v6 |
| option | --encoding | utf-8 | |
| option | -w, --write | off | Write back to PATH (not for stdin) |
| option | -o, --output-file | - | Output when not using --write |
pyne convert old.pine --to 6
pyne convert strategy.pine --to 6 -w
pyne parse-and-dump (dump / ast)
| Kind | Name | Default | Description |
|---|---|---|---|
| argument | PATH | required | Input file |
| option | --encoding | utf-8 | |
| option | --indent | 2 | Dump indent |
| option | -o, --output-file | - | Output path |
pyne dump strategy.pine
pyne parse-and-dump strategy.pine --indent 4 -o tree.txt
pyne parse-and-unparse (unparse)
| Kind | Name | Default | Description |
|---|---|---|---|
| argument | PATH | required | Input file |
| option | --encoding | utf-8 | |
| option | -o, --output-file | - | Output path |
pyne unparse messy.pine -o clean.pine
pyne lint
| Kind | Name | Default | Description |
|---|---|---|---|
| argument | PATH | optional | File; omit or - → stdin |
| option | --encoding | utf-8 | |
| option | --fail-on | errors | errors | warnings | all | never |
| option | --json | off | JSON array of findings |
| option | -q, --quiet | off | Summary only |
pyne lint strategy.pine
pyne lint --json --fail-on never strategy.pine
pyne lint --fail-on warnings strategy.pine
cat strategy.pine | pyne lint -
pyne compile
Compile via pynescript.compiler.compile_script. Requires
pip install "hoox-pyne[compile]" for full Numba path; --emit works without JIT.
| Kind | Name | Default | Description |
|---|---|---|---|
| argument | PATH | required | Pine file |
| option | --encoding | utf-8 | |
| option | --emit | off | Print generated Python only (no exec/JIT) |
| option | -o, --output-file | - | Where to write --emit output |
| option | --time / --no-time | time on | Print compile timing |
pyne compile script.pine --emit
pyne compile script.pine --emit -o out.py
pyne compile script.pine # warm load / compile-check
pyne prewarm
H2 warm-compile product path: pay cold JIT before first interactive run.
| Kind | Name | Default | Description |
|---|---|---|---|
| argument | PATH… | optional | Pine files to compile into IR caches |
| option | --encoding | utf-8 | |
| option | --force | off | Re-run builtin warm-up |
| option | --json | off | Machine-readable summary |
pyne prewarm # shared Numba kernels only
pyne prewarm strategy.pine lib/*.pine
pyne prewarm --json
pyne run
Compile and execute on deterministic synthetic OHLCV (same compile pipeline as
Pro API mode=compile). No --mode. Does not call Runtime.run. Prefer
package pynescript.runtime.Runtime / Pro API for real bars, libraries=, and
timeout_seconds.
| Kind | Name | Default | Description |
|---|---|---|---|
| argument | PATH | required | Pine file |
| option | --encoding | utf-8 | |
| option | --bars | 50 | Synthetic bar count |
| option | --json | off | Plot series summary as JSON |
| option | -q, --quiet | off | Errors / exit only |
pyne run strategy.pine --bars 100
pyne run strategy.pine --json
pyne optimize
Search input.* values for a strategy() script. Loops interpret Runtime (not /backtest/quick). Requires --space JSON.
| Kind | Name | Default | Description |
|---|---|---|---|
| argument | PATH | required | Pine file (- = stdin) |
| option | --encoding | utf-8 | |
| option | --bars | 120 | Synthetic bar count (min 8) |
| option | --trials | 20 | Trial budget (max 200) |
| option | --space | required | JSON {"params":[{"name","kind","min","max"}]} |
| option | --sampler | auto | auto | random | tpe | grid |
| option | --objective | composite | composite | net_pnl | profit_factor | calmar |
| option | --validation | holdout | holdout | walk-forward | in-sample |
| option | --train-bars | derive | Walk-forward train window |
| option | --test-bars | derive | Walk-forward test window |
| option | --step-bars | derive | Walk-forward step (default: the test window) |
| option | --holdout-frac | 0.3 | Holdout test fraction |
| option | --seed | unset | RNG seed |
| option | --json | off | Full study JSON |
--validation walk-forward derives windows from --bars when the bar flags are omitted: train=max(8, bars*2//3), test=max(4, bars//6), step=max(1, test) (so default --bars 120 → 80/20/20). Explicit --train-bars / --test-bars / --step-bars override that. The CLI refuses walk-forward when --bars < train+test. All-errored studies exit 1 even if the study status is success.
pyne optimize strat.pine --trials 20 --sampler tpe \
--space '{"params":[{"name":"Fast","kind":"int","min":3,"max":12}]}'
pyne optimize strat.pine --validation walk-forward --bars 120 --trials 20 \
--space '{"params":[{"name":"Fast","kind":"int","min":3,"max":12}]}'
pyne optimize strat.pine --validation walk-forward --train-bars 80 --test-bars 20 \
--space '{"params":[{"name":"Fast","kind":"int","min":3,"max":12}]}'
Library: pynescript.optimize.run_study. HTTP: POST /optimize.
pyne data
| Kind | Name | Default | Description |
|---|---|---|---|
| argument | SYMBOL | required | Ticker / market symbol |
| option | --provider | mock | mock | yahoo | alphavantage | ccxt |
| option | --period | 1y | e.g. 6mo, 1y |
| option | --interval | 1d | e.g. 1h, 1d |
| option | --api-key / --secret | empty | Provider credentials |
| option | --exchange | binance | CCXT exchange id |
| option | --format | table | table | json | csv |
| option | -o, --output-file | - | Output path |
pyne data AAPL
pyne data AAPL --provider yahoo --period 6mo
pyne data BTC/USDT --provider ccxt --exchange binance --format csv
CCXT needs pip install "hoox-pyne[data]".
pyne runner
HTTP client for the optional Flask hosted runner (PYNE_RUNNER=1). Group options apply to every subcommand.
| Kind | Name | Default | Description |
|---|---|---|---|
| option | --url | http://127.0.0.1:5002 | Pro API origin (PYNE_API_URL) |
| option | --token | empty | X-Admin-Token (ADMIN_TOKEN) |
| Subcommand | Role |
|---|---|
deploy PATH | Read a .pine / .pyne file and POST /scripts |
list | GET /scripts |
show ID | GET /scripts/:id |
delete ID | DELETE /scripts/:id |
tick | POST /cron/run (--id, --force) |
jobs | GET /cron/jobs |
enable ID / disable ID | PUT /cron/jobs |
pyne runner deploy script.pine --id demo --symbol BTCUSDT --source mock
pyne runner tick --id demo --force
pyne runner list
pyne runner --url http://127.0.0.1:5002 jobs
Full HTTP contract: hosted runner.
pyne info (ls)
| Kind | Name | Description |
|---|---|---|
| option | --json | Machine-readable payload |
Prints package version, Python, platform, and whether numba / rich are available.
Related: pyne-lsp (not a subcommand)
pip install "hoox-pyne[lsp]"
pyne-lsp
# alias: pynescript-lsp
python -m pynescript.langserver
Internals
| Item | Path |
|---|---|
| CLI group | src/pynescript/__main__.py |
| Entry | pyproject.toml → pyne / pynescript = pynescript.__main__:cli |
| parse/dump/unparse | src/pynescript/ast/helper.py |
| lint | src/pynescript/ast/linter.py |
| compile / prewarm | src/pynescript/compiler/ |
| optimize | src/pynescript/optimize/ |
| data | src/pynescript/util/data.py |
Invariants
- Aliases:
dump/ast→parse-and-dump;unparse→parse-and-unparse;fmt→format;ls→info. - Prefix match works when unique (
pynescript ch→check). checkwalks directories; dump/format take a single file.- Docker:
pynescript-cliimageENTRYPOINTispynescript(non-root). - Standalone binaries: GitHub Release
pynescript-cli-*(Nuitka).
Failure modes
| Situation | Result |
|---|---|
Parse failure (check / dump) | Non-zero exit |
Format --check drift | Exit 1 |
| Lint threshold | Non-zero per --fail-on |
| Compile without numba (full path) | Clear error; --emit still works |
| Provider failure | Click error with message |
Missing ccxt for data | Import/provider error → install [data] |