Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@backtest-kit/ui

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backtest-kit/ui

Full-stack UI framework for visualizing cryptocurrency trading signals, backtests, and real-time market data. React dashboard with candlestick charts, signal tracking, and risk analysis.

Source
npmnpm
Version
9.8.1
Version published
Weekly downloads
474
-52.31%
Maintainers
1
Weekly downloads
 
Created
Source

📊 @backtest-kit/ui

Full-stack UI framework for visualizing cryptocurrency trading signals, backtests, and real-time market data. Combines a Node.js backend server with a React dashboard - all in one package.

screenshot

Ask DeepWiki npm TypeScript

Interactive dashboard for backtest-kit with signal visualization, candle charts, risk analysis, and notification management. Built with React 18, Material-UI, and Lightweight Charts.

📚 Backtest Kit Docs | 🌟 GitHub

New to backtest-kit? The fastest way to get a real, production-ready setup is to clone the reference implementation — a fully working news-sentiment AI trading system with LLM forecasting, multi-timeframe data, and a documented February 2026 backtest. Start there instead of from scratch.

✨ Features

  • 📈 Interactive Charts: Candlestick visualization with Lightweight Charts (1m, 15m, 1h timeframes)
  • 🎯 Signal Tracking: View opened, closed, scheduled, and cancelled signals with full details
  • 📊 Risk Analysis: Monitor risk rejections and position management
  • 🔔 Notifications: Real-time notification system for all trading events
  • 💹 Trailing & Breakeven: Visualize trailing stop/take and breakeven events
  • 🌐 Multi-Exchange: Support for 100+ exchanges via CCXT integration
  • 🎨 Material Design: Beautiful UI with MUI 5 and Mantine components
  • 🌍 i18n Ready: Internationalization support built-in

📋 What It Does

@backtest-kit/ui provides both backend API and frontend dashboard:

ComponentDescription
serve()Start HTTP server with REST API endpoints
getRouter()Get expressjs-compatible router for custom middleware integration

🚀 Installation

npm install @backtest-kit/ui backtest-kit ccxt

📖 Usage

Quick Start - Launch Dashboard

import { serve } from '@backtest-kit/ui';

// Start the UI server
serve('0.0.0.0', 60050);

// Dashboard available at http://localhost:60050

Custom Logger Integration

import { setLogger } from '@backtest-kit/ui';

setLogger({
  log: (msg) => console.log(`[UI] ${msg}`),
  warn: (msg) => console.warn(`[UI] ${msg}`),
  error: (msg) => console.error(`[UI] ${msg}`),
});

📐 Dashboard Revenue Math

The Revenue metrics on the dashboard are calculated in dollar terms by summing the pnlCost field from all closed signals within each time window.

Dollar PnL formula

revenue[window] = Σ signal.pnl.pnlCost   (for all closed signals in that window)

pnlCost is computed by the backend (toProfitLossDto) as:

pnlCost = (pnlPercentage / 100) × pnlEntries
FieldSourceDescription
pnl.pnlCostIStorageSignalRowAbsolute P&L in USD — the only value summed for revenue
pnl.pnlPercentageIStorageSignalRowPercentage P&L (accounts for DCA-weighted entry price, slippage, and fees)
pnl.pnlEntriesIStorageSignalRowTotal invested capital in USD — sum of all entry costs (Σ entry.cost)

Example (1 DCA entry at $100, position closed +5%):

DCA entriespnlEntriespnlPercentagepnlCost
1$1005 %+$5.00
2$2005 %+$10.00
3$3005 %+$15.00

Time windows

The anchor point depends on execution mode:

  • Backtest mode — latest updatedAt across all closed signals (time windows are relative to the end of the run)
  • Live modeDate.now() (wall-clock time)
WindowRange
Today>= startOf(anchorDay)
Yesterday[anchorDay − 1d, anchorDay)
7 days>= anchorDay − 7d
31 days>= anchorDay − 31d

Revenue and signal count are tracked separately for each window and aggregated across all symbols on the Dashboard.

📐 Position PNL Math

Effective entry price (DCA-weighted)

When multiple DCA entries exist, the effective open price is a cost-weighted harmonic mean:

effectivePrice = Σcost / Σ(cost / price)

