Stock Tracker with Sentiment Analysis


Project codes are available at Github

This is a stock tracker app which implements sentiment analysis to capture the emotional pulse of the market. It analyses news headlines to provides insights into whether market sentiment is bullish, bearish, or neutral, thus helping investors to make informed decisions. It is built with React (frontend), NodeJS (backend) with SQL. Market data, including news on individual stocks are obtained from yahoo-finance2, a NodeJS library that interfaces with Yahoo Finance. Sentiment Analysis is powered by OpenAI's Large Language Model.

Adding stock entries

At its very basic, it allows the user to key in the stock symbol, quantity purchased and purchase amount. The stock symbols will need to match the ones used in Yahoo Finance. As an enhancement, the system could allow users to enter a stock name instead of its symbol, using a database or mapping table to convert stock names into their corresponding symbols.


directory-overview
Transaction form

Dashboard

On submitting the stock transaction, the dashboard will display the stock, quantity purchased, its purchase price and current price. The current prices are obtained from yfinance2, a Node.js library that provides an interface to Yahoo Finance's market data. It calculates the profit or loss for each stock in the stocks list. In addition, it calculates the overall profits/losses and percentage.


directory-overview
Dashboard

Sentiment Analysis

A special feature in this stock tracker is its ability to perform sentiment analysis on the user's stocks list. A sentiment analysis is as what it says; an analysis of sentiment towards something, which in this case is the stock itself. When the stock symbol in the stocks list is clicked, it retrieves a list of news articles for the chosen stock. The list of news articles is passed to OpenAI to perform analysis on the stocks' sentiment. The analysis is then returned to the user as seen below. Note that an OpenAI API key is required for it to work. Sentiment analysis, as the name suggests, evaluates the overall sentiment towards soemthing; in this case, a specific stock. When a stock symbol from the list is clicked, the application retrieves recent news articles related to that stock from yfinance2. These articles are then sent to OpenAI for sentiment analysis, which determines whether the sentiment is positive, negative, or neutral. The results are displayed to the user as shown below. An active OpenAI API key is required for this feature to function.


directory-overview
Sentiment analysis on Vanguard's S&P500 index fund

directory-overview
Sentiment analysis on Meta

directory-overview
Sentiment analysis on Lam Research Corp

Final thoughts

I started this project to experiment with sentiment analysis using OpenAI's model. In other words, we are trusting OpenAI's engine, a noteworthy choice given their position as an industry leader in AI technology. While the sentiment analysis itself is handled by OpenAI rather than being implemented in code, the project demonstrates how aggregated sentiment from multiple news sources can be analysed collectively to support trading decisions. Watch the YouTube video below for a walkthrough of the stock tracker app.