Personal project / Trading systems · Case Study

Crypto-Derivatives Trading System

An event-driven TypeScript system that turns candle signals into risk-checked orders, with every trading limit in one pure function.

RolePersonal project
TimelineMay 2026 to Aug 2026
DomainCrypto derivatives
Shape4 services · 8 shared packages
Quality3,810 test cases
CodePrivate repository
Trader registry with presence, feeds and signal outcomes
The Brief

Signals in, risk-checked orders out.

Strategies should be cheap to write and impossible to let loose: they publish signals and nothing else, while one service owns sizing, limits and orders.

One market-data ingester fetches 1-minute candles and derives every higher timeframe itself
Strategy processes hold no keys and never size or place orders; they only write signals to their own stream
One execution service admits, deduplicates and risk-checks each signal before placing orders and tracking fills
A Next.js dashboard reaches the API server to server, so the browser never holds the access token
Architecture & Stack

Streams between processes, one gate before the market.

Market data
Ingester1m candles · derived timeframes
Streams
Redis StreamsCandles in · signals out
Strategies
Trader processesSignals only, no keys
Execution
Risk gateOne pure function
Orders & fillsSingle instance, advisory lock
Control
Fastify + tRPCAPI · realtime
Next.jsDashboard
Stack
Language
TypeScriptNode 22pnpm + Turborepo
Services
Fastify 5tRPC 11Redis Streams
Data
PrismaPostgreSQLzod
Frontend
Next.jsReact 19
Quality
VitestDocker Compose
Key Decisions
01Only the execution service holds exchange keys and places orders
02Every limit (sizing, per-coin slots, four exposure ceilings, hedge reserve, margin) sits in one pure risk function shared by the order gate and the settings screen
03A priority-laned rate-limit budget keeps order traffic ahead of market data
04The wire format is defined once in zod and published as JSON Schema, with a drift test and cross-language parity fixtures
05Built with an AI coding-agent workflow I set up: 7 layer-author and 4 read-only auditor agents with fenced responsibilities
Walkthrough

Inside the product.

Screenshots from a local run on fictional demo data.

Control plane · Next.js dashboard
Risk settings with per-coin trade slots and exposure ceilings
Trade slots, exposure ceilings and hedge reserve
Per-coin policy table with long and short toggles
Per-coin direction and limit exceptions
Trader configuration dialog with JSON parameters
Per-trader parameters and take-profit cap
Core code
evaluateIntent risk function excerpt
One pure function checks every exposure ceiling
Zod schemas for entry and open signals
Signal wire contract defined once in zod
4Services
8Shared packages
3,810Test cases

Adding a strategy means writing a signal rule, not touching orders or limits: the risk function and the execution service are the only path to the market.

Next project

Faculty Reviews

→