This is the correct formula for fixed-dollar entries (not simple average), because buying $100 worth at different prices gives different coin quantities.

Partial closes (PP/PL)

Each partial stores a costBasisAtClose snapshot — the running dollar cost-basis before that partial fired. This avoids replaying the full entry history on every call.

Cost-basis replay:

for each partial[i]:
    closedDollar      += (percent[i] / 100) × costBasisAtClose[i]
    remainingCostBasis = costBasisAtClose[i] × (1 - percent[i] / 100)

# DCA entries added AFTER the last partial are appended:
remainingCostBasis += Σ entry.cost for entries[lastEntryCount..]

totalClosedPercent = closedDollar / totalInvested × 100

Effective price through partials is computed iteratively so that a partial sell does not change the entry price of the remaining coins:

# partial[0]:
  effPrice = costBasisAtClose[0] / Σ(cost/price for entries[0..cnt[0]])

# partial[j]:
  remainingCB = prev.costBasisAtClose × (1 - prev.percent / 100)
  oldCoins    = remainingCB / effPrice        ← coins still held
  newCoins    = Σ(cost/price for DCA entries between j-1 and j)
  effPrice    = (remainingCB + newCost) / (oldCoins + newCoins)

toProfitLossDto — weighted PNL with slippage & fees

Without partials:

priceOpenSlip  = effectivePrice × (1 ± slippage)
priceCloseSlip = priceClose     × (1 ∓ slippage)

pnlPercentage = (priceCloseSlip - priceOpenSlip) / priceOpenSlip × 100
fee           = CC_PERCENT_FEE × (1 + priceCloseSlip / priceOpenSlip)
pnlPercentage -= fee

With partials — dollar-weighted sum:

weight[i] = (percent[i] / 100 × costBasisAtClose[i]) / totalInvested

totalWeightedPnl = Σ weight[i] × pnl[i]           # each partial at its own effectivePrice
                 + remainingWeight × pnlRemaining   # rest closed at final priceClose

fee = CC_PERCENT_FEE                                              # open (once)
    + Σ CC_PERCENT_FEE × weight[i] × (closeSlip[i] / openSlip[i])  # per partial
    + CC_PERCENT_FEE × remainingWeight × (closeSlip / openSlip)     # final close

pnlPercentage = totalWeightedPnl - fee
pnlCost       = pnlPercentage / 100 × totalInvested
FieldDescription
totalInvestedΣ entry.cost (or CC_POSITION_ENTRY_COST if no _entry)
weight[i]Real dollar share of each partial relative to totalInvested
effectivePrice at partial iComputed via iterative costBasisAtClose replay up to partials[i]
priceOpen in resultgetEffectivePriceOpen(signal) — DCA-weighted harmonic mean across all entries

🖥️ Dashboard Views

The frontend provides specialized views for different trading events:

ViewDescription
Signal OpenedEntry details with chart visualization
Signal ClosedExit details with PnL analysis
Signal ScheduledPending orders awaiting activation
Signal CancelledCancelled orders with reasons
Risk RejectionSignals rejected by risk management
Partial Profit/LossPartial position closures
Trailing Stop/TakeTrailing adjustments visualization
BreakevenBreakeven level adjustments

Each view includes:

  • 📋 Detailed information form
  • 📈 1m, 15m, 1h candlestick charts
  • 📥 JSON export for all data

💡 Why Use @backtest-kit/ui?

Instead of building custom dashboards:

Without backtest-kit

// ❌ Without @backtest-kit/ui
// Build your own React app
// Implement chart components
// Create signal visualization
// Handle notifications
// Write API endpoints
// ... weeks of development

With backtest-kit

// ✅ With @backtest-kit/ui
import { serve } from '@backtest-kit/ui';

serve(); // Full dashboard ready!

Benefits:

  • 📊 Production-ready trading dashboard out of the box
  • 📈 Professional chart visualization with price lines and markers
  • 🔔 Complete notification system for all trading events
  • 🎨 Beautiful Material Design interface
  • ⚡ Fast development - focus on strategy, not UI
  • 🛡️ Full TypeScript support

🤝 Contribute

Fork/PR on GitHub.

📜 License

MIT © tripolskypetr

Keywords

backtest

FAQs

Package last updated on 19 May 2026

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