Canonical: https://www.brettsanders.com/blog/j5-trade-self-evolving-crypto-trading-system
Author: [Brett Sanders](https://www.brettsanders.com/)
Published: 2026-02-08
Updated: 2026-07-24

Field Note

# Building J5-Trade: A Multi-Model Crypto Trading System

How I built an automated Bitcoin trading system with three quantitative strategy models, LLM news sentiment, a four-agent analysis layer, and guardrailed risk management.

Published February 8, 2026 Updated July 24, 2026 11 min read

Trading Cryptocurrency Python React TypeScript AI LLM Sentiment Analysis Algorithmic Trading Full Stack Development WebSocket Real-time Systems Financial Technology

> **Update (July 2026):** The heuristic "self-evolution" parameter-tuning engine described below was an experiment that was **disabled in April 2026** — it was a rule-based tracker (not machine learning), and it wasn't earning its keep. The current system retains three quantitative strategy models and adds a four-agent analysis layer: Pricing, News Sentiment, Trade, and Coordinator. Guardrailed risk management remains authoritative. I've kept the original write-up below for the historical record, with framing corrected.

Over the past few weeks, I've built one of the most technically challenging and rewarding projects of my career: **J5-Trade**, an automated Bitcoin trading system — built with the help of my AI coding assistant. Not just another trading bot, but a system that evaluates multiple timeframes simultaneously through several independent quantitative strategies, layers in LLM-based news sentiment, and enforces disciplined, guardrailed risk management.

## The Core Concept: Why Multiple Models?

Most automated trading systems operate with a single strategy and a single timeframe. They make a decision, execute it, and hope for the best. J5-Trade takes a fundamentally different approach inspired by how professional trading desks operate: **multiple independent strategies working in concert**, each with its own risk budget and decision-making authority.

The system runs three distinct **quantitative strategy models** simultaneously (technical-analysis strategies built with `pandas_ta` — rules and indicators, not machine-learning models):

### 1. Aggressive Model (1m / 5m timeframes)

The day trader. Rapid-fire momentum bursts, mean reversion plays, and trend-following signals. Operates on 1-minute and 5-minute candles, looking for short-term inefficiencies. Daily loss limit: $700. Maximum 20 trades per day.

### 2. Balanced Model (15m / 1h timeframes)

The disciplined trader. Multi-timeframe trend alignment with stricter entry criteria. Only takes trades when 15-minute and 1-hour signals agree. Daily loss limit: $700. Volatility-scaled position sizing.

### 3. Big-Picture Model (1h / 4h / daily timeframes)

The strategist. Regime classification and macro-level posture. Determines whether we're in risk-on or risk-off conditions based on funding rates, volatility regimes, and market sentiment. Daily loss limit: $600. Maximum 2 trades per week.

Each model has its own personality, its own risk tolerance, and most importantly—its own ability to **veto the others** when market conditions don't align.

## What Makes J5-Trade Unique

### 🧬 Heuristic Parameter Tuning (later retired)

> **Note:** This subsystem was a *rule-based heuristic*, not machine learning — and I **disabled it in April 2026**. It's described here as originally built. It measured missed opportunities and nudged strategy parameters within hard guardrails; it never "learned" in any ML sense.

Most trading systems are static—you code a strategy, backtest it, deploy it, and hope the market doesn't change. J5-Trade instead **measured what it missed** and adjusted parameters by rule.

The tuning cycle worked like this:

1. **Missed Opportunity Tracker** runs hourly analysis windows, comparing optimal trades (in hindsight) vs. actual trades executed
2. **Strategy Evolver** diagnoses *why* alpha was missed—were signals too conservative? Did we miss trending moves? Were filters too tight?
3. **Automatic Parameter Adjustment** within guardrails (max 20% change per cycle) based on diagnosed patterns
4. **Evolution Log** records every adaptation with before/after values, creating a permanent audit trail

**Example Evolution Rules:**

- If >50% of windows had no signal generated → loosen volume ratio requirements, widen RSI thresholds
- If >30% of windows had trending moves missed → enable `trend_follower` strategy family
- If >40% of windows had signals vetoed by the resolver → relax spread threshold
- If capturing alpha but position sizes too small → increase clip size incrementally
- If trading actively but losing money → tighten entry filters and increase cooldown periods

Every change is logged to the database and visible in the dashboard's Evolution Log panel. If a change makes things worse, the system supports one-click rollback to previous parameter values.

![J5-Trade Dashboard showing Missed Opportunities analysis and Evolution Log](https://www.brettsanders.com/images/blog/j5-trade-evolution-dashboard.jpg) *The self-evolution system in action: Left panel shows missed alpha analysis with 7-day trends and hourly breakdowns. Right panel shows the Evolution Log with automatic parameter adjustments — the system loosening filters after detecting too many windows with no signals generated.*

### 🧠 Context-Aware Trading: Beyond Technical Indicators

J5-Trade doesn't trade in a vacuum. It integrates three layers of context:

**1. News Sentiment Analysis**\
Polls crypto news feeds for breaking headlines. Uses OpenAI/Gemini to score sentiment on a -1.0 (panic) to +1.0 (moon) scale. When RSI screams "BUY" but news headlines scream "EXCHANGE HACK," the system stays flat.

**2. Derivatives Context**\
Tracks funding rates, open interest, and liquidation zones. When funding rates spike positive (overleveraged longs), the system knows a correction is more likely. High open interest with extreme funding often precedes volatility.

**3. Volatility Regime Detection**\
Classifies current market conditions to adjust risk appetite. In high-volatility regimes, the system tightens position sizes and widens stop thresholds. In low-volatility consolidation, it watches for breakout setups.

### ⚖️ Signal Resolver: The Orchestra Conductor

When three models are generating signals simultaneously, you need a referee. The **Signal Resolver** implements a veto hierarchy:

```
Portfolio Risk Overlay (always wins)
    ↓
Big-Picture Regime Filter (can veto)
    ↓
Balanced Model Signal
    ↓
Aggressive Model Signal
```

It also handles:

- **Self-cross detection** - prevents models from fighting each other (one buying while another sells)
- **Correlation limits** - won't let all three models pile into the same direction without reason
- **Exposure reduction** during risk-off posture

### 🛡️ Risk Management: Sleep-at-Night Technology

J5-Trade has multiple safety layers:

- **Per-model daily loss limits** enforced by a dedicated risk management module
- **Global kill-switch at $2,000** cumulative loss
- **Consecutive loss cooldowns** (Aggressive: 3 losses = 30min cooldown, Balanced: 5 losses = 60min, Big-Picture: 3 losses = cooldown)
- **Stale data thresholds** - if price feed goes quiet, freeze new entries
- **Circuit breakers** on API calls to prevent rate limiting
- **Edge decay tracking** - rolling 30-day Sharpe per model, alerts when <0.5

The core BTC holdings are **never touched**. Only trading with allocated risk capital.

## The Tech Stack

Building a system that processes WebSocket streams, scores news with LLMs, maintains a comprehensive data persistence layer, and serves a real-time React dashboard required careful technology choices.

### Backend

- **Python** with asyncio for concurrent background processes
- **WebSocket** connection to exchange API
- **SQLite with WAL mode** for concurrent reads/writes across multiple data tables
- **Multiple background processes** with health monitoring and auto-restart capabilities

### Frontend

- **React + TypeScript** for type-safe UI components
- **Modern build tooling** for fast development and optimized production builds
- **TailwindCSS** for styling
- **Recharts** for real-time charts and visualizations
- **Component library** for accessible, polished UI primitives
- **Selective polling** - different components poll at different intervals to balance responsiveness vs API load

### API Server

- **Modern JavaScript runtime** for the API server
- RESTful endpoints for all system data
- Server-sent events (SSE) for live log streaming

### AI Integration

- **OpenAI** and **Google Gemini** for news sentiment scoring
- **Circuit breaker pattern** prevents API overuse and handles rate limiting gracefully

## The Dashboard: Full Visibility

Built a comprehensive real-time dashboard that gives me complete visibility into system behavior:

**System Overview Tab:**

- Current BTC price with 24h change
- Total PnL and loss budget remaining
- Process health status with visual indicators
- Current macro regime and multipliers
- System uptime and status

**Models Tab:**

- Per-model panels showing status, realized PnL, daily loss, trades today
- Signal history visualization
- Execution quality metrics: fill ratio, average slippage, cancel rate
- 30-day rolling Sharpe and edge decay warnings

**Evolution Log Tab:**

- Every parameter adaptation: param name, old value → new value, change %, reason
- Strategy family additions and removals
- Rollback status and one-click rollback capability

**Missed Opportunities Tab:**

- Visualizes captured alpha vs missed alpha
- Multi-day trend analysis: optimal PnL, actual PnL, capture rate
- Top miss reasons (e.g., "no signal generated", "signal vetoed", "spread too wide")

**Intel Feed Tab:**

- Live news headlines with sentiment scores and color-coded indicators
- Breaking/urgent news highlighted
- Expandable full article analysis

**System Logs:**

- Real-time monitoring of all background processes
- Filterable, searchable, with auto-scroll

## Architecture Highlights

### Modular Backend Design

The system consists of multiple independent Python processes that communicate through the shared database:

**Market Data Layer:**

- Real-time WebSocket price feed ingestion
- OHLCV candle aggregation across multiple timeframes (1m through daily)
- Historical data management for backtesting and analysis

**Intelligence Layer:**

- Three independent trading model processes (Aggressive, Balanced, Big-Picture)
- News sentiment analysis with LLM scoring
- Macro regime classification and derivatives monitoring
- Missed opportunity tracking and analysis

**Execution Layer:**

- Signal resolution and conflict management
- Order execution with sophisticated retry logic
- Risk enforcement and position tracking

**Operational Layer:**

- Health monitoring with automatic process recovery
- System logging and metrics collection
- Performance analytics and edge decay detection

All processes run concurrently, with a management interface that handles orchestration, startup, shutdown, and health checks.

### Simulation Mode

Before risking real capital, the system supports a simulation mode—paper trading with real market data. All trade logic executes identically, PnL is tracked separately, and I can validate strategy changes without financial risk.

## Future Plans

The roadmap includes some ambitious features:

**Multi-Asset Support:**\
Expand beyond BTC to ETH, SOL, and other majors. The architecture is already asset-agnostic—just need per-asset parameter tuning.

**Model Ensemble Learning:**\
A meta-model that learns which model to trust in which regime. "Balanced model historically does better during high-volatility contraction; give it more weight right now."

**Advanced Position Sizing:**\
Kelly criterion and volatility targeting at the portfolio level, not just per-model.

**Regime Detection 2.0:**\
Volatility clustering via GARCH models, correlation analysis across crypto/equities/bonds.

**Social Sentiment:**\
Integrate Twitter and Reddit sentiment via APIs (with spam filtering and bot detection).

**Distributed Architecture:**\
Move to microservices for horizontal scaling—separate containers for models, brain modules, execution.

## Lessons Learned

Building J5-Trade taught me some hard lessons about algorithmic trading:

### 1. Execution Quality > Signal Quality

In crypto, **fees, slippage, and spreads dominate**. A brilliant entry signal is worthless if you're paying 0.6% round-trip and getting slipped 0.2% on both sides. Prefer limit orders (maker fees), avoid wide-spread periods, and model slippage explicitly.

### 2. Self-Evolution Within Guardrails

Unrestricted parameter optimization leads to overfitting. Guardrails (max 20% change per cycle, only adjust based on meaningful sample sizes) prevent the system from chasing noise.

### 3. Per-Model Budgets = Accountability

When every model has its own risk budget, you can **measure edge per model**. If Aggressive is consistently losing money, you know where to focus your tuning efforts.

### 4. Log Everything

Signals generated but vetoed? Log it. Model wanted to trade but spread was too wide? Log it. These "no-trade" events are **gold** for understanding system behavior and improving strategies.

### 5. Circuit Breakers Are Not Optional

Crypto exchanges **will** rate-limit you. News APIs **will** go down. LLMs **will** time out. Every external dependency needs retry logic, exponential backoff, and circuit breakers.

### 6. Respect the Market

No amount of engineering brilliance can overcome a bad strategy. Stay humble. Measure everything. Kill strategies that don't work.

## Wrapping Up

J5-Trade represents weeks of intense building, countless refactors, and more than a few "oh crap" moments when something broke in production. But it's also one of the most technically satisfying projects I've built.

It's a multi-model trading system that combines several independent quantitative strategies, an LLM-based news-sentiment layer, a multi-agent analyst pipeline, and disciplined, guardrailed risk management. The combination of multi-model architecture, real-time context awareness, and full-stack observability creates something greater than the sum of its parts. (The heuristic parameter-tuning experiment was later retired — see the note above.)

Is it profitable? That's the $2,000 question (literally—that's the kill-switch threshold). Early results were mixed, and I treated it as a validation exercise rather than a money printer — the honest lesson being how hard persistent edge is, and how easily a tuning loop turns into sophisticated overfitting.

Either way, I've learned an enormous amount about trading, real-time systems, risk management, and what it takes to build production-grade financial software. And I've got a system that continuously teaches me about market microstructure, behavioral finance, and the humbling reality that the market always has more lessons to share.

***

**Interested in the technical details?** The system uses some fascinating patterns:

- Concurrent process communication via shared data layer
- Server-sent events for real-time log streaming
- Circuit breaker pattern for API stability
- Veto hierarchies for multi-agent decision-making
- Time-series analysis for missed opportunity detection
- Automatic parameter tuning within safety guardrails

Want to discuss algorithmic trading, multi-model systems, or just chat about the engineering challenges? Feel free to reach out. Always happy to talk shop with fellow engineers tackling complex problems.

**Remember:** Past performance is not indicative of future results. Trading crypto involves significant risk. J5-Trade is a personal learning project, not financial advice.
