A full-stack web application that calculates intrinsic values of S&P 500 stocks for informed investing
Originally a hackathon project at Shellhacks 2023, IntrinsIQ is a web app built in Next.js and Flask that functions as an initial screener for S&P 500 stock selections. It leverages the Yahoo Finance API to calculate intrinsic values.
Only after the hackathon was IntrinsIQ's utility fully realized, with our portfolio of top 10 recommendations outperforming the S&P 500 market with 11% higher annualized returns. Because of this success, we decided to refine and deploy IntrinsIQ.
IntrinsIQ calculates the intrinsic value of stocks within the S&P500 using a discounted cash flow model. Essentially, we are projecting the company’s future cash flows and discounting them to the present value.
intrinsic value
= (dcf + cash and short term investments - total debt) / shares outstanding
This calculation is useful for finding potentially undervalued stocks that will perform well in the future in the face of temporary market conditions. That said, it is paramount to recognize that this valuation method has its limitations due to its sensitivity to a large number of assumptions and forecasts. Some of them include:
- A 20 year time horizon
- Growth rate years 1-5 calculation from Finviz (“EPS next 5Y”)
- Growth rate years 6-10 being half of years 1-5 (conservative)
- Growth rate years 11-20 being following inflation
- An average long term US inflation rate of 3.28%
One limitation of this calculation involves few companies missing due to incomplete or uncleanable data.
Pre-requisite: Node.js must be installed.
- Navigate to the client directory:
cd client
- Install dependencies:
npm install
- In
/client
, create a file called.env.local
. This file must contain:
NEXT_PUBLIC_SERVER_URL=http://localhost:5000
- Run client in development mode:
npm run dev
This project is deployed on Vercel. To deploy on Vercel, simply push the code to a GitHub repository and connect it to Vercel. The deployment will be automatic.
Pre-requisite: Python and Docker must be installed.
- Navigate to the server directory:
cd server
- Install dependencies:
pip install -r requirements.txt
- In
/server
, include a validserviceAccount.json
that can be generated within the Google Cloud project'sIAM Service Accounts
. This is for the database (Firestore) connection and deployment. - In
/server
, create a file called.env
. This file must contain:
ENVIRONMENT=dev
- Run server in development mode:
python app.py
This project is deployed using Docker and Google Cloud Run.
- Description: Used to wake up the server when it is in a cold state upon loading the client home page.
- Response:
200 OK
: Returns a string IntrinsIQ API.
- Description: Fetch historical stock data for a specific company.
- Path Parameters:
company
: The company symbol or name to fetch the historical stock data for.
- Response:
-
200 OK
: Returns a JSON array of stock data for the specified company.[ { "company": "AAPL", "date": "2024-09-01", "price": 180.12, ... }, ... ]
-
404 Not Found
: If no data is available for the given company.
-
- Description: Fetch the latest 500 stock records, ordered by
date
in descending order and byrank
in ascending order. - Response:
200 OK
: Returns a JSON array of ranked stock data.[ { "company": "AAPL", "date": "2024-09-13", "rank": 1, ... }, ... ]
- Description: Updates the stock data in the database. Used by a weekly cron job.
- Headers:
AUTH
: The authorization key, should match theAUTH_KEY
environment variable.
- Response:
200 OK
: Returns a message indicating the update process is finished.401 Unauthorized
: If theAUTH
header is missing or incorrect.
- Description: Reranks the stocks in the database. Used by a weekly cron job.
- Headers:
AUTH
: The authorization key, should match theAUTH_KEY
environment variable.
- Response:
200 OK
: Returns a message indicating the re-rank process is finished.401 Unauthorized
: If theAUTH
header is missing or incorrect.
This project is licensed under the GPL-3.0 License - see the LICENSE file for details.
IntrinsIQ is not a financial advisor, nor is this meant to resemble any form of financial advice. Please consult a certified financial advisor before making any investment decisions and carry out your own due diligence.