High-performance technical indicators with zero dependencies - compatible with technicalindicators package
npm install fast-technical-indicators


A high-performance, zero-dependency technical indicators library for JavaScript and TypeScript. 100% API-compatible with the popular technicalindicators package, but with significant performance improvements and no external dependencies.
This library powers the Algoticker no-code algorithmic trading platform, but can be used independently in any JavaScript/Node.js project.
- ๐ฅ High Performance: Optimized algorithms with minimal overhead
- ๐ฆ Zero Dependencies: No external packages required
- ๐ 100% Compatible: Drop-in replacement for technicalindicators
- ๐ฏ Self-Sufficient: Each indicator method is completely independent
- ๐ Streaming Support: Real-time data processing with nextValue()
- ๐ก๏ธ Type Safe: Full TypeScript support with comprehensive type definitions
- โ
Well Tested: Extensive test suite comparing against reference implementation
Benchmarks show significant performance improvements over the original technicalindicators package:
| Indicator | Performance Improvement |
|-----------|------------------------|
| SMA | 3.6x - 9.6x faster |
| EMA | 2.5x - 8.8x faster |
| RSI | 6.4x - 8.6x faster |
| MACD | 4.9x - 7.9x faster |
| WMA | 5.1x - 7.1x faster |
| CCI | 3.1x - 6.4x faster |
| Stochastic | 1.3x - 1.8x faster |
| Bollinger Bands | 1.4x - 6.3x faster |
| ATR | 2.3x - 6.3x faster |
| OBV | 1.0x - 5.9x faster |
Performance improvements scale with dataset size. Larger datasets show more dramatic speedups.
Run benchmarks yourself: npm run benchmark
``bash`
npm install fast-technical-indicators
`typescript
import { sma, ema, rsi, macd, bollingerbands } from 'fast-technical-indicators';
const prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
// Simple Moving Average
const smaResult = sma({ period: 4, values: prices });
console.log(smaResult); // [2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5]
// Exponential Moving Average
const emaResult = ema({ period: 4, values: prices });
// Relative Strength Index
const rsiResult = rsi({ period: 14, values: prices });
// MACD
const macdResult = macd({
values: prices,
fastPeriod: 12,
slowPeriod: 26,
signalPeriod: 9
});
// Bollinger Bands
const bbResult = bollingerbands({
period: 20,
values: prices,
stdDev: 2
});
`
Perfect for real-time data processing:
`typescript
import { SMA, EMA, RSI, MACD } from 'fast-technical-indicators';
// Initialize indicators
const smaIndicator = new SMA({ period: 20, values: [] });
const rsiIndicator = new RSI({ period: 14, values: [] });
// Process data point by point
const prices = [100, 101, 99, 102, 98, 103];
prices.forEach(price => {
const smaValue = smaIndicator.nextValue(price);
const rsiValue = rsiIndicator.nextValue(price);
if (smaValue !== undefined) {
console.log(SMA: ${smaValue});RSI: ${rsiValue}
}
if (rsiValue !== undefined) {
console.log();`
}
});
`typescript
// Functional
sma({ period: 20, values: number[] }) => number[]
// Class-based
new SMA({ period: 20, values?: number[] })
smaInstance.nextValue(price: number) => number | undefined
`
`typescript
// Functional
ema({ period: 20, values: number[] }) => number[]
// Class-based
new EMA({ period: 20, values?: number[] })
emaInstance.nextValue(price: number) => number | undefined
`
`typescript
// Functional
rsi({ period: 14, values: number[] }) => number[]
// Class-based
new RSI({ period: 14, values?: number[] })
rsiInstance.nextValue(price: number) => number | undefined
`
`typescript
interface MACDInput {
values: number[];
fastPeriod?: number; // default: 12
slowPeriod?: number; // default: 26
signalPeriod?: number; // default: 9
SimpleMAOscillator?: boolean; // default: false
SimpleMASignal?: boolean; // default: false
}
interface MACDOutput {
MACD?: number;
signal?: number;
histogram?: number;
}
// Functional
macd(input: MACDInput) => MACDOutput[]
// Class-based
new MACD(input: MACDInput)
macdInstance.nextValue(price: number) => MACDOutput | undefined
`
`typescript
interface BollingerBandsInput {
period?: number; // default: 20
values: number[];
stdDev?: number; // default: 2
}
interface BollingerBandsOutput {
upper?: number;
middle?: number;
lower?: number;
pb?: number; // %B
width?: number; // Band width
}
// Functional
bollingerbands(input: BollingerBandsInput) => BollingerBandsOutput[]
// Class-based
new BollingerBands(input: BollingerBandsInput)
bbInstance.nextValue(price: number) => BollingerBandsOutput | undefined
`
This library is a drop-in replacement. Simply change your import:
`typescript
// Before
import { sma, ema, rsi, macd } from 'technicalindicators';
// After
import { sma, ema, rsi, macd } from 'fast-technical-indicators';
// Everything else stays the same!
`
The library includes comprehensive tests comparing results with the original technicalindicators package:
`bash`
npm test # Run tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage report
Run performance comparisons:
`bash`
npm run benchmark
Contributions are welcome! Please ensure:
1. All indicators remain zero dependency
2. Methods are self-sufficient (no internal function calls between indicators)
3. API remains 100% compatible with technicalindicators`
4. New indicators include comprehensive tests and benchmarks
MIT - see LICENSE file for details.
This library maintains API compatibility with the excellent technicalindicators package by @anandanand84. We've reimplemented the algorithms for better performance while keeping the familiar interface.
---
Made with โค๏ธ for the trading community
Build faster, trade smarter ๐