Files
wickra/bindings/wasm
kingchenc 3a6b5ebae3 feat(wasm): expose streaming update/isReady/warmupPeriod for 12 candle indicators (R3, R8)
Twelve WASM classes previously exposed only `batch()` (and not even
`reset()` for ten of them): ADX, WilliamsR, CCI, MFI, PSAR, Keltner,
Donchian, VWAP, AwesomeOscillator, Aroon, Stochastic, OBV. Browser
consumers wanting per-tick updates had to replay `batch()` on every new
candle — the opposite of the library's streaming-first promise.

Each class now exposes:

- `update(...)` — per-tick streaming update with the same column inputs
  as `batch()`. Single-output indicators return `Option<f64>`. Multi-
  output indicators (ADX, Keltner, Donchian, Aroon, Stochastic) return a
  named JS object (`{ plusDi, minusDi, adx }`, `{ upper, middle, lower }`,
  `{ up, down }`, `{ k, d }`) once warm, or `null` during warmup. This
  matches the existing `SuperTrend` convention so JS code can treat all
  multi-output WASM indicators uniformly.
- `reset()`, `isReady()`, `warmupPeriod()` — bring the lifecycle API to
  full parity with Python and Node.

`WasmKama` also gains the previously missing `warmupPeriod()` (R8). A
single new `wasm-bindgen-test` exercises every newly wired class against
a deterministic 40-bar synthetic OHLCV stream, asserting that
streaming `update` matches `batch` value-by-value and that the lifecycle
contract behaves the same as the core indicator.
2026-05-23 01:34:54 +02:00
..
2026-05-22 04:05:15 +02:00

wickra-wasm

WebAssembly bindings for the Wickra streaming-first technical indicators library.

Build

You need wasm-pack and the wasm32-unknown-unknown Rust target:

rustup target add wasm32-unknown-unknown
cargo install wasm-pack

Then from the repository root:

wasm-pack build bindings/wasm --target web --release --features panic-hook

The compiled package lands in bindings/wasm/pkg/. Targets:

  • --target web for native ES modules in browsers
  • --target bundler for webpack/Vite/Rollup
  • --target nodejs for Node.js

Example

import init, { SMA, RSI, MACD, version } from "./pkg/wickra_wasm.js";

await init();
console.log("wickra:", version());

// Streaming
const rsi = new RSI(14);
for (const price of livePrices) {
  const v = rsi.update(price);
  if (v !== undefined && v > 70) console.log("overbought");
}

// Batch (returns a Float64Array; NaN for warmup positions)
const sma = new SMA(20).batch(new Float64Array(historicalPrices));

An interactive demo lives in examples/wasm/index.html (top-level alongside the other language examples). After building the package with wasm-pack build, serve the repository root and open examples/wasm/index.html in a browser.