Market Monitor (Multi-Agent Market Intelligence Network)

Role: Solo, end-to-end
Tech Stack: Python 3.12+, Anthropic Claude, PostgreSQL 16, InspIRCd, Docker Compose, asyncio
Repository: Private. Demo available on request

Overview

Market Monitor is an adaptive intelligence system for monitoring rare earth and critical minerals markets. Three independently deployable services talk to each other through an IRC server and share state via PostgreSQL: a collector gathers market data, an intelligence service detects anomalies and runs investigations, and a trader executes paper options trades based on system signals.

The system adapts its behavior in real time. When the sentinel detects an anomaly, it escalates monitoring intensity, polling frequency goes up, investigation hypotheses are generated, and the LLM gets pulled in for multi-pass analysis. When the event resolves, the system enters a retrospective phase where it scores its own prediction accuracy and adjusts future confidence.

System Architecture

Three Docker services, loosely coupled through IRC channels and a shared PostgreSQL database:

graph TD
    subgraph "metals-collector"
    A[yfinance Poller] -->|prices| D[(PostgreSQL)]
    B[Finnhub + RSS News] -->|articles| D
    end

    subgraph "metals-intelligence"
    D --> E[Sentinel]
    E -->|anomaly detected| F[Researcher]
    F -->|hypothesis-evidence loop| G[Converged Investigation]
    D --> H[Chronicler]
    H -->|event synthesis| D
    H -->|resolution tracking| D
    D --> I[Digest]
    end

    subgraph "metals-trader"
    G -->|trade signal| J[Trade Evaluator]
    E -->|critical alert| J
    J -->|LLM evaluation| K[Strategy Selector]
    K --> L[Paper Execution]
    L -->|P&L tracking| M[Performance Analyzer]
    M -->|calibration feedback| D
    end

    N[IRC Server] <-.->|all services| D

IRC Channels: #prices #news #alerts #digest #chronicle #investigate #trades #ops

How It Works

1. Escalation State Machine

Markets are noisy. Monitoring everything at high intensity wastes API calls and LLM tokens. But under-monitoring during a genuine event means missing the signal entirely. So I built a four-level state machine that adapts monitoring intensity based on computed escalation scores.

LevelPrices PollNews PollLLM Usage
Normal15 min30 minNone
Elevated5 min15 minHypothesis generation
Intensive2 min10 minFull scenario modeling with self-critique
Retrospective15 min30 minLessons extraction and calibration

Transitions are driven by alert severity and a composite escalation score. The system decays back to normal after 8 hours of calm, or automatically enters retrospective after 48 hours of sustained elevation.

2. Multi-Turn Investigation Engine

A single LLM call can’t reliably diagnose a market anomaly. It needs to gather evidence, test hypotheses, and refine its assessment iteratively, same way an analyst would. So I built a hypothesis-evidence loop that runs until convergence.

3. Calibration Feedback Loop

LLM confidence scores are often poorly calibrated. A model that says “80% confident” isn’t right 80% of the time, which is a problem if you’re sizing positions based on that number. So I built a closed-loop system that tracks prediction accuracy and adjusts future behavior.

4. Paper Options Trading

Testing market intelligence quality means putting it into action, but with real money at risk you can’t iterate freely. Paper trading with confidence-scaled position sizing and strict risk management lets me actually measure the system.

5. IRC as Service Bus

The services need to communicate without tight coupling, and the system should be observable in real time. IRC works as a lightweight message bus with human-readable channels, and yes, it’s a little unusual, but it’s perfect for this.

Testing

480+ tests across 50 test files following strict TDD (red-green-refactor). Tests mirror the source structure: tests/sdk/, tests/agents/metals_collector/, tests/agents/metals_intelligence/, tests/agents/metals_trader/.

Tech Stack