01

Freelance

AITradingBot

Company
Freelance
Year
2024 — 2025
Type
AI/ML · Fintech
Role
Full Stack Engineer

Manual trading was slow, emotional, and inconsistent

Day traders spend hours analyzing charts, reading news, and making emotionally-charged decisions. The result: inconsistent returns, missed opportunities, and burnout. The challenge was to build a system that could reason about market conditions as well as a skilled trader — but without fatigue, bias, or hesitation.

I needed to create a bot that could ingest real-time market data, apply technical analysis, cross-reference with news sentiment, and execute trades autonomously — all while maintaining a clear audit trail of its reasoning.

Claude Sonnet as the reasoning core, RAG as the memory

Rather than building a traditional algorithmic trading bot with hard-coded rules, I used Claude Sonnet as the core reasoning engine. The LLM analyzes market conditions in natural language, considers multiple factors simultaneously, and produces structured trading decisions.

To ground Claude's analysis in reality, I implemented a RAG (Retrieval-Augmented Generation) pipeline using historical market data stored in Supabase. Before each analysis cycle, the system retrieves relevant historical patterns, previous trade outcomes, and technical indicators to provide context.

The entire workflow is orchestrated through n8n, which handles data ingestion, RAG retrieval, prompt construction, LLM inference, and trade execution in a single automated pipeline. Docker containerization ensures consistent deployment and easy scaling.

Structured Prompts

Developed a prompt engineering framework that forces Claude to output structured JSON with confidence scores, reducing hallucination by grounding decisions in retrieved data.

Historical Context

RAG pipeline retrieves similar market conditions from the past 2 years, giving the LLM pattern-matching capabilities beyond its training data.

Real-time Pipeline

n8n orchestration processes market data, runs analysis, and executes trades in under 30 seconds per cycle.

A fully autonomous trading system with human-readable reasoning

The final system operates 24/7 with minimal human intervention. Each trading decision comes with a detailed reasoning chain — explaining why the bot chose to buy, sell, or hold. This transparency was critical for building trust in the system.

The bot monitors multiple trading pairs, applies risk management rules (position sizing, stop-losses, take-profits), and logs every decision with full context. A dashboard built on Supabase provides real-time visibility into performance, open positions, and historical decisions.

Consistent performance with transparent decision-making

The RAG-augmented approach achieved 85% signal accuracy in backtesting, significantly outperforming simple rule-based bots. The structured prompt engineering reduced hallucinated signals by over 60% compared to raw LLM inference.

Most importantly, the system removed emotion from trading decisions entirely, leading to more disciplined risk management and consistent execution across market conditions.

The key insight was treating the LLM not as a black box, but as a reasoning engine that needs the right context to make good decisions — just like a human trader needs data to trade well.

85%
Signal accuracy with RAG pipeline
Faster analysis vs manual trading
24/7
Automated monitoring & execution
Next Case Study
Horizon
Personal Project