Skip to main content

Multi-Agent Investment Analysis System powered by CrewAI and Claude

Project description

ProspectAI - Multi-Agent Investment Analysis System

๐Ÿš€ Try It Now

Try the ProspectAI Web Demo โ€” Experience the agentic system in action!

Overview

ProspectAI is a multi-agent investment analysis system built on the CrewAI framework. It leverages five specialized AI agents running a six-task pipeline to produce investment recommendations through a systematic analysis workflow. The system supports Anthropic Claude models (default) and local Ollama models.

Current release: v1.5.12

โš ๏ธ Important Disclaimer

ProspectAI is built for educational purposes to help developers get initiated in Agentic AI development.

๐Ÿšจ INVESTMENT WARNING: This tool should NOT be used as an investment tool without proper knowledge of the investment domain. The analysis provided is for educational demonstration of AI capabilities and should not be considered as financial advice. Always consult with qualified financial professionals before making investment decisions.

Features

  • Multi-Agent System: Five specialized AI agents across a six-task pipeline for rigorous investment analysis
  • Anthropic Claude: Powered by Claude models (Sonnet, Opus) by default
  • Ollama Support: Run fully locally with Ollama models
  • Real Reddit Integration: Live Reddit sentiment analysis using public JSON endpoints โ€” no credentials required
  • Sector Analysis: Analyze 5 major sectors (Technology, Healthcare, Finance, Energy, Consumer)
  • Command-Line Interface: Easy-to-use CLI with flexible configuration
  • Environment-Based Config: Secure .env-based configuration with startup validation
  • Structured Output: Consistent, machine-readable JSON analysis results
  • CrewAI Framework: Professional multi-agent orchestration via LiteLLM

Architecture

The system runs five specialized agents across a six-task sequential pipeline. Each task receives the full output of all prior tasks as context.

MarketAnalyst โ†’ TechnicalAnalyst โ†’ FundamentalAnalyst โ†’ DraftStrategist โ†’ Critic โ†’ FinalStrategist
    Task 1           Task 2             Task 3              Task 4         Task 5      Task 6

Pipeline Tasks & Agents

Task Agent Tools Input context
1. Market Analysis MarketAnalyst RedditSentimentTool, SerperDevTool โ€”
2. Technical Analysis TechnicalAnalyst TechnicalAnalysisTool, TechnicalInterpretationTool Task 1
3. Fundamental Analysis FundamentalAnalyst FundamentalDataTool, FundamentalGraderTool Tasks 1โ€“2
4. Draft Strategy InvestorStrategic CompositeScoreTool, PortfolioAllocatorTool Tasks 1โ€“3
5. Critic Review Critic โ€” (synthesis only) Tasks 1โ€“4
6. Final Strategy InvestorStrategic CompositeScoreTool, PortfolioAllocatorTool Tasks 1โ€“5

Agent Descriptions

Market Analyst Agent (Task 1)

  • Purpose: Entry point โ€” identifies candidate stocks from live market signals
  • Function: Analyzes Reddit discussions to surface trending stocks, incorporating macro/geopolitical context at execution time
  • Data Sources: Reddit API (PRAW) with Serper web search as fallback
  • Output: Top 5 candidate stocks with sentiment scores and relevance metrics

Technical Analyst Agent (Task 2)

  • Purpose: Quantitative technical analysis
  • Function: Runs 13+ technical indicators per ticker using yfinance + ta library, then interprets signals using TechnicalInterpretationTool
  • Indicators: RSI, MACD, Bollinger Bands, ATR, SMA, EMA, VWAP, ADX, and more
  • Output: Per-stock signals, momentum scores (1โ€“10), market regime (TRENDING/REVERTING), entry zones, stop-loss levels

Fundamental Analyst Agent (Task 3)

  • Purpose: Financial statement and valuation analysis
  • Function: Fetches real P/E, margins, debt ratios, FCF, and growth rates via yfinance; grades each metric using FundamentalGraderTool
  • Output: Valuation grades (CHEAP/FAIR/EXPENSIVE), financial health ratings, growth outlook

Investor Strategic Agent โ€” Draft (Task 4)

  • Purpose: First-pass portfolio construction
  • Function: Computes composite scores via CompositeScoreTool, allocates positions via PortfolioAllocatorTool
  • Composite Score: 30 pts sentiment + 40 pts momentum + 30 pts fundamentals (max 100)
  • Recommendations: STRONG_BUY / BUY / HOLD / REDUCE / AVOID โ€” allocation cap 40% per position
  • Trade setups: LONG-BUY, SCALED-ENTRY, WAIT-FOR-ENTRY

