CLI Commands Reference

Complete option reference for the pyne Click CLI: check, format, lint, compile, run, optimize, prewarm, data, info, and more.

This page

CLI Commands Reference

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.3.14). 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
optimizeSearch input.* values over N interpret Runtime runs
dataFetch market bars
runnerHosted scripts on the Pro API (deploy / tick / list)
infolsVersion + optional extras
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
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
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
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
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
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
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
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
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
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.

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
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 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
enable ID / disable IDPUT /cron/jobs
pyne runner deploy script.pine --id demo --symbol BTCUSDT --source mock
pyne runner tick --id demo --force
pyne runner list
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 are available.


Related: pyne-lsp (not a subcommand)

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

Internals

ItemPath
CLI groupsrc/pynescript/__main__.py
Entrypyproject.tomlpyne / pynescript = pynescript.__main__:cli
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/astparse-and-dump; unparseparse-and-unparse; fmtformat; lsinfo.
  • Prefix match works when unique (pynescript chcheck).
  • 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