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

CommandAliasesPurpose
checkParse-only validation (CI-friendly exit codes)
formatfmtParse → unparse (structural format)
convertRewrite older Pine toward v5 or v6
parse-and-dumpdump, astAST dump
parse-and-unparseunparseRound-trip source
lintStatic diagnostics (JSON / fail-on)
compileTranspile or compile-check (Numba path)
prewarmWarm Numba builtins / script IR caches (H2)
runCompile + execute on synthetic OHLCV
executeRuntime.run JSON (MCP pyne_execute)
symbolsOutline functions / inputs / plots
parityInterpret vs compile last plot values
diagnosticsParse errors + lint in one JSON list
builtinLook up one Pine builtin (ta.sma)
optimizeSearch input.* values over N interpret Runtime runs
dataFetch market bars
runnerHosted scripts on the Pro API (deploy / tick / list)
infolsVersion + optional extras
mcpStdio server, config, tools, in-process call
bash
pyne --help
pyne --version
pyne <command> -h
# alias: pynescript …

pyne check

Validate that path(s) parse as Pine Script™.

KindNameDefaultDescription
argumentPATHS…(optional)Files and/or directories; omit or - → stdin
option--encodingutf-8Text encoding
option-q, --quietoffExit code only
option--ext.pineWhen PATH is a directory, only this suffix
bash
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).

KindNameDefaultDescription
argumentPATHrequiredFile or - (stdin)
option--encodingutf-8
option-w, --writeoffWrite back to PATH (not for stdin)
option--checkoffExit 1 if format would change (no write)
option-o, --output-file-Output when not using --write
bash
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).

KindNameDefaultDescription
argumentPATHrequiredFile or - (stdin)
option--torequired5 / 6 / v5 / v6
option--encodingutf-8
option-w, --writeoffWrite back to PATH (not for stdin)
option-o, --output-file-Output when not using --write
bash
pyne convert old.pine --to 6
pyne convert strategy.pine --to 6 -w

pyne parse-and-dump (dump / ast)

KindNameDefaultDescription
argumentPATHrequiredInput file
option--encodingutf-8
option--indent2Dump indent
option-o, --output-file-Output path
bash
pyne dump strategy.pine
pyne parse-and-dump strategy.pine --indent 4 -o tree.txt

pyne parse-and-unparse (unparse)

KindNameDefaultDescription
argumentPATHrequiredInput file
option--encodingutf-8
option-o, --output-file-Output path
bash
pyne unparse messy.pine -o clean.pine

pyne lint

KindNameDefaultDescription
argumentPATHoptionalFile; omit or - → stdin
option--encodingutf-8
option--fail-onerrorserrors | warnings | all | never
option--jsonoffJSON array of findings
option-q, --quietoffSummary only
bash
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.

KindNameDefaultDescription
argumentPATHrequiredPine file
option--encodingutf-8
option--emitoffPrint generated Python only (no exec/JIT)
option-o, --output-file-Where to write --emit output
option--time / --no-timetime onPrint compile timing
bash
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.

KindNameDefaultDescription
argumentPATH…optionalPine files to compile into IR caches
option--encodingutf-8
option--forceoffRe-run builtin warm-up
option--jsonoffMachine-readable summary
bash
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.

KindNameDefaultDescription
argumentPATHrequiredPine file
option--encodingutf-8
option--bars50Synthetic bar count
option--jsonoffPlot series summary as JSON
option-q, --quietoffErrors / exit only
bash
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.

KindNameDefaultDescription
argumentPATHrequiredPine file (- = stdin)
option--encodingutf-8
option--bars120Synthetic bar count (min 8)
option--trials20Trial budget (max 200)
option--spacerequiredJSON {"params":[{"name","kind","min","max"}]}
option--samplerautoauto | random | tpe | grid
option--objectivecompositecomposite | net_pnl | profit_factor | calmar
option--validationholdoutholdout | walk-forward | in-sample
option--train-barsderiveWalk-forward train window
option--test-barsderiveWalk-forward test window
option--step-barsderiveWalk-forward step (default: the test window)
option--holdout-frac0.3Holdout test fraction
option--seedunsetRNG seed
option--jsonoffFull 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 &lt; train+test. All-errored studies exit 1 even if the study status is success.

