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

@tradecanvas/core

v1.67.0

Published

Canvas rendering engine for @tradecanvas/chart

Readme

@tradecanvas/core

Canvas rendering engine, indicators, drawing tools, trading overlays, and real-time streaming for the @tradecanvas/chart library.

Live Demo | GitHub | Documentation

Install

You don't need to install this package directly. It's included as a dependency of @tradecanvas/chart.

npm install @tradecanvas/chart

What's Inside

Rendering Engine

Two stacked canvases — a hover repaints only the thin top one:

  Top canvas    (crosshair + axis pills, legend, countdown, measure)   z=1
  Scene canvas  (grid, candles, indicators, drawings, orders, axes)    z=0
  • RenderEngine -- orchestrates the render pipeline
  • LayerManager -- the scene and top canvases
  • RenderLoop -- requestAnimationFrame loop with dirty tracking
  • DPRManager -- device pixel ratio handling for crisp rendering

Chart Renderers (17 types)

CandlestickRenderer, HollowCandleRenderer, BarRenderer, LineRenderer, AreaRenderer, BaselineRenderer, RenkoRenderer, KagiRenderer, PointAndFigureRenderer, VolumeRenderer, VolumeCandleRenderer, EquivolumeRenderer, HLCAreaRenderer, StepLineRenderer, LineWithMarkersRenderer, CompareRenderer. Heikin-Ashi, Line Break, and Range Bars reuse CandlestickRenderer against transformed data.

Data transforms: toHeikinAshi, toRenko, toLineBreak, toKagi, toPointAndFigure, toRangeBars (and pointAndFigureColumns, the columns of toPointAndFigure with the box they were built on, to draw them that size)

Indicators (134 built-in)

Moving averages, bands and channels, trend and stops, VWAPs and profiles on the price pane; oscillators, volume and volatility indicators in panes of their own. Every id with its inputs, lines and levels is in the indicator catalog. Four more read a second symbol's bars (compareSymbol, spread, correlation, correlationlog); @tradecanvas/chart's Chart registers them with its symbol store.

Indicator parameters are read through getNumberParam / getIntParam helpers, so invalid values (NaN, Infinity, missing keys, non-numeric strings) safely fall back to defaults instead of producing NaN-laced calculations.

Extensible via IndicatorBase for custom indicators.

Indicator math in a worker

IndicatorWorkerHost wraps a Worker you create and exposes a Promise-based calculate(), with a per-request timeout and a ping() health check:

import { IndicatorWorkerHost } from '@tradecanvas/core'

// Your own worker, built from src/indicators/worker/indicator.worker.ts in the repository
const worker = new Worker(new URL('./indicator.worker.ts', import.meta.url), { type: 'module' })
const host = new IndicatorWorkerHost(worker)
const output = await host.calculate('rsi', config, bars)

Pass null instead of a worker to calculate synchronously (SSR, tests). The package does not ship a built worker script, and the chart computes its own indicators on the main thread; it does not route them through this host yet.

Drawing Tools (24)

Trendline, Horizontal/Vertical Lines, Ray, Extended Line, Parallel Channel, Fibonacci Retracement / Extension / Time Zones (new in 0.8), Rectangle, Ellipse, Triangle, Arrow, Pitchfork, Gann Fan/Box, Elliott Wave, Regression Channel, Date/Price Range, Measure, Anchored VWAP, Volume Profile Range, Text Annotation

All tools support magnet snapping, undo/redo, and serialization. Extensible via DrawingBase.

Trading

  • TradingManager -- manage positions and orders
  • TradingRenderer -- render entry lines, P&L zones, SL/TP markers
  • OrderRenderer -- render pending orders with drag-to-modify
  • DepthOverlay -- bid/ask depth visualization

Real-Time Streaming

  • StreamManager -- manage data connections with auto-reconnect
  • BinanceAdapter -- built-in Binance WebSocket adapter
  • MockAdapter -- testing and demo data
  • TickAggregator -- aggregate raw ticks into OHLC bars
  • ReconnectManager -- exponential backoff reconnection

Interaction

  • Pan, zoom (wheel/pinch), crosshair tracking
  • Keyboard shortcuts (arrows, +/-, Home/End, Space)
  • Drawing tool interaction with magnet snapping

Features

  • AlertManager -- price and indicator alerts
  • ReplayManager -- bar-by-bar historical replay (Chart-tied)
  • ReplayController (new in 0.8) -- headless replay decoupled from Chart; powers backtest visualization
  • ChartStateManager -- save/load chart state as JSON
  • UndoRedoManager -- undo/redo for drawings
  • DataExporter -- export visible/all data as CSV or JSON

UI

  • ChartLegend -- OHLCV overlay display
  • Screenshot -- export chart as PNG
  • Watermark -- background text watermark
  • BarCountdown -- time until candle close
  • SessionBreaks -- market session visualization

License

MIT