Technical indicators and overlays to run technical analysis with JavaScript / TypeScript.
Provide a TypeScript implementation for common technical indicators with arbitrary-precision decimal arithmetic.
- Accurate. Don't rely on type
number
and its precision limits. Use Big. - Typed. Source code is 100% TypeScript. No need to install external typings.
- Tested. Code coverage is 100%. No surprises when using it.
- Acceleration Bands (ABANDS)
- Average Directional Index (ADX)
- Average True Range (ATR)
- Bollinger Bands (BBANDS)
- Center of Gravity (CG)
- Double Exponential Moving Average (DEMA)
- Double Moving Average (DMA)
- Exponential Moving Average (EMA)
- Moving Average Convergence Divergence (MACD)
- Rate-of-Change (ROC)
- Relative Strength Index (RSI)
- Simple Moving Average (SMA)
- Smoothed Moving Average (SMMA)
import {SMA} from 'trading-signals';
const sma = new SMA(3);
// You can add numbers:
sma.update(40);
sma.update(30);
sma.update(20);
// You can add strings:
sma.update('10');
// You can add arbitrary-precision decimals:
import Big from 'big.js';
sma.update(new Big(30));
// You can get the result in various formats:
console.log(sma.getResult().valueOf()); // "20"
console.log(sma.getResult().toFixed(2)); // "20.00"
This library draws attention to miscalculations by throwing errors instead of returning default values. If you call getResult()
, before an indicator has received the required amount of input values, a NotEnoughDataError
will be thrown.
Example:
import {SMA} from 'trading-signals';
// Our interval is 3, so we need 3 input values
const sma = new SMA(3);
// We supply 2 input values
sma.update(10);
sma.update(40);
try {
// We will get an error, because the minimum amount of inputs is 3
sma.getResult();
} catch (error) {
console.log(error.constructor.name); // "NotEnoughDataError"
}
// We will supply the 3rd input value
sma.update(70);
// Now, we will receive a proper result
console.log(sma.getResult().valueOf()); // "40"
- Tulip Indicators (ANSI C)
- Pandas TA (Python)
- Jesse Trading Bot Indicators (Python)
- libindicators (C#)
- Cloud9Trader Indicators (JavaScript)
- Crypto Trading Hub Indicators (TypeScript)
Contributions, issues and feature requests are welcome!
Feel free to check the issues page.
This project is MIT licensed.
Please leave a star if you find this project useful.
If you like this project, you might also like these related projects:
- coinbase-pro-node, Actively maintained Coinbase Pro API written in TypeScript.
- ig-trading-api, IG CFD Trading API written in TypeScript.
- binance-api-node, Heavily tested and Promise-based Binance API with TypeScript definitions.