Inspiration

Investment is one of the best ways to grow one's asset, but most people do not know how to get started. This inspired me to build this application to provide professional advice and fill in information gaps so that even an ordinary person can try their hands at investing.

What it does

MarketPulse AI connects to a user's portfolio and strategy rules to offer:

  1. Interactive Portfolio Auditing: Visualizes asset allocations, holding concentrations, and tracks performance metrics dynamically.
  2. Context-Aware Research Copilot: A natural language chatbot powered by a Gemini AI Orchestrator that parses user intents to trigger backtests, macro stress tests, sandboxes, and dual-agent debates.
  3. Market News Sentinel: Caches ticker-specific market news and applies real-time AI compliance check flags to alert you of strategy rule violations.
  4. Simulated Paper Trading: Allows spinning up to 10 isolated sandbox sub-ledgers with custom virtual cash balances to test strategies.

How we built it

  • Frontend: A multi-tab dashboard built with Streamlit (custom dark styling, responsive columns, and reactive session states).
  • Core Reasoning Engine: Powered by Google Gemini API (gemini-3.1-flash-lite for conversational routing/synthesis, and text-embedding-001 for generating 768-dimensional embeddings).
  • Database (Relational + Vector): CockroachDB Serverless manages transactional relational tables and distributed HNSW vector indexes in a single SQL cluster.
  • Object Storage: Amazon S3 archives raw uploaded PDF transcripts and SEC filings for audit and compliance.
  • Financial APIs: Yahoo Finance pulls real-time quotes and historical price bars, supplemented by the Tavily Search API for macro event lookups.

Challenges we ran into

1. Streamlit Cloud SSL Connection Errors

When deploying the app to Linux-based Streamlit Community Cloud containers, psycopg2's database pool initialization crashed with the error invalid sslmode value: "verify-full". We resolved this by:

  1. Creating a packages.txt file at the root to prompt Streamlit's builder to install PostgreSQL's system library (libpq-dev).
  2. Developing a self-healing fallback chain in the python connection pool code that catches verify-full exceptions, automatically retries with sslmode=require, and if that fails, strips sslmode query parameters to allow native SSL/TLS negotiation.

2. Context Constraints & Parallel Agent Debates

Coordinating parallel Bull and Bear agents required feeding them structured news caches, portfolio metrics, and relevant HNSW strategy vectors concurrently. We had to carefully parse and trim inputs using token thresholds to prevent prompt bloat and keep latency low during parallel executions.

3. Inconsistent Agent Response

Due to the nature of LLMs, the agent tends to give responses unintended by the user. To fix this, we repeatedly refined the system prompts and defined rules and response formats for the agent to always adhere to. We also added a response validation step to ensure that the agent provided a correctly formatted response which also satisfies the user's requirements.

Accomplishments that we're proud of

  • Single-Cluster Database Convergence: Proved that CockroachDB Serverless can handle both transactional asset positions and distributed vector searches, removing the need for a separate vector database.
  • Conversational Intent Router: Built a Gemini-powered router that parses conversational prompts and maps them into transactional backend tool calls.

What we learned

  • Distributed HNSW Indexes rock: Running HNSW cosine similarity vector searches inside CockroachDB is extremely simple, removing the developer overhead of syncing records across two databases.
  • Structured JSON Intent Routing: Using Pydantic schemas to validate LLM outputs is highly reliable and provides type safety in Python agent workflows.
  • Utilizing TTL: Using CockroachDB's native Row-Level TTL simplifies cache management by pruning 30-day-old audit logs and news stories without writing custom cron scripts.

What's next for MarketPulse AI

  • Amazon Bedrock Integration: Implement the model abstraction layer to allow swapping Gemini with Amazon Bedrock models.
  • Scheduled Portfolio Auditing: Set up recurring cron jobs to audit holdings against strategy rules overnight and send automated email alerts.
  • Advanced Technical Backtesting: Expand the quant engine to support complex indicators (e.g. RSI-MACD crossovers and multi-asset pairs trading).

Built With

Share this project:

Updates

Submission history