An intelligent multi-agent system powered by CrewAI and Google Gemini that analyzes stock market data and provides actionable trading recommendations.
-
Multi-Agent Architecture: Specialized AI agents working together
- π Analyst Agent: Performs in-depth stock analysis using real-time market data
- πΌ Trader Agent: Makes strategic Buy/Sell/Hold decisions based on analysis
-
Real-Time Market Data: Fetches live stock prices and metrics using Yahoo Finance
-
AI-Powered Insights: Leverages Google Gemini 2.0 Flash for intelligent decision-making
-
Automated Workflow: Seamless task orchestration between agents
βββββββββββββββββββββββ
β User Input β
β (Stock Symbol) β
ββββββββββββ¬βββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββ
β Stock Crew β
β ββββββββββββββββββββββββββββββ β
β β Analyst Agent β β
β β - Fetches stock data β β
β β - Analyzes trends β β
β β - Provides insights β β
β ββββββββββββ¬ββββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββββββββββββ β
β β Trader Agent β β
β β - Reviews analysis β β
β β - Makes trade decision β β
β β - Recommends action β β
β ββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββ
β Trading Report β
β (Buy/Sell/Hold) β
βββββββββββββββββββββββ
- Python 3.8+
- Google Gemini API Key
- Internet connection for real-time data
-
Clone the repository
git clone https://github.com/yourusername/stockcrew-ai.git cd stockcrew-ai -
Create a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
Create a
.envfile in the project root:GEMINI_API_KEY=your_gemini_api_key_here
To get a Gemini API key:
- Visit Google AI Studio
- Sign in with your Google account
- Generate a new API key
Run the main script with a stock symbol:
# Edit main.py to change the stock symbol
python main.pyExample Output:
Stock: TSLA
Price: 245.32 USD
Change: +5.67 (+2.37%)
Analysis Summary:
- Current Price: Strong upward momentum
- Volume: Above average trading activity
- Recommendation: BUY - Positive trend indicators
Trading Decision: BUY
stockcrew-ai/
βββ agents/
β βββ analyst_agent.py # Financial analysis agent
β βββ trader_agent.py # Trading decision agent
βββ tasks/
β βββ analyse_task.py # Stock analysis task definition
β βββ trade_task.py # Trading decision task definition
βββ tools/
β βββ stock_research_tool.py # Yahoo Finance integration
βββ crew.py # Crew orchestration
βββ main.py # Entry point
βββ requirements.txt # Python dependencies
βββ .env # API keys (not in repo)
βββ .gitignore # Git ignore rules
βββ README.md # This file
- Role: Financial Market Analyst
- Tools: Live Stock Information Tool (Yahoo Finance)
- Temperature: 0.3 (balanced creativity/consistency)
- Function: Analyzes stock performance, trends, and key metrics
- Role: Strategic Stock Trader
- Tools: None (uses analysis from Analyst Agent)
- Temperature: 0.2 (more deterministic)
- Function: Makes Buy/Sell/Hold recommendations
- Fetches real-time stock data from Yahoo Finance
- Returns: Current price, daily change, percentage change
- Parameters: Stock ticker symbol (e.g., AAPL, TSLA, MSFT)
The project includes pydantic_agentic_ai.ipynb demonstrating:
- Pydantic AI agent creation
- Weather forecast tool integration (example)
- Async execution patterns
Edit main.py:
if __name__ == "__main__":
run("AAPL") # Change to any valid tickerModify temperature settings in agent files:
model_client = LLM(
model="gemini/gemini-2.0-flash",
api_key=GEMINI_API_KEY,
temperature=0.3, # Lower = more deterministic
max_tokens=2048
)Create a new tool in tools/:
from crewai.tools import tool
@tool("Your Tool Name")
def your_tool(param: str) -> str:
"""Tool description"""
# Implementation
return resultAny stock symbol available on Yahoo Finance, including:
- US Stocks: AAPL, GOOGL, MSFT, TSLA, AMZN
- Indian Stocks: RELIANCE.NS, TCS.NS, INFY.NS
- Crypto: BTC-USD, ETH-USD
This tool is for educational and research purposes only.
- Not financial advice
- Always do your own research
- Consult a licensed financial advisor before making investment decisions
- Past performance doesn't guarantee future results
- The developers are not responsible for any financial losses
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- CrewAI - Multi-agent framework
- Google Gemini - AI model
- yfinance - Yahoo Finance data
- LiteLLM - LLM integration
Suraj Kumar - @yourhandle
Project Link: https://github.com/yourusername/stockcrew-ai
β If you found this project helpful, please give it a star!