Files
wickra/bindings/node
kingchenc a0884fa010 B2: make fallible Node constructors throw instead of panicking
The 14 candle and multi-parameter indicator constructors passed raw
parameters through must() (an expect()), so invalid arguments such as
new MACD(0,0,0) or new BollingerBands(20,-1) aborted the whole process
over the napi boundary (the release profile sets panic=abort).

napi-rs 2.16 does accept a #[napi(constructor)] returning
napi::Result<Self> (the old must() comment was wrong), so each now
returns napi::Result<Self> and throws a clean JS error via map_err.
must()/clamp_period stay for the scalar macro, where period is clamped
and the Result is provably Ok. Verified: every invalid constructor
throws, valid ones still build.
2026-05-22 03:44:56 +02:00
..

@wickra/wickra

Node.js bindings for the Wickra streaming-first technical indicators library.

Install

Once published, install per platform via the precompiled native package:

npm install @wickra/wickra

Build from source

cd bindings/node
npm install
npm run build
npm test

The native module is built via napi-rs. The build script produces a wickra.<platform>-<arch>.node binary in the package root that index.js loads at runtime.

Usage

import { SMA, RSI, MACD, version } from '@wickra/wickra';

console.log('wickra', version());

// Batch:
const prices = Array.from({ length: 1000 }, (_, i) => 100 + Math.sin(i * 0.1) * 5);
const rsi = new RSI(14).batch(prices);

// Streaming:
const macd = new MACD(12, 26, 9);
for (const p of livePriceStream) {
  const v = macd.update(p);
  if (v && v.histogram > 0) console.log('bullish crossover candidate');
}

See index.d.ts for the full TypeScript surface.