Prediction with LSTM!
View Demo
This project aims to predict whether a company's stock price will rise or fall the next day to find out whether we can buy a stock or not. We selected three companies and collected data from 1999 to present.
We coded this project using Python, its packages, a Database and an API :
To get started, you are going to need :
You need to install Python from here first then download the file get-pip.py. In the terminal, go to the folder where the file was downloaded and type the following command :
python get-pip.py
Now create a folder, open it on an IDE and follow the instructions :
-
Get a free API Key at Alpha Vantage
- Create an
apiKey.txt
file in the root of the Trading folder and put your API key there. - To connect to MongoDB Atlas: Create a
mongoKey.txt
file at the root of the Trading folder and put in each line your username, password and the rest of the MongoDB Atlas link after the '@'.
- Create an
-
Open terminal and clone the repository
git clone https://github.com/SasaIA/Trading.git
- Install Python packages using pip
pip install -r requirements.txt
- Make sure to install MongoDB on your computer
- To launch a file, you must start the terminal and navigate to the folder that contains that file
- Open the terminal and type :
python api.py
python lstm.py
- Thats it you have the latest stock price for each company and the prediction for tomorrow.
- Every night, launch the
updatesPrice.py
file to update the database with the last stock price. - To launch the app, type in the terminal
streamlit run app.py
There are different files in this project:
- The first
api.py
allows to retrieve the data via the API and to store the data in a JSON file and then to send them to a database. - The second
lstm.py
predicts whether the stock will rise or fall the next day. - The third
updatesPrice.py
, allows us to update our database with the last known stock price. - The fourth
dataviz.ipynb
allows you to analyze data with different graphs. - The fifth
app.py
file is used to launch the application and have a visual on the latest stock prices, to have an overview of the graphs and predictions.