[Compatibility guarantee]

What PYNE promises for Pine Script™ v5/v6 syntax, semantics, builtins, and real-world script corpora — and what it does not.

Compatibility guarantee

Abstract

PYNE aims for high syntactic fidelity and strong semantic compatibility with TradingView® Pine Script™ v5/v6 on the language core: parser, AST round-trip, type system, collections, technical builtins, and strategy primitives. Compatibility is not a claim of full platform parity (hosted chart, proprietary market data, editor-only features).

Source distillations: docs/compatibility_guarantee.md (v1.1, 2026-07-12) and live test inventory. Metrics move as the suite grows — prefer CI and the implementation status matrix for current checkmarks.

Conceptual model

Interface surface

Compatibility metrics (summary)

CategoryClaimStatus posture
Parser & syntaxFull grammar on real scripts (138+ builtin corpus)Solid
AST round-tripStructural match on corpusVerified
BuiltinsBroad coverage (200+ / dispatch hundreds)Good → excellent by namespace
Technical indicatorsCore + advanced; numerical cross-checksValidated in tests / reports
Strategyentry/exit/close, events, risk, OCA, commissionFunctional / improved 2026-07
Type systemint/float/bool/string/color/series/UDT/collectionsStrong
Real-world scriptsHigh parse success on corpusTested

Historical guarantee doc cited 1142 automated tests at last update — re-run make test for live counts.

Language features (core)

Documented at 100% support posture for:

  • var / varip, type annotations, functions/methods
  • Control flow, UDTs, operators, string interpolation
  • Imports/libraries, v6 enum, switch expressions
  • Series history, array/matrix/map, tuple unpacking, method chaining

Builtins (guarantee lens)

FamilyGuarantee style
math.*IEEE-oriented precision; exact for discrete ops
ta.*Cross-validated vs reference implementations within tight relative error
str.* / array.*Behavioral parity on exercised surface
PlottingSignature + registry effects; rendering is external (AXIS / clients)
strategy.*Execution model in-process; not a licensed broker

Internals

ArtifactRole
docs/compatibility_guarantee.mdLong-form guarantee text
tests/data/builtin_scripts/*.pineParametrized corpus
tests/test_parse_and_unparse.pyRound-trip
tests/test_real_world_compatibility.pyReal-script posture
tests/fixtures/parity/Cross-impl strategy events
reports/compatibility_report.jsonMachine-readable reports if generated

Invariants & edge cases

  1. Parse success ≠ evaluate success. A script may round-trip yet depend on mock request.* data.
  2. Plot functions are not TradingView’s renderer. They validate and record; pixels are optional.
  3. Undocumented / beta TV syntax may fail (guarantee doc notes a v7-beta edge).
  4. Floating-point parity is statistical, not bit-identical for all recursive smoothers — see Numerical validation.
  5. Library export / import require in-process registration paths when not on TV’s CDN.

Worked examples

Round-trip check

from pynescript.ast.helper import parse, unparse
src = open("strategy.pine").read()
assert unparse(parse(src))  # structural fidelity; exact whitespace may differ

Corpus pytest (narrow)

pytest tests/test_parse_and_unparse.py -q --example-scripts-dir=tests/data/builtin_scripts

Failure modes

ObservationInterpretation
Parse error on new TV release notes featureSurface gap — see Missing features
Numerical drift on custom indicatorCompare bar-mode vs list-mode; check na propagation
Strategy equity mismatch vs TVCommission/slippage/fill model differences; seed data
Import resolution failsLibrary not registered in runtime

See also