techkit-full
v1.2.9
Published
Complete technical analysis suite - 189 indicators, risk metrics, pattern recognition. Native + WASM backends for Node.js AND Browser
Maintainers
Readme
TechKit Full
Complete Technical Analysis Suite
📊 189 Indicators • 🌐 Node.js + Browser • 📈 Risk Metrics • 🔍 Pattern Recognition
Installation • Browser Usage • Advanced Analytics • API Docs
✨ Why TechKit Full?
TechKit Full is the complete technical analysis solution that runs in both Node.js and Browser:
| Feature | techkit | techkit-full | |---------|---------|--------------| | Core Indicators | ✅ 158 | ✅ 158 | | Advanced Analytics | ❌ | ✅ 31 | | Risk Metrics | ❌ | ✅ Sharpe, Sortino, VaR | | Volatility Models | ❌ | ✅ GARCH, EWMA | | Pattern Recognition | ❌ | ✅ Harmonic, Chart Patterns | | Browser WASM | ✅ | ✅ | | Node.js Native | ✅ | ✅ |
📦 Installation
npm install techkit-full
# or
yarn add techkit-full
# or
pnpm add techkit-full🌐 Browser Usage (WASM)
TechKit Full runs entirely in the browser via WebAssembly!
Basic Browser Setup
<!DOCTYPE html>
<html>
<head>
<title>TechKit Full - Browser Demo</title>
</head>
<body>
<div id="output"></div>
<script type="module">
import {
init,
// Core indicators
SMA, RSI, MACD, BBANDS,
// Risk metrics (Full exclusive)
SHARPE, SORTINO, MAX_DRAWDOWN,
// Volatility models (Full exclusive)
GARCH_VOL, EWMA_VOL,
// Pattern recognition (Full exclusive)
MACDEXT, STOCHRSI
} from 'https://unpkg.com/techkit-full/dist/browser.mjs';
// Initialize WASM backend
await init();
console.log('✅ TechKit Full WASM ready!');
// Sample data
const prices = [100, 102, 101, 103, 105, 104, 106, 108, 107, 110];
const returns = prices.slice(1).map((p, i) => (p - prices[i]) / prices[i]);
// Core indicators
const sma = SMA.create(5);
const rsi = RSI.create(14);
console.log('SMA:', sma.calculate(prices));
console.log('RSI:', rsi.calculate(prices));
// Risk metrics (EXCLUSIVE to techkit-full!)
const sharpe = SHARPE.create(252, 0.02, 252);
console.log('Sharpe Ratio:', sharpe.calculate(returns));
const maxDD = MAX_DRAWDOWN.create();
console.log('Max Drawdown:', maxDD.calculate(prices));
// Extended indicators
const macdext = MACDEXT.create(12, 1, 26, 1, 9, 0);
console.log('MACDEXT:', macdext.calculate(prices));
</script>
</body>
</html>React Portfolio Dashboard
import { useEffect, useState } from 'react';
import {
init,
SMA, RSI, MACD, BBANDS,
SHARPE, SORTINO, MAX_DRAWDOWN, HIST_VAR, CVAR,
EWMA_VOL
} from 'techkit-full';
interface PortfolioMetrics {
sharpeRatio: number;
sortinoRatio: number;
maxDrawdown: number;
var95: number;
cvar95: number;
volatility: number;
}
function PortfolioDashboard({ priceData, returnsData }) {
const [initialized, setInitialized] = useState(false);
const [metrics, setMetrics] = useState<PortfolioMetrics | null>(null);
const [indicators, setIndicators] = useState(null);
useEffect(() => {
init().then(() => setInitialized(true));
}, []);
useEffect(() => {
if (!initialized) return;
// Calculate technical indicators
const sma20 = SMA.create(20).calculate(priceData);
const rsi = RSI.create(14).calculate(priceData);
const { macd, signal, histogram } = MACD.create(12, 26, 9).calculate(priceData);
const { upper, middle, lower } = BBANDS.create(20, 2, 2).calculate(priceData);
setIndicators({ sma20, rsi, macd, signal, histogram, upper, middle, lower });
// Calculate risk metrics
const sharpeRatio = SHARPE.create(252, 0.02, 252).calculate(returnsData)[0];
const sortinoRatio = SORTINO.create(252, 0.02, 252).calculate(returnsData)[0];
const maxDrawdown = MAX_DRAWDOWN.create().calculate(priceData)[0];
const var95 = HIST_VAR.create(0.95).calculate(returnsData)[0];
const cvar95 = CVAR.create(0.95).calculate(returnsData)[0];
const volatility = EWMA_VOL.create(0.94).calculate(returnsData).slice(-1)[0];
setMetrics({ sharpeRatio, sortinoRatio, maxDrawdown, var95, cvar95, volatility });
}, [initialized, priceData, returnsData]);
if (!initialized) return <div>Loading WASM...</div>;
return (
<div className="dashboard">
<div className="risk-metrics">
<h2>Risk Metrics</h2>
<table>
<tr><td>Sharpe Ratio</td><td>{metrics?.sharpeRatio.toFixed(3)}</td></tr>
<tr><td>Sortino Ratio</td><td>{metrics?.sortinoRatio.toFixed(3)}</td></tr>
<tr><td>Max Drawdown</td><td>{(metrics?.maxDrawdown * 100).toFixed(2)}%</td></tr>
<tr><td>95% VaR</td><td>{(metrics?.var95 * 100).toFixed(2)}%</td></tr>
<tr><td>95% CVaR</td><td>{(metrics?.cvar95 * 100).toFixed(2)}%</td></tr>
<tr><td>Volatility</td><td>{(metrics?.volatility * 100).toFixed(2)}%</td></tr>
</table>
</div>
<div className="chart">
{/* Render chart with indicators */}
</div>
</div>
);
}Trading Bot Dashboard (Browser)
import {
init,
SMA, EMA, RSI, MACD, BBANDS, ATR,
SHARPE, MAX_DRAWDOWN, EWMA_VOL
} from 'techkit-full';
class BrowserTradingBot {
private initialized = false;
// Indicator instances (reusable)
private sma20: any;
private sma50: any;
private rsi: any;
private macd: any;
private bbands: any;
private atr: any;
private ewmaVol: any;
// State
private prices: number[] = [];
private returns: number[] = [];
async initialize() {
await init();
// Create all indicators
this.sma20 = SMA.create(20);
this.sma50 = SMA.create(50);
this.rsi = RSI.create(14);
this.macd = MACD.create(12, 26, 9);
this.bbands = BBANDS.create(20, 2, 2);
this.atr = ATR.create(14);
this.ewmaVol = EWMA_VOL.create(0.94);
this.initialized = true;
console.log('🤖 Trading Bot WASM initialized!');
}
onNewCandle(open: number, high: number, low: number, close: number, volume: number) {
if (!this.initialized) return;
// Update price history
if (this.prices.length > 0) {
const ret = (close - this.prices[this.prices.length - 1]) / this.prices[this.prices.length - 1];
this.returns.push(ret);
}
this.prices.push(close);
// Calculate indicators (streaming)
const sma20Result = this.sma20.update(close);
const sma50Result = this.sma50.update(close);
const rsiResult = this.rsi.update(close);
const volResult = this.ewmaVol.update(this.returns[this.returns.length - 1] || 0);
// Generate signals
if (sma20Result.valid && sma50Result.valid && rsiResult.valid) {
const signal = this.generateSignal({
sma20: sma20Result.value,
sma50: sma50Result.value,
rsi: rsiResult.value,
volatility: volResult.valid ? volResult.value : 0
});
this.executeSignal(signal);
}
}
private generateSignal(data: any): 'BUY' | 'SELL' | 'HOLD' {
// Golden cross + RSI oversold + low volatility
if (data.sma20 > data.sma50 && data.rsi < 30 && data.volatility < 0.02) {
return 'BUY';
}
// Death cross + RSI overbought
if (data.sma20 < data.sma50 && data.rsi > 70) {
return 'SELL';
}
return 'HOLD';
}
private executeSignal(signal: string) {
console.log(`📊 Signal: ${signal}`);
// Execute trade via API
}
getPerformanceMetrics() {
if (this.returns.length < 20) return null;
const sharpe = SHARPE.create(252, 0.02, 252).calculate(this.returns);
const maxDD = MAX_DRAWDOWN.create().calculate(this.prices);
return {
sharpeRatio: sharpe[sharpe.length - 1],
maxDrawdown: maxDD[maxDD.length - 1]
};
}
}
// Usage
const bot = new BrowserTradingBot();
await bot.initialize();
// Connect to WebSocket
const ws = new WebSocket('wss://stream.binance.com/ws/btcusdt@kline_1m');
ws.onmessage = (event) => {
const kline = JSON.parse(event.data).k;
if (kline.x) { // Candle closed
bot.onNewCandle(
parseFloat(kline.o),
parseFloat(kline.h),
parseFloat(kline.l),
parseFloat(kline.c),
parseFloat(kline.v)
);
}
};📖 Documentation
Full Documentation: https://techkit-docs.netlify.app/
Quick Links
| Topic | Link | |-------|------| | Installation | Getting Started | | Quick Start | Quick Start Guide | | Node.js API | Node.js API Reference | | All Indicators | Indicator List | | Risk Metrics | Risk Metrics Guide | | Volatility Models | Volatility Models Guide | | Examples | Code Examples | | Changelog | Version History | | 中文文档 | Chinese Documentation |
API Documentation
🚀 Node.js Quick Start
import {
init,
SMA, RSI, MACD,
SHARPE, SORTINO, MAX_DRAWDOWN
} from 'techkit-full';
// Initialize (auto-detects Native backend in Node.js)
await init();
const prices = [100, 102, 101, 103, 105, 104, 106, 108, 107, 110];
const returns = prices.slice(1).map((p, i) => (p - prices[i]) / prices[i]);
// Core indicators
const sma = SMA.create(5).calculate(prices);
const rsi = RSI.create(14).calculate(prices);
// Risk metrics (techkit-full exclusive)
const sharpe = SHARPE.create(252, 0.02, 252).calculate(returns);
const sortino = SORTINO.create(252, 0.02, 252).calculate(returns);
const maxDD = MAX_DRAWDOWN.create().calculate(prices);
console.log(`
Portfolio Analysis:
Sharpe Ratio: ${sharpe[sharpe.length - 1].toFixed(3)}
Sortino Ratio: ${sortino[sortino.length - 1].toFixed(3)}
Max Drawdown: ${(maxDD[maxDD.length - 1] * 100).toFixed(2)}%
`);📈 Advanced Analytics
Risk Metrics
import {
SHARPE, SORTINO, CALMAR,
MAX_DRAWDOWN, HIST_VAR, CVAR
} from 'techkit-full';
await init();
const returns = [0.01, -0.02, 0.015, 0.008, -0.005, 0.02, 0.003, -0.01, 0.025];
// Sharpe Ratio (annualized)
const sharpe = SHARPE.create(252, 0.02, 252); // period, riskFreeRate, annualizationFactor
console.log('Sharpe:', sharpe.calculate(returns));
// Sortino Ratio (penalizes only downside volatility)
const sortino = SORTINO.create(252, 0.02, 252);
console.log('Sortino:', sortino.calculate(returns));
// Calmar Ratio (return / max drawdown)
const calmar = CALMAR.create(252);
console.log('Calmar:', calmar.calculate(returns));
// Value at Risk (95% confidence)
const var95 = HIST_VAR.create(0.95);
console.log('95% VaR:', var95.calculate(returns));
// Conditional VaR (Expected Shortfall)
const cvar95 = CVAR.create(0.95);
console.log('95% CVaR:', cvar95.calculate(returns));
// Maximum Drawdown
const prices = [100, 105, 103, 108, 102, 110, 105];
const maxDD = MAX_DRAWDOWN.create();
console.log('Max Drawdown:', maxDD.calculate(prices));Volatility Models
import {
EWMA_VOL, GARCH_VOL, REALIZED_VOL,
PARKINSON_VOL, GARMAN_KLASS_VOL
} from 'techkit-full';
await init();
// EWMA Volatility (RiskMetrics standard: λ=0.94)
const ewma = EWMA_VOL.create(0.94);
const ewmaVol = ewma.calculate(returns);
// GARCH(1,1) Volatility
const garch = GARCH_VOL.create();
const garchVol = garch.calculate(returns);
// Realized Volatility (rolling window)
const realized = REALIZED_VOL.create(20);
const realizedVol = realized.calculate(returns);
// Range-based volatility (more efficient)
const parkinson = PARKINSON_VOL.create(20);
const parkVol = parkinson.calculate(high, low);
// Garman-Klass (uses OHLC)
const gk = GARMAN_KLASS_VOL.create(20);
const gkVol = gk.calculate(open, high, low, close);Extended Indicators
import { MACDEXT, STOCHRSI } from 'techkit-full';
await init();
// MACDEXT - MACD with configurable MA types
// MA Types: 0=SMA, 1=EMA, 2=WMA, 3=DEMA, 4=TEMA, 5=TRIMA, 6=KAMA, 7=MAMA, 8=T3
const macdext = MACDEXT.create(
12, // fast period
1, // fast MA type (EMA)
26, // slow period
1, // slow MA type (EMA)
9, // signal period
0 // signal MA type (SMA)
);
const { macd, signal, histogram } = macdext.calculate(prices);
// STOCHRSI - Stochastic applied to RSI
const stochrsi = STOCHRSI.create(14, 14, 3, 3);
const { k, d } = stochrsi.calculate(prices);📊 Complete Indicator List
Core Indicators (158) - Same as techkit
- Moving Averages: SMA, EMA, WMA, DEMA, TEMA, KAMA, TRIMA, T3, MAMA, MAVP
- Momentum: RSI, MACD, STOCH, STOCHF, CCI, ADX, ADXR, APO, PPO, MOM, ROC, TRIX, ULTOSC, WILLR, MFI, CMO, AROON, BOP, DX
- Volatility: ATR, NATR, TRANGE, BBANDS
- Volume: OBV, AD, ADOSC
- Statistics: STDDEV, VAR, LINEARREG, LINEARREG_SLOPE/ANGLE/INTERCEPT, TSF, CORREL, BETA
- Hilbert: HT_TRENDLINE, HT_SINE, HT_TRENDMODE, HT_DCPERIOD, HT_DCPHASE, HT_PHASOR
- Price Transform: AVGPRICE, MEDPRICE, TYPPRICE, WCLPRICE
- Math: MIN, MAX, SUM, ADD, SUB, MULT, DIV, trigonometric functions
- Candlestick Patterns: 61 patterns (CDL*)
Advanced Analytics (31) - techkit-full Exclusive
| Category | Indicators | |----------|------------| | Risk Metrics | SHARPE, SORTINO, CALMAR, MAX_DRAWDOWN, HIST_VAR, CVAR | | Volatility Models | EWMA_VOL, GARCH_VOL, REALIZED_VOL, PARKINSON_VOL, GARMAN_KLASS_VOL, ROGERS_SATCHELL_VOL, YANG_ZHANG_VOL | | Structure | ZIGZAG, SWING, PIVOT, SUPPORT_RESISTANCE | | Patterns | HARMONIC, CHART_PATTERN, ELLIOTT_WAVE | | Extended | MACDEXT, MACDFIX, STOCHRSI, MA (generic) |
🌍 Platform Support
| Platform | Environment | Backend | Status | |----------|-------------|---------|--------| | Browser | Chrome/Firefox/Safari/Edge | WASM | ✅ | | Node.js | Windows x64 | Native | ✅ | | Node.js | macOS x64 | Native | ✅ | | Node.js | macOS ARM64 (M1/M2) | Native | ✅ | | Node.js | Linux x64 | Native | ✅ | | Deno | All platforms | WASM | ✅ | | Bun | All platforms | Native/WASM | ✅ |
⚡ Performance
Node.js (Native Backend)
| Operation | Time | vs Pure JS | |-----------|------|------------| | SMA × 10k | 0.3ms | 40x faster | | RSI × 10k | 0.5ms | 50x faster | | SHARPE × 1k | 0.1ms | 30x faster | | GARCH × 1k | 2ms | 50x faster |
Browser (WASM Backend)
| Operation | Time | vs Pure JS | |-----------|------|------------| | SMA × 10k | 1.2ms | 10x faster | | RSI × 10k | 2.0ms | 12x faster | | SHARPE × 1k | 0.3ms | 15x faster | | GARCH × 1k | 5ms | 20x faster |
📄 License
MIT License - see LICENSE for details.
🔗 Links
- 📖 Full Documentation - API Reference & Guides
- GitHub Repository
- Issue Tracker
- Changelog
- Base Package (techkit) - 158 core indicators
Complete Technical Analysis - Everywhere
Node.js • Browser • Deno • Bun
189 Indicators • Risk Metrics • Pattern Recognition
Made with ❤️ by the TechKit Team
