WAY- 1
virtualenv venv
way - 2
python -m venv
way - 3
conda create -n <env_name> python=3.11 -y
Next install the library
pip install -r requirements.txt
Run the streamlit app
streamlit run
The stock analysis agent is an AI-powered investment recommendation system built with LangGraph and Streamlit. It analyzes stock data and news to provide investment recommendations.
- 📊 Real-time stock data from Yahoo Finance
- 📰 Latest news articles via Serper API
- 🤖 AI-powered investment recommendations (BUY/HOLD/SELL)
- 🚀 Parallel processing for faster analysis
- 💡 Clean, lightweight Streamlit UI
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables: Create a
.envfile in the project root with:OPENAI_API_KEY=your_openai_api_key_here SERPER_API_KEY=your_serper_api_key_here- Get OpenAI API key from: https://platform.openai.com/api-keys
- Get Serper API key from: https://serper.dev
Option 1: Streamlit App (Recommended)
cd stock_analysis
streamlit run streamlit_app.pyOption 2: Jupyter Notebook
cd stock_analysis
jupyter notebook stock_analysis.ipynbThe agent uses LangGraph with three nodes that run in parallel:
-
Yahoo Finance Node (
get_stock_data):- Fetches historical stock data (1 year)
- Calculates key metrics (price, moving averages, volume, P/E ratio, etc.)
- Provides technical indicators
-
Serper News Node (
get_stock_news):- Fetches top 10 recent news articles about the stock
- Extracts titles, summaries, sources, and links
- Captures market sentiment
-
Analysis Node (
analyze_investment_decision):- Combines stock data and news
- Uses GPT-4o-mini to analyze and provide:
- Summary of key findings
- Risk assessment
- Investment recommendation (BUY/HOLD/SELL)
- Reasoning and key factors to monitor
- Open the Streamlit app in your browser
- Enter a stock ticker symbol (e.g., AAPL, MSFT, GOOGL)
- Click "Analyze Stock"
- View the results:
- Stock data with key metrics
- Recent news articles
- AI-generated investment recommendation
AAPL- Apple Inc.MSFT- Microsoft CorporationGOOGL- Alphabet Inc.TSLA- Tesla Inc.AMZN- Amazon.com Inc.
- The analysis is for informational purposes only
- Always do your own research before making investment decisions
- API rate limits may apply based on your subscription plans