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

Diagram

Rendering…

CLILibrary / subsystem
checkparse only (exit codes)
format / fmtparse + unparse
convertpynescript.util.pine_convert (any older version → v6)
parse-and-dump / dumpparse + dump
lintlint_script
compile / prewarm / runpynescript.compiler (+ [compile] extra)
optimizepynescript.optimize.run_study
datapynescript.util.data.get_provider
corpuspynescript.util.corpus_runtime (Rich UI over set01–set06)
runnerHTTP client for Flask /scripts + /cron/run (PYNE_RUNNER)
infoversion + optional extras
execute / symbols / parity / diagnostics / builtinMCP ops (Runtime.run, outline, last-value parity)
mcppynescript.mcp stdio server, tools, in-process call (MCP)

Interface surface

bash
pyne --help
pyne --version
pyne <command> --help
# alias: pynescript …
CommandInputOutput
check PATHS…files / dirs / stdinok/fail lines + exit code
format PATHfile or -formatted source (-w / --check)
convert PATH --to 6file or -rewritten v6 source (-w)
parse-and-dump PATHfileAST dump
parse-and-unparse PATHfilePine source
lint [PATH|-]file or stdindiagnostics (--json)
compile PATHfileemit Python or compile-check
prewarm [PATH…]optional fileswarm Numba / IR cache
run PATHfilesynthetic-bar execute
execute PATHfileRuntime.run JSON (--mode interpret|compile|auto)
symbols / parity / diagnostics / builtinfile / nameMCP-backed JSON
optimize PATHfile + --space JSONstrategy hyperparameter search
data SYMBOLsymbol + provider optstable / json / csv
runner …file / idhosted 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

MethodWhen
pip install hoox-pyneDefault 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-cliIsolated CI / one-shot checks
bash
# 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)

PathRole
src/pynescript/__main__.pyClick group; registers mcp + first-class execute/symbols/parity
src/pynescript/mcp/cli.pypyne mcp group, execute, symbols, parity, diagnostics, builtin
src/pynescript/ast/helper.pyparse, dump, unparse
src/pynescript/ast/linter.pylint_script
src/pynescript/compiler/compile / prewarm / run
src/pynescript/util/data.pyproviders + DataProviderError
src/pynescript/util/runner_cli.pypyne runner HTTP client
examples/sample .pine inputs
tests/test_cli.pyCLI unit suite (CI)

Invariants & edge cases

  • Encoding default is UTF-8 for file reads/writes.
  • --output-file - means stdout (Click allow_dash=True).
  • Lint without a path reads stdin — useful in git hooks and cat script.pine | pyne lint.
  • --fail-on defaults to errors (syntax/E001); warnings fails on any warning severity too; all fails if any issue exists.
  • data default provider is mock — offline-safe.
  • Alpha Vantage without key prints a warning and uses demo.
  • lint is one file or stdin — no directory walk. Use check for recursive parse-only (--ext).
  • run is compile-only on synthetic bars (--bars default 50). It does not call Runtime.run and has no --mode.

Worked examples

Inspect structure of a strategy

bash
pyne parse-and-dump examples/rsi_strategy.pine --indent 2 | less

Compare two scripts’ shapes in CI:

bash
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

bash
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

bash
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:

bash
git show HEAD:strategies/rsi.pine | pyne lint --fail-on errors -

Market data smoke checks

bash
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

bash
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:

bash
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 / messageCauseMitigation
Click path errorsmissing filecheck PATH exists and is a file
Parse exception during dumpinvalid syntaxfix source; use smaller repro
Lint failed with errors.--fail-on thresholdread E00x / W00x lines
DataProviderError → ClickExceptionnetwork / auth / missing depinstall [data], fix keys
Empty dump / unexpected treemode always exec for CLIexpression-only needs library mode="eval"

See also