New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

techkit

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

techkit

High-performance technical analysis library - Native + WASM backends, 158+ TA-Lib compatible indicators, works in Node.js AND Browser

latest
Source
npmnpm
Version
1.2.9
Version published
Maintainers
1
Created
Source

TechKit

npm version npm downloads License: MIT Documentation

High-Performance Technical Analysis Library

🚀 Native + WASM • 📊 158+ Indicators • 🌐 Node.js + Browser

InstallationQuick StartBrowser UsageAPI Docs

✨ Features

FeatureDescription
🚀 Dual BackendNative C++ for Node.js, WebAssembly for Browser
🌐 Browser SupportFull WASM support - run technical analysis in the browser!
📊 158+ IndicatorsComplete TA-Lib compatible indicator set
🎯 100% AccurateValidated against TA-Lib with < 1e-10 error tolerance
High PerformanceNative: 10-100x faster, WASM: 5-20x faster than pure JS
💾 Memory EfficientO(1) incremental updates, minimal footprint
🔒 Thread SafeEach indicator instance is independent
📦 Zero DependenciesNo runtime dependencies

📦 Installation

npm install techkit
# or
yarn add techkit
# or
pnpm add techkit

🚀 Quick Start

Node.js Usage

import { init, SMA, EMA, RSI, MACD, BBANDS } from 'techkit';

// Initialize (auto-detects best backend: Native in Node.js)
await init();

// Sample price data
const prices = [44.34, 44.09, 44.15, 43.61, 44.33, 44.83, 45.10, 45.42, 45.84, 46.08];

// Create indicator instances
const sma = SMA.create(20);
const rsi = RSI.create(14);

// Calculate over array
const smaResult = sma.calculate(prices);
const rsiResult = rsi.calculate(prices);

console.log('SMA:', smaResult);
console.log('RSI:', rsiResult);

🌐 Browser Usage (WASM)

TechKit runs entirely in the browser via WebAssembly! No server required.

Basic Browser Setup

<!DOCTYPE html>
<html>
<head>
    <title>TechKit Browser Demo</title>
</head>
<body>
    <script type="module">
        import { init, SMA, RSI, MACD, BBANDS } from 'https://unpkg.com/techkit/dist/browser.mjs';
        
        // Initialize WASM backend (required in browser)
        await init();
        
        // Now use indicators just like in Node.js!
        const prices = [44.34, 44.09, 44.15, 43.61, 44.33, 44.83, 45.10];
        
        const sma = SMA.create(5);
        const rsi = RSI.create(14);
        
        console.log('SMA:', sma.calculate(prices));
        console.log('RSI:', rsi.calculate(prices));
    </script>
</body>
</html>

React/Vue/Angular Integration

// React Component Example
import { useEffect, useState } from 'react';
import { init, SMA, RSI, MACD } from 'techkit';

function TechnicalChart({ priceData }) {
    const [indicators, setIndicators] = useState(null);
    const [initialized, setInitialized] = useState(false);
    
    useEffect(() => {
        // Initialize WASM on component mount
        init().then(() => setInitialized(true));
    }, []);
    
    useEffect(() => {
        if (!initialized || !priceData.length) return;
        
        // Create indicators
        const sma20 = SMA.create(20);
        const sma50 = SMA.create(50);
        const rsi = RSI.create(14);
        const macd = MACD.create(12, 26, 9);
        
        // Calculate
        setIndicators({
            sma20: sma20.calculate(priceData),
            sma50: sma50.calculate(priceData),
            rsi: rsi.calculate(priceData),
            macd: macd.calculate(priceData)
        });
    }, [initialized, priceData]);
    
    if (!initialized) return <div>Loading WASM...</div>;
    
    return (
        <div>
            {/* Render chart with indicators */}
        </div>
    );
}

Vue 3 Example

<template>
  <div>
    <div v-if="!initialized">Loading WASM...</div>
    <div v-else>
      <p>SMA(20): {{ sma20 }}</p>
      <p>RSI(14): {{ rsi14 }}</p>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, watch } from 'vue';
import { init, SMA, RSI } from 'techkit';

const props = defineProps(['prices']);
const initialized = ref(false);
const sma20 = ref([]);
const rsi14 = ref([]);

onMounted(async () => {
  await init();
  initialized.value = true;
});

