@luxalgo/vela-pinets
v0.2.3
Published
PineTS scripting engine for the Vela charting library — Pine Script indicators executed in-process or in a Web Worker, plugged into Vela's public ScriptingEngine port.
Readme
Vela-pinets
The PineTS scripting engine for the Vela charting
library — Pine Script indicators and strategies executed in-process (PineEngine) or
off the main thread (PineWorkerEngine), plugged into Vela's public ScriptingEngine
port. A strategy() script also emits its broker-emulator order fills as
IndicatorModel.trades (one marker per fill, at the fill bar and price), which Vela
paints as on-chart trade markers.
import { Vela } from '@luxalgo/vela';
import { PineEngine } from '@luxalgo/vela-pinets';
const chart = new Vela('#chart', { symbol: 'BTCUSDT', timeframe: '60' });
chart.registerEngine('pine', new PineEngine());
chart.addIndicator(`//@version=5
indicator("EMA 20", overlay=true)
plot(ta.ema(close, 20), color=color.orange)`);PineEngine— in-process: the simplest setup.@luxalgo/velaandpinetsare both peers of the whole package (npm i @luxalgo/vela-pinets @luxalgo/vela pinets) — the published entry imports both unconditionally, so each must resolve whichever engine you pick. Vela is a peer rather than a dependency for the same reason the browser build maps it ontowindow.Vela: a second copy would duplicate the SDK registries, not just the bytes. The worker avoids a second pinets by inlining its own at build time.PineWorkerEngine— the same Pine semantics in a Web Worker (source inlined at build time, spawned from a Blob URL): heavy scripts never block the chart.- Browser builds —
vela-pinets.global.js/.global.min.jsexposewindow.VelaPinetsfor script-tag usage; loadvela.global.jsfirst.
Development
npm install
npm run playground # http://localhost:5192 — Vela widget + this engine, HMR
npm run typecheck && npm run lint && npm run test && npm run buildVela is consumed as file:../Vela (built dist): clone this repo next to
Vela and build Vela first.
License
AGPL-3.0 — this package depends on pinets, which is AGPL-3.0 licensed.
The Vela charting library itself is Apache-2.0.
