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.
xcode-select --install)build-essential packageWindows + recent Visual Studio: Newer Visual Studio releases (e.g. VS 2026 / v18) are only detected by
node-gyp>= 12.1.0. Thenode-gypbundled with npm may be older and fail withCould not find any Visual Studio installation to use. See Windows Build Issues if you hit this.
npm install talib
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);
import talib from 'talib';
const result = talib.execute({
name: 'RSI',
startIdx: 0,
endIdx: prices.length - 1,
inReal: prices,
optInTimePeriod: 14
});
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
});
git clone https://github.com/oransel/node-talib.git
cd node-talib
npm install
The module will be built automatically during installation.
talib.version // TA-LIB version string
talib.functions // Array of all available functions
talib.functionUnstIds // Function unstable period IDs
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);
// 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
});
// 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
});
// 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
});
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)
};
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
npm test
If you encounter build errors:
# Clean and rebuild
npm run clean
npm install
# Or use rebuild script
npm run rebuild
Ensure Python is installed and in your PATH:
# Check Python installation
python --version
# or
python3 --version
Install Visual Studio Build Tools:
Could not find any Visual Studio installation to use / unknown version "undefined"
This means your node-gyp is too old to recognize your installed Visual Studio. Visual Studio 2026 (v18) requires node-gyp >= 12.1.0, but the copy bundled with npm is often older. Upgrade node-gyp and rebuild:
# Install a node-gyp that knows about modern Visual Studio
npm install --global node-gyp@latest
# Then rebuild from a cloned repo using that node-gyp
npm run clean
node ./src/lib/build.js
node-gyp configure
node-gyp build
When installing talib as a dependency (so you can't run the steps above directly), point npm at the upgraded node-gyp so its install step uses it:
npm install --global node-gyp@latest
npm config set node_gyp "$(npm prefix -g)/node_modules/node-gyp/bin/node-gyp.js"
Contributions are welcome! Please feel free to submit a Pull Request.
If this project helped you, consider supporting its development:
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.
C
96.4%
Makefile
2.1%
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.
xcode-select --install)build-essential packageWindows + recent Visual Studio: Newer Visual Studio releases (e.g. VS 2026 / v18) are only detected by
node-gyp>= 12.1.0. Thenode-gypbundled with npm may be older and fail withCould not find any Visual Studio installation to use. See Windows Build Issues if you hit this.
npm install talib
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);
import talib from 'talib';
const result = talib.execute({
name: 'RSI',
startIdx: 0,
endIdx: prices.length - 1,
inReal: prices,
optInTimePeriod: 14
});
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
});
git clone https://github.com/oransel/node-talib.git
cd node-talib
npm install
The module will be built automatically during installation.
talib.version // TA-LIB version string
talib.functions // Array of all available functions
talib.functionUnstIds // Function unstable period IDs
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);
// 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
});
// 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
});
// 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
});
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)
};
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
npm test
If you encounter build errors:
# Clean and rebuild
npm run clean
npm install
# Or use rebuild script
npm run rebuild
Ensure Python is installed and in your PATH:
# Check Python installation
python --version
# or
python3 --version
Install Visual Studio Build Tools:
Could not find any Visual Studio installation to use / unknown version "undefined"
This means your node-gyp is too old to recognize your installed Visual Studio. Visual Studio 2026 (v18) requires node-gyp >= 12.1.0, but the copy bundled with npm is often older. Upgrade node-gyp and rebuild:
# Install a node-gyp that knows about modern Visual Studio
npm install --global node-gyp@latest
# Then rebuild from a cloned repo using that node-gyp
npm run clean
node ./src/lib/build.js
node-gyp configure
node-gyp build
When installing talib as a dependency (so you can't run the steps above directly), point npm at the upgraded node-gyp so its install step uses it:
npm install --global node-gyp@latest
npm config set node_gyp "$(npm prefix -g)/node_modules/node-gyp/bin/node-gyp.js"
Contributions are welcome! Please feel free to submit a Pull Request.
If this project helped you, consider supporting its development:
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.
C
96.4%
Makefile
2.1%