Stock Exploration, Technical Analysis and ML Forecasting
- all in one application!
1 Singapore Management Universtiy , MITB, ISSS608
Comparing the performance of many stocks can be time consuming, especially if you want to do it over and over again. With the help of R, Shiny and the availability of many open-source R packages, we developed a simple stock Analyzer- to do technical analysis and forecasting of a stock portfolio.
Figure 1: Three main modules
Our project will explore and develop an app for this using selected stocks from the US Stock Market.
Exploration: Exploratory Data Analysis explores the trends
of stock prices and transaction volumes using TIME SERIES
analysis. We select multiple stocks from different sectors and
compare them within the same selected time period.
Technical Analysis: Many investors analyze stocks based on their fundamentals such as their revenue, valuation, or
industry trends but fundamental factors aren’t always reflected in the market price. Technical analysis using charts
help to identify trading signals and price patterns and provides as a window into market psychology to identify opportunities to profit. We built this with the core functions from TidyQuant[Ref.1] to support
1. Getting Financial Data from the web
2. Manipulating Financial Data
3. Performance Analysis and Portfolio analysis
Forecasting : As a final feature, we build a forecasting flow for a stock incorporating a dashboard to train several ML models( up to 8 ) and the associated visualisation and performance matrix of the trained models, as well as the forecasts comparison for the stock.
Figure 2: Forecast process
EDA For Single Stocks and Portfolio of Stocks
Exploratory Data Analysis implements a view of 4 equal sections, each showing a different types of chart.The charts can work with both single stocks, and portfolio of stocks.
Figure 3: EDA Visualisation
Technical Analysis for a Single Stock:
Figure 4: Sample Visualisation for Single Stock
Technical Analysis for a Portfolio:
Figure 5: Sample Visualisation for Portfolio
Forecasting for A Single Stock
Figure 6: Sample Visualization of Forecast Model Outcomes
Figure 7: Sample Visulisation Model Performance
One of the most difficult challenge of building this application is designing the layout of all the components of a module. The application needs to find the right balance between showing too many visualizations, which can overwhelmed the users, and showing too little, which can make it harder to draw out meaningful insights.
To tackle this challenge, the use of more advanced Bootstrap features is needed, which allows the hiding and showing of different components, thus the users themselves can decide how many visualizations is suitable for them. The packages that enables these Bootstrap features are shinydashboard and shinydashboardplus.In implementing technical analysis, it was discovered that some tidy packages,lacked integration with plotly R package, which meant that interactivity was not possible with the chart. While convenient, there are some limitations to the timetk and modeltime packages, which can result in difficulties when trying to configure smaller details of the visualizations. In some cases, it might be better to modeltime purely for processing and training data purposes and plot the trained data from scratch using ggplot2 in order to get the desired visualization
In conclusion,leveraging the recenlty available R packages that have specialised/built in technical functions for Financial Analysis and Shiny, we can provide to the investor a easy interface to perform stock evaluation and analysis.
1.TidyQuant Project Website https://business-science.github.io/tidyquant/
2.Hyndman,R.J.,& Athanasopoulos,G(2021)Forecasting: principles and practice,3rd edition
Stock Exploration, Technical Analysis and ML Forecasting
- all in one application!