Skip to main content

PYNE

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.3.10 · 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.

Ecosystem

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):

Deploy to Cloudflare

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.

Abstract

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.

Corpus snapshot (set01–04 · local measurement · 2026-08-09)

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.

Capabilities

Language front-end

  • Grammar. Approximate Pine Script™ v5–v6 language surface via ANTLR4 resource grammars.
  • AST. ASDL-generated nodes with visitor and transformer patterns.
  • Round-trip. parse → unparse with preservation of formatting intent.
  • Linter. Static checks for common structural and style issues.

Runtime

  • Bar-loop evaluation. Deterministic indicator and strategy execution on OHLCV.
  • Dual engine. Interpret (AST walk) and compile (Numba nopython kernels with object-mode fallback); mode ∈ {auto, compile, interpret}.
  • 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 /run and 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.sort and array.binary_search* take sort_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 to na (no invented foreign closes).

Surfaces

Surface Role
CLI (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

Installation

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
pip install -e ".[lsp,pro]"

Container images (GHCR)

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.3.10
docker run --rm -v "$PWD:/work" -w /work ghcr.io/hoox-sh/pyne/cli:0.3.10 check script.pine

# Language server (stdio; -i required)
docker pull ghcr.io/hoox-sh/pyne/lsp:0.3.10
docker run --rm -i -v "$PWD:/work" -w /work ghcr.io/hoox-sh/pyne/lsp:0.3.10

# Pro API
docker pull ghcr.io/hoox-sh/pyne/api:0.3.10
docker run --rm -p 5002:8080 -e ADMIN_TOKEN= ghcr.io/hoox-sh/pyne/api:0.3.10

Packages: ghcr.io/hoox-sh/pyne. Local: make docker-build-lsp.

Quickstart

Parse and unparse

from pynescript.ast.helper import parse, unparse

source = """
//@version=6
indicator("My RSI")
plot(ta.rsi(close, 14))
"""

tree = parse(source)
print(unparse(tree))

Evaluate an expression

from pynescript.ast.helper import literal_eval

literal_eval("1 + 2 * 3")  # 7
literal_eval("ta.rsi([100, 102, 101, 103, 105], 9)")

CLI

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 …

Language server

pip install "hoox-pyne[lsp]"
pyne-lsp
# alias: pynescript-lsp

Editor integration: PYNE for VS Code; Neovim, Zed, and Emacs configs under clients/.

Pro API

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

Library API (sketch)

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

CLI reference

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

Documentation

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

Compatibility

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.

Contributing

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      # ruff

HOOX Open Trading Stack

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

Side projects

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
pine-worker TypeScript Cloudflare® Worker — earlier edge evaluator; emits trade events toward HOOX. hoox-sh/pine-worker
pyne-agent-worker Workers AI Pine Script agent (RAG + pyne-worker validate loop). AXIS sister plugin. hoox-sh/pyne-agent-worker
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/ + pyne-lsp
pip install -e ".[lsp,pro]"                                          # CLI + LSP + Pro API
git clone https://github.com/hoox-sh/pynets.git
git clone https://github.com/hoox-sh/pyne-worker.git
git clone https://github.com/hoox-sh/axis.git

License

SPDX: AGPL-3.0-or-later · Copyright (C) 2024–2026 jango_blockchained

GNU Affero General Public License v3.0 or later — see LICENSE.

🔋 Batteries included.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hoox_pyne-0.3.10.tar.gz (5.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hoox_pyne-0.3.10-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file hoox_pyne-0.3.10.tar.gz.

File metadata

  • Download URL: hoox_pyne-0.3.10.tar.gz
  • Upload date:
  • Size: 5.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for hoox_pyne-0.3.10.tar.gz
Algorithm Hash digest
SHA256 228b1ad64a72e0aa5abc044c1640dfc55ab5c5426b8e7901d20fdbb14c8b6f1a
MD5 21179f8977dfc6710c32efc0c3f4acee
BLAKE2b-256 5acc66a723a822eec122edb32ab1eb074ab85e8837ec7803307acef18cf2ea6f

See more details on using hashes here.

File details

Details for the file hoox_pyne-0.3.10-py3-none-any.whl.

File metadata

  • Download URL: hoox_pyne-0.3.10-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for hoox_pyne-0.3.10-py3-none-any.whl
Algorithm Hash digest
SHA256 27cc66a9fabdc5d581f38e2a55553e9555e966a3bfac06072026753e1cd518dd
MD5 a3bb475dc817ba0ea311b7b1aaad5a0d
BLAKE2b-256 1aa60bf2ac348731a83a97144f5a7c962e3311ace21d404cf857fffaa7e8dd2b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page