A sophisticated web application for analyzing S&P 500 stocks using network analysis techniques to identify market leaders and independent movers. This project helps investors understand stock market dynamics by visualizing relationships between stocks and suggesting portfolio strategies.
Core Contributors: Jasmin, Suraj, Megha, Anupreet and Ivana.
- Network Analysis: Identifies stocks that are highly connected within the market network (Market Leaders) and those with more independent price movements (Independent Movers).
- Performance Metrics: Calculates expected returns, risk levels, and Sharpe ratios for each stock.
- Advanced Visualizations:
- Portfolio Composition Pie Chart
- Risk-Return Scatter Plot
- Performance Distribution Chart
- Cumulative Returns Chart
- Interactive UI: Modern, responsive interface built with Material-UI and React.
root/
├── api/ # Django backend API
│ ├── utils/ # Utility functions
│ │ └── data_loader.py # Data loading utilities
│ ├── tests/ # Backend tests
│ ├── views.py # API endpoints
│ ├── urls.py # URL routing
│ └── stock_analysis.py # Stock analysis logic
├── frontend/ # React frontend
│ ├── src/ # Source code
│ │ ├── components/ # React components
│ │ │ ├── AdvancedCharts.js # Advanced visualization components
│ │ │ ├── PortfolioCard.js # Portfolio display component
│ │ │ └── PerformanceChart.js # Performance visualization
│ │ ├── utils/ # Utility functions
│ │ │ ├── api.js # API communication
│ │ │ └── formatters.js # Data formatting utilities
│ │ ├── hooks/ # Custom React hooks
│ │ └── assets/ # Static assets
│ ├── public/ # Public assets
│ └── package.json # Frontend dependencies
├── data/ # Data files
│ ├── SNP 500 Price Data 2011-2020.csv # Historical data
│ └── SNP 500 Price Data 2021.csv # Validation data
├── stockanalysis/ # Django project settings
├── manage.py # Django management script
├── requirements.txt # Python dependencies
└── .env # Environment variables
- Python 3.8+
- Node.js 14+
- npm or yarn
-
Clone the repository:
git clone https://github.com/yourusername/RichGirls.git cd RichGirls -
Install backend dependencies:
pip install -r requirements.txt -
Install frontend dependencies:
cd frontend npm install -
Create environment files:
- Copy
.env.exampleto.envin the root directory - Copy
frontend/.env.exampletofrontend/.env
- Copy
-
Start the Django backend:
python manage.py runserver 8002 -
Start the React frontend:
cd frontend npm start -
Access the application at http://localhost:3000
GET /api/analysis/: Returns portfolio suggestions and performance metrics
The application uses the following steps to analyze stocks:
- Data Loading: Loads historical S&P 500 price data from 2011-2020
- Network Construction: Creates a network of stocks based on price correlations
- Centrality Analysis: Identifies stocks with high centrality (Market Leaders) and low centrality (Independent Movers)
- Performance Calculation: Computes expected returns, risk levels, and Sharpe ratios
- Validation: Tests the strategy against 2021 data
-
Backend:
- Django & Django REST Framework
- Pandas for data manipulation
- NetworkX for network analysis
- NumPy for numerical computations
-
Frontend:
- React for UI components
- Material-UI for styling
- Recharts for data visualization
- Axios for API communication
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.