npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

qntjs-lib

v2.0.3

Published

High-performance JavaScript/TypeScript library of technical-analysis indicators and array/math utilities (NaN-aware + dense fast paths).

Readme

qntjs-lib

CI NPM Version GitHub License

A pure fast JavaScript/TypeScript library of technical‑analysis indicators, trading performance/risk metrics, array utilities, and numerical helpers.

This package implements several TA indicators (EMA, TEMA, T3, MFI, KAMA, etc.), common trading performance metrics/utilities, vectorized math functions, and statistical helpers.

By default the main (typed) build returns typed arrays (e.g. Float64Array) for better numeric performance and predictable memory layout. A companion "untyped" build exposes the same API but returns plain number[] values for easier interoperability with plain JavaScript code.

The library has no runtime dependencies. It can be used in browser web applications or in Node.js environments that support ESM imports.

Quick Start

Install:

npm install qntjs-lib

Basic usage (default — typed output):

import { ta } from 'qntjs-lib';

const prices = [1,2,3,4,5,6,7];
// returns Float64Array by default (typed numeric output)
const out = ta.ema(prices, 3);

Basic usage (untyped — plain arrays):

import { ta } from 'qntjs-lib/untyped';

const prices = [1,2,3,4,5,6,7];
// returns plain number[] (easier to inspect/serialize)
const out = ta.ema(prices, 3);

When to use each:

  • Use the default import (qntjs-lib) when you want outputs as Float64Array for numeric performance and predictable memory layout.
  • Use qntjs-lib/untyped when you prefer plain number[] outputs for easier inspection or serialization.

Modules

Overview of top-level modules and minimal examples showing common usage patterns.

ta — technical indicators (moving averages, oscillators, volatility measures).

Example: compute an exponential moving average (EMA)

import { ta } from 'qntjs-lib';
const prices = [1,2,3,4,5,6,7];
const ema3 = ta.ema(prices, 3); // Float64Array

math — array-oriented math primitives and elementwise operations.

Example: elementwise subtract and scale

import { math } from 'qntjs-lib';
const a = [1,2,3];
const b = [0.1,0.1,0.1];
const diff = math.sub(a, b); // Float64Array of a-b
const scaled = math.scale(diff, 100);

perf — performance and risk helpers (returns, drawdowns, volatility, VaR/ES, ratios).

Example: compute daily returns, Sharpe, and parametric VaR

import { perf } from 'qntjs-lib';
const prices = [100, 110, 105, 120];
const rets = perf.returns(prices); // simple returns (Float32Array)
const daily = perf.dailyReturns([Date.now(), Date.now() + 86400000], [0.01, 0.02]);
const sr = perf.sharpe([0.01, -0.02, 0.03]);
const varP = perf.valueAtRisk([0.01, -0.02, 0.03], 0.05, 'parametric');

stats — aggregations, percentiles, variance, sampling utilities.

Example: quantile and sample

import { stats } from 'qntjs-lib';
const v = stats.quantile([1,2,3,4,5], 0.1);
const sample = stats.sample([1,2,3,4,5], 3);

arr — low-level array utilities (NaN handling, masks, fill/shift helpers).

Example: drop NaNs and forward-fill

import { arr } from 'qntjs-lib';
const a = [NaN, 1, NaN, 2];
const clean = arr.dropna(a);
const filled = arr.ffill(a);

List of available API

  • arr.* : isna, notna, fillna, ffill, bfill, replace, dropna, allna, equals, countna, havena, lag

  • math.* : add, sub, avg, mul, div, scale, abs, sign, round, floor, ceil, eq, neq, gt, gte, lt, lte, and, or, not, clamp, sum, prod, min, max, argmin, argmax, cumsum, cumprod, cummax, cummin, rollsum, rollmin, rollmax, rollminmax, rollprod, rollargmin, rollargmax, diff, randuniform, randnormal, dot, norm, ols, olsMulti

  • stats.* : mean, hmean, gmean, mad, skew, kurtosis, median, quantile, percentiles, var, covar, stdev, corr, zscore, norminmax, winsorize, sample, shuffle, bootstrap, rollmean, rollmedian, rollquantile, rollvar, rollcovar, rollstdev, rollcorr, rollskew, rollkurtosis

  • ta.* : dema, ema, hma, kama, sma, wma, vwma, trima, t3, tema, rma, ao, apo, aroon, change, cmo, kst, macd, mom, ppo, roc, rsi, stoch, stochrsi, ultosc, wpr, supertrend, adx, adxr, dx, cci, di, dpo, ichimoku, psar, atr, tr, natr, bb, bbw, donchian, keltner, adosc, obv, pnvi, wad, ad, mfi, cross, crossover, crossunder, rising, falling

  • perf.* : returns, logreturns, cumreturns, cagr, dailyreturns, dd, maxdd, maxddDetails, dduration, rollmaxdd, recoveryfactor, calmar, ulcer, rollulcer, sharpe, sortino, rollsharpe, rollsortino, vol, rollvol, var (valueAtRisk), expshortfall, tail, omega

skipna and dense fast-path

Where applicable, implementations are optimized for two common usage patterns:

  • NaN‑aware workflows (default): functions are NaN‑aware and will skip NaN values where appropriate.
  • Dense fast‑path: when you know inputs contain no NaNs you can opt into a dense, faster implementation by passing skipna=false to supported functions.
// NaN-aware (default)
ta.sma(pricesWithGaps, 5);

// Dense fast-path (assume no NaNs)
ta.sma(densePrices, 5, false);

Tests & development

Many functions, especially TA indicators are tested for correctness against Tulind library.

Run tests:

npm test

Build

npm run build

License

This project is licensed under the terms of the MIT license