Inspiration

Most investors don't lose money on bad stocks—they lose it to their own trading psychology. In behavioral finance, losses hurt roughly twice as much as equivalent gains feel good. Under pressure, loss aversion, recency bias, herd instinct, and FOMO hijack rational decision-making: triggering panic capitulation at the bottom of a red day or impulsive chasing at the peak of a hype spike. We built PortfolioGuard AI to act as an intelligent psychological circuit breaker—a pause button that audits market reality and checks your emotional blind spots before you execute a trade.

What it does

Stop letting headlines and market noise hijack your discipline. PortfolioGuard AI is a behavioral trading copilot and pre-trade sandbox that evaluates whether a Buy or Sell order is grounded in fundamental signal or driven by an emotional reaction. It benchmarks your proposed trade against rolling volatility, news sentiment drivers, and systemic market trends, then filters it through your personal psychological risk profile synced directly from Claude or Muse AI via MCP. Test trade scenarios across simulated TFSA, RRSP, and Non-registered accounts, backtest portfolio impact against historical market data in CAD, and receive a deterministic Go Ahead, Mixed, or Panic/Chasing verdict backed by verifiable telemetry. (Educational simulation only; not financial advice.)

How we built it

  • Persona-Conditioned Psychological & Risk Calibration (Claude & Muse AI MCP Integration): A signed per-user MCP server enables personal AI assistants like Claude and Muse AI to distill everyday behavioral tendencies, emotional triggers, and risk preferences into a structured investor persona profile and risk band (low, mid, or high) pushed directly into PortfolioGuard AI. At runtime, this persona profile parameterizes the Classifier’s decision thresholds in AWS Lambda and conditions Amazon Nova Lite's coaching framing—dynamically adapting both the quantitative panic/chasing gates and the psychological tone of the guidance to match how the investor thinks and reacts.
  • Five-Agent Supervisor System on Amazon Bedrock AgentCore: Built around five specialized agents—Orchestrator, Intake, Market, Classifier, and Explainer—separating psychological profile context, market regime analysis, and deterministic math. Market and Classifier pre-compute feature pipelines on price refreshes so pre-trade behavioral checks return with low latency at the moment of temptation.
  • Hybrid Sentiment & Quantitative Behavioral Scoring on AWS Lambda: Combines Amazon Bedrock headline scoring (raw sentiment and company vs. market scope) with hyperparameter-tuned threshold cutoffs—calibrated on the Financial PhraseBank corpus—to classify discrete sentiment states. These signals are fused with 60-day rolling volatility ($\sigma$), volume anomaly ratios, market beta, and cross-asset correlation to measure emotional divergence from fundamentals, with decision boundaries dynamically scaled to the investor's risk band (low, mid, or high).
  • Guardrailed Behavioral Coaching with Amazon Nova Lite: Translates verified Lambda telemetry payloads into calm, bias-aware guidance tailored to the investor's psychology—enforcing zero number hallucination or mutation so emotional narratives are countered with objective facts.
  • Verified Risk Telemetry & CAD Backtesting Engine: Deterministic analytics compute annualized volatility, maximum drawdown, Herfindahl-Hirschman Index (HHI) asset concentration, and cumulative CAD return curves comparing current vs. proposed holdings—making the long-term cost of impulsive trades visible before execution.
  • Cloud-Native Infrastructure & Full-Stack Connector: Investor profiles and market datasets reside in Amazon S3 with full infrastructure-as-code provisioning via AWS CloudFormation, paired with a Next.js frontend, FastAPI backend, and signed per-user MCP server for Claude and Muse AI.

Agentic architecture

PortfolioGuard AI implements a supervisor-pattern multi-agent architecture on Amazon Bedrock AgentCore. Agents orchestrate reasoning, behavioral context routing, and guardrailed coaching, while deterministic AWS Lambda tools execute every mathematical and statistical calculation.