Critic Agent (Task 5)

  • Purpose: Adversarial quality gate between the draft and final strategy
  • Function: Reviews the draft portfolio against 12 failure-mode checks (schema validity, allocation math, entry zone logic, R/R ratios, regime consistency, etc.) and emits structured directives for correction
  • Output: CriticOutput โ€” list of CritiqueItem objects with field, severity, and directive; approved flag if no issues

Investor Strategic Agent โ€” Final (Task 6)

  • Purpose: Revised, production-ready portfolio
  • Function: Incorporates all Critic directives and produces the definitive InvestorStrategicOutput โ€” identical schema to the draft but corrected
  • Output: Machine-readable JSON (pipeline_version: "2.0") with allocation percentages summing to 100%, post-generation validation warnings attached

Installation

Prerequisites

  • Python 3.9+
  • An Anthropic API key or a local Ollama installation

Install via pip

pip install prospectai

That's it. All dependencies (CrewAI, yfinance, ta, requests, etc.) are installed automatically.

Configure Environment

Create a .env file in the directory where you'll run prospectai (see env.example for the full template):

# LLM backend: anthropic | ollama
MODEL_PROVIDER=anthropic

# Global default model id for all agents (raw id, no provider prefix)
MODEL=claude-sonnet-4-6

# Required when MODEL_PROVIDER=anthropic
ANTHROPIC_API_KEY=your_key_here

# Optional: override MODEL for a specific agent only
# AGENT_MARKET_ANALYST_MODEL=claude-3-5-haiku-20241022
# AGENT_TECHNICAL_ANALYST_MODEL=
# AGENT_FUNDAMENTAL_ANALYST_MODEL=
# AGENT_INVESTOR_STRATEGIC_MODEL=

# Market data โ€” Reddit and/or Serper (at least one source required by the app)
# SERPER_API_KEY=your_key_here

# When MODEL_PROVIDER=ollama
# OLLAMA_BASE_URL=http://localhost:11434

Model resolution (simple rule): AGENT_*_MODEL (if set for that agent) โ†’ MODEL โ†’ legacy ANTHROPIC_MODEL / OLLAMA_MODEL if you still use older .env files. MODEL_PROVIDER selects Anthropic vs Ollama routing.

When you run the CLI, MODEL is also set to provider/model_id for CrewAIโ€™s environment fallback; the app still resolves raw ids for each agent from the variables above.

Getting your API keys

Ollama setup (optional โ€” local models)

# Install Ollama
# https://ollama.com/download

ollama serve
ollama pull qwen3.5:9b

Usage

# Analyze Technology sector (default)
prospectai

# Analyze a specific sector
prospectai --sector Healthcare
prospectai --sector Finance
prospectai --sector Energy
prospectai --sector Consumer

# Override the global MODEL for a single run
prospectai --model claude-opus-4-6 --sector Technology

# Use a local Ollama model
prospectai --ollama --sector Technology
prospectai --ollama --model llama3.2:8b --sector Healthcare
prospectai --ollama --url http://192.168.1.100:11434 --sector Finance

CLI Reference

Flag Description
--sector Sector to analyze: Technology, Healthcare, Finance, Energy, Consumer (default: Technology)
--model Override global MODEL for this run (raw model id)
--ollama Use local Ollama instead of Anthropic
--url Ollama server URL (overrides OLLAMA_BASE_URL)

Configuration

LLM environment variables

Variable Required Description
MODEL_PROVIDER Yes anthropic or ollama (CLI --ollama sets ollama)
MODEL Yes* Global default model id for all agents (raw id, e.g. claude-sonnet-4-6 or qwen3.5:9b)
ANTHROPIC_API_KEY If MODEL_PROVIDER=anthropic Anthropic API key
OLLAMA_BASE_URL If MODEL_PROVIDER=ollama Ollama server URL
AGENT_MARKET_ANALYST_MODEL No Overrides MODEL for the Market Analyst agent only
AGENT_TECHNICAL_ANALYST_MODEL No Overrides MODEL for the Technical Analyst agent only
AGENT_FUNDAMENTAL_ANALYST_MODEL No Overrides MODEL for the Fundamental Analyst agent only
AGENT_INVESTOR_STRATEGIC_MODEL No Overrides MODEL for the Investor Strategic agent only
ANTHROPIC_MODEL No Legacy fallback if MODEL is unset (Anthropic path)
OLLAMA_MODEL No Legacy fallback if MODEL is unset (Ollama path)

