Skip to main content

PYNE

An independent open toolchain for the PYNE language: ANTLR4 grammar, ASDL AST, dual-engine bar-loop runtime, language server, and HTTP evaluate surface.

Pine is usually executed inside a host chart. PYNE models the language as an inspectable pipeline — source through parse, AST, and deterministic bar-loop evaluation — so the same scripts can be analysed and run outside any particular UI. Import pynescript. CLIs: pyne, pyne-lsp, pyne-mcp (aliases pynescript, pynescript-lsp).

0.7.5 · PyPI hoox-pyne

PYNE is the language engine. HOOX is the execution mesh; AXIS is the charting PWA. All three publish under hoox.sh.


Pipeline

flowchart LR
  S["Source<br/>.pyne / .pine"] --> P["ANTLR4 lexer / parser"]
  P --> A["ASDL AST"]
  A --> R["Bar-loop<br/>interpret · compile · auto"]
  R --> O["Plots · fills · drawings<br/>strategy events · alerts"]
  O --> C["CLI"]
  O --> L["LSP"]
  O --> H["Pro API"]
  O --> Y["Pyodide"]
  O --> W["Cloudflare Workers"]

The same contract underlies the desk CLI, pyne-lsp, Flask POST /run, AXIS in-browser Pyodide, and pyne-worker (POST /run at the edge). Coverage and gaps: compatibility · missing features. Vendored OpenPineScript reference goldens live in tests/fixtures/tv_goldens/. Community set0x corpora and official reference builtins stay local-only.

Features

Area What you get
Parser ANTLR4 v5/v6 grammar, ASDL AST, parse ↔ unparse, structural linter, opt-in recovery (parse(..., recover=True))
Runtime Deterministic bar-loop interpret + Numba compile (auto), sessions, strategies, alerts, drawings
Language server Diagnostics, completion (~800+ builtins), hover, navigation, semantic tokens, formatting, Convert to v6
CLI check, format, lint, compile, run, execute, data, prewarm, mcp
MCP Stdio server + pyne mcp call for parse / lint / convert / compile / run
Backends Flask Pro API (/run, batch, preview, backtest, optimize), Cloudflare Workers, Pyodide
Security pyn_v2_ keys + SHA-256 fingerprint index, proxy-aware rate limits, auth/LSP throttles
Editors VS Code (AXIS Void / Hoox Signal / PYNE Volt themes), Neovim, Zed, Emacs
Parity 112 / 112 reference golden columns (OpenPineScript harnesses, ~2,475 daily bars, rel 1e-6)

