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

talib

v2.0.3

Published

Technical Analysis Library

Downloads

4,775

Readme

node-talib

A modern Node.js wrapper around TA-LIB, providing 100+ technical analysis indicators including ADX, MACD, RSI, Stochastic, Bollinger Bands, TRIX, and candlestick pattern recognition.

Features

  • 100+ Technical Indicators - Comprehensive indicator library
  • Modern JavaScript - ES6+, async/await, Promises
  • TypeScript Support - Full type definitions included
  • Dual API - Both synchronous and asynchronous execution
  • ESM & CommonJS - Works with both module systems
  • High Performance - Native C++ bindings via N-API
  • Cross-Platform - Works on macOS, Linux, and Windows
  • No Dependencies - No external dependencies required
  • Lightweight - No unnecessary dependencies, small footprint

Prerequisites

  • Node.js >= 22.0.0
  • Python (for node-gyp)
  • C++ Build Tools

Installation

npm install talib

Quick Start

CommonJS

const talib = require('talib');

// Synchronous execution
const result = talib.execute({
  name: 'SMA',
  startIdx: 0,
  endIdx: prices.length - 1,
  inReal: prices,
  optInTimePeriod: 20
});

console.log(result.result.outReal);

ES Modules

import talib from 'talib';

const result = talib.execute({
  name: 'RSI',
  startIdx: 0,
  endIdx: prices.length - 1,
  inReal: prices,
  optInTimePeriod: 14
});

TypeScript

import * as talib from 'talib';

const result: talib.ExecuteResult = talib.execute({
  name: 'MACD',
  startIdx: 0,
  endIdx: prices.length - 1,
  inReal: prices,
  optInFastPeriod: 12,
  optInSlowPeriod: 26,
  optInSignalPeriod: 9
});

Building from Source

git clone https://github.com/oransel/node-talib.git
cd node-talib
npm install

The module will be built automatically during installation.

API Reference

Module Properties

talib.version           // TA-LIB version string
talib.functions         // Array of all available functions
talib.functionUnstIds   // Function unstable period IDs

Methods

talib.execute(params[, callback])

Execute a technical analysis function.

Synchronous:

const result = talib.execute({
  name: 'SMA',
  startIdx: 0,
  endIdx: data.length - 1,
  inReal: data,
  optInTimePeriod: 20
});

Asynchronous:

talib.execute({
  name: 'SMA',
  startIdx: 0,
  endIdx: data.length - 1,
  inReal: data,
  optInTimePeriod: 20
}, (err, result) => {
  if (err) return console.error(err);
  console.log(result);
});

With Async/Await:

const result = await new Promise((resolve, reject) => {
  talib.execute(params, (err, result) => {
    if (err) reject(err);
    else resolve(result);
  });
});

talib.explain(functionName)

Get detailed information about a function's parameters.

const info = talib.explain('ADX');
console.log(info);
// {
//   name: 'ADX',
//   group: 'Momentum Indicators',
//   hint: 'Average Directional Movement Index',
//   inputs: [...],
//   optInputs: [...],
//   outputs: [...]
// }

talib.setUnstablePeriod(functionId, period)

Set the unstable period for a function.

talib.setUnstablePeriod(talib.functionUnstIds.TA_FUNC_UNST_EMA, 30);

Common Indicators

Moving Averages

// Simple Moving Average
const sma = talib.execute({
  name: 'SMA',
  startIdx: 0,
  endIdx: prices.length - 1,
  inReal: prices,
  optInTimePeriod: 20
});

// Exponential Moving Average
const ema = talib.execute({
  name: 'EMA',
  startIdx: 0,
  endIdx: prices.length - 1,
  inReal: prices,
  optInTimePeriod: 12
});

Momentum Indicators

// Relative Strength Index
const rsi = talib.execute({
  name: 'RSI',
  startIdx: 0,
  endIdx: prices.length - 1,
  inReal: prices,
  optInTimePeriod: 14
});

// MACD
const macd = talib.execute({
  name: 'MACD',
  startIdx: 0,
  endIdx: prices.length - 1,
  inReal: prices,
  optInFastPeriod: 12,
  optInSlowPeriod: 26,
  optInSignalPeriod: 9
});

Volatility Indicators

// Bollinger Bands
const bbands = talib.execute({
  name: 'BBANDS',
  startIdx: 0,
  endIdx: prices.length - 1,
  inReal: prices,
  optInTimePeriod: 20,
  optInNbDevUp: 2,
  optInNbDevDn: 2,
  optInMAType: 0 // SMA
});

// Average True Range
const atr = talib.execute({
  name: 'ATR',
  startIdx: 0,
  endIdx: prices.length - 1,
  high: highs,
  low: lows,
  close: closes,
  optInTimePeriod: 14
});

Moving Average Types

When an indicator accepts optInMAType:

const MAType = {
  SMA: 0,    // Simple Moving Average
  EMA: 1,    // Exponential Moving Average
  WMA: 2,    // Weighted Moving Average
  DEMA: 3,   // Double Exponential Moving Average
  TEMA: 4,   // Triple Exponential Moving Average
  TRIMA: 5,  // Triangular Moving Average
  KAMA: 6,   // Kaufman Adaptive Moving Average
  MAMA: 7,   // MESA Adaptive Moving Average
  T3: 8      // Triple Exponential Moving Average (T3)
};

Examples

Check the examples/ directory for more examples:

# Run basic example
node examples/adx.js

# Run modern async example
node examples/adx-modern.js

# Run synchronous example
node examples/adx-sync.js

# Run ES module example
node examples/esm-example.mjs

# Run multiple indicators example
node examples/multiple-indicators.js

Testing

npm test

Troubleshooting

Build Errors

If you encounter build errors:

# Clean and rebuild
npm run clean
npm install

# Or use rebuild script
npm run rebuild

Python Not Found

Ensure Python is installed and in your PATH:

# Check Python installation
python --version
# or
python3 --version

Windows Build Issues

Install Visual Studio Build Tools:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

If this project helped you, consider supporting its development:

  • PayPal
  • BTC: 18gT1wmq3RMoLBm2ZFv4PhiYbU5CMAQC6P

Links

License

Copyright (c) 2012-2026 Mustafa Oransel

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.