CLI Commands Reference
Complete option reference for the pyne Click CLI: check, format, lint, compile, run, optimize, prewarm, data, info, and more.
This page
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.6.31). 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 | |
execute | Runtime.run JSON (MCP pyne_execute) | |
symbols | Outline functions / inputs / plots | |
parity | Interpret vs compile last plot values | |
diagnostics | Parse errors + lint in one JSON list | |
builtin | Look up one Pine builtin (ta.sma) | |
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 |
mcp | Stdio server, config, tools, in-process call |
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 corpus
Rich front-end over the open-source Pine corpus (tests/data/set0N). Runs scripts through Runtime (or parse-only) and writes CSV + summary under .cache/.
| Subcommand | Role |
|---|---|
list | Show available sets and .pine counts (--json, --data) |
run | Execute sets (--sets, positional set names, --mode, --workers, …) |
| Kind | Name | Default | Description |
|---|---|---|---|
| option | --sets | set01,set02,set03 | Comma-separated corpus sets |
| argument | SETS_ARGS | optional | Extra set names (pyne corpus run set01 set02) |
| option | --mode | compile | interpret | compile | auto | run | parse |
| option | --timeout | 20 | Per-script seconds |
| option | --bars | 50 | Synthetic OHLCV length |
| option | --workers | 6 | Process pool size |
| option | --out | .cache/runtime_corpus_…csv | Results CSV |
| option | --resume | off | Skip files already in --out |
| option | --data | tests/data / $PYNE_CORPUS_DATA | Corpus root |
| option | --plain / --rich | auto | Disable or force Rich |
| option | --strict / --no-strict | strict | Exit 1 on residual failures |
pyne corpus list
pyne corpus run --sets set01,set02 --mode compile
pyne corpus run set01 --mode parse --workers 4 --plain
Engine module: pynescript.util.corpus_runtime (also used by scripts/corpus_run_runtime.py).
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 |
history | GET /cron/history (--id, --limit) |
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 history --id demo --limit 10
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 / mcp are available.
pyne execute
Runtime.run on PATH (MCP pyne_execute). Prints the JSON envelope. Unlike pyne run, this is interpret/compile/auto with optional caller OHLCV rows.
| Kind | Name | Default | Description |
|---|---|---|---|
| argument | PATH | File or - (stdin) | |
| option | --mode | auto | interpret / compile / auto |
| option | --bars | 50 | Synthetic bars when --ohlcv is omitted |
| option | --ohlcv | JSON array of {time,open,high,low,close,volume?} rows, or a file | |
| option | --inputs | JSON object of input.* overrides, or a file | |
| option | --timeout | 30s (cap 120) | Seconds |
| option | --sample | 8 | Trailing plot samples (max 64) |
| option | --trades | Include strategy trade extras | |
| option | --ticker / --timeframe | MCP / 1m | Runtime identity |
pyne execute script.pine --mode interpret --bars 50
pyne execute script.pine --ohlcv bars.json --inputs '{"len": 14}'
Exit 1 when ok is false.
pyne symbols / parity / diagnostics / builtin
JSON wrappers for the MCP-only tools. parity exits 1 when last values diverge. diagnostics exits 1 when any item is severity=error. builtin NAME looks up builtin_metadata.json.
pyne symbols script.pine
pyne parity script.pine --bars 24
pyne diagnostics script.pine
pyne builtin ta.sma
pyne mcp
Stdio Model Context Protocol server, plus in-process tool execution. Serving stdio requires pip install "hoox-pyne[mcp]". config, tools, and call do not.
| Kind | Name | Description |
|---|---|---|
| (no args) | Serve MCP on stdio (pyne-mcp) | |
| subcommand | config | Print mcpServers.pyne JSON |
| subcommand | tools | List catalog tool names (--json array) |
| subcommand | call TOOL [PATH] | Run a tool in-process and print JSON |
| option | --module | config only: python -m pynescript.mcp |
| option | --source / -s | call: inline Pine (overrides PATH) |
| option | --arg / -a | call: KEY=VALUE (JSON-coerced; repeatable) |
| option | --json | call: extra arguments object (inline or file) |
| option | --name | call: shortcut for --arg name= (pyne_builtin) |
pip install "hoox-pyne[mcp]"
pyne mcp config
pyne mcp tools
pyne mcp call lint script.pine
pyne mcp call execute script.pine --arg bars=24 --arg mode=interpret
pyne mcp
pyne-mcp
python -m pynescript.mcp
Tools, resources, prompts: MCP tools. Guide: MCP (agents).
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 |
| MCP | src/pynescript/mcp/ · pyne-mcp |
| 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] |