A professional-grade stock analysis web application built with Streamlit, featuring AI-powered recommendations, technical indicators, backtesting, and portfolio tracking.
- π Stock Overview - Real-time price charts, candlestick patterns, volume analysis
- π‘ Investment Advice - AI-powered BUY/SELL/HOLD recommendations with risk assessment
- π Technical Analysis - 8+ indicators (RSI, MACD, Bollinger Bands, SMA, etc.)
- π€ Price Prediction - Machine learning price forecasting using Random Forest
- β‘ Backtesting - Test trading strategies on historical data
- πΌ Portfolio Analysis - Track multiple stocks, correlation analysis
- π Watchlist Manager - Create and manage custom stock watchlists
- π Stock Comparison - Compare multiple stocks side-by-side
- π Stock Screener - Find stocks matching technical criteria
- π Price Alerts - Set alerts for price targets and indicators
- πΉ Performance Tracker - Track paper trading performance with P&L analysis
- βΏ Crypto Analysis - Dedicated cryptocurrency analysis with 24/7 market data and volatility metrics
- π° AI News Sentiment - AI-powered analysis of news headlines with sentiment scoring and trend detection
- πΌ Insider Trading Tracker - Monitor executive and insider transactions with buy/sell signals and multi-timeframe analysis
- π Earnings Calendar - Track upcoming earnings dates, analyze historical earnings performance, and monitor beat/miss rates
- π Chart Pattern Scanner - AI-powered detection of technical patterns (head & shoulders, double tops/bottoms, triangles) with trading signals
- π― Advanced Market Screener - 7 preset screeners to find gap-ups/downs, unusual volume, momentum stocks, value plays, high beta, and 52-week high breakouts
- π Global Markets Dashboard - Track 20 international indices (Asia, Europe, Americas including Malaysia KLCI), currencies (including MYR), commodities, and correlations with US markets in real-time
- π¦ ETF Holdings Explorer - Discover what stocks are inside any ETF, view top holdings with weights, analyze sector allocation, and understand fund concentration
- π Dark Mode - Toggle between light and dark themes
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtstreamlit run app.pyThe dashboard will open in your browser at http://localhost:8501
The codebase has been refactored from a single 2,428-line file into a clean, modular structure:
stock/
βββ app.py # Main entry point (152 lines - 94% reduction!)
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ DEVELOPER_GUIDE.md # Developer documentation
β
βββ data/
β βββ cache/ # Cached stock data
β βββ user_data/ # User preferences & data
β βββ watchlists.json
β βββ alerts.json
β βββ performance_tracker.json
β βββ preferences.json
β
βββ src/
βββ data/
β βββ fetcher.py # Stock data fetching (yfinance)
β βββ persistence.py # User data persistence
β βββ loader.py # Standardized data loading utilities
β βββ insider_data.py # Insider trading data
β βββ earnings_data.py # Earnings calendar & analysis
β βββ global_markets.py # Global markets data
β βββ etf_data.py # ETF holdings & info β NEW
β
βββ indicators/
β βββ trend.py # Trend indicators (SMA, EMA, MACD)
β βββ momentum.py # Momentum indicators (RSI, Stochastic)
β βββ volatility.py # Volatility indicators (Bollinger Bands, ATR)
β βββ volume.py # Volume indicators (OBV, VWAP)
β
βββ models/
β βββ random_forest.py # ML price prediction
β βββ feature_engineering.py # Feature creation for ML
β
βββ backtesting/
β βββ strategies.py # Trading strategies (SMA, RSI)
β
βββ analysis/
β βββ investment_recommendation.py # AI recommendation engine
β βββ sentiment_analyzer.py # News sentiment analysis
β βββ pattern_detector.py # Chart pattern detection
β βββ market_screener.py # Advanced market screener β NEW
β
βββ fundamental/
β βββ ratios.py # Financial ratios
β
βββ ui/
β βββ themes.py # Apple-inspired CSS themes β UPDATED
β βββ charts.py # Reusable chart functions
β βββ components.py # UI component library β NEW
β
βββ alerts/
β βββ checker.py # Price alert monitoring
β
βββ pages/ # 20 page modules
βββ __init__.py
βββ home.py
βββ stock_overview.py
βββ investment_advice.py
βββ technical_analysis.py
βββ price_prediction.py
βββ backtesting.py
βββ portfolio.py
βββ alerts.py
βββ performance_tracker.py
βββ stock_screener.py
βββ stock_comparison.py
βββ watchlist_manager.py
βββ crypto_analysis.py
βββ news_sentiment.py # AI news sentiment
βββ insider_trading.py # Insider trading tracker
βββ earnings_calendar.py # Earnings calendar & analysis
βββ pattern_scanner.py # Chart pattern detection
βββ market_screener.py # Advanced market screener
βββ global_markets.py # Global markets dashboard
βββ etf_explorer.py # ETF holdings explorer β NEW
- Frontend: Streamlit
- Data: yfinance, pandas, numpy
- Visualization: Plotly, mplfinance
- Machine Learning: scikit-learn, Random Forest
- Technical Indicators: pandas_ta, custom implementations
- Backtesting: backtesting.py library
- Navigate to Stock Overview
- Enter a ticker symbol (e.g., AAPL)
- Select date range
- Click "Load Stock Data"
- Go to Investment Advice
- Enter ticker symbol
- Enable "Include AI Prediction"
- Click "Analyze Stock"
- Review BUY/SELL/HOLD recommendation with price targets
- Open Watchlist Manager
- Create a new watchlist
- Add stocks to the watchlist
- View real-time prices
- Navigate to Stock Screener
- Select stock universe (watchlist or popular stocks)
- Set screening criteria (RSI, MACD, volume, etc.)
- Run screener to find matches
β Fixed Deprecation Warnings
- Replaced
use_container_width=Truewithwidth="stretch"(28 instances) - Code now compatible with Streamlit 1.40+
β Extracted Duplicate Code
- Created
src/ui/charts.pywith 9 reusable chart functions - Created
src/data/loader.pywith 9 standardized data loading utilities - Reduced code duplication by ~500 lines
β Added Type Hints
- Type annotations added to all utility modules
- Improved IDE support and code clarity
- Better error detection
β Modular Architecture
- Refactored from 2,428-line monolithic file to 16 organized modules
- app.py reduced to 152 lines (94% smaller!)
- Each page in its own file for easy maintenance
- Default stock list: Tech Giants (AAPL, MSFT, GOOGL, AMZN, META)
- Cache duration: 1 hour
- Dark mode: Off (toggle in sidebar)
Edit watchlist options in app.py:
if watchlist == "Custom Group":
default_stocks = ["TICKER1", "TICKER2", "TICKER3"]See DEVELOPER_GUIDE.md for detailed instructions.
Quick steps:
- Create
src/pages/new_page.pywith arender()function - Add import to
src/pages/__init__.py - Add page name to navigation list in
app.py - Add routing entry in
page_routesdictionary
The codebase follows these principles:
- Modular structure - Each page is a separate module
- Type hints - Functions have type annotations
- DRY principle - Reusable utilities for common operations
- Consistent styling - Standardized chart creation and data loading
- Check internet connection
- Verify ticker symbol is correct
- Try a different date range
- Reduce date range for analysis
- Clear cache: delete
data/cache/directory - Disable AI prediction for faster results
- Ensure all dependencies installed:
pip install -r requirements.txt - Check Python version: 3.8+
This tool is for educational and informational purposes only. It is NOT financial advice. Always:
- Do your own research
- Consult a licensed financial advisor
- Understand the risks of trading/investing
- Never invest more than you can afford to lose
Made with β€οΈ using Streamlit