A comprehensive stock analysis platform powered by real-time data, AI-driven sentiment analysis, and intelligent trading strategies. Built with a modern frontend and scalable Flask backend.
- Overview
- Features
- Tech Stack
- Project Structure
- Setup & Installation
- API Endpoints
- Environment Variables
- Usage Guide
- Docker Deployment
- Troubleshooting
Stockit is an intelligent stock analysis platform that combines:
- Real-time Stock Data: Integration with NSE India (National Stock Exchange) and Yahoo Finance
- AI Sentiment Analysis: FinBERT-powered analysis of financial news for sentiment detection
- Smart Trading Strategies: Automated generation of short-term, swing, and long-term trading suggestions
- Interactive Dashboard: Modern, responsive UI for comprehensive stock analysis
- Technical Analysis: Price charts, volume analysis, and historical data visualization
Perfect for investors, traders, and financial analysts who want data-driven insights at their fingertips.
- ๐ Real-time Stock Search: Instant search across Nifty 50 companies
- ๐ Interactive Price Charts: Line and candlestick charts with multiple timeframes (1M, 3M, 6M, 1Y)
- ๐ฐ News & Sentiment Analysis: Real-time news feed with AI-powered sentiment scoring
- ๐น Financial Metrics: Comprehensive display of Revenue, Net Profit, EBITDA, and more
- ๐ Trading Strategies: AI-generated trading recommendations based on technical and sentiment analysis
- ๐ Volume Analysis: Identify volume spikes and trading patterns
- ๐จ Modern UI: Clean, professional design inspired by Screener.in
- ๐ฆ Multi-Source Data Integration: NSE, Yahoo Finance, and custom Google Sheets data
- ๐ค FinBERT Sentiment Analysis: State-of-the-art NLP for financial news classification
- ๐ Historical Data: Complete OCHLV (Open, Close, High, Low, Volume) data
- ๐ CORS Support: Secure cross-origin requests
- ๐ก RESTful API: Well-documented endpoints for all data needs
- โก Caching & Optimization: Efficient data fetching and processing
- HTML5 - Semantic markup
- CSS3 - Responsive design with modern features
- JavaScript (ES6+) - Modular, component-based architecture
- Chart.js - Interactive data visualization
- Fetch API - Modern HTTP client
- Python 3.10 - Core programming language
- Flask - Lightweight web framework
- Flask-CORS - Cross-origin request handling
- yfinance - Yahoo Finance data integration
- nsepython - NSE India API client
- pandas - Data manipulation and analysis
- requests - HTTP client for API calls
- gradio_client - FinBERT sentiment analysis client
- python-dotenv - Environment variable management
- FinBERT - Hugging Face's financial BERT model for sentiment analysis
- Gradio - Model serving and API wrapper
- Docker - Containerization
- Docker Compose - Multi-container orchestration
Stockit/
โโโ README.md # This file
โโโ docker-compose.yml # Docker compose configuration
โโโ Dockerfile # Root Dockerfile for unified build
โ
โโโ client/ # Frontend application
โ โโโ index.html # Main dashboard UI
โ โโโ README.md # Frontend documentation
โ โโโ Dockerfile # Frontend container setup
โ โโโ css/
โ โ โโโ style.css # Styling and responsive design
โ โโโ js/
โ โ โโโ app.js # Application logic (479 lines)
โ โ โโโ api.js # API client (71 lines)
โ โโโ assets/ # Static images/icons
โ
โโโ backend/ # Flask API server
โ โโโ app.py # Main Flask application (318 lines)
โ โโโ functions.py # Core analysis functions (230 lines)
โ โโโ requirements.txt # Python dependencies
โ โโโ Dockerfile # Backend container setup
โ โโโ .env # Environment variables (git-ignored)
โ โโโ __pycache__/ # Python cache
โ
โโโ FinBERT_FinancialSentimentAnalysis/ # Sentiment analysis module
โ โโโ app.py # Gradio app for FinBERT
โ โโโ README.md # FinBERT documentation
โ โโโ requirements.txt # FinBERT dependencies
โ
โโโ MVP/ # Prototype versions
โ โโโ Stockit_MVP.html # Original MVP interface
โ
โโโ frontend/ # Alternative frontend folder (deprecated)
โโโ [legacy files]
| File | Purpose |
|---|---|
backend/app.py |
Flask server with 10+ API endpoints |
backend/functions.py |
Core functions for data fetching & analysis |
client/js/app.js |
Main application logic & UI rendering |
client/js/api.js |
API wrapper with error handling |
client/index.html |
Responsive HTML dashboard |
docker-compose.yml |
Orchestrates backend & frontend services |
- Python 3.10+
- Node.js (optional, for frontend serving)
- Docker & Docker Compose (for containerized deployment)
- Modern web browser (Chrome, Firefox, Safari, Edge)
cd "My BACKUP/Consultancy Project/Stockit"cd backend
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txtCreate .env file in backend/ directory:
NEWS_API_KEY=your_newsapi_key_here
GOOGLE_SHEETS_URL=your_google_sheets_api_urlcd backend
python app.pyBackend will run on: http://localhost:5000
# In a new terminal
cd client
# Using Python 3:
python -m http.server 8000Frontend will be available at: http://localhost:8000
# Build and start all services
docker-compose up --build
# Frontend: http://localhost:10000
# Backend: http://localhost:5000# Build the image
docker build -t stockit:latest .
# Run the container
docker run -p 10000:10000 -e FLASK_ENV=production stockit:latestCreate .env file in project root:
FLASK_ENV=production
GOOGLE_SHEETS_URL=your_google_sheets_api_url
NEWS_API_KEY=your_newsapi_key_herehttp://localhost:5000/api
GET /api/nifty50Description: Get list of all Nifty 50 companies
Response:
[
{
"Symbol": "ADANIPORTS",
"Company Name": "Adani Ports and Special Economic Zone",
"Speciality": "Ports & Logistics"
}
]GET /api/company/info?symbol=TCSDescription: Get company details and current price
Parameters:
symbol(required): Stock ticker (e.g., TCS, RELIANCE, INFY)
Response:
{
"Company Name": "Tata Consultancy Services Limited",
"Symbol": "TCS.NS",
"Price": 4085.55,
"Short Summary": "TCS is a leading global IT services & consulting..."
}GET /api/company/history?symbol=RELIANCE&start=2024-01-01&end=2024-12-31Description: Get historical stock data
Parameters:
symbol(required): Stock tickerstart(required): Start date (YYYY-MM-DD)end(required): End date (YYYY-MM-DD)
Response:
[
{
"Date": "2024-01-01",
"Open": 2885.50,
"Close": 2910.25,
"High": 2920.00,
"Low": 2880.00,
"Volume": 15432100
}
]GET /api/company/financials?symbol=INFYDescription: Get financial metrics (Revenue, Net Profit, EBITDA, etc.)
Parameters:
symbol(required): Stock ticker
Response:
{
"Revenue": 21156000000,
"Net Profit": 4156000000,
"EBITDA Margin": 21.5,
"P/E Ratio": 18.5,
"Market Cap": 650000000000
}GET /api/company/search?symbol=RELIANCEDescription: Search company and get news with AI sentiment analysis
Parameters:
symbol(required): Stock ticker
Response:
{
"data": [
{
"title": "Reliance Industries Announces Q4 Results",
"sentiment": "Positive",
"confidence": 0.87,
"pubdate": "2024-01-15T10:30:00Z",
"summary": "Strong Q4 performance with 15% YoY growth...",
"symbol": "RELIANCE"
}
]
}GET /api/news/analyze-full?symbol=TCSDescription: Comprehensive news sentiment analysis using FinBERT
Parameters:
symbol(required): Stock ticker
Response: Same as Company Search endpoint
| Variable | Description | Example |
|---|---|---|
NEWS_API_KEY |
API key for news source | abc123xyz |
GOOGLE_SHEETS_URL |
Google Sheets query endpoint | https://script.google.com/macros/... |
FLASK_ENV |
Environment mode | production or development |
PORT |
Port number (default: 5000) | 5000 |
# backend/.env
NEWS_API_KEY=your_api_key
GOOGLE_SHEETS_URL=your_sheets_urlenvironment:
- FLASK_ENV=production
- NEWS_API_KEY=${NEWS_API_KEY}
- GOOGLE_SHEETS_URL=${GOOGLE_SHEETS_URL}-
Search for a Stock
- Enter company name or ticker in search box
- Select from Nifty 50 suggestions
-
View Analytics
- Check real-time price and key metrics
- View company overview and financials
- Analyze multi-timeframe price charts
-
Read Sentiment
- Look at overall sentiment (Positive/Neutral/Negative)
- Check individual news articles with confidence scores
- Make informed trading decisions
-
Follow Trading Strategies
- Review AI-generated short-term strategies
- Check swing trading recommendations
- Evaluate long-term investment outlook
- Create function in
backend/functions.py - Add Flask route in
backend/app.py - Call from frontend
client/js/api.js - Render in
client/js/app.js
- Styling: Edit
client/css/style.css - Logic: Modify
client/js/app.js - API calls: Update
client/js/api.js
- Backend logs: Check terminal output when running
python app.py - Frontend logs: Open browser DevTools (F12 โ Console)
- API responses: Use browser Network tab to inspect requests/responses
- Docker installed and running
- Docker Compose (comes with Docker Desktop)
# Build images
docker-compose build
# Start services
docker-compose up
# In background
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down| Service | Port | Purpose |
|---|---|---|
backend |
5000 | Flask API server |
frontend |
10000 | Frontend web interface |
# Build
docker build -t stockit:latest .
# Run
docker run -p 10000:10000 \
-e FLASK_ENV=production \
-e GOOGLE_SHEETS_URL="your_url" \
stockit:latestIssue: "Cannot read properties of undefined"
- Solution: Ensure backend is running on http://localhost:5000
- Check: Browser Console (F12) for detailed error messages
Issue: Charts not displaying
- Solution: Verify
chart.jsis loaded in index.html - Check: Network tab for failed resource loads
Issue: News showing "No title"
- Solution: API response might have spaced keys (e.g.,
"title ") - Check: Browser Network tab โ inspect API response
Issue: "ModuleNotFoundError"
- Solution: Install dependencies:
pip install -r requirements.txt - Verify:
pip list | grep -E "flask|yfinance|pandas"
Issue: Port 5000 already in use
- Solution:
# Kill process on port 5000 lsof -ti:5000 | xargs kill -9 # macOS/Linux netstat -ano | findstr :5000 # Windows (then taskkill)
Issue: FinBERT sentiment returns "Neutral" for all
- Solution: Verify Gradio client is installed:
pip install gradio_client
Issue: 404 errors for /api/* endpoints
- Solution: Verify
static_folder='../client'in app.py - Check: Backend is serving frontend files correctly
Issue: CORS errors
- Solution: Flask-CORS is properly configured
- Check:
CORS(app)is called in app.py
- Frontend Details: See
client/README.md - FinBERT Setup: See
FinBERT_FinancialSentimentAnalysis/README.md
- NSEPython Documentation
- yfinance Documentation
- Flask Documentation
- FinBERT Model
- Chart.js Documentation
# Backend
cd backend && python app.py # Start backend
pip install -r requirements.txt # Install dependencies
python -m pip freeze > requirements.txt # Update requirements
# Frontend
cd client && python -m http.server 8000 # Serve frontend
npm install # If using npm
# Docker
docker-compose up --build # Build and start
docker-compose ps # View running services
docker logs stockit_backend_1 # View backend logs
docker-compose down # Stop all services
# Development
python -m pytest backend/tests/ # Run tests (if available)
python app.py --debug # Run in debug mode- User authentication & portfolios
- Watchlist functionality
- Advanced technical indicators (RSI, MACD, Bollinger Bands)
- Real-time stock alerts
- Export to PDF/Excel reports
- Mobile app (React Native/Flutter)
- Multi-market support (BSE, international exchanges)
- Machine learning price predictions
- Backtesting engine for strategies
- Social sentiment analysis (Twitter, Reddit)
This project is provided as-is for educational and commercial use.
For issues, questions, or contributions:
- Check the Troubleshooting section
- Review API endpoint documentation
- Check browser console for detailed errors
- Verify all dependencies are installed
Built with โค๏ธ for investors and traders.
Last Updated: February 2026
cd frontend
python server.py
The frontend will open on `http://localhost:8000`
#### Option B: Direct Browser Access
If you have a web server running, simply navigate to:
http://localhost:8000/index.html
## API Endpoints Available
### Company Data
- `GET /api/nifty50` - Get Nifty 50 companies list
- `GET /api/company/info?symbol=TCS` - Get company information
- `GET /api/company/history?symbol=RELIANCE&start=2026-01-01&end=2026-02-01` - Get historical OHLCV data
- `GET /api/company/financials?symbol=INFY` - Get financial metrics
### News & Sentiment Analysis
- `GET /api/news/analyze-full?symbol=TCS` - Get news and FinBERT sentiment analysis
- `POST /api/news/analyze` - Analyze news sentiment (JSON: `{"text": "..."}`)
## Frontend Features
### 1. Price Data Analysis
- **Input**: Stock symbol (e.g., TCS, RELIANCE) or CSV price data
- **Output**:
- Price trend (uptrend/downtrend/sideways)
- Period returns, average volume, volatility
- Interactive price charts with volume analysis
- Candlestick patterns
### 2. News Sentiment Analysis
- **Input**: Stock symbol or news headlines
- **Output**:
- Overall sentiment (positive/negative/neutral)
- Sentiment breakdown with confidence scores
- Keyword extraction
- Headlines analysis with sentiment labels
### 3. Financial Data Parsing
- **Input**: Financial metrics in text format
- **Output**: Organized financial table with metrics and values
### 4. Trading Strategy Generator
- **Input**: Price trend + News sentiment
- **Output**:
- Market outlook probability (bullish/bearish/consolidation)
- Short-term trader strategies
- Swing trader recommendations
- Long-term investor guidance
- Key insights and alerts
## Usage Examples
### Example 1: Analyze a Stock by Symbol
1. Open the frontend (http://localhost:8000)
2. Enter `TCS` in the Price Data input
3. Click "Analyze Price Data"
4. Enter `TCS` in the News input
5. Click "Analyze Sentiment"
6. Click "Generate Strategy" to see recommendations
### Example 2: Paste Custom Data
1. Copy OHLCV data (Date, Open, Close, High, Low, Volume)
2. Paste into Price Data field
3. Click "Analyze Price Data"
## Troubleshooting
### Backend not connecting
- Ensure Flask is running on port 5000
- Check firewall settings
- Verify all dependencies are installed
### No news data found
- Check if the stock symbol is valid (NSE symbol format)
- Try adding `.NS` suffix (e.g., TCS.NS)
### FinBERT not working
- Ensure `gradio_client` is installed
- Check internet connection (Gradio API requires external connection)
### CORS errors
- CORS is enabled in Flask (`flask-cors` installed)
- If issues persist, check browser console for specific errors
## Technical Details
### Frontend Technologies
- HTML5
- Vanilla JavaScript (no dependencies)
- CSS3 with variables and gradients
- Responsive design
- Dark theme with accent colors
### Backend Technologies
- Python Flask
- yfinance for stock data
- nsepython for NSE integration
- FinBERT (Gradio API) for sentiment analysis
- NewsAPI integration
- CORS enabled for cross-origin requests
### Data Flow
User Input โ Frontend (JavaScript) โ Backend API (Flask) โ Data Sources (yfinance, NSE, NewsAPI, FinBERT) โ Processed Results โ Frontend Display (Charts, Tables, Analysis)
## Future Enhancements
- Real-time data streaming
- Advanced technical indicators
- Portfolio backtesting
- Machine learning price predictions
- User authentication and saved analyses
- Mobile responsive optimization
- Export to PDF/CSV
## Support
For issues or questions, check the error console (F12 in browser) and backend terminal output for detailed error messages.