npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

trendcraft

v0.4.0

Published

Technical analysis library for TypeScript — 130+ indicators, backtesting, optimization, streaming, and zero dependencies

Readme

TrendCraft

A zero-dependency TypeScript technical-analysis library: 130+ indicators, signal detection, backtesting, optimization, and live streaming.

日本語版 README

TrendCraft turns raw OHLCV candles into indicators, trading signals, and backtested strategies — all in pure TypeScript with no runtime dependencies. Every indicator returns the same Series<T> shape ({ time, value }[]), so results compose cleanly and work with any chart library or data pipeline. It runs in Node and the browser.

Install

pnpm add trendcraft
# or
npm install trendcraft

Quick start

import { sma, rsi, bollingerBands } from 'trendcraft';
import { TrendCraft, goldenCrossCondition, deadCrossCondition, and, rsiBelow } from 'trendcraft';

const candles = [
  { time: 1700000000000, open: 100, high: 105, low: 99, close: 104, volume: 1000 },
  // ... more candles (OHLCV format)
];

// Compute indicators — each returns Series<T> = { time, value }[]
const sma20 = sma(candles, { period: 20 });
const rsi14 = rsi(candles, { period: 14 });
const bb    = bollingerBands(candles, { period: 20, stdDev: 2 });

// Backtest a strategy with the fluent API
const result = TrendCraft.from(candles)
  .strategy()
    .entry(and(goldenCrossCondition(), rsiBelow(50)))
    .exit(deadCrossCondition())
  .backtest({ capital: 1_000_000, stopLoss: 5, takeProfit: 15 });

console.log(`Return: ${result.totalReturnPercent.toFixed(2)}%  Sharpe: ${result.sharpeRatio.toFixed(3)}`);

Runnable scripts live in examples/quick-start/ (indicators, backtesting, optimization, screening, streaming).

What's inside

  • Indicators (130+) — moving averages (SMA, EMA, KAMA, T3, HMA…), trend (Ichimoku, Supertrend, Parabolic SAR), momentum (RSI, MACD, Stochastics, DMI/ADX, Connors RSI…), volatility (Bollinger Bands, ATR, Keltner, Donchian, Choppiness), volume (OBV, MFI, VWAP, CMF, Volume Profile, CVD…), price structure (pivots, swings, FVG, BOS/CHoCH, S/R zones), plus Smart Money Concepts, Wyckoff/VSA, ICT sessions, HMM regimes, adaptive indicators, and relative strength.
  • Signal detection — golden/dead crosses, RSI/MACD/OBV divergence, Bollinger squeeze, range-bound detection, and chart patterns (double top/bottom, head & shoulders, triangles, wedges, flags).
  • Backtesting — preset-condition strategies with stop loss, take profit, trailing stops, commission/slippage, multi-timeframe conditions, and full performance metrics (Sharpe, max drawdown, win rate, profit factor).
  • Optimization — grid search with constraints, walk-forward analysis for out-of-sample validation, and combination search.
  • Signal scoring — weighted multi-signal scoring with presets and a fluent ScoreBuilder.
  • Position sizing & risk — risk-based, ATR-based, Kelly, and fixed-fractional sizing; ATR stops and Chandelier Exit; VaR/CVaR, risk parity, and correlation-adjusted sizing.
  • StreamingcreateLiveCandle() aggregates ticks or candles and drives 90+ incremental indicator factories bar-by-bar, with state save/restore for resumable sessions.
  • Advanced analytics — pairs trading / cointegration, cross-asset correlation, alpha-decay monitoring, strategy robustness scoring, and signal explainability.

48 indicators are cross-validated against TA-Lib — see cross-validation/.

Entry points

// Indicators
import { sma, ema, rsi, macd, bollingerBands, atr } from 'trendcraft';

// Signal detection
import { goldenCross, deadCross, rsiDivergence, bollingerSqueeze } from 'trendcraft';

// Backtesting (fluent API + preset conditions)
import { TrendCraft, and, or, goldenCrossCondition, rsiBelow } from 'trendcraft';

// Optimization
import { gridSearch, walkForwardAnalysis } from 'trendcraft';

// Streaming
import { createLiveCandle, incremental } from 'trendcraft';

// Subpaths
import { ... } from 'trendcraft/safe';        // Result-typed indicators
import { ... } from 'trendcraft/incremental';  // Bar-by-bar factories
import { ... } from 'trendcraft/screening';    // Stock screening
import { ... } from 'trendcraft/manifest';     // Indicator metadata

A Candle accepts time as a Unix timestamp, date string, or Date; every indicator emits Series<T> = { time: number, value: T }[].

Three CLI tools ship with the package: trendcraft-screen, trendcraft-backtest, and trendcraft-analyze (run with npx; pass --list to see available conditions for screen/backtest).

Documentation

Disclaimer

trendcraft provides technical-analysis primitives for informational and educational purposes only. Indicator values, signals, and backtest results are not investment advice and are not a recommendation to buy, sell, or hold any financial instrument. You are solely responsible for any trading decisions made using this software.

License

MIT