Independent open toolchain for the Pine Scriptโข language โ formal grammar, algebraic AST, dual-engine bar-loop runtime, language server, and HTTP evaluation surface. Part of the HOOX open trading stack.
0.4.4 ยท PyPI hoox-pyne ยท import pynescript ยท CLIs pyne ยท pyne-lsp (aliases: pynescript ยท pynescript-lsp)
Pine Scriptโข and TradingViewยฎ are trademarks of TradingView, Inc.. Cloudflareยฎ is a trademark of Cloudflare, Inc.
PYNE is an independent, unofficial implementation. It is not affiliated with, authorized by, sponsored by, or endorsed by TradingView, Inc. or Cloudflare, Inc., and is not an official TradingViewยฎ product, service, or platform substitute.
Language references are for interoperability and compatibility documentation only. PYNE does not redistribute proprietary TradingViewยฎ platform software, charting UI, or closed data services.
Part of the HOOX open trading stack:
| Product | Role | Repo | Website |
|---|---|---|---|
| HOOX | Edge trading framework (Cloudflareยฎ Workers) | hoox-sh/hoox | hoox.sh ยท docs |
| PYNE | Pine Scriptโข toolchain + Pro API (this repo) | hoox-sh/pyne | hoox.sh/pyne ยท docs |
| pyne-worker | Python Cloudflareยฎ Worker โ edge evaluate | hoox-sh/pyne-worker | hoox.sh/pyne |
| pyne-agent-worker | NL โ PYNE scripts (Workers AIโข) | hoox-sh/pyne-agent-worker | PYNE agent |
| AXIS | Charting PWA | hoox-sh/axis | hoox.sh/axis ยท docs |
Edge evaluate (one-click, not this repo):
That button deploys pyne-worker โ a thin Workers host for POST /run. CLI, LSP, compile, Flask Pro API, and the language source of truth stay here. See pyne-worker limitations.
Pine Scriptโข is commonly executed inside a host charting environment. PYNE models the language as an inspectable pipeline โ source text through parse, AST construction, and deterministic bar-loop evaluation โ so the same scripts can be analysed and run outside any particular UI.
Source (.pyne / .pine)
โ ANTLR4 lexer / parser
โ ASDL AST
โ bar-loop (interpret | compile | auto)
โ plots ยท fills ยท drawings ยท strategy events ยท alerts
โ optional HTTP / edge / editor clients
The same pipeline underlies the desk CLI, the Language Server Protocol (LSP) binary, the Pro API, browser Pyodide evaluation (via AXIS), and Cloudflareยฎ Workers that share one evaluate contract.
Coverage and known gaps are documented under compatibility and implementation status. This repository does not ship third-party script corpora or TradingViewยฎ builtin downloads.
Open-source Pine regression sets (2477 scripts; not shipped in git) under parse+unparse and Runtime interpret (50 bars, 12s timeout):
| Suite | Rate | Detail |
|---|---|---|
| Parse + unparse | 99.96% | 2476 / 2477 OK โ residual is one intentional invalid line-wrap docs demo |
| Runtime interpret | 100% excl. EXPECTED | 2466 OK + 11 intentional demos (runtime.error guards, lower-TF security, pathological loops) |
| set01 Runtime | 100% | 249 / 249 OK |
Not a claim of TradingViewยฎ platform parity. Intentional demos are classified so OK% stays honest.
- Grammar. Approximate Pine Scriptโข v5โv6 language surface via ANTLR4 resource grammars.
- AST. ASDL-generated nodes with visitor and transformer patterns.
- Round-trip.
parse โ unparsewith preservation of formatting intent. - Linter. Static checks for common structural and style issues.
- Bar-loop evaluation. Deterministic indicator and strategy execution on OHLCV. Interpret (0.3.10) inlines Assign/Call after bar 0, skips unused derived series, and incrementally updates volume TA (
obv/wad/cmf/klinger).PYNE_SERIES_RINGdefault off. - Dual engine. Interpret (AST walk) and compile (Numba nopython kernels with object-mode fallback);
modeโ {auto,compile,interpret}. Object-mode recovers UDT/switch/map/matrix/drawing scripts that previously leakedTypingErroror stored objects into float64 series. - Warm compile. Disk IR cache, process prewarm, and recovery from corrupt cache state.
- Plot parity. Interpret โ compile series alignment verified by harness and tests (internal engine consistency, not platform certification).
- Alerts.
alert()/alertcondition()with documented frequency semantics (once_per_bar,once_per_bar_close,all); structured export on Pro/runand optional L2 webhooks. - Strategy surface. Entries, exits, events, commission/slippage paths, pending-fill behaviour under pyramiding constraints.
- Drawing GC. Honour of
max_lines_count,max_labels_count,max_boxes_count,max_polylines_count. - UDT collections.
array.sort/array.sort_indices/matrix.sortandarray.binary_search*takesort_field(const int index, default 0, or const string name) on arrays of user-defined types. - Security policy. Same-symbol simple OHLCV for
request.security; foreign or complex security resolves tona(no invented foreign closes).
| Surface | Role |
|---|---|
CLI (pyne, alias pynescript) |
Check, format, lint, compile, run, data fetch, prewarm |
LSP (pyne-lsp) |
Diagnostics, completion (~800+ builtins), hover, navigation, semantic tokens, formatting |
| VS Code extension | First-class .pyne / .pine (and related) associations |
| Pro API | HTTP evaluate, batch run, chart preview, quick backtest |
| Editors | Configurations for Neovim, Zed, Emacs (see clients/) |
| PyneTS | TypeScript / Bun library (@hoox/pynets) โ standalone repo, consumed here only as the pynets/ git submodule |
pip install hoox-pyne # core library + CLI
pip install "hoox-pyne[lsp]" # language server
pip install "hoox-pyne[compile]" # Numba compile path
pip install "hoox-pyne[data]" # market data providers
pip install "hoox-pyne[pro]" # Flask Pro API stack
# Development install from a clone
git clone --recurse-submodules https://github.com/hoox-sh/pyne.git
cd pyne
git submodule update --init --recursive # pynets/; needed after a plain clone
pip install -e ".[lsp,pro]"Multi-arch (linux/amd64, linux/arm64) images publish to GitHub Container Registry on v* tags (and via Actions โ GHCR โ Run workflow):
# CLI
docker pull ghcr.io/hoox-sh/pyne/cli:0.4.4
docker run --rm -v "$PWD:/work" -w /work ghcr.io/hoox-sh/pyne/cli:0.4.4 check script.pine
# Language server (stdio; -i required)
docker pull ghcr.io/hoox-sh/pyne/lsp:0.4.4
docker run --rm -i -v "$PWD:/work" -w /work ghcr.io/hoox-sh/pyne/lsp:0.4.4
# Pro API
docker pull ghcr.io/hoox-sh/pyne/api:0.4.4
docker run --rm -p 5002:8080 -e ADMIN_TOKEN=โฆ ghcr.io/hoox-sh/pyne/api:0.4.4Packages: ghcr.io/hoox-sh/pyne. Local: make docker-build-lsp.
from pynescript.ast.helper import parse, unparse
source = """
//@version=6
indicator("My RSI")
plot(ta.rsi(close, 14))
"""
tree = parse(source)
print(unparse(tree))from pynescript.ast.helper import literal_eval
literal_eval("1 + 2 * 3") # 7
literal_eval("ta.rsi([100, 102, 101, 103, 105], 9)")pyne check script.pine
pyne format script.pine -w
pyne lint script.pine
pyne run script.pine --bars 100
pyne compile script.pine --emit
pyne data AAPL --provider yahoo --period 6mo
pyne info
# aliases still work: pynescript check โฆpip install "hoox-pyne[lsp]"
pyne-lsp
# alias: pynescript-lspEditor integration: PYNE for VS Code; Neovim, Zed, and Emacs configs under clients/.
Self-hosted (or managed) HTTP surface for script evaluation and previews:
| Endpoint | Description |
|---|---|
POST /run |
Execute script (mode default auto); returns plots, series, events, drawings, alerts |
POST /run/batch |
Multiple scripts on shared OHLCV |
POST /compile/prewarm |
Warm Numba builtins / optional scripts |
POST /preview/chart |
Chart thumbnail |
POST /preview/indicator |
Indicator chart (SMA, EMA, RSI, MACD, โฆ) |
POST /backtest/quick |
Quick backtest with equity curve |
/run accepts mode โ {auto, compile, interpret}, returns structured errors (error_kind, error_type, error_bar), and can forward last-bar alert firings to an optional webhook (webhook_url or server ALERT_WEBHOOK_URL).
make run # :5002
curl -s http://127.0.0.1:5002/run \
-H 'Content-Type: application/json' \
-d '{
"script": "//@version=6\nindicator(\"demo\")\nplot(close)\nalert(close > open, alert.freq_once_per_bar)",
"data": [{"open":1,"high":2,"low":0.5,"close":1.5,"time":1,"volume":1}],
"mode": "auto"
}'Documentation: POST /run ยท Alerts ยท API hub
from pynescript.ast.helper import parse, unparse, literal_eval
from pynescript.ast.linter import lint_script
from pynescript.ast.transformer import NodeTransformer
tree = parse(source_code)
warnings = lint_script(source_code)
value = literal_eval("ta.sma([100, 102, 101], 3)")
class Renamer(NodeTransformer):
def visit_Name(self, node):
if node.id == "close":
node.id = "price"
return node| Command | Purpose |
|---|---|
check <file> |
Parse-only validation |
format <file> |
Format via parse โ unparse |
lint <file> |
Static analysis |
parse-and-dump <file> |
Print AST |
parse-and-unparse <file> |
Normalize source |
compile <file> |
Numba host pipeline / emit |
run <file> |
Execute on synthetic (or provided) OHLCV |
prewarm [PATHโฆ] |
Warm compile caches |
data <symbol> |
Fetch market data |
info |
Version and optional extras |
Language server entry point: pyne-lsp (alias pynescript-lsp; separate console script).
Canonical product documentation: hoox.sh/pyne/docs
| Topic | Link |
|---|---|
| Installation ยท quick start | Getting started |
| Evaluate scripts | Evaluate guide |
| Alerts & webhooks | Runtime alerts |
| Compiler & parity | Compiler ยท Parity |
| Pro API | API ยท Usage |
| LSP | LSP hub ยท VS Code |
| Compatibility | Compatibility ยท Status |
In-repository notes: Roadmap ยท Missing features ยท Changelog
PYNE targets practical runtime fidelity verified with first-party fixtures, unit tests, and (when present locally) open-source corpus sets. Latest local corpus snapshot (set01โ04, 2026-08-09): parse 99.96%, Runtime interpret 100% excl. intentional demos โ see the table under Abstract. It does not claim:
- official TradingViewยฎ certification or endorsement
- complete platform parity (chart host, data model, every edge-case builtin, or closed UI behaviour)
- that results will match the TradingViewยฎ platform on every script or bar
Prefer the published compatibility and implementation status pages for current surface coverage.
Results obtained with PYNE are for research, development, and self-hosted evaluation. They are not financial advice and are not provided by TradingView, Inc.
See CONTRIBUTING.md. Code of conduct: CODE_OF_CONDUCT.md. Security reports: SECURITY.md.
make install # editable install with LSP
make test # pytest
make lint # ruffPYNE is part of the HOOX Open Trading Stack โ three complementary open projects under one product site:
| Product | Role | Repository | Website |
|---|---|---|---|
| HOOX | Edge trading framework (Cloudflareยฎ Workers) โ signal validation and execution at the edge | hoox-sh/hoox | hoox.sh ยท docs |
| PYNE | Pine Scriptโข-oriented toolchain, LSP, Pro API, dual-engine runtime (this repository) | hoox-sh/pyne | hoox.sh/pyne ยท docs |
| AXIS | Installable charting PWA (Solid + Vite) โ optional UI over evaluate contracts | hoox-sh/axis | hoox.sh/axis ยท docs |
https://hoox.sh
โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโ
โผ โผ โผ
HOOX PYNE AXIS
(edge execution) (Pine engine) (charting UI)
โ โ โ
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
trade signals / eval API
How they relate
- PYNE owns language semantics: parse, evaluate/compile, alerts, strategy events, and the HTTP evaluate surface (
/run, batch, previews). - AXIS is an optional chart host. It can call PYNEโs Pro API (or edge workers) to plot series, fills, and drawings โ evaluation does not require AXIS.
- HOOX is an optional execution mesh. Strategy events and alert webhooks from PYNE can feed edge trade paths; HOOX does not replace the PYNE runtime.
Evaluation never depends on a proprietary chart host. AXIS and HOOX are optional clients of the same open evaluate contract. None of these projects is affiliated with or endorsed by TradingView, Inc.
This repository plus satellites that share the evaluate contract. Python pynescript.runtime remains the language SoT.
| Project | Role | Repository |
|---|---|---|
| PYNE | This repository โ grammar, AST, dual-engine Runtime, Pro API, CLI (pyne / pynescript). PyPI hoox-pyne. |
hoox-sh/pyne |
| pyne-lsp | Language server (pyne-lsp / pynescript-lsp) โ extras [lsp], Nuitka binaries, Docker ghcr.io/hoox-sh/pyne/lsp. |
hoox-sh/pyne ยท docs ยท GHCR |
| pyne-vscode | VS Code / Open VSX extension (hoox-sh.pyne). Package pyne-vscode-*.vsix on Releases. Needs hoox-pyne[lsp] or a pyne-lsp binary. |
vscode-extension/ ยท Marketplace |
| PyneTS | TypeScript / Bun library (@hoox/pynets) โ parse, unparse, interpret. Same public names as Python. Submodule pynets/. |
hoox-sh/pynets |
| pyne-worker | Python Cloudflareยฎ Worker โ edge POST /run, cron, R2, alerts. Thin host over package Runtime. |
hoox-sh/pyne-worker ยท docs |
| pyne-agent-worker | Workers AI PYNE Agent (RAG + optional pyne-worker validate). AXIS plugin. | hoox-sh/pyne-agent-worker ยท docs |
| AXIS | Charting PWA (Solid + Vite). Calls Pro API or edge /run; ships the VPS static frontend/dist. |
hoox-sh/axis |
| HOOX | Edge trading mesh. Optional sink for strategy events and alert webhooks. | hoox-sh/hoox |
HOOX also publishes execution-plane workers (hoox-worker, trade-worker, telegram-worker, d1-worker, โฆ) under github.com/hoox-sh. Those are execution and ops, not the Pine language toolchain.
git clone --recurse-submodules https://github.com/hoox-sh/pyne.git # PYNE + pynets/ submodule (pyne-lsp is in-tree)
git submodule update --init --recursive # after a plain clone
pip install -e ".[lsp,pro]" # CLI + LSP + Pro API
git clone https://github.com/hoox-sh/pynets.git # TypeScript library
git clone https://github.com/hoox-sh/pyne-worker.git # edge POST /run
git clone https://github.com/hoox-sh/pyne-agent-worker.git # NL authoring
git clone https://github.com/hoox-sh/axis.gitSPDX: AGPL-3.0-or-later ยท Copyright (C) 2024โ2026 jango_blockchained
GNU Affero General Public License v3.0 or later โ see LICENSE.
๐ Batteries included.