bash
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

KindNameDefaultDescription
argumentSYMBOLrequiredTicker / market symbol
option--providermockmock | yahoo | alphavantage | ccxt
option--period1ye.g. 6mo, 1y
option--interval1de.g. 1h, 1d
option--api-key / --secretemptyProvider credentials
option--exchangebinanceCCXT exchange id
option--formattabletable | json | csv
option-o, --output-file-Output path
bash
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/.

SubcommandRole
listShow available sets and .pine counts (--json, --data)
runExecute sets (--sets, positional set names, --mode, --workers, …)
KindNameDefaultDescription
option--setsset01,set02,set03Comma-separated corpus sets
argumentSETS_ARGSoptionalExtra set names (pyne corpus run set01 set02)
option--modecompileinterpret | compile | auto | run | parse
option--timeout20Per-script seconds
option--bars50Synthetic OHLCV length
option--workers6Process pool size
option--out.cache/runtime_corpus_…csvResults CSV
option--resumeoffSkip files already in --out
option--datatests/data / $PYNE_CORPUS_DATACorpus root
option--plain / --richautoDisable or force Rich
option--strict / --no-strictstrictExit 1 on residual failures
bash
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.

KindNameDefaultDescription
option--urlhttp://127.0.0.1:5002Pro API origin (PYNE_API_URL)
option--tokenemptyX-Admin-Token (ADMIN_TOKEN)
SubcommandRole
deploy PATHRead a .pine / .pyne file and POST /scripts
listGET /scripts
show IDGET /scripts/:id
delete IDDELETE /scripts/:id
tickPOST /cron/run (--id, --force)
jobsGET /cron/jobs
historyGET /cron/history (--id, --limit)
enable ID / disable IDPUT /cron/jobs
bash
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)

KindNameDescription
option--jsonMachine-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.

KindNameDefaultDescription
argumentPATHFile or - (stdin)
option--modeautointerpret / compile / auto
option--bars50Synthetic bars when --ohlcv is omitted
option--ohlcvJSON array of {time,open,high,low,close,volume?} rows, or a file
option--inputsJSON object of input.* overrides, or a file
option--timeout30s (cap 120)Seconds
option--sample8Trailing plot samples (max 64)
option--tradesInclude strategy trade extras
option--ticker / --timeframeMCP / 1mRuntime identity
bash
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.

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

KindNameDescription
(no args)Serve MCP on stdio (pyne-mcp)
subcommandconfigPrint mcpServers.pyne JSON
subcommandtoolsList catalog tool names (--json array)
subcommandcall TOOL [PATH]Run a tool in-process and print JSON
option--moduleconfig only: python -m pynescript.mcp
option--source / -scall: inline Pine (overrides PATH)
option--arg / -acall: KEY=VALUE (JSON-coerced; repeatable)
option--jsoncall: extra arguments object (inline or file)
option--namecall: shortcut for --arg name= (pyne_builtin)
bash
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)

bash
pip install "hoox-pyne[lsp]"
pyne-lsp
# alias: pynescript-lsp
python -m pynescript.langserver

Internals

ItemPath
CLI groupsrc/pynescript/__main__.py
Entrypyproject.toml → pyne / pynescript = pynescript.__main__:cli
MCPsrc/pynescript/mcp/ · pyne-mcp
parse/dump/unparsesrc/pynescript/ast/helper.py
lintsrc/pynescript/ast/linter.py
compile / prewarmsrc/pynescript/compiler/
optimizesrc/pynescript/optimize/
datasrc/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).
  • check walks directories; dump/format take a single file.
  • Docker: pynescript-cli image ENTRYPOINT is pynescript (non-root).
  • Standalone binaries: GitHub Release pynescript-cli-* (Nuitka).

Failure modes

SituationResult
Parse failure (check / dump)Non-zero exit
Format --check driftExit 1
Lint thresholdNon-zero per --fail-on
Compile without numba (full path)Clear error; --emit still works
Provider failureClick error with message
Missing ccxt for dataImport/provider error → install [data]

See also