Skip to content

Bitvested/ta.js

Repository files navigation

Technical Analysis (ta.js)

npm version Downloads License: MIT

A powerful, lightweight JavaScript library for Technical Analysis and financial market data calculations.


NOTE

ta.js works in React out of the box — pure JavaScript, zero runtime dependencies, side-effect-free exports. Import from the ESM bundle and call the functions:

import { sma, rsi } from 'ta.js/ta.esm.js';

The only Node-only feature is ta.multi.sim (Monte Carlo via worker_threads); the build pipeline aliases it to a browser stub so ta.multi is undefined in browser bundles rather than crashing.

Install

NPM

npm install ta.js

CDN

Three browser bundles are shipped. Pick whichever fits your setup:

<!-- IIFE bundle (recommended) — exposes `window.ta` -->
<script src="https://unpkg.com/ta.js/ta.iife.min.js"></script>
<script>
  ta.sma([1,2,3,4,5,6,10], 6);     // [3.5, 5]
  ta.aroon.up([[10,7],[12,9],[14,11],[13,10],[15,12]], 4);
</script>

<!-- ES module (for <script type="module"> and modern bundlers) -->
<script type="module">
  import { sma, rsi } from 'https://unpkg.com/ta.js/ta.esm.js';
  sma([1,2,3,4,5,6,10], 6);
</script>

<!-- Legacy bundle (top-level function globals; kept for backward compatibility) -->
<script src="https://unpkg.com/ta.js/ta.min.js"></script>

Usage

CommonJS (Node)

const ta = require('ta.js');
ta.sma([1,2,3,4,5,6,10], 6);         // [3.5, 5]
ta.aroon.up([[10,7],[12,9],[14,11],[13,10],[15,12]], 4);

ES modules

import { sma, rsi, aroon } from 'ta.js/ta.esm.js';
sma([1,2,3,4,5,6,10], 6);

Browser

<script src="https://unpkg.com/ta.js/ta.iife.min.js"></script>
<script>
  ta.sma([1,2,3,4,5,6,10], 6);
</script>

Performance

ta.js v2.0 is the fastest pure-JS technical-analysis library at production data sizes. Across 67 cross-library benchmark cases at 100k bars, ta.js wins 66, typically by 2-3× over the next-best competitor and ~10× over tulind's native C bindings (JS↔C marshaling overhead overwhelms the native-math advantage at every size we tested).

Headline indicators at 100,000 bars (ops/sec, higher is better):

indicator ta.js next-best margin
sma 2,290 @debut/indicators 779 2.94×
ema 1,870 trading-signals 1,480 1.26×
rsi 1,340 @debut/indicators 373 3.59×
macd 606 trading-signals 337 1.80×
bbands 1,140 @debut/indicators 370 3.08×
atr 1,380 @debut/indicators 1,000 1.38×
stoch 303 @debut/indicators 241 1.26×
vwap 1,220 technicalindicators 400 3.05×

Measured on Apple M3 / Darwin 25.3.0 arm64 / Node v25.1.0 against technicalindicators 3.1.0, trading-signals 7.4.3, @debut/indicators 1.3.22, and tulind 0.8.20. Full per-case tables across 1k / 10k / 100k bar inputs are in BENCHMARKS.md. Reproduce on your hardware with:

cd bench
npm install
npm run bench:md   # regenerates BENCHMARKS.md + bench/results.json

Quote ratios, not absolute ops/sec, when comparing across machines.

Examples

https://github.com/Bitvested/ta.js/blob/main/EXAMPLES.md

Moving Averages

Indicators

Oscillators

Bands

Statistics

Random functions

Chart Types

Miscellaneous

Experimental

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

👨‍💻 Maintained By

ta.js is an open-source project created and actively maintained by Nino Kroesen.

This library was built with performance in mind for high-frequency data and algorithmic trading systems. If you are interested in seeing these indicators in action within a live quantitative trading environment, check out Bitvested.


About

Financial Technical Analysis in JavaScript

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors