A modern, responsive stock analysis and forecasting dashboard built with React and FastAPI. This is a React-based clone of the original Streamlit application with enhanced UI/UX and better performance.
- ๐ Interactive Stock Charts: Real-time stock price visualization with candlestick charts and moving averages
- ๐ฎ Advanced Forecasting: Multiple forecasting algorithms including:
- Linear Regression
- Polynomial Regression
- Moving Average
- ARIMA
- Facebook Prophet
- Support Vector Regression
- ๐ฐ Real-time News: Latest news articles related to selected stocks
- ๐จ Modern Dark Theme: Beautiful, responsive UI with Tailwind CSS
- ๐ Key Metrics: Current price, 52-week high/low, volume, and forecast predictions
- ๐ Smart Search: Search by ticker symbol or company name with autocomplete
- ๐ฑ Responsive Design: Works perfectly on desktop, tablet, and mobile devices
- Frontend: React 18 + TypeScript + Tailwind CSS + Chart.js
- Backend: FastAPI + Python 3.8+
- Data Source: Yahoo Finance (yfinance)
- Caching: DuckDB for efficient data caching
- Charts: Chart.js with react-chartjs-2
- Node.js 16+ and npm
- Python 3.8+
- pip
- Navigate to the backend directory:
cd backend
- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Start the FastAPI server:
python main.py
The backend will be available at http://localhost:8000
- Navigate to the frontend directory:
cd frontend
- Install dependencies:
npm install
- Start the development server:
npm start
The frontend will be available at http://localhost:3000
- Start the backend server (from the
backend
directory):
python main.py
- Start the frontend development server (from the
frontend
directory):
npm start
-
Open your browser and navigate to
http://localhost:3000
-
Search for a stock using the search bar or click on popular stocks
-
Explore the features:
- View interactive price charts
- Switch between different forecasting methods
- Read the latest news
- Analyze key metrics
The FastAPI backend provides the following endpoints:
POST /api/search
- Search for stock tickersPOST /api/stock-data
- Get stock data and metricsPOST /api/forecast
- Get price forecastsPOST /api/news
- Get news articlesGET /api/health
- Health check
- StockSearch: Smart search with autocomplete and popular stocks
- StockChart: Interactive price charts with moving averages
- ForecastChart: Forecast visualization with multiple algorithms
- StockMetrics: Key performance indicators
- NewsSection: News articles with external links
- Cache Duration: Modify
CACHE_DURATION_HOURS
andCACHE_DURATION_DAYS
inmain.py
- Market Hours: Update
MARKET_HOURS
for different exchanges - API Rate Limits: Adjust timeout and retry settings
- API Base URL: Update
API_BASE_URL
insrc/services/api.ts
- Theme Colors: Modify
tailwind.config.js
for custom colors - Chart Options: Customize chart appearance in component files
The application is fully responsive and works on:
- Desktop: Full-featured experience with sidebar and main content
- Tablet: Optimized layout with collapsible sidebar
- Mobile: Stacked layout with touch-friendly controls
- Using Docker:
# Create Dockerfile in backend directory
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "main.py"]
- Using cloud platforms:
- Heroku
- Railway
- DigitalOcean App Platform
- AWS Elastic Beanstalk
- Build for production:
npm run build
- Deploy to:
- Vercel
- Netlify
- AWS S3 + CloudFront
- GitHub Pages
Stocks-React/
โโโ backend/
โ โโโ main.py # FastAPI application
โ โโโ requirements.txt # Python dependencies
โ โโโ stock_cache.db # DuckDB cache (auto-created)
โโโ frontend/
โ โโโ public/
โ โโโ src/
โ โ โโโ components/ # React components
โ โ โโโ services/ # API services
โ โ โโโ types.ts # TypeScript types
โ โ โโโ App.tsx # Main app component
โ โโโ package.json
โ โโโ tailwind.config.js
โโโ README.md
-
New Forecasting Method:
- Add function in
backend/main.py
- Update frontend dropdown options
- Add method to API service
- Add function in
-
New Chart Type:
- Create new component in
src/components/
- Import Chart.js plugins as needed
- Add to main App component
- Create new component in
-
New Data Source:
- Add API endpoint in
backend/main.py
- Create service function in
src/services/api.ts
- Update types in
src/types.ts
- Add API endpoint in
- CORS Errors: Ensure backend is running on port 8000 and frontend on port 3000
- Chart Not Rendering: Check if Chart.js plugins are properly registered
- API Timeout: Increase timeout in
src/services/api.ts
- Build Errors: Clear node_modules and reinstall dependencies
Enable debug logging by setting environment variables:
# Backend
export DEBUG=1
python main.py
# Frontend
export REACT_APP_DEBUG=1
npm start
This project is for educational and informational purposes only. Stock market investments carry risk, and past performance does not guarantee future results. Always consult with a financial advisor before making investment decisions.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For questions or issues:
- Check the troubleshooting section
- Search existing issues
- Create a new issue with detailed description
Note: This application is for educational purposes only. Always verify data accuracy and consult financial professionals before making investment decisions.