Skip to content

Znaxh/Stock-Analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ˆ Stock-Analyzer

A comprehensive stock analysis and prediction platform featuring real-time market data, technical analysis, CAPM calculations, and ARIMA-based price forecasting.

πŸš€ Features

πŸ“Š CAPM Calculator

  • Calculate Beta and Expected Returns using Capital Asset Pricing Model
  • Analyze stock risk vs market performance
  • Interactive price performance charts
  • Compare multiple stocks simultaneously

πŸ“‰ Stock Technical Analysis

  • Real-time stock data visualization
  • Technical indicators and moving averages
  • Volume analysis and trend identification
  • Historical price charts with multiple timeframes

πŸ“ˆ Stock Prediction

  • 30-day price forecasting using ARIMA models
  • Interactive prediction charts
  • Model accuracy metrics (RMSE)
  • Search by stock ticker or company name

πŸ› οΈ Tech Stack

Backend

  • FastAPI: Modern, fast web framework for building APIs
  • Streamlit: Interactive web app framework
  • yFinance: Real-time financial data
  • Pandas & NumPy: Data manipulation and analysis
  • Plotly: Interactive visualizations
  • Statsmodels: ARIMA time series modeling
  • Scikit-learn: Machine learning utilities

Frontend

  • React 19: Modern UI framework
  • Vite: Fast build tool and dev server
  • Tailwind CSS: Utility-first CSS framework
  • Recharts: React charting library
  • Axios: HTTP client for API calls
  • Lucide React: Beautiful icons

πŸ“‚ Project Structure

Stock-Analyzer/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py                 # FastAPI application entry point
β”‚   β”œβ”€β”€ Home.py                 # Streamlit main page
β”‚   β”œβ”€β”€ pages/                  # Streamlit pages
β”‚   β”‚   β”œβ”€β”€ 1_CAPM_Calculator.py
β”‚   β”‚   β”œβ”€β”€ 2_Stock_Analysis.py
β”‚   β”‚   └── Stock_Prediction.py
β”‚   β”œβ”€β”€ routers/                # FastAPI route handlers
β”‚   β”‚   β”œβ”€β”€ capm.py
β”‚   β”‚   β”œβ”€β”€ stock_analysis.py
β”‚   β”‚   └── stock_prediction.py
β”‚   β”œβ”€β”€ models/                 # Pydantic models
β”‚   └── requirements.txt
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/                    # React source code
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
└── README.md

πŸš€ Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • npm or yarn

Backend Setup

  1. Clone the repository
git clone <repository-url>
cd Stock-Analyzer
  1. Set up Python environment
cd backend
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements.txt
  1. Run FastAPI server
python3 -m uvicorn main:app --reload --host 0.0.0.0 --port 8000
  1. Run Streamlit app (alternative interface)
streamlit run Home.py

Frontend Setup

  1. Navigate to frontend directory
cd frontend
  1. Install dependencies
npm install
  1. Start development server
npm run dev

🌐 Access Points

πŸ“Š API Endpoints

CAPM Calculator

  • POST /api/capm/calculate - Calculate CAPM for selected stocks
  • GET /api/capm/available-stocks - Get list of available stocks

Stock Analysis

  • GET /api/analysis/{symbol} - Get technical analysis for a stock
  • GET /api/analysis/{symbol}/indicators - Get technical indicators

Stock Prediction

  • POST /api/prediction/predict - Generate price predictions
  • GET /api/prediction/model-info - Get model information

πŸ”§ Configuration

Environment Variables

Create a .env file in the backend directory:

# Optional: Add any API keys or configuration
YAHOO_FINANCE_API_KEY=your_key_here

CORS Configuration

The FastAPI backend is configured to allow requests from:

πŸ§ͺ Development

Backend Development

cd backend
# Run with auto-reload
python3 -m uvicorn main:app --reload --host 0.0.0.0 --port 8000

Frontend Development

cd frontend
# Run with hot reload
npm run dev

Building for Production

cd frontend
npm run build

πŸ“ˆ Usage Examples

CAPM Analysis

  1. Select multiple stocks (e.g., TSLA, AAPL, MSFT)
  2. Choose analysis period (1-10 years)
  3. View calculated Beta values and expected returns
  4. Compare normalized price movements

Stock Prediction

  1. Search for a stock by name or symbol
  2. View 30-day price forecast
  3. Analyze model accuracy (RMSE)
  4. Compare predicted vs historical prices

Technical Analysis

  1. Enter stock symbol
  2. Select time period (1D to Max)
  3. View candlestick charts and indicators
  4. Analyze volume and price trends

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Yahoo Finance for providing free financial data
  • Streamlit and FastAPI communities for excellent frameworks
  • React and Vite teams for modern frontend tooling

πŸ“ž Support

For support, email [your-email@example.com] or create an issue in the repository.


Made with ❀️ by [Your Name]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors