Gary Miller

LEAD_APPLIED_AI.ENG // FULL_STACK_AI.SYSTEMS // QUANT.DEV

SYS.LOG: Investment Matrix

>_ EXECUTIVE SUMMARY

Investment Matrix is a self-hosted cryptocurrency research and paper-trading platform built to connect live market ingestion, historical analysis, portfolio workflows, and AI-assisted risk review in one operational system.

The platform separates fast deterministic market logic from deeper asynchronous analysis. Exchange data enters through event-driven adapters, backtesting and paper execution remain inspectable, and locally hosted Ollama models can produce structured research without sending proprietary strategy prompts to a commercial model API.

>_ ARCHITECTURE & NETWORK ISOLATION

The Docker Compose topology isolates the frontend, backend, database, and inference services on purpose-specific networks. Exchange-facing adapters receive external market data, while the Next.js UI, FastAPI services, TimescaleDB, Redis, Celery workers, and local Ollama inference remain under the operator's control.

>_ CORE ENGINEERING CHALLENGES

1. Async Ingestion & Backpressure Management: Public exchanges emit thousands of ticks per second. A single-threaded Python ingestion loop would collapse under this weight. I separated stream adapters from writers—lightweight WebSockets parse JSON ticks directly into Redis Streams as a backpressure buffer. A dedicated async writer service then performs bulk multi-row inserts into TimescaleDB, avoiding database transaction blocking.

2. Structuring Local LLM Contracts: Open-source LLMs frequently hallucinate markdown, inline comments, or unstructured prose, crashing downstream JSON parsers. I built an aggressive sanitization pipeline that strips markdown fences, removes control characters, and isolates outermost JSON brackets. This is paired with a resilient Pydantic validation retry loop that automatically feeds schema errors back to the model for self-correction.

3. Balancing Latency vs. Analytical Depth: Deep multi-agent audits take ~60 seconds locally, missing fast execution windows. I engineered a dual-track decision engine: a deterministic fast-lane (evaluating VWAP, CVD, ATR, RSI) that executes in milliseconds, running parallel to an asynchronous Celery task that conducts deeper LLM risk assessments and thesis logging.

>_ PERFORMANCE METRICS

  • Inference Cost: Reduced from ~$0.05 per decision to $0.00 (Self-Hosted GPU).
  • Ingestion Lag: Processed from tick to TimescaleDB in < 85ms.
  • Backtest Execution: Dropped from 8.5s to 1.1s (87% Speedup) utilizing TimescaleDB continuous aggregate hypertables.
  • Data Posture: Strategy prompts and AI inference remain on local infrastructure; external network use is limited to configured market-data sources.

>_ ENGINEERING SIGNAL

Investment Matrix demonstrates event-driven ingestion, backpressure management, time-series data design, distributed task execution, schema-constrained LLM output, quantitative backtesting, and operational tradeoffs between latency and analytical depth.

ACCESS_SOURCE_CODE()