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.
From recording raw market data to executing algorithmic strategies against a live exchange, traderapp covers the full lifecycle.
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.
Capture live order book snapshots and trade streams to PostgreSQL. Replay recordings deterministically for backtesting, with simulated order fills and balance tracking.
Test any strategy against historical recordings before risking capital. Full report generation with account balance tracking, order annotations, and performance metrics.
Pluggable strategy architecture with built-in implementations: EMA crossover (SlowFastMA), peak/valley detection, and market making with spread orders.
Market recordings, trades, order book snapshots, and strategy state are stored in PostgreSQL with JSONB support. Knex migrations keep the schema versioned and portable.
Structured Pino logging with correlation IDs via AsyncLocalStorage, OpenTelemetry tracing, and SigNoz integration for dashboards, traces, and alerting in production.
Strategies subscribe to exchange events through an abstract base class. A built-in promise queue serializes all event processing to prevent race conditions.
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.
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.
Detects peaks and valleys in price action to identify reversal points. Buys near valleys, sells near peaks based on local extrema.
Intentional no-op. Useful for recording market data or testing the exchange connection without placing any orders.
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.
A typical workflow starts with recording real market data, then iterating on a strategy via backtests, and finally going live with confidence.
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
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
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
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
Choose between a minimal local setup or a full production stack with secrets management, CI/CD, orchestration, and observability.