@vulcan-js/strategies

Composable trading strategies with structured signal output for the Vulcan library


Keywords
technical-analysis, trading, strategy, signals, backtesting
License
MIT
Install
npm install @vulcan-js/strategies@0.2.0

Documentation

Vulcan

A TypeScript library for technical analysis indicators, built on generator-based streaming architecture with high-precision decimal arithmetic.

Features

  • Generator-based streaming — Process data point-by-point via standard iterators, naturally composable with for-of loops and pipelines
  • High-precision arithmetic — Powered by dnum, representing numbers as [value: bigint, decimals: number] tuples — no floating-point rounding errors
  • Full TypeScript support — Strict types for all indicators, options, and outputs
  • Modular packages — Pick only what you need: core primitives, indicators, strategies, or backtesting

Packages

Package Description
@vulcan-js/core Core types (CandleData, Processor, SignalGenerator) and utilities (createSignal, collect)
@vulcan-js/indicators All technical indicators (trend, momentum, volume)
@vulcan-js/strategies Composable trading strategies with structured signal output
@vulcan-js/backtest Backtesting engine with position management and statistics
@vulcan-js/forge All-in-one package that re-exports all Vulcan modules

Installation

# All-in-one (includes all packages)
pnpm add @vulcan-js/forge

# Or install individual packages as needed
pnpm add @vulcan-js/indicators   # Indicators (includes core)
pnpm add @vulcan-js/strategies   # Strategies (includes core + indicators)
pnpm add @vulcan-js/backtest     # Backtesting (includes core + strategies)

Usage

Basic — Generator iteration

Every indicator is a generator function. Pass an iterable source and iterate over the results:

import { collect } from '@vulcan-js/core'
import { sma } from '@vulcan-js/indicators'

const prices = [10, 11, 12, 13, 14, 15]

// Collect all results into an array
const results = collect(sma(prices, { period: 3 }))

// Or iterate lazily
for (const value of sma(prices, { period: 3 })) {
  console.log(value) // Dnum tuple: [bigint, number]
}

Stateful processor — Real-time / streaming

Use .create() to get a stateful processor for feeding data point-by-point:

import { rsi } from '@vulcan-js/indicators'

const process = rsi.create({ period: 14 })

// Feed new prices as they arrive
const result1 = process(100)
const result2 = process(102)
const result3 = process(98)

Supported Indicators

Trend

  • Aroon Indicator
  • Balance of Power (BOP)
  • Chande Forecast Oscillator (CFO)
  • Commodity Channel Index (CCI)
  • Double Exponential Moving Average (DEMA)
  • Exponential Moving Average (EMA)
  • Mass Index (MI)
  • Moving Average Convergence Divergence (MACD)
  • Moving Max (MMAX)
  • Moving Min (MMIN)
  • Moving Sum (MSUM)
  • Parabolic SAR (PSAR)
  • Qstick
  • Random Index (KDJ)
  • Rolling Moving Average (RMA)
  • Simple Moving Average (SMA)
  • Since Change
  • Triple Exponential Moving Average (TEMA)
  • Triangular Moving Average (TRIMA)
  • Triple Exponential Average (TRIX)
  • Typical Price
  • Volume Weighted Moving Average (VWMA)
  • Vortex Indicator

Momentum

  • Absolute Price Oscillator (APO)
  • Awesome Oscillator (AO)
  • Chaikin Oscillator (CMO)
  • Ichimoku Cloud
  • Percentage Price Oscillator (PPO)
  • Percentage Volume Oscillator (PVO)
  • Price Rate of Change (ROC)
  • Relative Strength Index (RSI)
  • Stochastic Oscillator (STOCH)
  • Williams R (WILLR)

Volume

  • Accumulation/Distribution (AD)

License

MIT