*Or set a legacy model var above instead of MODEL.

Other environment variables

Variable Required Description
REDDIT_CLIENT_ID + REDDIT_CLIENT_SECRET One source* Reddit API (preferred for sentiment)
SERPER_API_KEY One source* Web search fallback when Reddit is unavailable

*The app requires at least one of: Reddit credentials or Serper.

Anthropic Claude Models

Model Use Case
claude-sonnet-4-6 Best balance of quality and speed (default)
claude-opus-4-6 Highest quality, deeper reasoning
claude-haiku-4-5-20251001 Fastest, lowest cost

Ollama Models

Model Notes
qwen3.5:9b Good reasoning, recommended for analysis
llama3.2:8b General purpose
llama3.2:3b Lightweight, fast
mistral:7b Good for analytical tasks

Per-agent model overrides

Preferred: set optional AGENT_*_MODEL variables in .env or your host secrets (e.g. Modal). Each variable overrides the global MODEL for that agent only.

Fallback: you can still set llm.model per agent in config/agents.yaml if no env-based id is resolved for that agent.

See AGENT_LLM_CONFIGURATION.md for additional notes on agent LLM configuration.

Development

To contribute or run from source:

git clone https://github.com/moisesprat/ProspectAI.git
cd ProspectAI
python -m venv .venv
source .venv/bin/activate       # Windows: .venv\Scripts\activate
pip install -e .

After installing in editable mode the prospectai command is available and picks up any local changes immediately.

Project Structure

ProspectAI/
โ”œโ”€โ”€ agents/                              # AI agent implementations
โ”‚   โ”œโ”€โ”€ base_agent.py
โ”‚   โ”œโ”€โ”€ market_analyst_agent.py
โ”‚   โ”œโ”€โ”€ technical_analyst_agent.py
โ”‚   โ”œโ”€โ”€ fundamental_analyst_agent.py
โ”‚   โ”œโ”€โ”€ investor_strategic_agent.py
โ”‚   โ””โ”€โ”€ critic_agent.py                 # Adversarial reviewer (v1.5.0+)
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ agents.yaml                     # Agent behavior (role, goal, model, temperature)
โ”‚   โ”œโ”€โ”€ tasks.yaml                      # Task definitions (descriptions, output schemas)
โ”‚   โ”œโ”€โ”€ agent_config_loader.py
โ”‚   โ”œโ”€โ”€ task_config_loader.py
โ”‚   โ””โ”€โ”€ config.py
โ”œโ”€โ”€ schemas/
โ”‚   โ””โ”€โ”€ agent_outputs.py                # Pydantic output schemas for all 5 agents
โ”œโ”€โ”€ utils/
โ”‚   โ”œโ”€โ”€ reddit_sentiment_tool.py        # Reddit PRAW sentiment tool
โ”‚   โ”œโ”€โ”€ technical_analysis_tool.py      # 13+ indicator calculator
โ”‚   โ”œโ”€โ”€ technical_interpretation_tool.py
โ”‚   โ”œโ”€โ”€ fundamental_data_tool.py        # yfinance financial data fetcher
โ”‚   โ”œโ”€โ”€ fundamental_grader_tool.py      # Grades individual fundamental metrics
โ”‚   โ”œโ”€โ”€ composite_score_tool.py         # 30/40/30 composite scoring
โ”‚   โ”œโ”€โ”€ portfolio_allocator_tool.py     # Allocation math with 40% cap
โ”‚   โ””โ”€โ”€ recommendation_validator.py    # Post-generation validation
โ”œโ”€โ”€ scripts/
โ”‚   โ””โ”€โ”€ deploy.sh                       # Bump version, build, publish to PyPI, deploy Modal
โ”œโ”€โ”€ tests/
โ”œโ”€โ”€ main.py                             # CLI entry point (prospectai command)
โ”œโ”€โ”€ prospect_ai_crew.py                 # CrewAI orchestration (6-task pipeline)
โ”œโ”€โ”€ pyproject.toml
โ””โ”€โ”€ README.md