Recent hardening (0.7.5+)

  • Parser — escaped triple-quoted delimiters, wrapped for headers after to/by/in, INV073/INV074 leading-operator rules, zero-padded decimals, and parse_with_errors() for mangled corpus/docs input. All 215 expected-success set06 fixtures pass strict-or-recovery.
  • API — new pyn_v2_ keys carry a SHA-256 fingerprint; invalid keys skip PBKDF2. /datafeed/session is API-key scoped, rate limits use the proxy-trusted client IP, /auth/validate and /lsp/* are throttled, and ?api_key= is opt-in only.
  • Performance — clean-source compile sanitization, stamped-node parse-cache scrubbing, ta.max same-bar fast path, one bar-open TA/var snapshot per realtime bar, and a trailing-chrome fast path for corpus sanitization.
  • Corpus — local-only audit tool (scripts/audit_pine_corpus.py) detects Expand (N lines) truncation and trailing scrape chrome; quarantined entries live under tests/data/_truncated/ and are never shipped.

Surfaces

Surface Role
CLI (pyne) Check, format, lint, compile, run (compile smoke), execute (Runtime.run), data, prewarm, MCP call
LSP (pyne-lsp) Diagnostics, completion (~800+ builtins), hover, navigation, semantic tokens, formatting
MCP (pyne-mcp / pyne mcp) Stdio server and in-process pyne mcp call — parse / lint / convert / compile / Runtime.run
VS Code First-class .pyne / .pine (extension)
Pro API HTTP evaluate, batch, chart preview, quick backtest, /optimize, datafeed
Editors Neovim, Zed, Emacs under clients/
PyneTS TypeScript / Bun library @hoox-sh/pynets

Front-end. Approximate Pine v5–v6 via ANTLR4 resource grammars; ASDL AST with visitor/transformer; parse → unparse; structural linter.

Runtime. Deterministic indicator and strategy evaluation on OHLCV. Dual engine: interpret (AST walk) and compile (Numba nopython with object-mode fallback); mode ∈ {auto, compile, interpret}. Persistent sessions (Runtime.create_session, append_bars, update_last_bar). Alerts with documented frequency. Strategy entries/exits, commission/slippage, drawing GC. request.security same-symbol simple OHLCV and allowlisted ta.*; foreign or complex security resolves to na.


Install

pip install hoox-pyne                 # library + CLI
pip install "hoox-pyne[lsp]"          # language server
pip install "hoox-pyne[compile]"      # Numba path
pip install "hoox-pyne[data]"         # market data
pip install "hoox-pyne[pro]"          # Flask Pro API
pip install "hoox-pyne[mcp]"          # stdio MCP (pyne mcp call needs no extra)

git clone https://github.com/hoox-sh/pyne.git
cd pyne
pip install -e ".[lsp,pro]"

Editors: the VS Code extension lives in its own repo — hoox-sh/pyne-lsp-vsce. It is a thin client for pyne-lsp and ships no server of its own; install hoox-pyne[lsp] (or let the extension prompt for it). Neovim / Zed / Emacs configs are in clients/.

GHCR multi-arch images on v* tags:

docker pull ghcr.io/hoox-sh/pyne/cli:0.7.5
docker run --rm -v "$PWD:/work" -w /work ghcr.io/hoox-sh/pyne/cli:0.7.5 check script.pine

docker pull ghcr.io/hoox-sh/pyne/lsp:0.7.5
docker run --rm -i -v "$PWD:/work" -w /work ghcr.io/hoox-sh/pyne/lsp:0.7.5

docker pull ghcr.io/hoox-sh/pyne/api:0.7.5
docker run --rm -p 5002:8080 -e ADMIN_TOKEN=… ghcr.io/hoox-sh/pyne/api:0.7.5

docker pull ghcr.io/hoox-sh/pyne/mcp:0.7.5
docker run --rm -p 5003:8080 ghcr.io/hoox-sh/pyne/mcp:0.7.5

Packages: ghcr.io/hoox-sh/pyne.

Edge POST /run (thin Workers host, separate repo):

Deploy to Cloudflare

Read pyne-worker limitations before deploying.


Quickstart

from pynescript.ast.helper import parse, unparse, literal_eval

source = """
//@version=6
indicator("My RSI")
plot(ta.rsi(close, 14))
"""
print(unparse(parse(source)))
literal_eval("1 + 2 * 3")  # 7

# Opt-in recovery for mangled corpus/docs input:
from pynescript.ast.helper import parse_with_errors
tree, errors = parse_with_errors('//@version=6\nindicator("x")\nalgopoint.co\nplot(close)\n')
pyne check script.pine
pyne format script.pine -w
pyne lint script.pine
pyne execute script.pine --mode interpret --bars 50
pyne compile script.pine --emit
pyne data AAPL --provider yahoo --period 6mo
pyne mcp tools
pyne mcp call lint script.pine
pip install "hoox-pyne[lsp]"
pyne-lsp
pip install "hoox-pyne[mcp]"
pyne mcp config          # mcpServers JSON
pyne mcp                 # stdio
pyne mcp call execute script.pine --arg bars=50 --arg mode=interpret

MCP catalog: tools. Editors: VS Code; Neovim / Zed / Emacs in clients/. CLI map: commands.

Pro API

make run binds :5002. POST /run accepts mode ∈ {auto, compile, interpret} and returns plots, series, events, drawings, alerts (error_kind / error_bar on failure). Optional webhook_url / ALERT_WEBHOOK_URL for last-bar alert firings.

make run

curl -s http://127.0.0.1:5002/run \
  -H 'Content-Type: application/json' \
  -d '{
    "script": "//@version=6\nindicator(\"demo\")\nplot(close)",
    "data": [{"open":1,"high":2,"low":0.5,"close":1.5,"time":1,"volume":1}],
    "mode": "auto"
  }'

Also: /run/batch, /compile/prewarm, /preview/chart, /backtest/quick, /optimize, /lsp/*, CCXT datafeed, optional hosted runner (PYNE_RUNNER=1). Docs: POST /run · API.

Pro routes use Authorization: Bearer … / Authorization: ApiKey …. New keys are pyn_v2_ with a SHA-256 fingerprint for fast invalid-key rejection; legacy pyn_ keys still work. /datafeed/session requires an API key and is owner-scoped. /auth/validate and /lsp/* have always-on rate limits; ?api_key= is opt-in only (ALLOW_API_KEY_QUERY=1).


MCP

PYNE ships a Model Context Protocol server so agents and editors can parse, lint, convert, compile, and run Pine without shelling out.

pip install "hoox-pyne[mcp]"
pyne mcp tools                  # list every tool
pyne mcp config                 # print the mcpServers JSON
pyne mcp                        # stdio server (pyne-mcp)
pyne mcp call lint script.pine  # in-process call, no server
Tool Purpose
pyne_parse / pyne_check Parse source → AST / diagnostics
pyne_lint / pyne_format Structural lint and format
pyne_convert Convert Pine v1–v5 toward v6
pyne_compile / pyne_prewarm Compile to the Numba IR / warm caches
pyne_run / pyne_execute Runtime.run over OHLCV (interpret / compile / auto)
pyne_hover / pyne_complete / pyne_signature Language intelligence for editors
pyne_optimize Strategy HPO
pyne_runner_* Hosted script registry + bar-close ticks

Client config (pyne mcp config prints this):

{
  "mcpServers": {
    "pyne": { "command": "pyne-mcp" }
  }
}

Full catalog: MCP tools · MCP guide.


Reference goldens

Nine reference harnesses were run inside the reference platform on BINANCE:BTCUSDT 1D. The reference log exports — OHLCV plus every plot column — ship in-tree. PYNE replays the same scripts on those bars.

112 columns · ~2,475 bars each · rel 1e-6 / abs 1e-9 · all agree

That is the same fixture set OpenPineScript uses: ta.*, math.*, strategy broker timing, and control-flow / loop probes, compared against the reference platform's own per-bar output. Coverage of that slice is 112 / 112. Chart host, remaining builtins, and live data are tracked under compatibility / missing features.

make tv-goldens          # 112 columns vs the vendored exports
make tv-goldens-strict   # fail on any divergence

Recipe, provenance, and GPL-3.0 notice: tests/fixtures/tv_goldens/.

Compatibility

The goldens above are the numerical check against the platform on that fixture set. Interpret ↔ compile plot parity is gated on first-party TA goldens; official reference builtins report 0 MISMATCH when they are present locally.

The 2026-11-23 local corpus audit reached 36 parse failures in 21,500 actual scripts (~0.17%); every inspected failure was an invalid/truncated/negative fixture, not a valid-Pine feature gap. 215/215 @expects parse: success set06 fixtures pass strict-or-recovery. Local-only corpus hygiene: python scripts/audit_pine_corpus.py --root tests/data.

Foreign / complex request.security resolves to na. reference Supertrend band ratchet, tick-path broker, and pixel chart UI are out of scope. Map: compatibility · missing features.

Results are for research, development, and self-hosted evaluation. They are not financial advice and are not provided by TradingView, Inc.


Documentation

Canonical docs: hoox.sh/pyne/docs

Topic Link
Install · quick start Getting started
CLI Guide · commands
MCP Guide · tools
Runtime Evaluate · alerts · compiler
Parser Helper API · grammar · error model
Pro API · security API · auth and keys · security
LSP Hub · VS Code
Coverage Compatibility · missing
Reference goldens fixture README · COMPATIBILITY.md
In-tree CHANGELOG · CONTRIBUTING · SECURITY
make install       # editable + LSP
make test          # pytest
make lint          # ruff
make tv-goldens    # 112 columns vs vendored reference exports

Ecosystem

                    https://hoox.sh
           ┌──────────────┼──────────────┐
           ▼              ▼              ▼
         HOOX            PYNE           AXIS
    (edge execution)  (Pine engine)  (charting UI)
Product Role Docs
HOOX Signal in → risk → CEX / DEX hop → notify docs.hoox.sh
PYNE PYNE language grammar, AST, dual-engine runtime, LSP, Pro API hoox.sh/pyne/docs
AXIS Installable charting PWA (Solid + Vite; offline via Pyodide) hoox.sh/axis/docs

Satellites: PyneTS, pyne-worker, pyne-agent-worker, pyne-lsp / pyne-vscode (in this tree), axis-plugin-boilerplate. HOOX isolate list: hoox-sh/hoox.


License

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

Educational and research use. Trading involves substantial risk of loss. This is not financial advice.

Pine Script(TM) and TradingView(R) are trademarks of TradingView, Inc.; Cloudflare(R) 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.

Metadata

Release files for hoox-pyne 0.7.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hoox-pyne 0.7.5
File Size Uploaded Provenance Actions
hoox_pyne-0.7.5.tar.gz 5.1 MB Without provenance Details for hoox_pyne-0.7.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hoox-pyne 0.7.5
File Interpreter ABI Platform Actions
hoox_pyne-0.7.5-py3-none-any.whl Python 3 none any Details for hoox_pyne-0.7.5-py3-none-any.whl

Total release size: 7.0 MB

Release files / hoox_pyne-0.7.5.tar.gz

Download URL hoox_pyne-0.7.5.tar.gz
Size 5.1 MB
Tags Source
SHA-256 checksum
How to use checksums
7359e7e69ad4c7f585111fc3153632dc4d824b445e8bb0668031409f6e38558d
BLAKE2b-256 checksum
How to use checksums
97ca4e891d1a6e654e1e0ecbace084b81247c7e61d9aee1d82b0541c041fa031
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / hoox_pyne-0.7.5-py3-none-any.whl

Download URL hoox_pyne-0.7.5-py3-none-any.whl
Size 1.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
37ea0e7a64a4b36be43ec180a4ed0999f057a95f89b84d041dec9305efe60018
BLAKE2b-256 checksum
How to use checksums
6e25cce6ca889fb5d2830c6a14d5eeafce670fcd0a1a4c20f31d696cdccc6687
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for hoox-pyne 0.7.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.5 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page