Built with TypeScript & Node.js

Crypto trading from
your terminal.

A CLI-first cryptocurrency trading system for the Bitvavo exchange. Record live market data, backtest strategies against real recordings, and execute trades via WebSocket -- all without leaving the command line.

trader -- btceur
# Record live market data $ trader record -name=session01 -market=btceur -depth=25 --enable-datastore Recording started for btceur (depth: 25) # Backtest the SlowFastMA strategy $ trader backtest -recording=session01 -strat=sfmax --enable-datastore Replaying 14,203 trades across 8h window... Signal: FALL | EMA cross -1.2% | BUY 150 EUR @ 63,482 Signal: RISE | EMA cross +0.9% | SELL 150 EUR @ 64,891 (+2.2%) Backtest complete. Report saved. # Go live $ trader run -strat=sfmax -market=btceur -depth=25 --enable-datastore

Everything you need to trade systematically

From recording raw market data to executing algorithmic strategies against a live exchange, traderapp covers the full lifecycle.

Real-Time WebSocket Trading

Connect directly to Bitvavo's WebSocket API for sub-second market data, order book management, and trade execution. No polling, no REST overhead -- pure streaming.

Record & Replay

Capture live order book snapshots and trade streams to PostgreSQL. Replay recordings deterministically for backtesting, with simulated order fills and balance tracking.

Strategy Backtesting

Test any strategy against historical recordings before risking capital. Full report generation with account balance tracking, order annotations, and performance metrics.

Multiple Strategies

Pluggable strategy architecture with built-in implementations: EMA crossover (SlowFastMA), peak/valley detection, and market making with spread orders.

PostgreSQL Persistence

Market recordings, trades, order book snapshots, and strategy state are stored in PostgreSQL with JSONB support. Knex migrations keep the schema versioned and portable.

Full Observability

Structured Pino logging with correlation IDs via AsyncLocalStorage, OpenTelemetry tracing, and SigNoz integration for dashboards, traces, and alerting in production.

Pluggable trading algorithms

Strategies subscribe to exchange events through an abstract base class. A built-in promise queue serializes all event processing to prevent race conditions.

sfmax
SlowFastMA

Slow/fast EMA crossover. Buys on fall signals, sells on rise with a 2% take-profit margin. 6-hour buy debounce, 30-minute sell debounce, and quality gates on EMA data.

maker
MarketMaker

Places 10 buy and 10 sell limit orders as a spread around the current price. Refreshes the grid when the price moves 0.75% from the anchor.

pv
PeakValley

Detects peaks and valleys in price action to identify reversal points. Buys near valleys, sells near peaks based on local extrema.

noop
NoopStrategy

Intentional no-op. Useful for recording market data or testing the exchange connection without placing any orders.

Clean layers, event-driven core

The system is structured in distinct layers. The Exchange abstraction emits events that strategies consume, making it trivial to swap between live, dry-run, and replay modes.

CLI
show-book
record
backtest
run
create-order
|
Handlers
run handler
backtest handler
record handler
|
Exchange
bitvavo (live)
stubbed (dry-run)
replay (backtest)
EventEmitter
Strategy
sfmax
maker
pv
noop
|
Data
PostgreSQL
JSONB snapshots
Pino + OTel
SigNoz

From data capture to live execution

A typical workflow starts with recording real market data, then iterating on a strategy via backtests, and finally going live with confidence.

Record Market Data

Capture live order book updates and trades for any market. Data is streamed via WebSocket and persisted to PostgreSQL as time-series records.

trader record -name=btc_session -market=btceur

Backtest Your Strategy

Replay recorded data through the exchange abstraction. The replay engine simulates order fills and balance changes, so your strategy runs as if trading live.

trader backtest -recording=btc_session -strat=sfmax

Dry-Run Against Live Data

Connect to the real exchange but route orders through a stubbed implementation. Validates your strategy against live market conditions without risking capital.

trader run -strat=sfmax -market=btceur -dryrun=yes

Go Live

Execute with real orders on Bitvavo. The strategy handles buy/sell signals, debounce logic, safety checks, and graceful shutdown. State is persisted so it can recover from crashes.

trader run -strat=sfmax -market=btceur

TypeScript Node.js v22 PostgreSQL WebSocket OpenTelemetry Docker

Run it your way

Choose between a minimal local setup or a full production stack with secrets management, CI/CD, orchestration, and observability.

Direct CLI

Easy path

Install Node.js, clone the repo, fill in your .env, and start trading. No containers or orchestration needed.

  • Install globally with npm run clinstall
  • Single process, minimal resource footprint
  • Ideal for local development and backtesting

Production Stack

Ops path

Docker Compose environment with Vault, Concourse CI, Nomad, SigNoz, and Nginx with automatic TLS via Certbot.

  • Auto-restart and scheduling via Nomad
  • Secrets in Vault, never on disk in plaintext
  • CI/CD pipelines for builds and migrations
  • Full observability with SigNoz dashboards