Request flow

  1. Orchestrator receives the proposed trade intent, determines agent invocation order, and records the end-to-end execution trace.
  2. Intake parses the Buy or Sell parameters and ingests the investor's psychological persona profile and risk band from Amazon S3 or the active MCP connector (Claude / Muse AI).
  3. Market retrieves price action, 60-day volatility ($\sigma$), volume ratios, beta, and market correlation via Lambda tools, leveraging pre-computed snapshots from price refreshes.
  4. Classifier applies persona-conditioned, risk-band-adaptive thresholds to the feature vector, executes the historical CAD portfolio backtest, and outputs a typed behavioral verdict: Go Ahead, Mixed, or Panic/Chasing.
  5. Explainer (Amazon Nova Lite) translates the verified Lambda metrics and verdict into clear, persona-aligned coaching without altering a single figure.

Key agentic capabilities

  • Autonomous task routing: The Orchestrator interprets trade context and delegates selectively across specialized agents.
  • Deterministic tool grounding: Every calculation—volatility, correlation, drawdown, HHI concentration, and CAD backtesting—runs in auditable Lambda functions, separating agentic reasoning from verifiable arithmetic.
  • Strict context isolation & typed handoffs: Each agent receives only the state required for its role and passes structured schemas (status, metrics, assumptions, warnings).
  • Proactive pre-computation: Market and Classifier pipelines pre-run on price refreshes so behavioral guardrails are ready immediately when market volatility spikes.
  • Runtime psychological adaptation: Updating the investor profile via Claude or Muse AI shifts quantitative thresholds and coaching tone in real time—producing distinct verdicts for the exact same trade across different investor mindsets.
  • End-to-end observability: An interactive execution trace exposes which agent ran, which Lambda tools were invoked, and the exact payloads returned.
  • Zero-hallucination numeric guardrails: The Explainer narrates verified outputs strictly within numeric bounds, preventing fabricated statistics.
  • Human-in-the-loop discipline: PortfolioGuard AI acts strictly as a pre-trade decision sandbox—intervening on impulse without ever executing live brokerage orders.

Behavioral trading guardrails: counteracting cognitive biases

  • Loss aversion & capitulation prevention: The Market agent uses beta and cross-asset correlation to separate a broad systemic sell-off from an idiosyncratic company deterioration, preventing investors from locking in losses at market bottoms out of fear.
  • FOMO & herd-instinct detection: The Classifier scores chasing (buying into abnormal price/volume spikes) and panic selling (exiting into acute drawdowns) against volatility-normalized historical baselines.
  • Recency & availability bias counterweight: Anchors short-term headline panic against 60-day rolling volatility regimes and multi-year CAD backtests so a single red week doesn't derail a multi-year plan.
  • Cross-checked portfolio mandates: Evaluates every order against macro market correlation, portfolio concentration (HHI), and drawdown exposure, flagging mandate drift before it happens.
  • Persona-conditioned psychological bounds: Sensitivity gates tighten or widen by risk band—for a capital-preservation investor like Robert, stability bounds flag volatility moves that a high-risk growth investor would clear.

Data

  1. Starter prices (29 tickers, 2021-11-12 to 2026-11-12): Real daily OHLCV market data across core North American equities and ETFs.
  2. Simulated current baseline dataset: Models a calm market baseline, pairing 60 real trading days with low-volatility, neutral simulated news flow.
  3. Simulated marketchange stress dataset: Five simulated stress trading days (2026-11-13 to 2026-11-19) designed to trigger classic emotional trading traps—featuring gap-downs, volume spikes, and negative headlines across both a systemic tech/market pullback (QQQ, NVDA, SHOP.TO, SPY) and an idiosyncratic single-company shock (ENB.TO).
  4. Bedrock-scored news headlines: Simulated headlines tagged with raw sentiment scores and scope (company or market), mapped into discrete sentiment states via Lambda's calibrated threshold cutoffs.
  5. Investor presets (Amira, Mateo, Robert; TFSA, RRSP, Non-registered): Archetype psychological profiles and Canadian account structures (e.g., Amira holds a concentrated growth portfolio of NVDA, SHOP.TO, and QQQ, with NVDA at ~42% weight, contrasting with capital-preservation profiles like Robert).
  6. Extended historical prices (2018-01-02 to 2021-11-11, 29 tickers, Yahoo Finance): ~30,800 historical daily price rows powering multi-year CAD backtests.
  7. VIX daily close (2018-01-02 to 2026-11-13, Yahoo ^VIX): ~2,230 daily volatility index observations for macro fear/regime context.
  8. Financial PhraseBank (Malo et al., v1.0): 4,838 annotated financial sentences (positive, neutral, negative with annotator agreement levels) used to calibrate Lambda's sentiment classification thresholds. CC BY-NC-SA 3.0: non-commercial use only, attribution required.
  9. Forward-return labels: 5-day forward return benchmarks computed for each historical flagged drawdown event to quantify the post-panic rebound cost.
  10. Synthetic behavioral personas (1,000 rows): Generated investor profiles spanning risk tolerance, time horizon, investment goal, and account type, labeled against PortfolioGuard AI's deterministic risk-band gates (explicitly tagged as synthetic).

