Inspiration

Every trader knows the frustration of making decisions driven by emotion rather than strategy. Studies show that 80% of retail traders lose money, not because they lack market knowledge, but because of psychological biases like revenge trading after a loss, overtrading during volatile markets, or holding losing positions too long due to loss aversion. We wanted to build a tool that acts as a personal trading psychologist, one that analyzes your actual trading behaviour, identifies unconscious patterns, and provides evidence-based coaching to help you become a more disciplined trader.

What it does

CogniTrade is an AI-powered trading psychology platform that helps traders identify and overcome their behavioral biases. It combines three core capabilities:

  • Behavioral Bias Detection — Upload your trading history (CSV) and our ML models (XGBoost-based) analyze your trades to detect three critical biases: overtrading, revenge trading, and loss aversion. Each bias is scored with probability metrics and backed by specific evidence from your trade data.
  • AI Trading Expert — A conversational AI agent powered by LLMs that acts as your personal trading psychologist. It can query your trade data directly via SQL, cite specific timestamps and patterns, and provide actionable recommendations tailored to your behavior.
  • Journal Analysis — A RoBERTa-based NLP model that analyzes your trading journal entries to detect psychological biases including FOMO, Gambler's Fallacy, and more — helping you recognize emotional patterns before they impact your trades.
  • Paper Trading Simulator — Practice trading with real-time market data, place market/limit/stop-loss orders, track your portfolio, and then analyze your simulated trades for behavioral patterns.
  • Behavioural-finance quiz game — Learn the definition of and practice recognizing biases in a person's state of mind.

How we built it

Front end: React + TypeScript with Vite, styled using TailwindCSS and Radix UI components. Framer Motion powers smooth animations, and lightweight-charts renders real-time market visualizations. Zustand manages global state for the trading simulator.

Backend: Flask API serving four custom ML models: Overtrading Model (XGBoost) — Analyzes 15-minute sliding windows for trade clustering, burst frequency, and position sizing patterns Revenge Trading Model (XGBoost) — Compares baseline behavior vs. post-loss windows to detect emotional retaliation trades Loss Aversion Model (XGBoost) — Identifies asymmetric holding patterns (cutting winners early, holding losers too long) Journal Bias Detector (RoBERTa/Transformers) — Multi-label text classification for 5 psychological biases

AI Agent: Backboard SDK orchestrates an LLM-powered expert agent with tool-calling capabilities. DuckDB enables the agent to run SQL queries against uploaded trade data in real-time, grounding its analysis in concrete evidence.

Integrations: Alpaca API for real-time market data, Gradium for speech-to-text transcription of trade notes, and WebSocket streaming for live updates.

Challenges we ran into

  1. Feature Engineering for Behavioral Models — Translating abstract psychological concepts like "revenge trading" into quantifiable features required extensive research into behavioral finance literature and iterative experimentation with different windowing strategies.
  2. Generating Quality Training Data — We built custom synthetic data generators (generate_trader_behaviors.py) that simulate realistic trader personas (calm, overtrader, revenge trader, loss-averse) to train our models.
  3. Lack of available APIs at the free tier that supports live market data.

Accomplishments that we're proud of

  • Four production-ready ML models that detect distinct behavioral biases with interpretable feature outputs and high accuracy, using what we've learned from Stats and AI courses!
  • End-to-end integration from CSV upload → bias scoring → AI-generated expert report → conversational follow-up

What we learned

  1. Behavioral finance is complex — Biases like loss aversion manifest differently across traders; a one-size-fits-all threshold doesn't work. Window-based statistical analysis with relative comparisons proved more robust.
  2. Good UX matters for sensitive feedback — Telling someone they have "revenge trading tendencies" requires careful framing. We learned to balance honesty with encouragement, presenting biases as opportunities for growth.

What's next for CogniTrade

Brokerage Integration, Connect directly to Alpaca, Interactive Brokers, Wealthsimple or Robinhood to analyze real trades automatically! Real-time Alerts — Detect bias patterns as they happen and send warnings before you place an impulsive trade Expanded Bias Detection — Add models for confirmation bias, anchoring, and sunk cost fallacy Community Benchmarking — Anonymous comparison of your bias scores against similar traders to provide context Mobile App — Quick journaling and bias check-ins on the go Personalized Coaching Plans — Multi-week programs with daily exercises to systematically reduce identified biases

Built With

Share this project:

Updates