Our project aims to learn and apply machine learning techniques to predict stock prices and trends in the stock market. We will be building a web application that will predict U.S. stock market prices. We will focus on the US stock market and the large companies that are part of the Standards and Poor (S&P) 500, a stock market index that tracks the performance of these large companies. Some of these are Apple, Google, Amazon, and Microsoft.
We divided our project into several strategies. In each one, we used different machine learning techniques that we have learned in this course to improve and get the best-predicted trading results that simulate the actual trending. Some of the strategies that will be used to predict the direction of the stock trend will be based on the dataset, and others can indicate a stock price for a specific day. Moreover, we will compare the results between the strategies to see which one was more accurate.
Type | Sub Type | Algorithm |
---|---|---|
Supervised Learning | RNN | LSTM |
This section lists all major frameworks/libraries used to bootstrap this project.
Following the instructions below should get you up and running and quickly as possible without googling around to run the code.
Below is the list things you need to use the software and how to install them. Note, these instructions assume you are using a Mac OS. If you are using Windows you will need to go through these instructions yourself and update this READ for future users.
pyenv
brew update
brew install pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
python
pyenv install 3.9.5
pyenv global 3.9.5
poetry
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
miniconda
cd /tmp
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh"
bash Mambaforge-$(uname)-$(uname -m).sh
Restart new terminal session in order to initiate mini conda environmental setup
Git LFS
brew install git-lfs
Below is the list of steps for installing and setting up the app. These instructions do not rely on any external dependencies or services outside of the prerequisites above.
git clone git@github.com:fall2023csce5214/lstm_stock_market_prediction.git
conda env create -f environment.yml
conda activate lstm_stock_market_prediction
docker-compose build
In order to view or execute the various notebooks run the following command on any of the sub folders in this directory.
Here is an example to launch the LSTM Notebook.
jupyter notebook
Once inside the notebook use the following link on examples of how to use the notebook.
Here is an example to launch docker to run the unit test on the command line.
docker-compose up -d
docker-compose exec lstm-web-service bash
poetry run python -m pytest -k test_appl_lstm_60_day_model
Here is an example to launch docker to populate the database and launch the web service.
docker-compose up -d
docker-compose logs -f lstm-web-service
Then hit the following URL to test the web service. Note, wait until the web service starts. You will see a message like the following:
INFO: Will watch for changes in these directories: ['/lstm']
INFO: Uvicorn running on http://0.0.0.0:10000 (Press CTRL+C to quit)
INFO: Started reloader process [142] using statreload
INFO: Started server process [146]
INFO: Waiting for application startup.
INFO: Application startup complete.
http://localhost:10000/predict?ticker_symbol=AAPL&date=2023-09-22
The response would look something like the following:
{
"trading_date": "2023-09-22",
"closing_price": 177.7
}
Stock Market Analysis + Prediction using LSTM
Jibril Moalim
Lakshmi Prasanna Valdas
Larry Johnson
Monish Galla
Vamshidhar Reddy Venumula
Project Link: https://github.com/fall2023csce5214/ltsm_stock_market_prediction/