← Back to Work

( Case Study · 2025 )

Trading Agent

Trading Agent

Overview

A self-learning, utility-based trading agent built on LangGraph that observes market data, reasons with LLMs, simulates strategies, executes paper trades, and improves from feedback.

The agent loop

  • Fetch data — historical OHLCV via Alpaca (yFinance fallback) plus technical indicators.
  • Analyse — an LLM scores sentiment and confidence per symbol.
  • Build strategy — allocates capital by sentiment/confidence with entry & exit rules.
  • Backtest — simulates day-by-day with targets and stop-losses.
  • Execute — places paper trades on Alpaca only when the backtest is positive.
  • Evaluate — computes portfolio metrics.
  • Self-improve — the LLM proposes refinements for the next run.
  • Stack

    Python · LangGraph · multi-LLM (OpenAI / Groq / Ollama / HuggingFace) · Alpaca + yFinance

    Highlights

  • Stateful, risk-aware decision pipeline with persistent memory.
  • Provider-agnostic LLM layer and a polished CLI.
  • Backtest gating so only validated strategies ever trade.