CLI Guide
Use the pyne Click CLI to check, format, lint, compile, run, execute (Runtime.run), corpus-test sets, call MCP tools, optimize, prewarm, and fetch data.
This page
Abstract
The preferred pyne console script (alias pynescript) is a Click group over the same helpers used by the library API. Install with pip install hoox-pyne (live on PyPI). It is optimized for shell pipelines, CI gates, one-shot inspection, and light compile/run smokes. pyne execute is Runtime.run (JSON). Full multi-bar evaluation with real OHLCV also lives on the package pynescript.runtime.Runtime or Pro API. Exhaustive flags: CLI commands.
Conceptual model
Rendering…
| CLI | Library / subsystem |
|---|---|
check | parse only (exit codes) |
format / fmt | parse + unparse |
convert | pynescript.util.pine_convert (any older version → v6) |
parse-and-dump / dump | parse + dump |
lint | lint_script |
compile / prewarm / run | pynescript.compiler (+ [compile] extra) |
optimize | pynescript.optimize.run_study |
data | pynescript.util.data.get_provider |
corpus | pynescript.util.corpus_runtime (Rich UI over set01–set06) |
runner | HTTP client for Flask /scripts + /cron/run (PYNE_RUNNER) |
info | version + optional extras |
execute / symbols / parity / diagnostics / builtin | MCP ops (Runtime.run, outline, last-value parity) |
mcp | pynescript.mcp stdio server, tools, in-process call (MCP) |
Interface surface
pyne --help
pyne --version
pyne <command> --help
# alias: pynescript …
| Command | Input | Output |
|---|---|---|
check PATHS… | files / dirs / stdin | ok/fail lines + exit code |
format PATH | file or - | formatted source (-w / --check) |
convert PATH --to 6 | file or - | rewritten v6 source (-w) |
parse-and-dump PATH | file | AST dump |
parse-and-unparse PATH | file | Pine source |
lint [PATH|-] | file or stdin | diagnostics (--json) |
compile PATH | file | emit Python or compile-check |
prewarm [PATH…] | optional files | warm Numba / IR cache |
run PATH | file | synthetic-bar execute |
execute PATH | file | Runtime.run JSON (--mode interpret|compile|auto) |
symbols / parity / diagnostics / builtin | file / name | MCP-backed JSON |
optimize PATH | file + --space JSON | strategy hyperparameter search |
data SYMBOL | symbol + provider opts | table / json / csv |
runner … | file / id | hosted deploy + tick (runner) |
info | — | version + extras |
mcp | — | stdio MCP server; config / tools / call TOOL |
Not part of this Click group: language server — use pyne-lsp (alias pynescript-lsp). MCP also has console script pyne-mcp.
Install options
| Method | When |
|---|---|
pip install hoox-pyne | Default desk / CI use |
pip install "hoox-pyne[compile]" | Need Numba compile / run modes |
pip install "hoox-pyne[mcp]" | Stdio MCP server (pyne-mcp / pyne mcp). pyne execute / mcp call need no extra |
GitHub Release binary pynescript-cli-* | No Python install |
Docker pynescript-cli | Isolated CI / one-shot checks |
# Docker
docker buildx bake cli
docker run --rm -v "$PWD:/work" -w /work pynescript-cli:latest check script.pine
# Compose (repo root)
make docker-cli ARGS="lint script.pine --json"
# Standalone binary (from GitHub Release)
chmod +x pynescript-cli-linux-x86_64
./pynescript-cli-linux-x86_64 info
Internals (repo paths)
| Path | Role |
|---|---|
src/pynescript/__main__.py | Click group; registers mcp + first-class execute/symbols/parity |
src/pynescript/mcp/cli.py | pyne mcp group, execute, symbols, parity, diagnostics, builtin |
src/pynescript/ast/helper.py | parse, dump, unparse |
src/pynescript/ast/linter.py | lint_script |
src/pynescript/compiler/ | compile / prewarm / run |
src/pynescript/util/data.py | providers + DataProviderError |
src/pynescript/util/runner_cli.py | pyne runner HTTP client |
examples/ | sample .pine inputs |
tests/test_cli.py | CLI unit suite (CI) |
Invariants & edge cases
- Encoding default is UTF-8 for file reads/writes.
--output-file -means stdout (Clickallow_dash=True).- Lint without a path reads stdin — useful in git hooks and
cat script.pine | pyne lint. --fail-ondefaults toerrors(syntax/E001);warningsfails on any warning severity too;allfails if any issue exists.datadefault provider ismock— offline-safe.- Alpha Vantage without key prints a warning and uses
demo. lintis one file or stdin — no directory walk. Usecheckfor recursive parse-only (--ext).runis compile-only on synthetic bars (--barsdefault 50). It does not callRuntime.runand has no--mode.
Worked examples
Inspect structure of a strategy
pyne parse-and-dump examples/rsi_strategy.pine --indent 2 | less
Compare two scripts’ shapes in CI:
pyne parse-and-dump a.pine --output-file /tmp/a.ast
pyne parse-and-dump b.pine --output-file /tmp/b.ast
diff -u /tmp/a.ast /tmp/b.ast
Format / normalize
pyne format messy.pine -w
pyne format strategy.pine --check # CI drift gate (exit 1 if would change)
pyne parse-and-unparse messy.pine --output-file clean.pine
Lint gate in CI
set -e
# lint is one file or stdin — not a directory walk
for f in strategies/*.pine strategies/*.pyne; do
pyne lint --fail-on warnings "$f"
done
# parse-only gate over a tree:
pyne check strategies/ --ext .pine
Stdin pipeline:
git show HEAD:strategies/rsi.pine | pyne lint --fail-on errors -
Market data smoke checks
pyne data AAPL
pyne data AAPL --provider yahoo --period 1y --interval 1d
pyne data BTC/USDT --provider ccxt --exchange binance
pyne data EUR/USD --provider alphavantage --api-key "$AV_KEY"
Typical table keys (from __main__.py): symbol, provider, bars, period / interval, first close, last close, change, high / low, avg volume. --format json emits full OHLCV lists.
Compile, prewarm, synthetic run
pip install "hoox-pyne[compile]"
pyne compile script.pine # compile-check (Numba or object-mode)
pyne compile script.pine --emit # print generated Python
pyne prewarm # warm shared Numba kernels
pyne prewarm script.pine # also compile that source into IR caches
pyne run script.pine --bars 100 # compile-only execute on synthetic OHLCV
pyne execute script.pine --mode interpret --bars 50
pyne mcp call execute script.pine --arg bars=50 --arg mode=interpret
Compose with library for evaluation
pyne run is compile-only smoke. pyne execute is Runtime.run (JSON; --mode, --ohlcv, --inputs, --timeout). The same ops are pyne mcp call TOOL. Direct library use:
pyne format strat.pine -o /tmp/s.pine
python - <<'PY'
from pathlib import Path
from pynescript.runtime import Runtime
# hand off to Runtime or your own visitor
print(Path("/tmp/s.pine").read_text()[:40])
PY
Failure modes
| Exit / message | Cause | Mitigation |
|---|---|---|
| Click path errors | missing file | check PATH exists and is a file |
| Parse exception during dump | invalid syntax | fix source; use smaller repro |
Lint failed with errors. | --fail-on threshold | read E00x / W00x lines |
DataProviderError → ClickException | network / auth / missing dep | install [data], fix keys |
| Empty dump / unexpected tree | mode always exec for CLI | expression-only needs library mode="eval" |