[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
| Surface | Entry | Typical job |
|---|---|---|
| CLI | pynescript … | One-shot parse, format, lint, market data |
| Library | from pynescript.ast import parse, unparse | Embed parse/transform/eval in tools |
| LSP | pynescript-lsp | Diagnostics, completion, hover in editors |
| Pro API | POST /run | Shared evaluate contract for AXIS / workers |
| AXIS | separate product | Chart PWA AXIS over evaluate results |
| HOOX | separate product | Edge 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_evalin under ten minutes. - Configuration — Extras, console scripts, Pro API env vars, editor settings.
2. Operational guides
Daily workflows against the same pipeline:
- CLI —
parse-and-dump,parse-and-unparse,lint,data,download-builtin-scripts. - Library API —
parse,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)
| Want | Command / import | Docs |
|---|---|---|
| Install core | pip install pynescript | Installation |
| Install LSP | pip install "pynescript[lsp]" | Editors |
| Install market data deps | pip install "pynescript[data]" | CLI data |
| Parse file | pynescript parse-and-dump path.pine | CLI |
| Normalize source | pynescript parse-and-unparse path.pine | CLI |
| Lint | pynescript lint path.pine | CLI |
| Library parse | from pynescript.ast import parse, unparse | Library API |
| Expression eval | from pynescript.ast.helper import literal_eval | Evaluate |
| Start LSP | pynescript-lsp (stdio) | Editors |
| Local Pro API | make run / python -m backend.app | Pro API usage |
Two console scripts are registered in pyproject.toml:
| Script | Module | Role |
|---|---|---|
pynescript | pynescript.__main__:cli | Desk CLI (Click group) |
pynescript-lsp | pynescript.langserver.__main__:main | Language 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:
| Path | Role |
|---|---|
src/pynescript/__main__.py | Click CLI: parse-and-dump, parse-and-unparse, lint, data, download-builtin-scripts |
src/pynescript/ast/helper.py | Public parse, unparse, dump, walk, literal_eval |
src/pynescript/ast/linter.py | lint_script / PineLinter |
src/pynescript/ast/evaluator/ | Bar-aware and literal evaluators |
src/pynescript/langserver/ | LSP features and server |
src/pynescript/util/data.py | Historical data providers (mock, yahoo, alphavantage, ccxt) |
backend/app.py | Flask Pro API entry (/run, auth, blueprints) |
backend/runtime.py | HTTP-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.
parse→unparseshould 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 byliteral_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 usingpinescript_filepathcan 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
| Symptom | Likely cause | Where to go |
|---|---|---|
pynescript: command not found | Package not on PATH / venv inactive | Installation |
pynescript-lsp missing | Installed without [lsp] extra | Editors |
SyntaxError on parse | Grammar mismatch or truncated source | Troubleshooting |
/run 400 NO_DATA | Missing OHLCV list | Pro API usage |
| Numerical drift vs TradingView | Builtin / series edge case | Compatibility |
See also
- PYNE product map — full stack overview
- Installation
- Quick start
- Evaluate contract (API)
- AXIS docs — optional chart
- HOOX docs — optional edge trade mesh