What can be added next

Dataset Source Planned use (not implemented)
Credit spreads FRED (restricted from hackathon build environment) Secondary macro stress indicator alongside VIX for market fear regime detection.
Population risk attitudes Federal Reserve Survey of Consumer Finances, Statistics Canada Survey of Financial Security Empirical distributions of risk tolerance and investment horizon to replace synthetic persona priors.
Investor decision labels In-app behavioral scenario check-ins Ground-truth behavioral reaction labels to train personalized psychological calibration adapters.
FiQA sentiment dataset Public financial Q&A and sentiment benchmark Additional domain-specific training text alongside Financial PhraseBank (subject to license review).
Timestamped news archive Accumulated fetch_news.py feeds or licensed financial wire archive Event-driven backtesting of headline sentiment shocks against subsequent price action.
Corporate events & filings SEC EDGAR, SEDAR+, and corporate_actions.csv Enable the Market agent to distinguish scheduled earnings/filings from unexpected news shocks.
Read-only brokerage holdings Wealthsimple and Questrade read-only API links Sync live Canadian portfolio positions in place of simulated presets.

Accomplishments that we're proud of

  • True multi-agent orchestration on AWS: Built a five-agent supervisor system on Amazon Bedrock AgentCore with full step-by-step execution trace visibility.
  • Psychology-aware dynamic verdicts: Demonstrated the exact same market drawdown resolving as a routine hold for one investor persona and a high-risk panic flag for another.
  • Auditable, test-backed deterministic core: Achieved 78 passing automated tests (63 across deterministic Lambda scoring/backtesting functions and 15 across agent orchestration flows).
  • Seamless MCP assistant integration: Built a signed per-user MCP connector allowing Claude and Muse AI to inject live behavioral investor profiles directly into the pre-trade guard.

What's next for PortfolioGuard AI

  • Online persona-conditioned neural calibration: Train a lightweight neural adapter from interactive in-app behavioral scenario check-ins to fine-tune per-user sensitivity weights, benchmarked directly against our deterministic Lambda threshold engine (which remains as the auditable safety fallback).
  • Walk-forward out-of-sample backtesting: Validate panic and chasing flags out-of-sample against 5-day and 20-day forward returns versus a passive "always hold" baseline.
  • Behavioral pattern memory: Track historical trade simulations to surface personal recurring cognitive habits (e.g., "You consistently attempt to sell growth holdings after two consecutive red days").
  • Regime-aware signal upgrades: Add Hidden Markov Model (HMM) volatility regime detection and calibrated FinBERT confidence intervals alongside Bedrock headline scoring.
  • 24-hour cooling-off workflow & trade journal: Introduce an optional time-locked pause on Panic/Chasing verdicts paired with a structured decision journal to review emotional state vs. actual outcomes 30 days later.
  • Live read-only brokerage sync: Connect Wealthsimple and Questrade accounts in read-only mode to evaluate real TFSA/RRSP allocations.
  • Omnichannel MCP alerts & bilingual support: Surface pre-trade verdicts directly inside Claude, Muse AI, and mobile push notifications, with full English and French localization for Canadian investors.
  • Production hardening: Integrate Amazon Bedrock AgentCore Observability with OpenTelemetry, end-to-end KMS encryption for persona profiles with explicit user consent, and full compliance review prior to live retail deployment.

Wiki: https://github.com/KneewYen/datathon2026/wiki

Built With

  • amazon-bedrock-agentcore-(5-agents)-amazon-bedrock
  • awsiam
  • cloudformation
  • cloudwatch
  • fastapi
  • lambda
  • mcp
  • novalite
  • pandas
  • python
  • s3
  • strand-agents-sdk
Share this project:

Updates

Submission history