watch([() => props.prices, initialized], ([prices, ready]) => {
  if (!ready || !prices.length) return;
  
  const smaIndicator = SMA.create(20);
  const rsiIndicator = RSI.create(14);
  
  sma20.value = smaIndicator.calculate(prices);
  rsi14.value = rsiIndicator.calculate(prices);
});
</script>

Real-Time Chart Application

import { init, SMA, EMA, RSI, MACD, BBANDS } from 'techkit';

class TradingDashboard {
    private sma: any;
    private rsi: any;
    private macd: any;
    private bbands: any;
    private initialized = false;
    
    async initialize() {
        // Initialize WASM backend
        await init();
        
        // Create indicator instances (reusable!)
        this.sma = SMA.create(20);
        this.rsi = RSI.create(14);
        this.macd = MACD.create(12, 26, 9);
        this.bbands = BBANDS.create(20, 2, 2);
        
        this.initialized = true;
        console.log('TechKit WASM initialized!');
    }
    
    calculateIndicators(prices: number[]) {
        if (!this.initialized) {
            throw new Error('Call initialize() first!');
        }
        
        return {
            sma: this.sma.calculate(prices),
            rsi: this.rsi.calculate(prices),
            macd: this.macd.calculate(prices),
            bbands: this.bbands.calculate(prices)
        };
    }
    
    // Streaming updates
    onNewPrice(price: number) {
        const smaResult = this.sma.update(price);
        const rsiResult = this.rsi.update(price);
        
        if (smaResult.valid) {
            this.updateChart('sma', smaResult.value);
        }
        if (rsiResult.valid) {
            this.updateChart('rsi', rsiResult.value);
        }
    }
    
    private updateChart(indicator: string, value: number) {
        // Update your chart library (Chart.js, Highcharts, etc.)
    }
}

// Usage
const dashboard = new TradingDashboard();
await dashboard.initialize();

// Fetch price data
const prices = await fetchPrices('BTCUSD');
const indicators = dashboard.calculateIndicators(prices);

// Subscribe to real-time updates
websocket.on('price', (price) => dashboard.onNewPrice(price));

Webpack/Vite Configuration

Vite (vite.config.js):

export default {
    optimizeDeps: {
        exclude: ['techkit']  // Let Vite handle WASM properly
    },
    build: {
        target: 'esnext'  // Required for top-level await
    }
}

Webpack (webpack.config.js):

module.exports = {
    experiments: {
        asyncWebAssembly: true,
        topLevelAwait: true
    },
    module: {
        rules: [
            {
                test: /\.wasm$/,
                type: 'webassembly/async'
            }
        ]
    }
};

🔄 Streaming / Incremental Updates

Perfect for real-time data feeds in both Node.js and Browser:

import { init, SMA, RSI } from 'techkit';

await init();

// Create stateful indicators
const sma = SMA.create(20);
const rsi = RSI.create(14);

// WebSocket real-time feed
const ws = new WebSocket('wss://stream.example.com/prices');

ws.onmessage = (event) => {
    const price = JSON.parse(event.data).price;
    
    // O(1) incremental update - no recalculation!
    const smaResult = sma.update(price);
    const rsiResult = rsi.update(price);
    
    if (smaResult.valid && rsiResult.valid) {
        console.log(`SMA: ${smaResult.value.toFixed(2)}, RSI: ${rsiResult.value.toFixed(2)}`);
        updateUI(smaResult.value, rsiResult.value);
    }
};

📊 Available Indicators

Moving Averages

FunctionDescriptionParameters
SMASimple Moving Averageperiod
EMAExponential Moving Averageperiod
WMAWeighted Moving Averageperiod
DEMADouble Exponential MAperiod
TEMATriple Exponential MAperiod
KAMAKaufman Adaptive MAperiod
TRIMATriangular MAperiod
T3T3 Moving Averageperiod, vFactor

Momentum Indicators

FunctionDescriptionParameters
RSIRelative Strength Indexperiod
MACDMACDfast, slow, signal
STOCHStochastic OscillatorkPeriod, kSlow, dPeriod
CCICommodity Channel Indexperiod
ADXAverage Directional Indexperiod
MOMMomentumperiod
ROCRate of Changeperiod
WILLRWilliams %Rperiod
MFIMoney Flow Indexperiod
APOAbsolute Price Oscillatorfast, slow
PPOPercentage Price Oscillatorfast, slow
CMOChande Momentum Oscillatorperiod
AROONAroon Indicatorperiod
ULTOSCUltimate Oscillatorp1, p2, p3
TRIXTriple Smooth EMAperiod

