CLI Guide

Use the pyne Click CLI to check, format, lint, compile, run, optimize, prewarm, fetch data, and more.

This page

CLI Guide

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. Full multi-bar evaluation with real OHLCV belongs 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
runnerHTTP client for Flask /scripts + /cron/run (PYNE_RUNNER)
infoversion + optional extras

Interface surface

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
optimize PATHfile + --space JSONstrategy hyperparameter search
data SYMBOLsymbol + provider optstable / json / csv
runner …file / idhosted deploy + tick (runner)
infoversion + extras

Not part of this Click group: language server — use pyne-lsp (alias pynescript-lsp).

Install options

MethodWhen
pip install hoox-pyneDefault desk / CI use
pip install "hoox-pyne[compile]"Need Numba compile / run modes
GitHub Release binary pynescript-cli-*No Python install
Docker pynescript-cliIsolated 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)

PathRole
src/pynescript/__main__.pyAll command implementations
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

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

Compose with library for evaluation

pyne run is compile-only smoke. Real bars + mode / libraries / timeout_seconds belong on the package Runtime:

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