Running Tests

python tests/test_skeleton.py
python tests/test_reddit_output.py Technology
python tests/test_technical_analyst.py
python tests/test_market_analyst_llm.py

Building and Publishing

pip install build twine
python -m build
twine upload dist/*

Troubleshooting

Issue Fix
prospectai: command not found Run pip install prospectai or activate the venv where it's installed
.env file not found Create a .env file in your current working directory
Missing keys error at startup Check the listed keys against your .env (especially MODEL / MODEL_PROVIDER and market data keys)
ANTHROPIC_API_KEY invalid Verify key at console.anthropic.com
Ollama connection refused Run ollama serve and verify OLLAMA_BASE_URL
Ollama model not found Run ollama pull <model-name>
No stocks found from Reddit Reddit public API may be rate-limited; add SERPER_API_KEY as fallback

Release Notes

v1.5.12 โ€” Refactor sentiment component calculation in CompositeScoreTo

  • Refactor sentiment component calculation in CompositeScoreTool; update tests for sentiment scoring logic
  • Enhance task configurations to handle price data errors; update schemas for optional current_price and price_data_error fields
  • Update README and deployment script for version 1.5.9; enhance test coverage and patch Crew usage
  • Refactor tests for FundamentalDataTool, RedditSentimentTool, TechnicalAnalysisTool, and CompositeScoreTool
  • Enhance agent and task configurations to include composite_score validation; add deploy script for version management

v1.5.11 โ€” Refactor sentiment component calculation in CompositeScoreTo

  • Refactor sentiment component calculation in CompositeScoreTool; update tests for sentiment scoring logic

v1.5.10 โ€” Enhance task configurations to handle price data errors; upd

  • Enhance task configurations to handle price data errors; update schemas for optional current_price and price_data_error fields

v1.5.9 โ€” Test coverage & graceful unknowns

  • Comprehensive test suite for FundamentalDataTool, RedditSentimentTool, TechnicalAnalysisTool, and CompositeScoreTool
  • FundamentalGraderTool now propagates UNKNOWN states instead of crashing on missing data
  • CompositeScoreTool handles unknown fundamental data gracefully, preventing scoring errors on tickers with incomplete financials
  • Added FundamentalGraderTool test coverage

v1.5.8 โ€” Composite score validation & deploy script

  • Added composite_score validation in agent and task configurations to enforce score integrity
  • Introduced scripts/deploy.sh for one-command version bumping, PyPI publishing, and Modal deployment

Roadmap

Next โ€” Multi-sector analysis

  • Support analyzing up to 3 sectors in a single pipeline run
  • Stocks from all sectors compete on composite score for portfolio slots
  • Cross-sector portfolio diversification rules

Future

  • Integration with financial news APIs (Bloomberg, Reuters)
  • Monte Carlo simulations for portfolio scenarios
  • Advanced risk metrics (VaR, CVaR, Sharpe ratios)
  • PDF report generation with charts

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes with tests where applicable
  4. Submit a pull request

License

MIT License โ€” see LICENSE for details.

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prospectai-1.5.12.tar.gz (83.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prospectai-1.5.12-py3-none-any.whl (73.9 kB view details)

Uploaded Python 3

File details

Details for the file prospectai-1.5.12.tar.gz.

File metadata

  • Download URL: prospectai-1.5.12.tar.gz
  • Upload date:
  • Size: 83.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for prospectai-1.5.12.tar.gz
Algorithm Hash digest
SHA256 d2321e5db64877345d1bcddef8e0eb1750cd4b744a513fdb51de5172002063e0
MD5 f32517debc5fef08666aa41356cbb493
BLAKE2b-256 90c5dde39d201bac503b164854c32475b5d071a271e50fefc5f4b7bd043a9208

See more details on using hashes here.

File details

Details for the file prospectai-1.5.12-py3-none-any.whl.

File metadata

  • Download URL: prospectai-1.5.12-py3-none-any.whl
  • Upload date:
  • Size: 73.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for prospectai-1.5.12-py3-none-any.whl
Algorithm Hash digest
SHA256 01389855172ac129243e0fe9e28248b0379b2fa404d12b72b2785739c2d478c3
MD5 602f13868a3912f8999fa73ef5f31559
BLAKE2b-256 990de8228f2093c7afaa3785e6b59e70b86865d4f53f0157219061dbcde9d824

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page