Inheritance '21 - Team S.T.A.R.
Table of Contents
A blazing fast web application to analyze the current trends in the stock a user chooses. The app applies a variety of algorithms to make the analysis of the user easier based on historical data from the exchanges. An ML price predictor is also implemented.
The key features of stock market analyzer:
|
- Stock Market Analyser Server
- Stock Market Analyser Linear Regression Model Deployment
- Stock Market Analyser ANN Model Deployment
- Search any stock and get real-time updates, along with historical data and reviews
- Autosuggest Searchbar
- Latest Financial News Section
- r/WallStreetBets Sentiment Analysis
- Dark Mode implementation
- Server-side endpoint
- API for the linear regression model
- API for the ANN model
- Hosting the model
- Market Dashboard
- Linking the predictions page through the REST API for the model (has been tested on the localhost)
- Real-time charts (partially added, dark-mode sync and responsiveness are remaining)
- Add a portfolio where a user can create an account and pin the stocks of his interest, using MongoDB
- Improve the searchbar autosuggest performance with a regex-based implementation at the server-side
- Cache requests at the proxy server for a snappy real-time performance
- An UpStox-inspired computer application, using ElectronJS
- Clone the GitHub repo
$ git clone https://github.com/toshan-luktuke/stock-market-analyser.git
- Enter the
client
directory. Install all the required dependencies. Ensure that remove any globally-installed packages like the React CLI, Tailwind CLI, PostCSS CLI or ESLint are uninstalled before proceeding ahead$ cd client $ npm install
- Repeat the same process for the
server
directory once all the dependencies for theclient
directory are installedAlso setup the$ cd ../server $ npm install
.env
file for storing the environment variables. A demo file for this is as follows:PORT = 5000 API_KEY_AV = your AlphaVantage API key API_KEY_YF = your YahooFinance API key API_KEY_FMP = your FinancialModellingPrep API key
- If you are working on Visual Studio Code or WebStorm, it'd be convenient to install the extensions for Prettier and ESLint.
- Create a virtual environment on the anaconda command prompt (Install conda if not installed) and then switch to that virtual environment. Lets say the name of the env is test.
$ conda create -n test python=3.8 anaconda $ conda activate test
- Enter the
Model
directory look for requirments.txt and install the packages.$ pip install -r requirements.txt
- Look for the
main.py
andtest.py
files in theModel
directory and have them ready. (The packages for flask would already be installed when you run previous command number 2 in the above section)
Once the required setup and installation is completed, you can start developing and running the project.
- Backend: Go to the
server
directory and run thedev
script to activate nodemonBefore pushing any commit, make sure to run the$ cd server $ npm run dev
lint
script and fix any linting errorsThe requests will be listened at the$ npm run lint
localhost
port which was specified in the.env
file. For example, if it was specified as 5000, the requests should be made athttp://localhost:5000/
Use the browser or any other API-testing client like Postman or Insomnia to test any newly added routes.
- Frontend: Go to the
client
directory and run thestart
script to start the React App.The web-app can be viewed at$ cd client $ npm start
http://localhost:3000/
If you get an ESLint, Tailwind or PostCSS version conflict error, make a.env
file in theclient
directory with the following contents:SKIP_PREFLIGHT_CHECK = true
-
Locate to the
Model
directory. The models for the project are inlinear_reg_model.py
andann_model.py
files. -
Open the command prompt for anaconda and switch to the virtual environment that you created and locate to the
Model
directory. (example: test)$ conda activate test
-
Open another command prompt for anaconda and switch to the virtual environment that you created and locate to the
Model
directory. (example: test)$ conda activate test
-
To initiate the server, type the following in the first command prompt
$ python main.py
-
To run the linear regression model, type the following in the second prompt while the server is running.
$ python test.py
You can follow the below mentioned steps to create a model of your desired stock. You can also refer the video tutorial in the gdrive link It is important to know that these steps must be performed only after setting up the virtual environment
- Pull the
ml-dev
branch onto your local machine
$ git switch ml-dev
- Once inside your text-editor, open the linear_reg_model.py file inside
Model
folder. At the end of the file call thefind_r
function
# At the file saving part edit the name of the file path as the code name of the stock.
# example: filename="../Models/Linear regression/stock_name.pkl"
# At the end of the file
find_r(Stock name)
-
This will create a
.pkl
file in the Models folder. -
Now add the stock name as a string in the array
list_stocks
in the file main.py -
You can now execute the main.py and test.py files on your local machine as stated in the above section
# In the first conda prompt
$ python main.py
# In the second conda prompt
$ python test.py
Here you can enter the code name of the stock and the prediction will be displayed
- Switch over to the
ml-host-ann
branch locally
$ git checkout ml-host-ann
- Open the ann_model.py file currently in the Model folder, and call the
find
function towards the very end
# While saving the file, rename the path of the file as the code name of the particular stock.
# As: "../Models/ANN/stock_name.h5"
# Towards the end, call the find function
# find(Stock_name)
This will create a .h5
file in the Models folder
-
Once this is done, add the stock name in the array
list_stocks
in main.py on the same branch -
Execute the 2 files main.py & test.py locally as shown above (similar to Step 5 of Linear Regression)
On entering the valid stock name, your prediction will be displayed
Team members