[End User Hub]

Choose-your-path guide for installing PYNE, running the CLI, embedding the library, wiring editors, and calling the Pro API.

End User Hub

This track is for people who consume PYNE: parse and reformat Pine Script™, lint before upload, evaluate expressions or full scripts against OHLCV, wire an editor via LSP, or call the HTTP evaluate contract. Contributor internals (grammar regeneration, AST builder, bar-loop semantics) live under Core, Runtime, and DevOps.

Abstract

PYNE exposes one language pipeline through several thin surfaces:

.pine source
  → parse (ANTLR4 + ASDL AST)
  → optional: dump | unparse | lint | walk/transform
  → optional: evaluate (literal_eval | bar-loop Runtime)
  → plots / events / drawings / metrics

The desk path is the pynescript Click CLI and pynescript.ast library API. The editor path is pynescript-lsp (stdio). The HTTP path is the Flask Pro API (POST /run, preview, backtest). The optional chart is AXIS; the optional trade mesh is HOOX. Evaluation does not require either.

Conceptual model

SurfaceEntryTypical job
CLIpynescript …One-shot parse, format, lint, market data
Libraryfrom pynescript.ast import parse, unparseEmbed parse/transform/eval in tools
LSPpynescript-lspDiagnostics, completion, hover in editors
Pro APIPOST /runShared evaluate contract for AXIS / workers
AXISseparate productChart PWA AXIS over evaluate results
HOOXseparate productEdge execution mesh after strategy events

Choose your path

1. Getting started

New install, first parse, and environment knobs:

  • Installation — PyPI, extras (lsp, data), Hatch checkout, smoke checks.
  • Quick start — Parse → dump → unparse → lint → literal_eval in under ten minutes.
  • Configuration — Extras, console scripts, Pro API env vars, editor settings.

2. Operational guides

Daily workflows against the same pipeline:

  • CLIparse-and-dump, parse-and-unparse, lint, data, download-builtin-scripts.
  • Library APIparse, unparse, dump, walk, visitors, transformers, linter.
  • Evaluate scripts — Expression eval, bar-loop Runtime, strategy events, mock vs live data.
  • Editors — VS Code, Neovim, Zed, Emacs, Helix; clients/ snippets.
  • Pro API usage/run, /run/batch, preview, backtest as a consumer.
  • Troubleshooting — Parse failures, recursion limits, missing extras, CORS, auth.

3. Reference

  • CLI commands — Full option trees for every Click command.
  • Glossary — AST, series, bar-loop, Runtime, ASDL, and related terms.
  • FAQ — Version support, TradingView parity, licensing, AXIS/HOOX boundaries.

Interface surface (consumer map)

WantCommand / importDocs
Install corepip install pynescriptInstallation
Install LSPpip install "pynescript[lsp]"Editors
Install market data depspip install "pynescript[data]"CLI data
Parse filepynescript parse-and-dump path.pineCLI
Normalize sourcepynescript parse-and-unparse path.pineCLI
Lintpynescript lint path.pineCLI
Library parsefrom pynescript.ast import parse, unparseLibrary API
Expression evalfrom pynescript.ast.helper import literal_evalEvaluate
Start LSPpynescript-lsp (stdio)Editors
Local Pro APImake run / python -m backend.appPro API usage

Two console scripts are registered in pyproject.toml:

ScriptModuleRole
pynescriptpynescript.__main__:cliDesk CLI (Click group)
pynescript-lsppynescript.langserver.__main__:mainLanguage server (pygls)

Do not conflate them: lint and parse live on pynescript; editor features live on pynescript-lsp.

Internals (repo paths)

Consumer-relevant code only — deeper design is linked from each guide:

PathRole
src/pynescript/__main__.pyClick CLI: parse-and-dump, parse-and-unparse, lint, data, download-builtin-scripts
src/pynescript/ast/helper.pyPublic parse, unparse, dump, walk, literal_eval
src/pynescript/ast/linter.pylint_script / PineLinter
src/pynescript/ast/evaluator/Bar-aware and literal evaluators
src/pynescript/langserver/LSP features and server
src/pynescript/util/data.pyHistorical data providers (mock, yahoo, alphavantage, ccxt)
backend/app.pyFlask Pro API entry (/run, auth, blueprints)
backend/runtime.pyHTTP-facing Runtime.run bar loop
examples/Worked scripts (parse, RSI strategy, datafeed)
clients/Editor client configs (Neovim, Zed, Emacs)
vscode-extension/VS Code extension package

Invariants & edge cases

  • Round-trip is first-class. parseunparse should preserve semantics; use it to normalize formatting, not as a semantic rewrite.
  • Mode split. parse(..., mode="exec") yields a script tree; mode="eval" parses a single expression (used by literal_eval).
  • No proprietary host required. Evaluation works offline with mock or supplied OHLCV; AXIS/HOOX are optional.
  • Extras are opt-in. Core parse/lint needs only base deps (antlr4-python3-runtime, click, …). LSP needs [lsp]; CCXT paths need [data] / [datafeed].
  • Parametrized corpus. Tests under tests/data/builtin_scripts/ are large; a fixture using pinescript_filepath can explode CI runtime if misused.

Worked examples

Minimal library round-trip:

from pynescript.ast import parse, unparse

source = """
//@version=5
indicator("My RSI")
plot(ta.rsi(close, 14))
"""
tree = parse(source)
print(unparse(tree))

Minimal CLI:

pip install pynescript
pynescript parse-and-dump examples/rsi_strategy.pine
pynescript lint examples/rsi_strategy.pine

Minimal HTTP evaluate (local server running):

curl -s http://127.0.0.1:5002/ \
  | python -m json.tool

Failure modes

SymptomLikely causeWhere to go
pynescript: command not foundPackage not on PATH / venv inactiveInstallation
pynescript-lsp missingInstalled without [lsp] extraEditors
SyntaxError on parseGrammar mismatch or truncated sourceTroubleshooting
/run 400 NO_DATAMissing OHLCV listPro API usage
Numerical drift vs TradingViewBuiltin / series edge caseCompatibility

See also