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.14 · 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. 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_RING default off.
  • 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 (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

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

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

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

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 · 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)
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.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.14.tar.gz (5.1 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.14-py3-none-any.whl (1.2 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hoox_pyne-0.3.14.tar.gz
  • Upload date:
  • Size: 5.1 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.14.tar.gz
Algorithm Hash digest
SHA256 fe5093b0ed0e264e03f92724d731fa4fc1e3d784711a10ab6bf57e70e1c43c52
MD5 841c96ac7eff4413c03a711a13148437
BLAKE2b-256 b07d816bfba5b0d1302ec68759c9ff72e92771a8f4a7468e8a469f70b88bda00

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hoox_pyne-0.3.14-py3-none-any.whl
  • Upload date:
  • Size: 1.2 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.14-py3-none-any.whl
Algorithm Hash digest
SHA256 7ba5c9ba2849894345b561c02045143d6d2610a2b49b4e219d27abf3a3cfa570
MD5 d8b9594114324e8c908ed4bbb14de4f5
BLAKE2b-256 2bf21822426912ba24bf95e595cc0a286f602f0fc5f5ac979e509b2d38b4ae45

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