Skip to content

Repository files navigation

📈 LLM-Powered Stock Analyzer

Predicting stock prices based on the current market trend analysis


🛠️ Tech Stack

Component Technology
Language Python 3.9+
Web Framework Streamlit
Stock Data yfinance
LLM API OpenAI GPT
Environment python-dotenv

🚀 Quick Start (5 Minutes)

Step 1: Extract & Enter Directory

unzip llm-stock-analyzer.zip -d llm-stock-analyzer
cd llm-stock-analyzer

Step 2: Run Initialization

bash init.sh

This will:

  • Make all scripts executable
  • Create virtual environment
  • Install dependencies
  • Prompt for your OpenAI API key

Step 3: Run the Application

./run.sh

Open browser at: http://localhost:8501


📁 Project Structure

llm-stock-analyzer/
│
├── 🐍 Python Modules
│   ├── app.py           # Main Streamlit application
│   ├── stock_data.py    # Yahoo Finance data fetching
│   ├── llm_service.py   # OpenAI API integration
│   ├── prompts.py       # Prompt templates
│   └── config.py        # Configuration management
│
├── 🔧 Shell Scripts
│   ├── init.sh          # First-time initialization
│   ├── setup.sh         # Full environment setup
│   ├── dev.sh           # Developer quick restart
│   ├── test.sh          # Test suite runner
│   └── run.sh           # Production runner
│
├── ⚙️ Configuration
│   ├── requirements.txt # Python dependencies
│   ├── .env.example     # Environment template
│   └── .gitignore       # Git ignore rules
│
└── 📖 Documentation
    └── README.md        # This file

🔧 Shell Scripts Reference

Script Command Purpose
init.sh bash init.sh First-time setup (run once)
setup.sh ./setup.sh Reinstall environment
dev.sh ./dev.sh Quick restart during development
dev.sh ./dev.sh --demo Use demo data (no API calls)
test.sh ./test.sh Run all tests
test.sh ./test.sh --quick Skip API tests
run.sh ./run.sh Run the application

🧪 Testing

Run All Tests

./test.sh

Quick Test (Skip API Tests)

./test.sh --quick

Test API Connection Only

source venv/bin/activate
python -c "
from llm_service import validate_api_connection
success, message = validate_api_connection()
print(f'Status: {message}')
"

🐛 Common Issues & Fixes

Issue: 429 Too Many Requests (Yahoo Finance)

429 Client Error: Too Many Requests

Fix: Use demo mode or wait 10-15 minutes

./dev.sh --demo

Issue: 401 Invalid API Key (OpenAI)

Incorrect API key provided

Fix: Update your .env file with a valid key from https://platform.openai.com/api-keys

Issue: Permission Denied

zsh: permission denied: ./setup.sh

Fix: Make scripts executable

chmod +x *.sh

Issue: yfinance TypeError (Python 3.9)

TypeError: unsupported operand type(s) for |

Fix: Install compatible version

pip install yfinance==0.2.40

📊 Demo Mode

When Yahoo Finance is rate-limiting, use demo mode with sample data:

./dev.sh --demo

Available demo tickers:

  • AAPL - Apple Inc.
  • GOOGL - Alphabet Inc.
  • MSFT - Microsoft Corporation
  • RELIANCE.NS - Reliance Industries (India)

🔑 API Key Setup

  1. Go to https://platform.openai.com/api-keys
  2. Create a new API key
  3. Add to .env file:
OPENAI_API_KEY=sk-your-api-key-here

📝 Sample Tickers to Try

Market Tickers
US AAPL, GOOGL, MSFT, AMZN, TSLA, NVDA, META
India (NSE) RELIANCE.NS, TCS.NS, INFY.NS, HDFCBANK.NS
UK (LSE) HSBA.L, BP.L, VOD.L

About

Predicting stock prices based on the current market trend analysis

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages