prospectai 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- prospectai-1.0.0/LICENSE +21 -0
- prospectai-1.0.0/PKG-INFO +329 -0
- prospectai-1.0.0/README.md +298 -0
- prospectai-1.0.0/agents/__init__.py +13 -0
- prospectai-1.0.0/agents/base_agent.py +85 -0
- prospectai-1.0.0/agents/fundamental_analyst_agent.py +24 -0
- prospectai-1.0.0/agents/investor_strategic_agent.py +49 -0
- prospectai-1.0.0/agents/market_analyst_agent.py +23 -0
- prospectai-1.0.0/agents/technical_analyst_agent.py +44 -0
- prospectai-1.0.0/config/__init__.py +0 -0
- prospectai-1.0.0/config/agent_config_loader.py +154 -0
- prospectai-1.0.0/config/agents.yaml +233 -0
- prospectai-1.0.0/config/config.py +51 -0
- prospectai-1.0.0/data/__init__.py +0 -0
- prospectai-1.0.0/main.py +147 -0
- prospectai-1.0.0/prospect_ai_crew.py +488 -0
- prospectai-1.0.0/prospectai.egg-info/PKG-INFO +329 -0
- prospectai-1.0.0/prospectai.egg-info/SOURCES.txt +34 -0
- prospectai-1.0.0/prospectai.egg-info/dependency_links.txt +1 -0
- prospectai-1.0.0/prospectai.egg-info/entry_points.txt +2 -0
- prospectai-1.0.0/prospectai.egg-info/requires.txt +11 -0
- prospectai-1.0.0/prospectai.egg-info/top_level.txt +6 -0
- prospectai-1.0.0/pyproject.toml +51 -0
- prospectai-1.0.0/setup.cfg +4 -0
- prospectai-1.0.0/tests/test_agents.py +176 -0
- prospectai-1.0.0/tests/test_cli.py +174 -0
- prospectai-1.0.0/tests/test_config.py +108 -0
- prospectai-1.0.0/tests/test_crew.py +282 -0
- prospectai-1.0.0/tests/test_tools_fundamental.py +212 -0
- prospectai-1.0.0/tests/test_tools_reddit.py +182 -0
- prospectai-1.0.0/tests/test_tools_technical.py +200 -0
- prospectai-1.0.0/utils/__init__.py +0 -0
- prospectai-1.0.0/utils/enhanced_pdf_generator.py +886 -0
- prospectai-1.0.0/utils/fundamental_data_tool.py +160 -0
- prospectai-1.0.0/utils/reddit_sentiment_tool.py +219 -0
- prospectai-1.0.0/utils/technical_analysis_tool.py +428 -0
prospectai-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ProspectAI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: prospectai
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Multi-Agent Investment Analysis System powered by CrewAI and Claude
|
|
5
|
+
Author: moisesprat
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: investment,ai,crewai,stock-analysis,multi-agent
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: crewai>=1.0.0
|
|
20
|
+
Requires-Dist: crewai-tools>=1.0.0
|
|
21
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
22
|
+
Requires-Dist: pandas>=2.1.4
|
|
23
|
+
Requires-Dist: numpy>=1.26.0
|
|
24
|
+
Requires-Dist: requests>=2.31.0
|
|
25
|
+
Requires-Dist: yfinance>=0.2.28
|
|
26
|
+
Requires-Dist: PyYAML>=6.0
|
|
27
|
+
Requires-Dist: ta>=0.10.2
|
|
28
|
+
Requires-Dist: praw>=7.7.0
|
|
29
|
+
Requires-Dist: anthropic>=0.40.0
|
|
30
|
+
Dynamic: license-file
|
|
31
|
+
|
|
32
|
+
# ProspectAI - Multi-Agent Investment Analysis System
|
|
33
|
+
|
|
34
|
+
## Overview
|
|
35
|
+
|
|
36
|
+
ProspectAI is a multi-agent investment analysis system built on the CrewAI framework. It leverages four specialized AI agents to provide comprehensive investment recommendations through a systematic analysis workflow. The system supports Anthropic Claude models (default) and local Ollama models.
|
|
37
|
+
|
|
38
|
+
**🎉 First Official Release - v1.0.0**
|
|
39
|
+
|
|
40
|
+
### ⚠️ Important Disclaimer
|
|
41
|
+
|
|
42
|
+
**ProspectAI is built for educational purposes to help developers get initiated in Agentic AI development.**
|
|
43
|
+
|
|
44
|
+
**🚨 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.**
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
- **🤖 Multi-Agent System**: Four specialized AI agents for different aspects of investment analysis
|
|
49
|
+
- **🧠 Anthropic Claude**: Powered by Claude models (Sonnet, Opus) by default
|
|
50
|
+
- **🦙 Ollama Support**: Run fully locally with Ollama models
|
|
51
|
+
- **📊 Real Reddit Integration**: Live Reddit sentiment analysis for trending stocks (top 5 per sector)
|
|
52
|
+
- **🏭 Sector Analysis**: Analyze 5 major sectors (Technology, Healthcare, Finance, Energy, Consumer)
|
|
53
|
+
- **⚡ Command-Line Interface**: Easy-to-use CLI with flexible configuration
|
|
54
|
+
- **🔒 Environment-Based Config**: Secure `.env`-based configuration with startup validation
|
|
55
|
+
- **📈 Structured Output**: Consistent, machine-readable JSON analysis results
|
|
56
|
+
- **🚀 CrewAI Framework**: Professional multi-agent orchestration via LiteLLM
|
|
57
|
+
|
|
58
|
+
## Architecture
|
|
59
|
+
|
|
60
|
+
The system consists of four specialized agents working in sequence:
|
|
61
|
+
|
|
62
|
+
### Agent Pipeline
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
MarketAnalystAgent → TechnicalAnalystAgent → FundamentalAnalystAgent → InvestorStrategicAgent
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Each agent receives the full output of all prior agents as context.
|
|
69
|
+
|
|
70
|
+
### Market Analyst Agent 📊
|
|
71
|
+
- **Purpose**: Entry point of the investment pipeline
|
|
72
|
+
- **Function**: Analyzes Reddit discussions to identify trending stocks at the current moment in time, incorporating macro/geopolitical context
|
|
73
|
+
- **Data Sources**: Reddit API (PRAW) with Serper web search as fallback
|
|
74
|
+
- **Output**: Top 5 candidate stocks with sentiment scores and relevance metrics
|
|
75
|
+
- **Sectors**: Technology, Healthcare, Finance, Energy, Consumer
|
|
76
|
+
|
|
77
|
+
### Technical Analyst Agent 📈
|
|
78
|
+
- **Purpose**: Quantitative technical analysis
|
|
79
|
+
- **Function**: Runs 13+ technical indicators per ticker using `yfinance` + `ta` library
|
|
80
|
+
- **Indicators**: RSI, MACD, Bollinger Bands, ATR, SMA, EMA, VWAP, ADX, and more
|
|
81
|
+
- **Output**: Per-stock signals, momentum scores (1–10), risk levels, entry zones, stop-loss levels
|
|
82
|
+
|
|
83
|
+
### Fundamental Analyst Agent 🏢
|
|
84
|
+
- **Purpose**: Financial statement and valuation analysis
|
|
85
|
+
- **Function**: Fetches real P/E, margins, debt ratios, FCF, and growth rates via `yfinance`
|
|
86
|
+
- **Output**: Valuation grades (CHEAP/FAIR/EXPENSIVE), financial health ratings, growth outlook
|
|
87
|
+
|
|
88
|
+
### Investor Strategic Agent 🎯
|
|
89
|
+
- **Purpose**: Final synthesis and portfolio construction
|
|
90
|
+
- **Function**: Applies the composite score formula and builds portfolio allocations
|
|
91
|
+
- **Composite Score**: 30 pts sentiment + 40 pts momentum + 30 pts fundamentals (max 100)
|
|
92
|
+
- **Recommendations**: `STRONG_BUY / BUY / HOLD / REDUCE / AVOID`
|
|
93
|
+
- **Output**: Machine-readable JSON with allocation percentages summing to 100%
|
|
94
|
+
|
|
95
|
+
## Project Structure
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
ProspectAI/
|
|
99
|
+
├── agents/ # AI agent implementations
|
|
100
|
+
│ ├── base_agent.py # Abstract base class; LLM instantiation via crewai.LLM
|
|
101
|
+
│ ├── market_analyst_agent.py
|
|
102
|
+
│ ├── technical_analyst_agent.py
|
|
103
|
+
│ ├── fundamental_analyst_agent.py
|
|
104
|
+
│ └── investor_strategic_agent.py
|
|
105
|
+
├── config/
|
|
106
|
+
│ ├── agents.yaml # Primary place to tune agent behavior
|
|
107
|
+
│ ├── agent_config_loader.py # Reads agents.yaml
|
|
108
|
+
│ └── config.py # Config class — reads env vars, no defaults
|
|
109
|
+
├── utils/
|
|
110
|
+
│ ├── reddit_sentiment_tool.py # PRAW-based Reddit sentiment tool
|
|
111
|
+
│ ├── technical_analysis_tool.py # yfinance + ta indicators
|
|
112
|
+
│ └── fundamental_data_tool.py # yfinance fundamentals
|
|
113
|
+
├── tests/ # Test suite
|
|
114
|
+
├── main.py # CLI entry point; .env validation
|
|
115
|
+
├── prospect_ai_crew.py # CrewAI orchestration
|
|
116
|
+
├── requirements.txt
|
|
117
|
+
├── env.example # Template — copy to .env
|
|
118
|
+
└── README.md
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Installation
|
|
122
|
+
|
|
123
|
+
### Prerequisites
|
|
124
|
+
- Python 3.9+
|
|
125
|
+
- An Anthropic API key **or** a local Ollama installation
|
|
126
|
+
|
|
127
|
+
### 1. Clone and Set Up
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
git clone <your-repo-url>
|
|
131
|
+
cd ProspectAI
|
|
132
|
+
python -m venv .venv
|
|
133
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
134
|
+
pip install -r requirements.txt
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### 2. Configure Environment
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
cp env.example .env
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Then open `.env` and fill in your values. The app will fail at startup with a clear error listing any missing required keys.
|
|
144
|
+
|
|
145
|
+
### 3. Anthropic API Setup (Default Provider)
|
|
146
|
+
|
|
147
|
+
1. Get your API key from [console.anthropic.com](https://console.anthropic.com)
|
|
148
|
+
2. Add to `.env`:
|
|
149
|
+
```bash
|
|
150
|
+
ANTHROPIC_API_KEY=your_key_here
|
|
151
|
+
ANTHROPIC_MODEL=claude-sonnet-4-6
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 4. Market Data Setup (at least one required)
|
|
155
|
+
|
|
156
|
+
**Option A — Reddit API (preferred):**
|
|
157
|
+
1. Visit [reddit.com/prefs/apps](https://www.reddit.com/prefs/apps) and create a "script" app
|
|
158
|
+
2. Add to `.env`:
|
|
159
|
+
```bash
|
|
160
|
+
REDDIT_CLIENT_ID=your_client_id
|
|
161
|
+
REDDIT_CLIENT_SECRET=your_client_secret
|
|
162
|
+
REDDIT_USER_AGENT=ProspectAI/1.0
|
|
163
|
+
```
|
|
164
|
+
See [REDDIT_API_SETUP.md](REDDIT_API_SETUP.md) for detailed instructions.
|
|
165
|
+
|
|
166
|
+
**Option B — Serper web search fallback:**
|
|
167
|
+
1. Get your key at [serper.dev](https://serper.dev)
|
|
168
|
+
2. Add to `.env`:
|
|
169
|
+
```bash
|
|
170
|
+
SERPER_API_KEY=your_key_here
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### 5. Ollama Setup (Optional — Local Models)
|
|
174
|
+
|
|
175
|
+
1. Install Ollama: [ollama.com/download](https://ollama.com/download)
|
|
176
|
+
2. Start the service:
|
|
177
|
+
```bash
|
|
178
|
+
ollama serve
|
|
179
|
+
```
|
|
180
|
+
3. Pull a model:
|
|
181
|
+
```bash
|
|
182
|
+
ollama pull qwen3.5:9b
|
|
183
|
+
# or: llama3.2:8b, mistral:7b, etc.
|
|
184
|
+
```
|
|
185
|
+
4. Add to `.env`:
|
|
186
|
+
```bash
|
|
187
|
+
OLLAMA_BASE_URL=http://localhost:11434
|
|
188
|
+
OLLAMA_MODEL=qwen3.5:9b
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Usage
|
|
192
|
+
|
|
193
|
+
### Basic Usage
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Analyze Technology sector with Anthropic Claude (default)
|
|
197
|
+
python main.py
|
|
198
|
+
|
|
199
|
+
# Analyze a specific sector
|
|
200
|
+
python main.py --sector Healthcare
|
|
201
|
+
python main.py --sector Finance
|
|
202
|
+
python main.py --sector Energy
|
|
203
|
+
python main.py --sector Consumer
|
|
204
|
+
|
|
205
|
+
# Override the Claude model for a single run
|
|
206
|
+
python main.py --model claude-opus-4-6 --sector Technology
|
|
207
|
+
|
|
208
|
+
# Use a local Ollama model
|
|
209
|
+
python main.py --ollama --sector Technology
|
|
210
|
+
|
|
211
|
+
# Use Ollama with a specific model or remote server
|
|
212
|
+
python main.py --ollama --model llama3.2:8b --sector Healthcare
|
|
213
|
+
python main.py --ollama --url http://192.168.1.100:11434 --sector Finance
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### CLI Reference
|
|
217
|
+
|
|
218
|
+
| Flag | Description |
|
|
219
|
+
|---|---|
|
|
220
|
+
| `--sector` | Sector to analyze: Technology, Healthcare, Finance, Energy, Consumer (default: Technology) |
|
|
221
|
+
| `--model` | Override model name from `.env` |
|
|
222
|
+
| `--ollama` | Use local Ollama instead of Anthropic |
|
|
223
|
+
| `--url` | Ollama server URL (overrides `OLLAMA_BASE_URL`) |
|
|
224
|
+
|
|
225
|
+
### Testing
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
python tests/test_skeleton.py
|
|
229
|
+
python tests/test_reddit_output.py [sector]
|
|
230
|
+
python tests/test_technical_analyst.py
|
|
231
|
+
python tests/test_market_analyst_llm.py
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Configuration
|
|
235
|
+
|
|
236
|
+
### Environment Variables
|
|
237
|
+
|
|
238
|
+
| Variable | Required | Description |
|
|
239
|
+
|---|---|---|
|
|
240
|
+
| `ANTHROPIC_API_KEY` | Yes | Anthropic API key |
|
|
241
|
+
| `ANTHROPIC_MODEL` | Yes | Claude model (e.g. `claude-sonnet-4-6`) |
|
|
242
|
+
| `REDDIT_CLIENT_ID` | One of A or B | Reddit API client ID |
|
|
243
|
+
| `REDDIT_CLIENT_SECRET` | One of A or B | Reddit API client secret |
|
|
244
|
+
| `REDDIT_USER_AGENT` | No | Defaults to `ProspectAI/1.0` |
|
|
245
|
+
| `SERPER_API_KEY` | One of A or B | Serper web search key (fallback) |
|
|
246
|
+
| `OLLAMA_BASE_URL` | If `--ollama` | Ollama server URL |
|
|
247
|
+
| `OLLAMA_MODEL` | If `--ollama` | Ollama model name |
|
|
248
|
+
|
|
249
|
+
### Anthropic Claude Models
|
|
250
|
+
|
|
251
|
+
| Model | Use Case |
|
|
252
|
+
|---|---|
|
|
253
|
+
| `claude-sonnet-4-6` | Best balance of quality and speed (default) |
|
|
254
|
+
| `claude-opus-4-6` | Highest quality, deeper reasoning |
|
|
255
|
+
| `claude-haiku-4-5-20251001` | Fastest, lowest cost |
|
|
256
|
+
|
|
257
|
+
### Ollama Models
|
|
258
|
+
|
|
259
|
+
| Model | Notes |
|
|
260
|
+
|---|---|
|
|
261
|
+
| `qwen3.5:9b` | Good reasoning, recommended for analysis |
|
|
262
|
+
| `llama3.2:8b` | General purpose |
|
|
263
|
+
| `llama3.2:3b` | Lightweight, fast |
|
|
264
|
+
| `mistral:7b` | Good for analytical tasks |
|
|
265
|
+
|
|
266
|
+
### Per-Agent Model Override
|
|
267
|
+
|
|
268
|
+
Each agent can use a different model by editing `config/agents.yaml`:
|
|
269
|
+
|
|
270
|
+
```yaml
|
|
271
|
+
market_analyst:
|
|
272
|
+
llm:
|
|
273
|
+
provider: "anthropic"
|
|
274
|
+
model: "claude-opus-4-6" # Use Opus for the most context-heavy agent
|
|
275
|
+
|
|
276
|
+
technical_analyst:
|
|
277
|
+
llm:
|
|
278
|
+
provider: "anthropic"
|
|
279
|
+
model: "claude-sonnet-4-6" # Sonnet for the rest
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
See [AGENT_LLM_CONFIGURATION.md](AGENT_LLM_CONFIGURATION.md) for full details.
|
|
283
|
+
|
|
284
|
+
## Roadmap
|
|
285
|
+
|
|
286
|
+
### v1.1 - Enhanced Market Analysis
|
|
287
|
+
- Integration with financial news APIs (Bloomberg, Reuters)
|
|
288
|
+
- Real-time market sentiment from multiple sources
|
|
289
|
+
- Enhanced sector rotation analysis
|
|
290
|
+
|
|
291
|
+
### v1.2 - Agent Improvements
|
|
292
|
+
- Enhanced financial modeling capabilities
|
|
293
|
+
- More sophisticated valuation algorithms
|
|
294
|
+
- Advanced portfolio optimization
|
|
295
|
+
|
|
296
|
+
### v1.3 - Advanced Risk Management
|
|
297
|
+
- Monte Carlo simulations for portfolio scenarios
|
|
298
|
+
- Advanced risk metrics (VaR, CVaR, Sharpe ratios)
|
|
299
|
+
- Dynamic risk adjustment based on market conditions
|
|
300
|
+
|
|
301
|
+
## Troubleshooting
|
|
302
|
+
|
|
303
|
+
| Issue | Fix |
|
|
304
|
+
|---|---|
|
|
305
|
+
| `.env file not found` | Run `cp env.example .env` and fill in your keys |
|
|
306
|
+
| Missing keys error at startup | Check the listed keys against your `.env` |
|
|
307
|
+
| `ANTHROPIC_API_KEY` invalid | Verify key at [console.anthropic.com](https://console.anthropic.com) |
|
|
308
|
+
| Ollama connection refused | Run `ollama serve` and verify `OLLAMA_BASE_URL` |
|
|
309
|
+
| Ollama model not found | Run `ollama pull <model-name>` |
|
|
310
|
+
| Reddit 401 error | Verify `REDDIT_CLIENT_ID` and `REDDIT_CLIENT_SECRET` |
|
|
311
|
+
| No stocks found | Check Reddit credentials or add `SERPER_API_KEY` as fallback |
|
|
312
|
+
|
|
313
|
+
## Contributing
|
|
314
|
+
|
|
315
|
+
1. Fork the repository
|
|
316
|
+
2. Create a feature branch
|
|
317
|
+
3. Make your changes with tests where applicable
|
|
318
|
+
4. Submit a pull request
|
|
319
|
+
|
|
320
|
+
## License
|
|
321
|
+
|
|
322
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
323
|
+
|
|
324
|
+
## Acknowledgments
|
|
325
|
+
|
|
326
|
+
- Built on the [CrewAI](https://github.com/joaomdmoura/crewAI) framework
|
|
327
|
+
- LLM routing via [LiteLLM](https://github.com/BerriAI/litellm)
|
|
328
|
+
- Inspired by modern multi-agent AI systems
|
|
329
|
+
- [Author webpage](https://moisesprat.github.io)
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# ProspectAI - Multi-Agent Investment Analysis System
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
ProspectAI is a multi-agent investment analysis system built on the CrewAI framework. It leverages four specialized AI agents to provide comprehensive investment recommendations through a systematic analysis workflow. The system supports Anthropic Claude models (default) and local Ollama models.
|
|
6
|
+
|
|
7
|
+
**🎉 First Official Release - v1.0.0**
|
|
8
|
+
|
|
9
|
+
### ⚠️ Important Disclaimer
|
|
10
|
+
|
|
11
|
+
**ProspectAI is built for educational purposes to help developers get initiated in Agentic AI development.**
|
|
12
|
+
|
|
13
|
+
**🚨 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.**
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **🤖 Multi-Agent System**: Four specialized AI agents for different aspects of investment analysis
|
|
18
|
+
- **🧠 Anthropic Claude**: Powered by Claude models (Sonnet, Opus) by default
|
|
19
|
+
- **🦙 Ollama Support**: Run fully locally with Ollama models
|
|
20
|
+
- **📊 Real Reddit Integration**: Live Reddit sentiment analysis for trending stocks (top 5 per sector)
|
|
21
|
+
- **🏭 Sector Analysis**: Analyze 5 major sectors (Technology, Healthcare, Finance, Energy, Consumer)
|
|
22
|
+
- **⚡ Command-Line Interface**: Easy-to-use CLI with flexible configuration
|
|
23
|
+
- **🔒 Environment-Based Config**: Secure `.env`-based configuration with startup validation
|
|
24
|
+
- **📈 Structured Output**: Consistent, machine-readable JSON analysis results
|
|
25
|
+
- **🚀 CrewAI Framework**: Professional multi-agent orchestration via LiteLLM
|
|
26
|
+
|
|
27
|
+
## Architecture
|
|
28
|
+
|
|
29
|
+
The system consists of four specialized agents working in sequence:
|
|
30
|
+
|
|
31
|
+
### Agent Pipeline
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
MarketAnalystAgent → TechnicalAnalystAgent → FundamentalAnalystAgent → InvestorStrategicAgent
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Each agent receives the full output of all prior agents as context.
|
|
38
|
+
|
|
39
|
+
### Market Analyst Agent 📊
|
|
40
|
+
- **Purpose**: Entry point of the investment pipeline
|
|
41
|
+
- **Function**: Analyzes Reddit discussions to identify trending stocks at the current moment in time, incorporating macro/geopolitical context
|
|
42
|
+
- **Data Sources**: Reddit API (PRAW) with Serper web search as fallback
|
|
43
|
+
- **Output**: Top 5 candidate stocks with sentiment scores and relevance metrics
|
|
44
|
+
- **Sectors**: Technology, Healthcare, Finance, Energy, Consumer
|
|
45
|
+
|
|
46
|
+
### Technical Analyst Agent 📈
|
|
47
|
+
- **Purpose**: Quantitative technical analysis
|
|
48
|
+
- **Function**: Runs 13+ technical indicators per ticker using `yfinance` + `ta` library
|
|
49
|
+
- **Indicators**: RSI, MACD, Bollinger Bands, ATR, SMA, EMA, VWAP, ADX, and more
|
|
50
|
+
- **Output**: Per-stock signals, momentum scores (1–10), risk levels, entry zones, stop-loss levels
|
|
51
|
+
|
|
52
|
+
### Fundamental Analyst Agent 🏢
|
|
53
|
+
- **Purpose**: Financial statement and valuation analysis
|
|
54
|
+
- **Function**: Fetches real P/E, margins, debt ratios, FCF, and growth rates via `yfinance`
|
|
55
|
+
- **Output**: Valuation grades (CHEAP/FAIR/EXPENSIVE), financial health ratings, growth outlook
|
|
56
|
+
|
|
57
|
+
### Investor Strategic Agent 🎯
|
|
58
|
+
- **Purpose**: Final synthesis and portfolio construction
|
|
59
|
+
- **Function**: Applies the composite score formula and builds portfolio allocations
|
|
60
|
+
- **Composite Score**: 30 pts sentiment + 40 pts momentum + 30 pts fundamentals (max 100)
|
|
61
|
+
- **Recommendations**: `STRONG_BUY / BUY / HOLD / REDUCE / AVOID`
|
|
62
|
+
- **Output**: Machine-readable JSON with allocation percentages summing to 100%
|
|
63
|
+
|
|
64
|
+
## Project Structure
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
ProspectAI/
|
|
68
|
+
├── agents/ # AI agent implementations
|
|
69
|
+
│ ├── base_agent.py # Abstract base class; LLM instantiation via crewai.LLM
|
|
70
|
+
│ ├── market_analyst_agent.py
|
|
71
|
+
│ ├── technical_analyst_agent.py
|
|
72
|
+
│ ├── fundamental_analyst_agent.py
|
|
73
|
+
│ └── investor_strategic_agent.py
|
|
74
|
+
├── config/
|
|
75
|
+
│ ├── agents.yaml # Primary place to tune agent behavior
|
|
76
|
+
│ ├── agent_config_loader.py # Reads agents.yaml
|
|
77
|
+
│ └── config.py # Config class — reads env vars, no defaults
|
|
78
|
+
├── utils/
|
|
79
|
+
│ ├── reddit_sentiment_tool.py # PRAW-based Reddit sentiment tool
|
|
80
|
+
│ ├── technical_analysis_tool.py # yfinance + ta indicators
|
|
81
|
+
│ └── fundamental_data_tool.py # yfinance fundamentals
|
|
82
|
+
├── tests/ # Test suite
|
|
83
|
+
├── main.py # CLI entry point; .env validation
|
|
84
|
+
├── prospect_ai_crew.py # CrewAI orchestration
|
|
85
|
+
├── requirements.txt
|
|
86
|
+
├── env.example # Template — copy to .env
|
|
87
|
+
└── README.md
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Installation
|
|
91
|
+
|
|
92
|
+
### Prerequisites
|
|
93
|
+
- Python 3.9+
|
|
94
|
+
- An Anthropic API key **or** a local Ollama installation
|
|
95
|
+
|
|
96
|
+
### 1. Clone and Set Up
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
git clone <your-repo-url>
|
|
100
|
+
cd ProspectAI
|
|
101
|
+
python -m venv .venv
|
|
102
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
103
|
+
pip install -r requirements.txt
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 2. Configure Environment
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
cp env.example .env
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Then open `.env` and fill in your values. The app will fail at startup with a clear error listing any missing required keys.
|
|
113
|
+
|
|
114
|
+
### 3. Anthropic API Setup (Default Provider)
|
|
115
|
+
|
|
116
|
+
1. Get your API key from [console.anthropic.com](https://console.anthropic.com)
|
|
117
|
+
2. Add to `.env`:
|
|
118
|
+
```bash
|
|
119
|
+
ANTHROPIC_API_KEY=your_key_here
|
|
120
|
+
ANTHROPIC_MODEL=claude-sonnet-4-6
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 4. Market Data Setup (at least one required)
|
|
124
|
+
|
|
125
|
+
**Option A — Reddit API (preferred):**
|
|
126
|
+
1. Visit [reddit.com/prefs/apps](https://www.reddit.com/prefs/apps) and create a "script" app
|
|
127
|
+
2. Add to `.env`:
|
|
128
|
+
```bash
|
|
129
|
+
REDDIT_CLIENT_ID=your_client_id
|
|
130
|
+
REDDIT_CLIENT_SECRET=your_client_secret
|
|
131
|
+
REDDIT_USER_AGENT=ProspectAI/1.0
|
|
132
|
+
```
|
|
133
|
+
See [REDDIT_API_SETUP.md](REDDIT_API_SETUP.md) for detailed instructions.
|
|
134
|
+
|
|
135
|
+
**Option B — Serper web search fallback:**
|
|
136
|
+
1. Get your key at [serper.dev](https://serper.dev)
|
|
137
|
+
2. Add to `.env`:
|
|
138
|
+
```bash
|
|
139
|
+
SERPER_API_KEY=your_key_here
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### 5. Ollama Setup (Optional — Local Models)
|
|
143
|
+
|
|
144
|
+
1. Install Ollama: [ollama.com/download](https://ollama.com/download)
|
|
145
|
+
2. Start the service:
|
|
146
|
+
```bash
|
|
147
|
+
ollama serve
|
|
148
|
+
```
|
|
149
|
+
3. Pull a model:
|
|
150
|
+
```bash
|
|
151
|
+
ollama pull qwen3.5:9b
|
|
152
|
+
# or: llama3.2:8b, mistral:7b, etc.
|
|
153
|
+
```
|
|
154
|
+
4. Add to `.env`:
|
|
155
|
+
```bash
|
|
156
|
+
OLLAMA_BASE_URL=http://localhost:11434
|
|
157
|
+
OLLAMA_MODEL=qwen3.5:9b
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Usage
|
|
161
|
+
|
|
162
|
+
### Basic Usage
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
# Analyze Technology sector with Anthropic Claude (default)
|
|
166
|
+
python main.py
|
|
167
|
+
|
|
168
|
+
# Analyze a specific sector
|
|
169
|
+
python main.py --sector Healthcare
|
|
170
|
+
python main.py --sector Finance
|
|
171
|
+
python main.py --sector Energy
|
|
172
|
+
python main.py --sector Consumer
|
|
173
|
+
|
|
174
|
+
# Override the Claude model for a single run
|
|
175
|
+
python main.py --model claude-opus-4-6 --sector Technology
|
|
176
|
+
|
|
177
|
+
# Use a local Ollama model
|
|
178
|
+
python main.py --ollama --sector Technology
|
|
179
|
+
|
|
180
|
+
# Use Ollama with a specific model or remote server
|
|
181
|
+
python main.py --ollama --model llama3.2:8b --sector Healthcare
|
|
182
|
+
python main.py --ollama --url http://192.168.1.100:11434 --sector Finance
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### CLI Reference
|
|
186
|
+
|
|
187
|
+
| Flag | Description |
|
|
188
|
+
|---|---|
|
|
189
|
+
| `--sector` | Sector to analyze: Technology, Healthcare, Finance, Energy, Consumer (default: Technology) |
|
|
190
|
+
| `--model` | Override model name from `.env` |
|
|
191
|
+
| `--ollama` | Use local Ollama instead of Anthropic |
|
|
192
|
+
| `--url` | Ollama server URL (overrides `OLLAMA_BASE_URL`) |
|
|
193
|
+
|
|
194
|
+
### Testing
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
python tests/test_skeleton.py
|
|
198
|
+
python tests/test_reddit_output.py [sector]
|
|
199
|
+
python tests/test_technical_analyst.py
|
|
200
|
+
python tests/test_market_analyst_llm.py
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Configuration
|
|
204
|
+
|
|
205
|
+
### Environment Variables
|
|
206
|
+
|
|
207
|
+
| Variable | Required | Description |
|
|
208
|
+
|---|---|---|
|
|
209
|
+
| `ANTHROPIC_API_KEY` | Yes | Anthropic API key |
|
|
210
|
+
| `ANTHROPIC_MODEL` | Yes | Claude model (e.g. `claude-sonnet-4-6`) |
|
|
211
|
+
| `REDDIT_CLIENT_ID` | One of A or B | Reddit API client ID |
|
|
212
|
+
| `REDDIT_CLIENT_SECRET` | One of A or B | Reddit API client secret |
|
|
213
|
+
| `REDDIT_USER_AGENT` | No | Defaults to `ProspectAI/1.0` |
|
|
214
|
+
| `SERPER_API_KEY` | One of A or B | Serper web search key (fallback) |
|
|
215
|
+
| `OLLAMA_BASE_URL` | If `--ollama` | Ollama server URL |
|
|
216
|
+
| `OLLAMA_MODEL` | If `--ollama` | Ollama model name |
|
|
217
|
+
|
|
218
|
+
### Anthropic Claude Models
|
|
219
|
+
|
|
220
|
+
| Model | Use Case |
|
|
221
|
+
|---|---|
|
|
222
|
+
| `claude-sonnet-4-6` | Best balance of quality and speed (default) |
|
|
223
|
+
| `claude-opus-4-6` | Highest quality, deeper reasoning |
|
|
224
|
+
| `claude-haiku-4-5-20251001` | Fastest, lowest cost |
|
|
225
|
+
|
|
226
|
+
### Ollama Models
|
|
227
|
+
|
|
228
|
+
| Model | Notes |
|
|
229
|
+
|---|---|
|
|
230
|
+
| `qwen3.5:9b` | Good reasoning, recommended for analysis |
|
|
231
|
+
| `llama3.2:8b` | General purpose |
|
|
232
|
+
| `llama3.2:3b` | Lightweight, fast |
|
|
233
|
+
| `mistral:7b` | Good for analytical tasks |
|
|
234
|
+
|
|
235
|
+
### Per-Agent Model Override
|
|
236
|
+
|
|
237
|
+
Each agent can use a different model by editing `config/agents.yaml`:
|
|
238
|
+
|
|
239
|
+
```yaml
|
|
240
|
+
market_analyst:
|
|
241
|
+
llm:
|
|
242
|
+
provider: "anthropic"
|
|
243
|
+
model: "claude-opus-4-6" # Use Opus for the most context-heavy agent
|
|
244
|
+
|
|
245
|
+
technical_analyst:
|
|
246
|
+
llm:
|
|
247
|
+
provider: "anthropic"
|
|
248
|
+
model: "claude-sonnet-4-6" # Sonnet for the rest
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
See [AGENT_LLM_CONFIGURATION.md](AGENT_LLM_CONFIGURATION.md) for full details.
|
|
252
|
+
|
|
253
|
+
## Roadmap
|
|
254
|
+
|
|
255
|
+
### v1.1 - Enhanced Market Analysis
|
|
256
|
+
- Integration with financial news APIs (Bloomberg, Reuters)
|
|
257
|
+
- Real-time market sentiment from multiple sources
|
|
258
|
+
- Enhanced sector rotation analysis
|
|
259
|
+
|
|
260
|
+
### v1.2 - Agent Improvements
|
|
261
|
+
- Enhanced financial modeling capabilities
|
|
262
|
+
- More sophisticated valuation algorithms
|
|
263
|
+
- Advanced portfolio optimization
|
|
264
|
+
|
|
265
|
+
### v1.3 - Advanced Risk Management
|
|
266
|
+
- Monte Carlo simulations for portfolio scenarios
|
|
267
|
+
- Advanced risk metrics (VaR, CVaR, Sharpe ratios)
|
|
268
|
+
- Dynamic risk adjustment based on market conditions
|
|
269
|
+
|
|
270
|
+
## Troubleshooting
|
|
271
|
+
|
|
272
|
+
| Issue | Fix |
|
|
273
|
+
|---|---|
|
|
274
|
+
| `.env file not found` | Run `cp env.example .env` and fill in your keys |
|
|
275
|
+
| Missing keys error at startup | Check the listed keys against your `.env` |
|
|
276
|
+
| `ANTHROPIC_API_KEY` invalid | Verify key at [console.anthropic.com](https://console.anthropic.com) |
|
|
277
|
+
| Ollama connection refused | Run `ollama serve` and verify `OLLAMA_BASE_URL` |
|
|
278
|
+
| Ollama model not found | Run `ollama pull <model-name>` |
|
|
279
|
+
| Reddit 401 error | Verify `REDDIT_CLIENT_ID` and `REDDIT_CLIENT_SECRET` |
|
|
280
|
+
| No stocks found | Check Reddit credentials or add `SERPER_API_KEY` as fallback |
|
|
281
|
+
|
|
282
|
+
## Contributing
|
|
283
|
+
|
|
284
|
+
1. Fork the repository
|
|
285
|
+
2. Create a feature branch
|
|
286
|
+
3. Make your changes with tests where applicable
|
|
287
|
+
4. Submit a pull request
|
|
288
|
+
|
|
289
|
+
## License
|
|
290
|
+
|
|
291
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
292
|
+
|
|
293
|
+
## Acknowledgments
|
|
294
|
+
|
|
295
|
+
- Built on the [CrewAI](https://github.com/joaomdmoura/crewAI) framework
|
|
296
|
+
- LLM routing via [LiteLLM](https://github.com/BerriAI/litellm)
|
|
297
|
+
- Inspired by modern multi-agent AI systems
|
|
298
|
+
- [Author webpage](https://moisesprat.github.io)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .base_agent import BaseAgent
|
|
2
|
+
from .market_analyst_agent import MarketAnalystAgent
|
|
3
|
+
from .technical_analyst_agent import TechnicalAnalystAgent
|
|
4
|
+
from .fundamental_analyst_agent import FundamentalAnalystAgent
|
|
5
|
+
from .investor_strategic_agent import InvestorStrategicAgent
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
'BaseAgent',
|
|
9
|
+
'MarketAnalystAgent',
|
|
10
|
+
'TechnicalAnalystAgent',
|
|
11
|
+
'FundamentalAnalystAgent',
|
|
12
|
+
'InvestorStrategicAgent'
|
|
13
|
+
]
|