Volatility Indicators

FunctionDescriptionParameters
ATRAverage True Rangeperiod
NATRNormalized ATRperiod
TRANGETrue Range-
BBANDSBollinger Bandsperiod, nbDevUp, nbDevDn

Volume Indicators

FunctionDescriptionParameters
OBVOn Balance Volume-
ADAccumulation/Distribution-
ADOSCA/D Oscillatorfast, slow

Statistical Functions

FunctionDescriptionParameters
STDDEVStandard Deviationperiod
VARVarianceperiod
LINEARREGLinear Regressionperiod
LINEARREG_SLOPELR Slopeperiod
LINEARREG_ANGLELR Angleperiod
CORRELPearson Correlationperiod
BETABeta Coefficientperiod

Hilbert Transform (Cycle Indicators)

FunctionDescription
HT_TRENDLINEInstantaneous Trendline
HT_SINESineWave
HT_TRENDMODETrend vs Cycle Mode
HT_DCPERIODDominant Cycle Period
HT_DCPHASEDominant Cycle Phase
HT_PHASORPhasor Components

⚡ Performance

Node.js (Native Backend)

IndicatorTechKitPure JSSpeedup
SMA(20) × 10k0.3ms12ms40x
RSI(14) × 10k0.5ms25ms50x
MACD × 10k0.8ms45ms56x
BBANDS × 10k0.6ms35ms58x

Browser (WASM Backend)

IndicatorTechKit WASMPure JSSpeedup
SMA(20) × 10k1.2ms12ms10x
RSI(14) × 10k2.0ms25ms12x
MACD × 10k3.2ms45ms14x
BBANDS × 10k2.4ms35ms15x

Benchmarks on Chrome 120, Apple M1

📖 Documentation

Full Documentation: https://techkit-docs.netlify.app/

TopicLink
InstallationGetting Started
Quick StartQuick Start Guide
Node.js APINode.js API Reference
All IndicatorsIndicator List
ExamplesCode Examples
ChangelogVersion History
中文文档Chinese Documentation

🔧 API Reference

📖 Full API documentation: techkit-docs.netlify.app/en/api/nodejs-api/

Initialization

import { init, getBackendInfo } from 'techkit';

// Initialize backend (required before using indicators)
await init();

// Check which backend is active
const info = getBackendInfo();
console.log(info);
// Node.js: { type: 'native', ready: true }
// Browser: { type: 'wasm', ready: true }

Indicator Factory Pattern

// All indicators use the factory pattern
const indicator = IndicatorName.create(param1, param2, ...);

// Calculate over array
const results = indicator.calculate(dataArray);

// Incremental update (returns { value, valid })
const result = indicator.update(newValue);

// Reset state
indicator.reset();

// Properties
indicator.lookback;  // Warmup period needed
indicator.ready;     // Is warmup complete?

Multi-Output Indicators

// MACD returns 3 arrays
const macd = MACD.create(12, 26, 9);
const { macd: macdLine, signal, histogram } = macd.calculate(prices);

// Bollinger Bands returns 3 arrays
const bbands = BBANDS.create(20, 2, 2);
const { upper, middle, lower } = bbands.calculate(prices);

// Stochastic returns 2 arrays
const stoch = STOCH.create(14, 3, 3);
const { k, d } = stoch.calculate(high, low, close);

🌍 Platform Support

PlatformEnvironmentBackendStatus
BrowserChrome/Firefox/Safari/EdgeWASM
Node.jsWindows x64Native
Node.jsmacOS x64Native
Node.jsmacOS ARM64 (M1/M2)Native
Node.jsLinux x64Native
DenoAll platformsWASM
BunAll platformsNative/WASM

📄 License

MIT License - see LICENSE for details.

Works everywhere JavaScript runs!

Node.js • Browser • Deno • Bun

Made with ❤️ by the TechKit Team

Keywords

technical-analysis

FAQs

Package last updated on 10 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts