Completed System Architect & Backend Developer

Sentiment-Driven Automated Trading System

Sentiment in, risk-checked orders out — an event-driven crypto trading pipeline with volatility-adaptive sizing, momentum-based exits, and full audit logging.

NestJSTypeScriptNode.jsTurborepoRedisBullMQ+9 more

Fully Automated Sentiment-to-Execution Trading Pipeline

7 NestJS Microservices in a Turborepo Monorepo

Dedicated Risk Engine Approving Every Trade

6 External API Integrations — Kraken, Deribit, Binance & 3 Sentiment Sources

Volatility-Adaptive Sizing & Gamma Scalping

Event-Driven TCP Transport with Redis + BullMQ

Project Showcase

Sentiment-Driven Automated Trading System

Overview

An event-driven automated trading system for BTC, ETH, and SOL perpetual futures on Kraken Futures. Instead of trading purely on price charts, it continuously measures market sentiment from three independent sources — AI analyst headlines (MarketsAI), social sentiment (LunarCrush), and news articles (NewsData.io) — normalizes each to a −1…+1 scale, and blends them into a weighted composite score every minute during US market hours. Positive sentiment opens longs, negative opens shorts, and neutral regimes trigger small gamma-scalping trades sized by a volatility-regime service backed by the Deribit DVOL index. A dedicated risk-management service approves or rejects every trade against position caps, equity limits, and leverage rules, runs a prioritized exit engine on every sentiment tick, and hands approved orders to an execution service that sets leverage, extracts real VWAP fill prices, and places exchange-side stop-loss and take-profit orders. The whole system is a Turborepo monorepo of 7 NestJS microservices communicating over TCP, with Redis + BullMQ for scheduling and shared state, centralized audit logging, and Docker Compose / PM2 deployment.

Responsibilities

Microservice & monorepo architecture

Risk engine & prioritized exit logic

Order execution & position management

Exchange & sentiment API integrations

Redis/BullMQ scheduling & shared state

Docker Compose & PM2 deployment

Designed and built the entire system end-to-end — a 7-service NestJS monorepo covering the sentiment pipeline, risk engine, volatility-regime detection, exchange execution, and centralized logging.

Architecture

Sentiment Sources (every 1 min)

MarketsAI
LunarCrush
NewsData.io
Sentiment Service — normalize & weighted composite score
sentiment.received event (TCP broadcast)

Decision Layer

Risk Management Service
Volatility Regime Service
Execution Service — leverage → market entry → VWAP → SL/TP
Kraken Futures API

Tech Stack

NestJS (hybrid HTTP + TCP microservices)TypeScriptNode.jsBullMQMongoose
TurborepoRedisDocker ComposePM2
Kraken Futures APIDeribit DVOLBinance API
MarketsAILunarCrushNewsData.io

Features

Sentiment Pipeline

  • Composite sentiment score from three independent sources, each normalized to a −1…+1 scale with configurable weights
  • BullMQ-scheduled 1-minute trading cycle, gated to US market hours
  • Per-source error isolation — one failing source never kills the cycle
  • MarketsAI session management with Redis-cached tokens and automatic re-login on 401

Risk Management

  • Entry gauntlet: one position per ticker, max 5 concurrent positions, 2% equity per trade, 2× leverage per position, 4× aggregate leverage cap
  • Instrument-aware position sizing with contract precision, exchange minimums, and available-equity checks
  • Prioritized exit engine: sentiment flip → momentum scale-out → momentum stall → 48h max holding period
  • Anti-churn controls: minimum hold time, minimum price-move threshold, per-symbol trade cooldowns
  • Portfolio state sync from Kraken with rolling Redis price history for EMA calculations

Execution & Safety

  • Isolated-margin leverage setup, market entry, and VWAP fill extraction before placing protective orders
  • Exchange-side stop-loss and take-profit orders that trigger even if the bot is down
  • Tick-size-aware price rounding and precision-aware size rounding on every order
  • Manual close-all-positions / close-all-orders kill switches
  • Testnet-first safety defaults out of the box

Volatility & Gamma Scalping

  • Deribit DVOL regime classification (LOW / NORMAL / HIGH) with a Binance 24h-move fallback
  • Regime-adaptive leverage multipliers and gamma trade size/frequency multipliers
  • Neutral-sentiment gamma scalping with tight targets, disabled entirely in high volatility

Observability & Ops

  • Central logging service collecting structured events from all services, with 10-day auto-pruning
  • Three deployment modes: Docker Compose dev (hot reload), Docker Compose prod, and PM2
  • Two-file config split — secrets/networking vs. strategy tuning knobs

Engineering Challenges

Challenge 1: Blending Three Heterogeneous Sentiment Sources into One Tradable Signal

Challenge

Each sentiment provider speaks a different language — categorical POSITIVE/NEUTRAL/NEGATIVE labels, 1–5 social scores, and confidence-weighted news labels — and any of them can fail or degrade at any time.

Solution

Normalized every source to a common −1…+1 scale, combined them with configurable weights into a single composite score with long/short/hold thresholds, and isolated each source's errors so one failing API never kills the trading cycle.

Challenge 2: Preventing Overtrading on a 1-Minute Signal

Challenge

A sentiment score refreshing every 60 seconds can whipsaw, and naively acting on every tick would churn positions and bleed fees.

Solution

Layered anti-churn controls into the risk engine: a minimum hold period before momentum exits, a minimum price-move threshold, per-symbol trade cooldowns, and a one-time scale-out flag so partial exits fire only once per position.

Performance & Security

Exchange-Side Stop-Loss & Take-Profit OrdersAggregate Leverage Cap (Total Notional / Equity)Per-Source Error Isolation in the Sentiment PipelineSigned Kraken API Requests with Testnet/Production SwitchRedis-Cached Auth Tokens with Automatic Re-LoginManual Close-All Kill SwitchesCentralized Structured Logging with 10-Day Retention

Lessons Learned

  • Protective orders belong on the exchange, not in the bot — stops must survive process downtime
  • Anti-churn controls matter as much as entry signals in a high-frequency decision loop
  • Real fill prices (VWAP), not requested prices, must drive stop-loss and take-profit placement
  • Per-source failure isolation keeps a multi-API pipeline alive when one provider degrades
  • Splitting secrets from strategy tuning config makes iterating on trading parameters safe and fast

Project Details

Role

System Architect & Backend Developer

Team Size

2 developers

Platform

Headless trading bot (server-side)

Architecture

Event-Driven Microservices (NestJS TCP + Redis/BullMQ)

Database

Redis + MongoDB

Status

Completed

Deployment

Docker Compose / PM2

Interested in working together?

Let's talk about how I can help build and ship your next production application.