{"id":412,"date":"2023-04-01T23:08:00","date_gmt":"2023-04-01T15:08:00","guid":{"rendered":"https:\/\/philip.twinight.co\/portfolio\/?p=412"},"modified":"2024-03-07T00:12:13","modified_gmt":"2024-03-06T16:12:13","slug":"stock-market-price-trend-prediction-using-time-series-forecasting","status":"publish","type":"post","link":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/","title":{"rendered":"Stock Market Price Trend Prediction Using Time Series Forecasting"},"content":{"rendered":"\n<p>This is the group project of SDSC4107 \u2013 Financial Engineering and Analytics. I did the project in my year 3 2022\/23 Semester B.<\/p>\n\n\n\n<p><strong>Presentation Slides:<\/strong><\/p>\n\n\n<div class=\"ose-google-docs ose-uid-f3c52def11b0ae8ee8b696a9746e1a23 ose-embedpress-responsive\" style=\"width:600px; height:550px; max-height:550px; max-width:100%; display:inline-block;\" data-embed-type=\"GoogleDocs\"><iframe loading=\"lazy\" allowFullScreen=\"true\" src=\"https:\/\/docs.google.com\/presentation\/d\/e\/2PACX-1vQUBup5hX2DPLfpokSg9eh9ZWr2Nw5IYnHqtGHPSrPY9CyIFS7ASKa4WtFu4mTOEOYAIb0QpBLqnNKy\/embed?start=false&#038;loop=false&#038;delayms=3000\" frameborder=\"0\" width=\"600\" height=\"550\" allowfullscreen=\"true\" mozallowfullscreen=\"true\" webkitallowfullscreen=\"true\"><\/iframe><\/div>\n\n\n\n<p>Course Instructor: Dr. Qi WU<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Introduction\" >Introduction<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Methodology\" >Methodology<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Model_1_Autoregressive_Integrated_Moving_Average\" >Model 1: Autoregressive Integrated Moving Average<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Model_2_Long_Short-Term_Memory_Networks\" >Model 2: Long Short-Term Memory Networks<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Model_3_Multi-layer_Perceptron\" >Model 3: Multi-layer Perceptron<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Result_and_Discussion\" >Result and Discussion<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Model_1_Autoregressive_Integrated_Moving_Average-2\" >Model 1: Autoregressive Integrated Moving Average<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Model_2_Long_Short-Term_Memory_Networks-2\" >Model 2: Long Short-Term Memory Networks<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Model_3_Multi-layer_Perceptron-2\" >Model 3: Multi-layer Perceptron<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Limitations_and_Future_Studies\" >Limitations and Future Studies<\/a><ul class='ez-toc-list-level-2' ><li class='ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Limitation\" >Limitation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Future_Studies\" >Future Studies<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Conclusion\" >Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Reference\" >Reference<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#Code_Appendix\" >Code Appendix<\/a><\/li><\/ul><\/nav><\/div>\n<h1 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Introduction\"><\/span>Introduction<span class=\"ez-toc-section-end\"><\/span><\/h1>\n\n\n\n<p>This report focuses on the topic of \u201cStock market price trend prediction using time series forecasting.\u201d, which we focus on three major models, including autoregressive integrated moving average model (ARIMA), Long-Short-Term Memory model(LSTM) and Multi-layer model (MLP). The dataset used for this analysis is the Hang Seng Index (HSI) from the years 2010 to 2023. The dataset is loaded into Python, and libraries are imported for data manipulation, visualization, and modeling. <\/p>\n\n\n\n<p>Although the HSI is a widely used yardstick for measuring the performance of the Hong Kong stock market, predicting its future values can offer important clues about the state of the economy. Time series forecasting can assist traders and investors in deciding whether to buy or sell stocks in a way that will maximize portfolio returns. Forecasting can also be used to spot developing trends and market patterns, which helps financial analysts predict how the markets will behave in the future. By analyzing historical trends and identifying patterns, forecasting can assist in predicting future values, which can help to inform investment strategies and reduce risk. <\/p>\n\n\n\n<p>Forecasting can also give important insights into the underlying elements that influence the performance of the stock market, such as monetary indicators, political developments, and investor sentiment. Therefore, in this report, we try to analyze the performance of three different commonly used models, including ARIMA, LSTM and MLP, on HSI and examine the result using different measures. <\/p>\n\n\n\n<p>Time series forecasting on the HSI can offer insightful information about the stock market&#8217;s potential performance, helping investors make more accurate predictions about the future, make wise investment decisions and reduce investment risk. We therefore hope that our findings in this report can provide insight into each model&#8217;s market performance, the benefits of various time series forecasting models, and their application in practice. <\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Methodology\"><\/span>Methodology<span class=\"ez-toc-section-end\"><\/span><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Model_1_Autoregressive_Integrated_Moving_Average\"><\/span>Model 1: Autoregressive Integrated Moving Average <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The Autoregressive Integrated Moving Average (ARIMA) model is a popular linear time series forecasting model that combines autoregressive (AR) and moving average (MA) components with differencing to make the time series stationary. It is particularly suitable for univariate time series data with no obvious seasonal components. <\/p>\n\n\n\n<p>To forecast HSI prices using the ARIMA model, the following steps were carried out: <\/p>\n\n\n\n<p>Data Acquisition and Preprocessing: The historical HSI data was obtained from Yahoo Finance using the yfinance library. The dataset was resampled to averages every month and split into two sets, one for training (80% of the data) and another for testing (20% of the data). <\/p>\n\n\n\n<p>Splitting the dataset: The dataset is divided between training and testing sets, with the latest 30 months of data saved for testing. <\/p>\n\n\n\n<p>Model Selection: The auto_arima function from the pmdarima library was used to find the best-fitting ARIMA model based on the Akaike Information Criterion (AIC). The function performs a stepwise search for the optimal model, considering various combinations of p, d, and q parameters. <\/p>\n\n\n\n<p>Performing stepwise search to minimize aic ARIMA(0,2,0)(0,0,0)[0] intercept : AIC=322.554, Time=0.02 sec ARIMA(1,2,0)(0,0,0)[0] intercept : AIC=322.988, Time=0.03 sec ARIMA(0,2,1)(0,0,0)[0] intercept : AIC=323.177, Time=0.21 sec ARIMA(0,2,0)(0,0,0)[0] : AIC=320.573, Time=0.04 sec ARIMA(1,2,1)(0,0,0)[0] intercept  : AIC=324.773, Time=0.19 sec <\/p>\n\n\n\n<p>Best model: ARIMA(0,2,0)(0,0,0)[0] <\/p>\n\n\n\n<p>Total fit time: 0.519 seconds <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=441855221  fetchpriority=\"high\" loading=\"eager\" decoding=\"async\" width=\"1415\" height=\"686\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-1.jpeg\" alt=\"\" class=\"wp-image-413\" srcset=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:1415\/h:686\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-1.jpeg 1415w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:300\/h:145\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-1.jpeg 300w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:1024\/h:496\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-1.jpeg 1024w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:768\/h:372\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-1.jpeg 768w\" sizes=\"auto, (max-width: 792px) 100vw, 792px\" \/><\/figure>\n\n\n\n<p>Figure 1. ARIMA model summary <\/p>\n\n\n\n<p>Model Diagnostics: Once the optimal ARIMA model is selected, we perform diagnostic checks by plotting the residuals and analyzing their properties. This step ensures the model&#8217;s assumptions are not violated, and its performance is reliable. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=433529397  fetchpriority=\"high\" loading=\"eager\" decoding=\"async\" width=\"896\" height=\"496\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-2.png\" alt=\"\" class=\"wp-image-414\" srcset=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:896\/h:496\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-2.png 896w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:300\/h:166\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-2.png 300w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:768\/h:425\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-2.png 768w\" sizes=\"auto, (max-width: 792px) 100vw, 792px\" \/><\/figure>\n\n\n\n<p>Figure 2. ARIMA Model Diagnosis Diagram <\/p>\n\n\n\n<p>Model Evaluation: The ARIMA model is applied to the test dataset to forecast future HSI closing prices. We then evaluate the model&#8217;s accuracy by comparing its predictions to the actual HSI prices using performance metrics such as Root Mean Squared Error (RMSE) and Mean Absolute Percentage Error (MAPE). <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Model_2_Long_Short-Term_Memory_Networks\"><\/span>Model 2: Long Short-Term Memory Networks <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>LSTM is a type of Recurrent Neural Network (RNN) architecture that is particularly well-suited for handling time-series data. LSTM networks are designed to handle long-term dependencies, which makes them well-suited for time-series data where the order of events matters. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=781171991  loading=\"lazy\" decoding=\"async\" width=\"411\" height=\"455\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-3.png\" alt=\"\" class=\"wp-image-415\" srcset=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:411\/h:455\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-3.png 411w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:271\/h:300\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-3.png 271w\" sizes=\"auto, (max-width: 411px) 100vw, 411px\" \/><\/figure>\n\n\n\n<p>Figure 3. LSTM Model Summary The LSTM model used in this report consists of several layers: <\/p>\n\n\n\n<p>-Input layer: The input layer receives the input data, which in this case is the historical stock market prices. <\/p>\n\n\n\n<p>-LSTM layer: The LSTM layer is the core of the model. It consists of several memory cells, which allow the network to capture long-term dependencies in the data. Each memory cell has three gates: the input gate, forget gate, and output gate. These gates control the flow of information in and out of the memory cell. <\/p>\n\n\n\n<p>-Dense layer: The dense layer is a fully connected layer that maps the output of the LSTM layer to the output of the model. <\/p>\n\n\n\n<p>-Dropout layer: The dropout layer is used to prevent overfitting. It randomly drops out some of the neurons in the network during training, which helps to prevent the network from memorizing the training data. <\/p>\n\n\n\n<p>The LSTM model is trained using backpropagation through time (BPTT), which is a variant of the backpropagation algorithm that is designed for recurrent neural networks. During training, the model is presented with a sequence of historical stock market prices and asked to predict the next value in the sequence. The difference between the predicted value and the actual value is used to update the weights in the network, using gradient descent. <\/p>\n\n\n\n<p>It is also trained using the Adam optimizer, which is a popular optimization algorithm for training neural networks. The optimizer adjusts the learning rate during training, which helps to improve convergence. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=463648792  loading=\"lazy\" decoding=\"async\" width=\"430\" height=\"372\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-4.png\" alt=\"\" class=\"wp-image-416\" srcset=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:430\/h:372\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-4.png 430w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:300\/h:260\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-4.png 300w\" sizes=\"auto, (max-width: 430px) 100vw, 430px\" \/><\/figure>\n\n\n\n<p>Figure 4. Preprocessing HSI dataset <\/p>\n\n\n\n<p>The data is pre-processed by checking for null values using the isnull() function and dropping the rows containing null values using the dropna() function. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=1690520866  loading=\"lazy\" decoding=\"async\" width=\"959\" height=\"487\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-5.jpeg\" alt=\"\" class=\"wp-image-417\" srcset=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:959\/h:487\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-5.jpeg 959w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:300\/h:152\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-5.jpeg 300w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:768\/h:390\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-5.jpeg 768w\" sizes=\"auto, (max-width: 792px) 100vw, 792px\" \/><\/figure>\n\n\n\n<p>Figure 5. HSI stock analysis <\/p>\n\n\n\n<p>A time series plot is created to visualize the data. The plot shows the trend of the HSI over time, indicating a general downward trend with some fluctuations. <\/p>\n\n\n\n<p>The LSTM model is used for time series forecasting. The data is split into training and testing sets. The MinMaxScaler function is used for feature scaling. The LSTM model is trained on the training set using a sequential model with dense and dropout layers. The model is then evaluated on the testing set using the mean squared error (MSE) and mean absolute error (MAE) metrics. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Model_3_Multi-layer_Perceptron\"><\/span>Model 3: Multi-layer Perceptron <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The mechanism of MLP(Multi-Layer Perceptron): MLP model is a type of feedforward neural network that consists of multiple layers of artificial neurons and organized in a sequence. Each neuron in the network receives input from the previous <\/p>\n\n\n\n<p>layer and passes output to the next layer until the final output layer produces the predicted result. <\/p>\n\n\n\n<p>The MLP model is a supervised learning algorithm that is commonly used for regression and classification tasks, including image and speech recognition, natural language processing, and most importantly, financial forecasting. It is a powerful tool for capturing complex nonlinear relationships between inputs and outputs, making it particularly useful in applications where traditional linear models may not be sufficient. Therefore in this project, we use it as a tool to forecast the HSI. <\/p>\n\n\n\n<p>Before performing MLP, as we only obtain numeric data from the dataset, we set the \u201cclosing price\u201d as our target attribute, and there are in total 2518 input parameters for training the model. The following are the null values in the dataset. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=2144043601  loading=\"lazy\" decoding=\"async\" width=\"156\" height=\"143\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-6.jpeg\" alt=\"\" class=\"wp-image-418\"\/><\/figure>\n\n\n\n<p>Figure 6. Dataset Null value <\/p>\n\n\n\n<p>After dropping the null value, we started to construct our model. It is constructed of 3 dense layers, and 2 dropout layers. While the dense layer is a layer that is deeply connected with its preceding layer which means it maps all the output of its previous layer and used to change the dimension of the vectors using every neuron. In the model, the first two 2 RELU functions and the last one are linear as to give weight to the remaining 65 parameters. For the dropout layer, it is used to prevent overfitting. By randomly dropping out some neurons from the previous layer, the influence of the training data can be minimized. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=254791903  loading=\"lazy\" decoding=\"async\" width=\"366\" height=\"223\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-7.png\" alt=\"\" class=\"wp-image-419\" srcset=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:366\/h:223\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-7.png 366w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:300\/h:183\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-7.png 300w\" sizes=\"auto, (max-width: 366px) 100vw, 366px\" \/><\/figure>\n\n\n\n<p>Figure 7. MLP Model Summary <\/p>\n\n\n\n<p>The dataset is split into two sets, one for training (67% of the data) and another for testing (33% of the data). We set the step-back function in the model to be in 3 days, which means each prediction is 3 days after the training days, each day is predicted using the sum of its previous record to estimate the result, which below is the graph of the prediction we draw from the model. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=1311101798  loading=\"lazy\" decoding=\"async\" width=\"314\" height=\"200\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-8.jpeg\" alt=\"\" class=\"wp-image-420\" srcset=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:314\/h:200\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-8.jpeg 314w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:300\/h:191\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-8.jpeg 300w\" sizes=\"auto, (max-width: 314px) 100vw, 314px\" \/><\/figure>\n\n\n\n<p>Figure 8. MLP Model prediction <\/p>\n\n\n\n<p>Multilayer Perceptron improved from the simple perceptron model which can only work with one neuron and understand linear relationship between input and output, with MLP, the horizons are expanded and now can have many layers of neurons, and are capable of learning more complex patterns. <\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Result_and_Discussion\"><\/span>Result and Discussion<span class=\"ez-toc-section-end\"><\/span><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Model_1_Autoregressive_Integrated_Moving_Average-2\"><\/span>Model 1: Autoregressive Integrated Moving Average <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>After implementing the ARIMA model, the &#8216;auto_arima&#8217; function identified the best model as ARIMA(0,2,0), based on the lowest AIC value. The diagnostic plots indicated that the model&#8217;s residuals were approximately normally distributed with no apparent autocorrelation, suggesting the model is a good fit for the data. <\/p>\n\n\n\n<p>Upon applying the ARIMA model to the test dataset, we generated a time series plot that displayed the actual HSI prices, the predicted prices, and the corresponding 95% confidence intervals. The visual inspection of the plot reveals that the ARIMA model captures the overall trend of the HSI, although it may not precisely predict the short-term fluctuations. <\/p>\n\n\n\n<p>Prediction Result\uff1a <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=2106234611  loading=\"lazy\" decoding=\"async\" width=\"1023\" height=\"463\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-9.png\" alt=\"\" class=\"wp-image-421\" srcset=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:1023\/h:463\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-9.png 1023w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:300\/h:136\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-9.png 300w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:768\/h:348\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-9.png 768w\" sizes=\"auto, (max-width: 792px) 100vw, 792px\" \/><\/figure>\n\n\n\n<p>Figure 9. ARIMA Prediction Result <\/p>\n\n\n\n<p>To further assess the model&#8217;s performance, we computed the RMSE and MAPE values. The RMSE value was found to be 2718.10, while the MAPE value was 11.97%. These metrics show that the ARIMA model provides a reasonably accurate forecast of the HSI closing p <\/p>\n\n\n\n<p>In this report, we applied the ARIMA model to forecast HSI prices and assessed its performance using the RMSE and MAPE metrics. The results show that the ARIMA model is capable of capturing the general trend of the HSI prices, but further improvements could be made by incorporating additional factors or using more advanced time-series models, such as LSTM or MLP. Overall, the ARIMA model can serve as a useful tool for HSI price prediction when used in combination with other analysis methods. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Model_2_Long_Short-Term_Memory_Networks-2\"><\/span>Model 2: Long Short-Term Memory Networks <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=1196752208  loading=\"lazy\" decoding=\"async\" width=\"904\" height=\"428\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-10.jpeg\" alt=\"\" class=\"wp-image-422\" srcset=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:904\/h:428\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-10.jpeg 904w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:300\/h:142\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-10.jpeg 300w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:768\/h:364\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-10.jpeg 768w\" sizes=\"auto, (max-width: 792px) 100vw, 792px\" \/><\/figure>\n\n\n\n<p>Figure 10. LSTM model prediction results <\/p>\n\n\n\n<p>In this report, the LSTM model is trained on a training set of historical stock market prices, and the performance of the model is evaluated on a testing set. The mean squared error (MSE) and mean absolute error (MAE) are used as evaluation metrics. These metrics quantify the difference between the predicted values and the actual values, with lower values indicating better performance. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=857479247  loading=\"lazy\" decoding=\"async\" width=\"343\" height=\"48\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-11.png\" alt=\"\" class=\"wp-image-423\" srcset=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:343\/h:48\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-11.png 343w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:300\/h:42\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-11.png 300w\" sizes=\"auto, (max-width: 343px) 100vw, 343px\" \/><\/figure>\n\n\n\n<p>Figure 11. MSE, MAE and Root MSE results <\/p>\n\n\n\n<p>The mean squared error (MSE) and mean absolute error (MAE) for the testing set are calculated as 997566.67 and 826.06, respectively. The model performs not bad, it somehow captures the overall trend of HSI which is indicating that the LSTM model can also be used for time series forecasting of stock market prices. <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=1410163269  loading=\"lazy\" decoding=\"async\" width=\"2034\" height=\"1014\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-12.png\" alt=\"\" class=\"wp-image-424\" srcset=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:1920\/h:957\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-12.png 2034w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:300\/h:150\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-12.png 300w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:1024\/h:510\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-12.png 1024w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:768\/h:383\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-12.png 768w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:1536\/h:766\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-12.png 1536w\" sizes=\"auto, (max-width: 792px) 100vw, 792px\" \/><\/figure>\n\n\n\n<p>Figure 12. Plotting simple HSI trend <\/p>\n\n\n\n<p>The time series plot shows that the HSI has experienced an overall downward trend with some fluctuations. The fluctuations in the HSI can be attributed to various factors, such as changes in economic policies, geopolitical tensions, and natural disasters. <\/p>\n\n\n\n<p>Overall, this report shows that time series forecasting using LSTM models can be an effective method for predicting stock market prices. It is important to note that other factors beyond time series data can also influence stock market prices, and therefore, predictions made using time series models should be used in conjunction with other analysis methods. <\/p>\n\n\n\n<p>Compared to other machine learning models like MLP (Multi-Layer Perceptron) or ARIMA (AutoRegressive Integrated Moving Average), LSTM models are generally better suited for time-series forecasting tasks because: <\/p>\n\n\n\n<p>\n  They can handle variable-length input sequences: In time-series forecasting, the length of the input sequence (i.e., the historical data) can vary depending on the forecasting horizon. LSTM models can handle variable-length input sequences, making them more flexible than models that require a fixed-length input.\n<\/p>\n\n\n\n<p>They can capture long-term dependencies: Time-series data often involves complex dependencies between past and future values. LSTM models are designed to capture these dependencies, making them more effective at modeling complex patterns in the data. <\/p>\n\n\n\n<p>They can handle nonlinear relationships: Time-series data often involves non-linear relationships between past and future values. LSTM models are capable of modeling these non-linear relationships, making them more effective than linear models like ARIMA. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Model_3_Multi-layer_Perceptron-2\"><\/span>Model 3: Multi-layer Perceptron <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>For the prediction result, after testing, we find that the model perform best with 200 epochs with batch size of 2, which means the algorithm takes the first 2 samples from the training dataset each time to trains the network and take the next two, which is the third and the fourth in training the network again, so it is relatively computational expensive. The following are the result, <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img data-opt-id=544470184  loading=\"lazy\" decoding=\"async\" width=\"465\" height=\"477\" src=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-13.jpeg\" alt=\"\" class=\"wp-image-425\" srcset=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:465\/h:477\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-13.jpeg 465w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:292\/h:300\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-13.jpeg 292w, https:\/\/mlcznkdztmb6.i.optimole.com\/w:50\/h:50\/q:mauto\/f:best\/ig:avif\/dpr:2\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/word-image-412-13.jpeg 50w\" sizes=\"auto, (max-width: 465px) 100vw, 465px\" \/><\/figure>\n\n\n\n<p>Figure 13. Plotting MLP model prediction trend <\/p>\n\n\n\n<p>With the loss of 14092188 when entering the epoch 200, as the number shows, both the training and testing MSE lie in a stable range, which is around 2500 RMSE. Besides, from the graph, it can be seen that the prediction on the both the training and the testing set is lower than the true index, it may due to the initiate point of the weighting parameter is from zero, and with the 2 drop-out function in the model, the overfit problem is solved, but also result in the low training and testing score. The model takes 413 seconds in computing, which is expensive as it is in batch size of 2. <\/p>\n\n\n\n<p>Lastly, as the graph shows, the prediction has the RMSE of 2677 even in predicting the 3 days result. It can be clearly shown that there are still a lot of adjustments that need to be made if we want to make profit using the MLP model in predicting the actual market stock price. <\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Limitations_and_Future_Studies\"><\/span>Limitations and Future Studies<span class=\"ez-toc-section-end\"><\/span><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Limitation\"><\/span>Limitation<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Despite the promising results obtained by the three models we built in this report, there are still some limitations that need to be acknowledged. One of the main limitations is the assumption that the future behavior of the HSI index will follow the patterns observed in the past data. However, the financial market is notoriously unpredictable, and it is important to take into account all external factors when making predictions based on time-series data. <\/p>\n\n\n\n<p>Another limitation is the reliance on a single indicator, such as the MSE or MAE, to evaluate the performance of our models. While these indicators can provide useful information about the accuracy of the models, they do not necessarily capture all aspects of model performance that are relevant in real-world financial applications. For instance, a model with low MSE or MAE may still be unsuitable for trading if it leads to unprofitable decisions. <\/p>\n\n\n\n<p>Furthermore, the report only considers a single input dataset, namely the HSI index. However, it is well known that the behavior of the financial market is influenced by multiple factors, such as different interest rates, and the types of commodities etc. <\/p>\n\n\n\n<p>Therefore, future studies should explore the use of multiple input dataset or variables to capture the complexity of the financial market. For example, adding different types of financial products such as futures, forex or bonds to be the input dataset can also be some good choices. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Future_Studies\"><\/span>Future Studies<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>One possible avenue for future research is to investigate alternative deep learning models that can handle complex time-series data, such as Convolutional Neural Networks (CNNs) or Transformer models. These models have shown promising results in other domains, such as computer vision and natural language processing, and may provide new insights into the patterns of financial market data. <\/p>\n\n\n\n<p>Another area for future research is to investigate the use of alternative performance metrics that capture other aspects of model performance that are relevant in financial applications. For instance, metrics such as the Sharpe ratio, the Sortino ratio, or the maximum drawdown can provide a more comprehensive evaluation of the model&#8217;s suitability for trading. <\/p>\n\n\n\n<p>Moreover, future studies should also explore the use of multiple input variables to capture the complexity of the financial market. For instance, incorporating economic indicators, such as interest rates and inflation rates, may improve the accuracy of the model&#8217;s predictions and lead to more profitable trading decisions. <\/p>\n\n\n\n<p>Finally, it is important to validate the performance of our models on out-of-sample data, that is, data that was not used in the training or testing phase. This will provide a more accurate estimate of the model&#8217;s generalization ability and its suitability for real-world financial applications. <\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h1>\n\n\n\n<p>In this report, we have compared the performance of three different time series forecasting models, including ARIMA, LSTM, and MLP, on the Hang Seng Index (HSI) dataset from 2010 to 2023. We have assessed the performance of these models using various evaluation metrics, such as RMSE, MAPE, MSE, and MAE. <\/p>\n\n\n\n<p>The results showed that all three models could capture the overall trend of the HSI, but LSTM and MLP models outperformed the ARIMA model significantly. The LSTM and MLP models&#8217; advantages lie in their ability to handle variable-length input sequences, capture long-term dependencies, and manage nonlinear interactions. Besides, MLP models can handle vast amounts of data, including category and numerical variables, making them helpful for capturing various input features that can impact stock prices. <\/p>\n\n\n\n<p>However, it is crucial to recognize the models&#8217; limitations and consider any outside factors that may affect financial market behavior. To create models that are more appropriate for real-world financial applications and capture the complexity of the financial market, future studies should explore the use of different input datasets or variables. <\/p>\n\n\n\n<p>In conclusion, using LSTM and MLP models for time series forecasting can provide useful insights into market trends and prospective stock price movements. Investors can benefit from these models when combined with other analytical methods, as they can help make informed decisions and reduce risk. <\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Reference\"><\/span>Reference<span class=\"ez-toc-section-end\"><\/span><\/h1>\n\n\n\n<p>Hochreiter, S., &amp; Schmidhuber, J. (1997). Long short-term memory. Neural computation, 9(8), 1735-1780. <\/p>\n\n\n\n<p>Brownlee, J. (2018). Time series forecasting with Python: Discover the new way to analyze data and make predictions. Machine Learning Mastery. <\/p>\n\n\n\n<p>Bengio, Y., Simard, P., &amp; Frasconi, P. (1994). Learning long-term dependencies with gradient descent is difficult. IEEE Transactions on Neural Networks, 5(2), 157-166. https:\/\/doi.org\/10.1109\/72.279181 <\/p>\n\n\n\n<p>Brownlee, J. (2020). How to Develop LSTM Models for Time Series Forecasting. Machine Learning Mastery. https:\/\/machinelearningmastery.com\/how-to-develop-lstm-models-for-time-series-forecasting\/ Chollet, F. (2018). Deep learning with Python. Manning Publications. <\/p>\n\n\n\n<p>Hochreiter, S., &amp; Schmidhuber, J. (1997). Long short-term memory. Neural Computation, 9(8), 1735-1780. https:\/\/doi.org\/10.1162\/neco.1997.9.8.1735 <\/p>\n\n\n\n<p>Lipton, Z. C., Berkowitz, J., &amp; Elkan, C. (2015). A critical review of recurrent neural networks for sequence learning. arXiv preprint arXiv:1506.00019. <\/p>\n\n\n\n<p>Patan\u00e8, G., &amp; Maringhini, G. (2021). Stock Market Prediction Using Deep Learning Techniques: A Survey. Journal of Risk and Financial Management, 14(3), 107. https:\/\/doi.org\/10.3390\/jrfm14030107 <\/p>\n\n\n\n<p>Yao, L., &amp; Deng, S. (2020). A comparative study on time series forecasting using deep learning approaches. Journal of Forecasting, 39(4), 606-618. https:\/\/doi.org\/10.1002\/for.2655 <\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Code_Appendix\"><\/span>Code Appendix<span class=\"ez-toc-section-end\"><\/span><\/h1>\n\n\n\n<p>ARIMA:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Import necessary libraries\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport yfinance as yf\nfrom pmdarima.arima import auto_arima\nfrom sklearn.metrics import mean_squared_error\n\n# Download and preprocess the data\nhsi = yf.download('^HSI', start='2019-02-23', end='2023-03-23')\nhsi = hsi&#x5B;'Close'].resample('M').mean()  # Resample the data by month\n\n# Split the data into training and test sets\ntrain_data = hsi&#x5B;:int(0.8 * len(hsi))]\ntest_data = hsi&#x5B;int(0.8 * len(hsi)):]\n\n# Fit the ARIMA model\nmodel_autoARIMA = auto_arima(train_data, trace=True, suppress_warnings=True)\nfitted = model_autoARIMA.fit(train_data)\n\n# Make predictions\nfc, conf_int = fitted.predict(n_periods=len(test_data), return_conf_int=True, alpha=0.05)\nfc_series = pd.Series(fc, index=test_data.index)\nlower_series = pd.Series(conf_int&#x5B;:, 0], index=test_data.index)\nupper_series = pd.Series(conf_int&#x5B;:, 1], index=test_data.index)\n\n# Plot the results\nplt.figure(figsize=(12, 5), dpi=100)\nplt.plot(train_data, label='Training')\nplt.plot(test_data, color='blue', label='Actual HSI Price')\nplt.plot(fc_series, color='orange', label='Predicted HSI Price')\nplt.fill_between(lower_series.index, lower_series, upper_series, color='k', alpha=.100)\nplt.title('HSI Price Prediction')\nplt.xlabel('Time')\nplt.ylabel('HSI Price')\nplt.legend(loc='upper left', fontsize=8)\nplt.show()\n\n# Calculate performance metrics\nrmse = np.sqrt(mean_squared_error(test_data, fc_series))\nprint(f'RMSE: {rmse:.2f}')\nmape = np.mean(np.abs((test_data - fc_series) \/ test_data)) * 100\nprint(f'MAPE: {mape:.2f}%')\n<\/pre><\/div>\n\n\n<p>LSTM:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom sklearn.preprocessing import MinMaxScaler\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense, LSTM, Dropout\n\n# Load the data\ndf = pd.read_csv('HSI.csv')\ndf.set_index('Date', inplace=True)\n\n# Visualize the closing price history\nplt.figure(figsize=(16, 8))\nplt.title('Close Price History')\nplt.plot(df&#x5B;'Close'])\nplt.xlabel('Date', fontsize=18)\nplt.ylabel('Close Price USD ($)', fontsize=18)\nplt.show()\n\n# Create a new dataframe with only the 'Close' column\ndata = df.filter(&#x5B;'Close'])\n\n# Convert the dataframe to a numpy array\ndataset = data.values\n\n# Get the number of rows to train the model on\ntraining_data_len = int(np.ceil(len(dataset) * .95))\n\n# Scale the data\nscaler = MinMaxScaler(feature_range=(0, 1))\nscaled_data = scaler.fit_transform(dataset)\n\n# Create the training data set\ntrain_data = scaled_data&#x5B;0:int(training_data_len), :]\nx_train = &#x5B;]\ny_train = &#x5B;]\n\nfor i in range(60, len(train_data)):\n    x_train.append(train_data&#x5B;i-60:i, 0])\n    y_train.append(train_data&#x5B;i, 0])\n        \nx_train, y_train = np.array(x_train), np.array(y_train)\n\n# Reshape the data\nx_train = np.reshape(x_train, (x_train.shape&#x5B;0], x_train.shape&#x5B;1], 1))\n\n# Build the LSTM model\nmodel = Sequential()\nmodel.add(LSTM(50, return_sequences=True, input_shape=(x_train.shape&#x5B;1], 1)))\nmodel.add(LSTM(50, return_sequences=False))\nmodel.add(Dense(25))\nmodel.add(Dense(1))\n\n# Compile the model\nmodel.compile(optimizer='adam', loss='mean_squared_error')\n\n# Train the model\nmodel.fit(x_train, y_train, batch_size=1, epochs=1)\n\n# Create the testing data set\ntest_data = scaled_data&#x5B;training_data_len - 60:, :]\nx_test = &#x5B;]\ny_test = dataset&#x5B;training_data_len:, :]\n\nfor i in range(60, len(test_data)):\n    x_test.append(test_data&#x5B;i-60:i, 0])\n\n# Convert the data to a numpy array\nx_test = np.array(x_test)\n\n# Reshape the data\nx_test = np.reshape(x_test, (x_test.shape&#x5B;0], x_test.shape&#x5B;1], 1 ))\n\n# Get the models predicted price values \npredictions = model.predict(x_test)\npredictions = scaler.inverse_transform(predictions)\n\n# Get the root mean squared error (RMSE)\nrmse = np.sqrt(np.mean(((predictions - y_test) ** 2)))\nprint('RMSE:', rmse)\n\n# Plot the data\ntrain = data&#x5B;:training_data_len]\nvalid = data&#x5B;training_data_len:]\nvalid&#x5B;'Predictions'] = predictions\n\n# Visualize the data\nplt.figure(figsize=(16,8))\nplt.title('Model')\nplt.xlabel('Date', fontsize=18)\nplt.ylabel('Close Price USD ($)', fontsize=18)\nplt.plot(train&#x5B;'Close'])\nplt.plot(valid&#x5B;&#x5B;'Close', 'Predictions']])\nplt.legend(&#x5B;'Train', 'Val', 'Predictions'], loc='lower right')\nplt.show()\n<\/pre><\/div>\n\n\n<p>MLP:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ndef MLP():\n    # Print title\n    print()\n    print(format('How to predict a timeseries using Multi Layer Perceptron in Keras', '*^92'))\n\n    # Import necessary libraries\n    import pandas as pd\n    import time\n    import numpy as np\n    from keras.layers.core import Dense, Dropout\n    from keras.models import Sequential\n    import matplotlib.pyplot as plt\n\n    # Start timer\n    start_time = time.time()\n\n    # Load the dataset\n    dataframe = pd.read_csv('\/content\/^HSI (4).csv', usecols=&#x5B;1], engine='python', skipfooter=3)\n    dataframe.replace(&#x5B;np.inf, -np.inf], np.nan, inplace=True)\n    dataframe.dropna(inplace=True)\n    dataset = dataframe.values\n    dataset = dataset.astype('float32')\n\n    # Split into train and test sets\n    train_size = int(len(dataset) * 0.67)\n    train_dataset, test_dataset = dataset&#x5B;0:train_size, :], dataset&#x5B;train_size:len(dataset), :]\n\n    # Window -&gt; X timestep back\n    step_back = 3\n    X_train, Y_train = &#x5B;], &#x5B;]\n    for i in range(len(train_dataset) - step_back - 1):\n        a = train_dataset&#x5B;i:(i + step_back), 0]\n        X_train.append(a)\n        Y_train.append(train_dataset&#x5B;i + step_back, 0])\n    X_train = np.array(X_train)\n    Y_train = np.array(Y_train)\n\n    X_test, Y_test = &#x5B;], &#x5B;]\n    for i in range(len(test_dataset) - step_back - 1):\n        a = test_dataset&#x5B;i:(i + step_back), 0]\n        X_test.append(a)\n        Y_test.append(test_dataset&#x5B;i + step_back, 0])\n    X_test = np.array(X_test)\n    Y_test = np.array(Y_test)\n\n    # Set up a MLP network in Keras\n    model = Sequential()\n    model.add(Dense(units=128, input_dim=step_back, activation='relu'))\n    model.add(Dropout(0.2))\n    model.add(Dense(units=64, input_dim=step_back, activation='relu'))\n    model.add(Dropout(0.2))\n    model.add(Dense(units=1, activation='linear'))\n    model.summary()\n    model.compile(loss='mean_squared_error', optimizer='rmsprop')\n    model.fit(X_train, Y_train, epochs=200, batch_size=2, verbose=1)\n\n    # Estimate model performance\n    print()\n    trainScore = model.evaluate(X_train, Y_train, verbose=1)\n    print('Train Score: %.2f MSE (%.2f RMSE)' % (trainScore, np.sqrt(trainScore)))\n    testScore = model.evaluate(X_test, Y_test, verbose=1)\n    print('Test Score: %.2f MSE (%.2f RMSE)' % (testScore, np.sqrt(testScore)))\n\n    # Evaluate the skill of the trained model\n    trainPredict = np.array(model.predict(X_train))\n    trainPredict = np.reshape(trainPredict, (len(trainPredict), 1))\n    testPredict = np.array(model.predict(X_test))\n    testPredict = np.reshape(testPredict, (len(testPredict), 1))\n\n    # Shift train predictions for plotting\n    trainPredictPlot = np.empty_like(dataset)\n    trainPredictPlot&#x5B;:, :] = np.nan\n    trainPredictPlot&#x5B;step_back:len(trainPredict) + step_back, :] = trainPredict\n\n    # Shift test predictions for plotting\n    testPredictPlot = np.empty_like(dataset)\n    testPredictPlot&#x5B;:, :] = np.nan\n    testPredictPlot&#x5B;len(trainPredict) + (step_back * 2) + 1:len(dataset) - 1, :] = testPredict\n\n    # Plot baseline and predictions\n    plt.plot(dataset)\n    plt.plot(trainPredictPlot, label=&quot;True&quot;)\n    plt.plot(testPredictPlot, label=&quot;Prediction&quot;)\n    plt.ylabel('Stock price')\n    plt.legend()\n    plt.show()\n\n    # Print execution time\n    print()\n    print(&quot;Execution Time %s seconds: &quot; % (time.time() - start_time))\n\nMLP()\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>This is the group project of SDSC4107 \u2013 Financial Engineering and Analytics. I did the project in my year 3 2022\/23 Semester B. Presentation Slides: Course Instructor: Dr. Qi WU &hellip; <a href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/\" class=\"more-link\"><span>Continue reading<span class=\"screen-reader-text\">Stock Market Price Trend Prediction Using Time Series Forecasting<\/span><\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":426,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,71],"tags":[39,13,41,40],"class_list":["post-412","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-proj","category-quant-finance-trading","tag-2022-23-semester-b","tag-data-science","tag-financial-engineering-and-analytics","tag-sdsc4016"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Stock Market Price Trend Prediction Using Time Series Forecasting - Philip\u2019s Data Science Diary<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Stock Market Price Trend Prediction Using Time Series Forecasting - Philip\u2019s Data Science Diary\" \/>\n<meta property=\"og:description\" content=\"This is the group project of SDSC4107 \u2013 Financial Engineering and Analytics. I did the project in my year 3 2022\/23 Semester B. Presentation Slides: Course Instructor: Dr. Qi WU &hellip; Continue readingStock Market Price Trend Prediction Using Time Series Forecasting\" \/>\n<meta property=\"og:url\" content=\"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/\" \/>\n<meta property=\"og:site_name\" content=\"Philip\u2019s Data Science Diary\" \/>\n<meta property=\"article:published_time\" content=\"2023-04-01T15:08:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-06T16:12:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/Time-Series-Forecasting-for-Stock-Prices.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Philip\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Philip\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/\"},\"author\":{\"name\":\"Philip\",\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/#\\\/schema\\\/person\\\/ef4f7cedd9b3bde11e126c4dbe1f8414\"},\"headline\":\"Stock Market Price Trend Prediction Using Time Series Forecasting\",\"datePublished\":\"2023-04-01T15:08:00+00:00\",\"dateModified\":\"2024-03-06T16:12:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/\"},\"wordCount\":3172,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/#\\\/schema\\\/person\\\/ef4f7cedd9b3bde11e126c4dbe1f8414\"},\"image\":{\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\/\\/philip.twinight.co\\/portfolio\\/wp-content\\/uploads\\/2024\\/03\\/Time-Series-Forecasting-for-Stock-Prices.png\",\"keywords\":[\"2022\\\/23 Semester B\",\"Data Science\",\"Financial Engineering and Analytics\",\"SDSC4016\"],\"articleSection\":[\"Projects\",\"Quant Finance &amp; Trading\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/\",\"url\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/\",\"name\":\"Stock Market Price Trend Prediction Using Time Series Forecasting - Philip\u2019s Data Science Diary\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\/\\/philip.twinight.co\\/portfolio\\/wp-content\\/uploads\\/2024\\/03\\/Time-Series-Forecasting-for-Stock-Prices.png\",\"datePublished\":\"2023-04-01T15:08:00+00:00\",\"dateModified\":\"2024-03-06T16:12:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/#primaryimage\",\"url\":\"https:\\/\\/philip.twinight.co\\/portfolio\\/wp-content\\/uploads\\/2024\\/03\\/Time-Series-Forecasting-for-Stock-Prices.png\",\"contentUrl\":\"https:\\/\\/philip.twinight.co\\/portfolio\\/wp-content\\/uploads\\/2024\\/03\\/Time-Series-Forecasting-for-Stock-Prices.png\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/2023\\\/04\\\/01\\\/stock-market-price-trend-prediction-using-time-series-forecasting\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9801\",\"item\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Stock Market Price Trend Prediction Using Time Series Forecasting\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/#website\",\"url\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/\",\"name\":\"Philip\u2019s University Data Science Journey\",\"description\":\"Navigating Data Science: From Classroom to Career\",\"publisher\":{\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/#\\\/schema\\\/person\\\/ef4f7cedd9b3bde11e126c4dbe1f8414\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/#\\\/schema\\\/person\\\/ef4f7cedd9b3bde11e126c4dbe1f8414\",\"name\":\"Philip\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\/\\/philip.twinight.co\\/portfolio\\/wp-content\\/uploads\\/2024\\/03\\/favicon.png\",\"url\":\"https:\\/\\/philip.twinight.co\\/portfolio\\/wp-content\\/uploads\\/2024\\/03\\/favicon.png\",\"contentUrl\":\"https:\\/\\/philip.twinight.co\\/portfolio\\/wp-content\\/uploads\\/2024\\/03\\/favicon.png\",\"width\":16,\"height\":16,\"caption\":\"Philip\"},\"logo\":{\"@id\":\"https:\\/\\/philip.twinight.co\\/portfolio\\/wp-content\\/uploads\\/2024\\/03\\/favicon.png\"},\"description\":\"Data Scientist &amp; Systems Engineer. Graduated from City University of Hong Kong. Previously founded Twinight Limited as CTO, developing AI investment analytics and automated trading solutions. Currently working as a Test and Integration Engineer on a Vessel Traffic Service (VTS) system in the maritime industry since December 2024.\",\"sameAs\":[\"https:\\\/\\\/philip.twinight.co\\\/portfolio\"],\"url\":\"https:\\\/\\\/philip.twinight.co\\\/portfolio\\\/index.php\\\/author\\\/philip\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Stock Market Price Trend Prediction Using Time Series Forecasting - Philip\u2019s Data Science Diary","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/","og_locale":"en_GB","og_type":"article","og_title":"Stock Market Price Trend Prediction Using Time Series Forecasting - Philip\u2019s Data Science Diary","og_description":"This is the group project of SDSC4107 \u2013 Financial Engineering and Analytics. I did the project in my year 3 2022\/23 Semester B. Presentation Slides: Course Instructor: Dr. Qi WU &hellip; Continue readingStock Market Price Trend Prediction Using Time Series Forecasting","og_url":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/","og_site_name":"Philip\u2019s Data Science Diary","article_published_time":"2023-04-01T15:08:00+00:00","article_modified_time":"2024-03-06T16:12:13+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/Time-Series-Forecasting-for-Stock-Prices.png","type":"image\/png"}],"author":"Philip","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Philip","Estimated reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#article","isPartOf":{"@id":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/"},"author":{"name":"Philip","@id":"https:\/\/philip.twinight.co\/portfolio\/#\/schema\/person\/ef4f7cedd9b3bde11e126c4dbe1f8414"},"headline":"Stock Market Price Trend Prediction Using Time Series Forecasting","datePublished":"2023-04-01T15:08:00+00:00","dateModified":"2024-03-06T16:12:13+00:00","mainEntityOfPage":{"@id":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/"},"wordCount":3172,"commentCount":0,"publisher":{"@id":"https:\/\/philip.twinight.co\/portfolio\/#\/schema\/person\/ef4f7cedd9b3bde11e126c4dbe1f8414"},"image":{"@id":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#primaryimage"},"thumbnailUrl":"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/Time-Series-Forecasting-for-Stock-Prices.png","keywords":["2022\/23 Semester B","Data Science","Financial Engineering and Analytics","SDSC4016"],"articleSection":["Projects","Quant Finance &amp; Trading"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/","url":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/","name":"Stock Market Price Trend Prediction Using Time Series Forecasting - Philip\u2019s Data Science Diary","isPartOf":{"@id":"https:\/\/philip.twinight.co\/portfolio\/#website"},"primaryImageOfPage":{"@id":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#primaryimage"},"image":{"@id":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#primaryimage"},"thumbnailUrl":"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/Time-Series-Forecasting-for-Stock-Prices.png","datePublished":"2023-04-01T15:08:00+00:00","dateModified":"2024-03-06T16:12:13+00:00","breadcrumb":{"@id":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#primaryimage","url":"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/Time-Series-Forecasting-for-Stock-Prices.png","contentUrl":"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/Time-Series-Forecasting-for-Stock-Prices.png","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/philip.twinight.co\/portfolio\/index.php\/2023\/04\/01\/stock-market-price-trend-prediction-using-time-series-forecasting\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9801","item":"https:\/\/philip.twinight.co\/portfolio\/"},{"@type":"ListItem","position":2,"name":"Stock Market Price Trend Prediction Using Time Series Forecasting"}]},{"@type":"WebSite","@id":"https:\/\/philip.twinight.co\/portfolio\/#website","url":"https:\/\/philip.twinight.co\/portfolio\/","name":"Philip\u2019s University Data Science Journey","description":"Navigating Data Science: From Classroom to Career","publisher":{"@id":"https:\/\/philip.twinight.co\/portfolio\/#\/schema\/person\/ef4f7cedd9b3bde11e126c4dbe1f8414"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/philip.twinight.co\/portfolio\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":["Person","Organization"],"@id":"https:\/\/philip.twinight.co\/portfolio\/#\/schema\/person\/ef4f7cedd9b3bde11e126c4dbe1f8414","name":"Philip","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/favicon.png","url":"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/favicon.png","contentUrl":"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/favicon.png","width":16,"height":16,"caption":"Philip"},"logo":{"@id":"https:\/\/mlcznkdztmb6.i.optimole.com\/w:auto\/h:auto\/q:mauto\/f:best\/ig:avif\/https:\/\/philip.twinight.co\/portfolio\/wp-content\/uploads\/2024\/03\/favicon.png"},"description":"Data Scientist &amp; Systems Engineer. Graduated from City University of Hong Kong. Previously founded Twinight Limited as CTO, developing AI investment analytics and automated trading solutions. Currently working as a Test and Integration Engineer on a Vessel Traffic Service (VTS) system in the maritime industry since December 2024.","sameAs":["https:\/\/philip.twinight.co\/portfolio"],"url":"https:\/\/philip.twinight.co\/portfolio\/index.php\/author\/philip\/"}]}},"_links":{"self":[{"href":"https:\/\/philip.twinight.co\/portfolio\/index.php\/wp-json\/wp\/v2\/posts\/412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/philip.twinight.co\/portfolio\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/philip.twinight.co\/portfolio\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/philip.twinight.co\/portfolio\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/philip.twinight.co\/portfolio\/index.php\/wp-json\/wp\/v2\/comments?post=412"}],"version-history":[{"count":4,"href":"https:\/\/philip.twinight.co\/portfolio\/index.php\/wp-json\/wp\/v2\/posts\/412\/revisions"}],"predecessor-version":[{"id":454,"href":"https:\/\/philip.twinight.co\/portfolio\/index.php\/wp-json\/wp\/v2\/posts\/412\/revisions\/454"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/philip.twinight.co\/portfolio\/index.php\/wp-json\/wp\/v2\/media\/426"}],"wp:attachment":[{"href":"https:\/\/philip.twinight.co\/portfolio\/index.php\/wp-json\/wp\/v2\/media?parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/philip.twinight.co\/portfolio\/index.php\/wp-json\/wp\/v2\/categories?post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/philip.twinight.co\/portfolio\/index.php\/wp-json\/wp\/v2\/tags?post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}