Quick Start Guide

This guide will get you up and running with TechKit in under 5 minutes.

Choose Your Language

Python Quick Start

Installation

pip install techkit

Basic Usage

import numpy as np
from techkit import SMA, EMA, RSI, MACD, BBANDS

# Sample price data
prices = np.array([44.0, 44.5, 43.5, 44.0, 44.5, 45.0, 45.5, 46.0, 45.5, 45.0,
                   44.5, 44.0, 44.5, 45.0, 45.5, 46.0, 46.5, 47.0, 46.5, 46.0])

# Method 1: Object-Oriented API (recommended for real-time)
sma = SMA(period=10)
for price in prices:
    result = sma.update(price)
    if result.valid:
        print(f"SMA: {result.value:.2f}")

# Method 2: Batch Calculation (recommended for backtesting)
sma_values = SMA(10).calculate(prices)
rsi_values = RSI(14).calculate(prices)
print(f"Latest SMA: {sma_values[-1]:.2f}")
print(f"Latest RSI: {rsi_values[-1]:.2f}")

Multi-Output Indicators

from techkit import MACD, BBANDS

# MACD returns three arrays
macd = MACD(fast=12, slow=26, signal=9)
macd_line, signal_line, histogram = macd.calculate(prices)

# Bollinger Bands returns three arrays
bb = BBANDS(period=20, nbdev=2.0)
upper, middle, lower = bb.calculate(prices)

TA-Lib Compatible API

# Drop-in replacement for TA-Lib
from techkit import talib_compat as ta

# Same function signatures as TA-Lib
sma = ta.SMA(prices, timeperiod=20)
rsi = ta.RSI(prices, timeperiod=14)
macd, signal, hist = ta.MACD(prices, fastperiod=12, slowperiod=26, signalperiod=9)
upper, middle, lower = ta.BBANDS(prices, timeperiod=20, nbdevup=2.0, nbdevdn=2.0)

Working with Pandas

import pandas as pd
from techkit import RSI, MACD

# Load your data
df = pd.read_csv('ohlcv.csv')

# Calculate indicators (works with pandas Series)
df['RSI'] = RSI(14).calculate(df['close'].values)
df['SMA_20'] = SMA(20).calculate(df['close'].values)

# Multi-output with pandas
macd, signal, hist = MACD().calculate(df['close'].values)
df['MACD'] = macd
df['MACD_Signal'] = signal
df['MACD_Hist'] = hist

Node.js Quick Start

Installation

npm install techkit

Basic Usage

const tk = require('techkit');

// Initialize (required before use)
await tk.init();

// Sample data
const prices = [44.0, 44.5, 43.5, 44.0, 44.5, 45.0, 45.5, 46.0, 45.5, 45.0];

// Method 1: Streaming API (for real-time)
const sma = tk.sma(10);
const rsi = tk.rsi(14);

for (const price of prices) {
    const smaResult = sma.update(price);
    const rsiResult = rsi.update(price);
    
    if (smaResult.valid) {
        console.log(`SMA: ${smaResult.value.toFixed(2)}`);
    }
}

// Method 2: Batch API
const smaValues = tk.SMA(prices, 10);
const rsiValues = tk.RSI(prices, 14);
console.log(`Latest SMA: ${smaValues[smaValues.length - 1].toFixed(2)}`);

Browser Usage

<script src="https://unpkg.com/techkit/dist/techkit.min.js"></script>
<script>
    const { sma, rsi, macd } = techkit;
    
    // Initialize
    await techkit.init();
    
    const indicator = sma(20);
    const result = indicator.update(100.5);
    
    if (result.valid) {
        document.getElementById('sma').textContent = result.value.toFixed(2);
    }
</script>

C++ Quick Start

Include Header

#include <techkit/techkit.hpp>
#include <iostream>
#include <vector>

int main() {
    std::vector<double> prices = {44.0, 44.5, 43.5, 44.0, 44.5, 
                                   45.0, 45.5, 46.0, 45.5, 45.0};
    
    // Create indicators (RAII - automatic cleanup)
    techkit::SMA sma(10);
    techkit::RSI rsi(14);
    
    // Streaming updates
    for (double price : prices) {
        auto sma_r = sma.update(price);
        auto rsi_r = rsi.update(price);
        
        if (sma_r.valid) {
            std::cout << "SMA: " << sma_r.value << std::endl;
        }
    }
    
    // Batch calculation
    auto results = sma.calculate(prices.data(), prices.size());
    
    return 0;
}

CMake Integration

find_package(techkit REQUIRED)
target_link_libraries(your_app PRIVATE techkit::static)

C Quick Start

Basic Usage

#include <techkit/techkit_c.h>
#include <stdio.h>

int main() {
    double prices[] = {44.0, 44.5, 43.5, 44.0, 44.5, 
                       45.0, 45.5, 46.0, 45.5, 45.0};
    int n = sizeof(prices) / sizeof(prices[0]);
    
    // Create indicator
    tk_indicator sma = tk_sma_new(10);
    
    // Stream updates
    for (int i = 0; i < n; i++) {
        tk_result r = tk_update(sma, prices[i]);
        if (r.valid) {
            printf("SMA: %.2f\n", r.value);
        }
    }
    
    // Cleanup
    tk_free(sma);
    
    return 0;
}

Common Patterns

Real-Time Chart Updates

from techkit import SMA, EMA, RSI, MACD

class ChartIndicators:
    def __init__(self):
        self.sma_20 = SMA(20)
        self.sma_50 = SMA(50)
        self.rsi = RSI(14)
        self.macd = MACD(12, 26, 9)
    
    def on_new_bar(self, bar):
        """Called when new bar arrives"""
        return {
            'sma_20': self.sma_20.update(bar['close']),
            'sma_50': self.sma_50.update(bar['close']),
            'rsi': self.rsi.update(bar['close']),
            'macd': self.macd.update(bar['close'])
        }
    
    def reset(self):
        """Reset all indicators"""
        self.sma_20.reset()
        self.sma_50.reset()
        self.rsi.reset()
        self.macd.reset()

Indicator Chaining

from techkit import Chain, RSI, EMA

# Create smoothed RSI: RSI(14) -> EMA(9)
smoothed_rsi = Chain([RSI(14), EMA(9)])
result = smoothed_rsi.calculate(prices)

OHLCV Indicators

from techkit import ATR, ADX, STOCH

# These indicators require OHLCV data
atr = ATR(14)
adx = ADX(14)
stoch = STOCH(14, 3, 3)

for bar in ohlcv_data:
    atr_result = atr.update_ohlcv(bar['open'], bar['high'], 
                                   bar['low'], bar['close'], bar['volume'])

Next Steps