Back to work

AI stock & macro-risk analysis grounded in Soros's reflexivity

Role

AI Engineer

Year

2025

ReflexAI — AI stock and macro risk analysis platform
PythonGoogle GeminiRAGChromaDBSentence-TransformersyfinancePandasVercel

5

Analysis layers

3

Risk diagnostics

2

AI reasoning modes

3

REST endpoints

System Architecture

The Problem

Most stock tools output numbers or buy/sell signals with no reasoning about why markets become fragile. ReflexAI takes a different angle — grounded in George Soros's theory of reflexivity (perception → price → fundamentals) — analyzing how feedback loops amplify financial risk, pairing hard financials with AI reasoning that stays philosophically consistent.

What I Built

A dual-lane platform that fuses quantitative reality with grounded AI reasoning:

  • Financial analysis: pulls and normalizes income statements, balance sheets, and cash flows for any public company via yfinance
  • Risk diagnostics: computes liquidity, leverage, and profitability-resilience metrics designed to expose systemic fragility — not just report ratios
  • Dual AI reasoning: a direct Gemini mode and a RAG mode grounded in a curated Soros knowledge corpus (Sentence-Transformer embeddings + ChromaDB)
  • Ticker-aware context injection so the LLM reasons over a live market snapshot without becoming a trading bot
  • A three-endpoint REST API (financials, chatbot, ragbot) behind a web UI deployed on Vercel

Key Decisions

The trade-offs — and why:

  • Made RAG the core so answers stay grounded in Soros's actual framework instead of confident hallucination
  • Used annual (not intraday) data to strip trading noise and focus on structural, macro risk
  • Modeled leverage as a non-linear risk amplifier rather than a static ratio, separating accounting profitability from economic durability
  • Kept ticker detection conservative to avoid false positives injecting the wrong market context

Challenges

The hard parts:

  • Grounding vs. fluency: tuning retrieval so responses stay faithful to the corpus while still reading naturally
  • Serverless vector persistence: the ChromaDB index depends on filesystem state, which is tricky on Vercel's ephemeral environment
  • Situated reasoning: injecting just enough market context to be relevant without turning the assistant into a signal generator

Results

An interpretable research tool that pairs quantitative risk diagnostics with grounded, Soros-style reasoning — letting users explore how narrative and fundamentals feed back on each other, live at the deployed site.

What's Next

Agent-based macro simulations, scenario stress-testing, and portfolio-level systemic-risk views.