Skip to content

toshan-luktuke/stock-market-analyser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stock Photo
Stock Market Analyzer

Stock Market Analyzer - This web app uses machine learning to analyse the stock market.
Inheritance '21 - Team S.T.A.R.

GitHub issues GitHub stars GitHub contributors

Table of Contents

📝Description

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:
  • Select your desired listed stock
  • Get the analysis of that stock
  • Get future predictions based on the stock's previous history

🔗Links

Frontend (Vercel)

Assets

Backend (Heroku)

While learning🥺

🤖Tech-Stack

Python Numpy pandas scikit-learn matplot Seaborn Tensorflow HTML5 CSS3 Tailwind PostCSS JavaScript Node JS Nodemon ESLint Flask

📈Progress

  • 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)

🔮Future Scope

  • 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

🛠Project Setup

For the web-app

  1. Clone the GitHub repo
    $ git clone https://github.com/toshan-luktuke/stock-market-analyser.git
    
  2. 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
    
  3. Repeat the same process for the server directory once all the dependencies for the client directory are installed
    $ cd ../server
    $ npm install
    
    Also setup the .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
    
  4. If you are working on Visual Studio Code or WebStorm, it'd be convenient to install the extensions for Prettier and ESLint.

For the model

  1. 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
    
  2. Enter the Model directory look for requirments.txt and install the packages.
    $ pip install -r requirements.txt
    

For the Flask API

  1. Look for the main.py and test.py files in the Model directory and have them ready. (The packages for flask would already be installed when you run previous command number 2 in the above section)

💻Usage

Once the required setup and installation is completed, you can start developing and running the project.

For the web-app

  1. Backend: Go to the server directory and run the dev script to activate nodemon
    $ cd server
    $ npm run dev
    
    Before pushing any commit, make sure to run the lint script and fix any linting errors
    $ npm run lint
    
    The requests will be listened at the localhost port which was specified in the .env file. For example, if it was specified as 5000, the requests should be made at http://localhost:5000/

    Use the browser or any other API-testing client like Postman or Insomnia to test any newly added routes.

  2. Frontend: Go to the client directory and run the start script to start the React App.
    $ cd client
    $ npm start
    
    The web-app can be viewed at http://localhost:3000/

    If you get an ESLint, Tailwind or PostCSS version conflict error, make a .env file in the client directory with the following contents:
    SKIP_PREFLIGHT_CHECK = true
    

For the model and for the Flask API

  1. Locate to the Model directory. The models for the project are in linear_reg_model.py and ann_model.py files.

  2. 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
    
  3. 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
    
  4. To initiate the server, type the following in the first command prompt

    $ python main.py
    
  5. To run the linear regression model, type the following in the second prompt while the server is running.

    $ python test.py
    

🔮Future scope

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

Linear regression models

  1. Pull the ml-dev branch onto your local machine
$ git switch ml-dev
  1. Once inside your text-editor, open the linear_reg_model.py file inside Model folder. At the end of the file call the find_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)
  1. This will create a .pkl file in the Models folder.

  2. Now add the stock name as a string in the array list_stocks in the file main.py

  3. 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

ANN models

  1. Switch over to the ml-host-ann branch locally
$ git checkout ml-host-ann
  1. 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

  1. Once this is done, add the stock name in the array list_stocks in main.py on the same branch

  2. 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

👩‍💻Contributors

Team members

👨‍🏫Mentors

About

This web app uses machine learning to analyse the stock market.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •