This project is a web application designed to predict stock market trends using a combination of machine learning algorithms and sentiment analysis of tweets. By integrating real-time public sentiment with historical data, MLstockApp aims to provide more accurate and timely investment insights.
- Real-time Sentiment Analysis: Integrates Twitter API to fetch live tweets and analyze their sentiment.
- Machine Learning Predictions: Uses historical stock data and advanced machine learning models to predict future stock prices.
- Interactive Dashboards: Visualizes stock trends, sentiment analysis results, and prediction outcomes.
- User Authentication: Secure user login and registration functionality.
- Frontend: HTML, CSS, JavaScript, Bootstrap
- Backend: Flask, SQLAlchemy
- Database: SQLite
- Machine Learning: Scikit-Learn, Pandas, Numpy
- Sentiment Analysis: VaderSentiment, Tweepy
- Visualization: Matplotlib, Plotly
Follow these steps to get the project up and running on your local machine.
-
Clone the repository:
git clone https://github.com/kaushikjadhav01/Stock-Market-Prediction-Web-App-using-Machine-Learning-And-Sentiment-Analysis.git cd Stock-Market-Prediction-Web-App-using-Machine-Learning-And-Sentiment-Analysis
-
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
-
Install the required packages:
pip install -r requirements.txt
-
Set up environment variables:
- Create a
.env
file in the root directory of the project. - Add your Twitter API keys and other necessary configurations to the
.env
file.
Example:
TWITTER_API_KEY=your_api_key TWITTER_API_SECRET_KEY=your_api_secret_key TWITTER_ACCESS_TOKEN=your_access_token TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret
- Create a
-
Initialize the database:
flask db init flask db migrate -m "Initial migration." flask db upgrade
-
Run the application:
flask run
-
Access the application: Open your browser and navigate to http://127.0.0.1:5000.
- Register/Login: Create an account or log in to access the application.
- Select Stock: Choose the stock you want to analyze.
- Fetch Data: The application will retrieve historical stock data and live tweets related to the selected stock.
- View Predictions: Analyze the predicted stock prices and sentiment analysis results on the interactive dashboard.
MLstockApp/
│
├── app/
│ ├── __init__.py
│ ├── routes.py
│ ├── models.py
│ ├── static/
│ ├── templates/
│ └── utils/
├── migrations/
├── tests/
├── .env
├── .gitignore
├── README.md
├── requirements.txt
└── run.py
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Stock Market Prediction Web App based on Machine Learning and Sentiment Analysis of Tweets (API keys included in code). The front end of the Web App is based on Flask and Wordpress. The App forecasts stock prices of the next seven days for any given stock under NASDAQ or NSE as input by the user. Predictions are made using three algorithms: ARIMA, LSTM, Linear Regression. The Web App combines the predicted prices of the next seven days with the sentiment analysis of tweets to give recommendation whether the price is going to rise or fall.
- Install XAMPP server
- Download wordpress zip folder from this link.
- Extract the downloaded zip into
htdocs
folder of XAMPP. - Open the
wp-config.php
file from the extracted folder and add your phpmyadmin username and password. - Go to phpmyadmin, create a new database called
wordpress
. - Select this database, go to Operations tab and Import the
wordpress.sql
file into this created databse. - Clone the repo, cd into it
- Run
pip install -r requirements.txt
- Run
python main.py
to start server. - Go to
localhost/wordpress
to access the app.