pISSN: 2723 - 6609 e-ISSN: 2745-5254
Vol. 5, No. 5 Mei 2024 http://jist.publikasiindonesia.id/
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2098
Predictive Analysis of Indonesian Stock Market Prices Using
Deep Learning: An Application of Diffusion Variational
Autoencoders
Ardisurya
Universitas Indonesia Depok, Indonesia
*Correspondence
ABSTRACT
Keywords: Diffusion
Variation Autoencoder;
Stock price prediction;
Indonesia stock market;
Deep Learning; Technical
Analysis.
This study introduces the application of the Diffusion
Variational Autoencoder (D-VAE), a deep learning
technique, for predicting stock prices in the Indonesian stock
market. With the challenges presented by market volatility
and complex data distributions, D-VAE is explored for its
capability to encapsulate uncertainty and model complex
distributions. This study is significant as it explores the
potential of D-VAE in the context of the Indonesian stock
market, which has not been widely studied before. Historical
stock data from Yahoo Finance was collected over one year
and preprocessed for training and validation of the model.
The model is trained with an architecture designed to allow
tuning of the latent space, utilising ReLU and linear
activation functions for the encoder and decoder. The
model's performance is evaluated using the Mean Squared
Error (MSE), Mean Absolute Error (MAE), and R-squared
metrics, yielding results that highlight the model's capability
to enhance the accuracy of stock price predictions. By
leveraging machine learning techniques in stock price
prediction models, this study underscores the significant
contribution such approaches can make to informed and
successful investment decisions underpinned by robust data.
Introduction
Stocks are financial instruments that offer investors a fraction of a company's
ownership. Investors who invest in a stock have a high percentage of the profits earned
by the company (Patel, Kumar, & Yadav, 2023). As a vital component in the economy,
the stock market is an indicator of economic health and a platform for companies to
accumulate capital. However, the high volatility of the stock market, influenced by
various factors such as the economy, politics, and social issues, makes stock price
prediction very complex and challenging (Farild, Sawaji, & Poddala, 2023).
The stock market not only acts as an indicator of economic health but also as an
arena for investors to optimise their investment decisions (Al-Alawi & Alaali, 2023).
Accuracy in stock price prediction significantly impacts companies' investment decisions.
Predictive Analysis of Indonesian Stock Market Prices Using Deep Learning: An Application of
Diffusion Variational Autoencoders
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2099
An interesting approach in this regard is the application of the Diffusion Variational
Autoencoder (D-VAE). This deep learning technique can capture uncertainty and model
complex data distributions (Koa, Ma, Ng, & Chua, 2023). Although D-VAE has shown
potential in other domains as an application, its use for stock price prediction in the
Indonesian market has yet to be extensively explored.
Research related to stock price prediction has been growing and pushing
computational intelligence to encourage the enhancement of prediction model
performance further (Shen & Shafiq, 2020). Technical analysis, which predicts stock
prices based on historical data such as stock trading volume and price movements, and
approaches such as ARIMA (Islam & Nguyen, 2020) and Stochastic Oscillator
(Alviyanil’Izzah et al., 2021), will be utilised in this research using historical stock data
from companies in Indonesia.
On the other hand, the popularity of machine learning in predicting stock prices is
increasing, presenting systems to learn from historical data. Techniques like LSTM (Qiu,
Wang, & Zhou, 2020) and Support Vector Machine (SVM) (Madhusudan, 2020) have
been widely used in stock price prediction. This research aims to bridge a gap in the
literature by critically evaluating and applying D-VAE for stock price prediction in the
Indonesian market, offering new insights into the potential of D-VAE in this context(Nath
& Shakhari, n.d.).
Integrating machine learning, especially D-VAE, and technical analysis is expected
to yield more accurate and effective stock price prediction models for the Indonesian
stock market, making a valuable contribution to data-based investment decision-making.
Research Methods
This study was designed to test a stock price prediction model for the Indonesian
stock market using the Diffusion Variational Autoencoder (D-VAE). This approach
combines Deep Learning techniques with technical analysis to understand and predict the
dynamics of stock prices in the Indonesian stock market.
Data Collection and Preparation
The data used in this study is from Yahoo Financethe period they have taken
ranges from January 1st, 2022, to January 1st, 2023. The data consists of the columns for
the opening (Open), highest (High), lowest (Low), closing (Close) prices, and the trading
volume (Volume) of stocks in the Indonesian stock market. The collected data was then
processed to eliminate any missing data. We extracted relevant features from this data to
construct the model and the target for predictions. These features include the opening,
highest, lowest prices, and trading volume. Then, for the closing price, it becomes the
prediction target. Before feeding the data into the mel, we normalised the feature andarget
using MiMaxScaer. T steps cruciao nsmore stable d ffii earng the matheatical mode us t
normalie hedta:X
Scaled
=
X- X
min
X
max
-X
min
y
Scal
=
y- y
min
y
max
-y
min
Ardisurya
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2100
Where the value X represents the actual value of the feature to be normalised. For
Xmin, it is the minimum value of each feature in the data, serving as the lower reference
value for normalisation. Similarly, Xmax is the maximum value of each feature in the
data, serving as the upper reference value for normalisation. The value Xscaled is the
normalised value of the feature. The normalisation process changes the actual data to a
scale from 0 to 1.
While y represents the actual value of the target to be normalised, for men, it is the
smallest value among all the target values in the data. This value serves as the lower
reference point for the range of normalisation. For max, it is the most significant value
among all the target values in the data. This value serves as the upper reference point for
the range of normalisation. Finally, scale is the normalised target value. The result of this
normalisation process changes the original data into a scale from 0 to 1.
Diffusion Variational Autoencoder (D-VAE) Model Architecture
The developed D-VAE model is based on a tunable latent space architecture that
consists of an encoder and a decoder. The encoder captures the complex relationships
among the numerous features of the volatile stock market and outputs a prediction of the
closing price. The encoder operates as a data compression mechanism, encoding the input
data into a more compact representation within the latent space. This compression to a
more succinct representation is accomplished through a series of hidden layers. The input
layer receives the input, matching the number of features used. This serves as the entry
point into the D-VAE model. As for the hidden layers, they consist of multiple layers with
neuron units varying in number. These layers have the Rectified Linear Unit (ReLU)
activation function. ReLU is chosen because it does not activate at negative input values,
which can help mitigate the vanishing gradient problem, as the derivative of the ReLU
function remains constant for all positive inputs, thus facilitating a more efficient training
process.
f
󰇛
x
󰇜
=max(0,x)
In the ReLU activation function used in the D-VAE architecture, the variable x
represents the input for the ReLU function. The previous layer's output within the neural
network is used as the input for the ReLU function. If the output (f(x)) is higher than zero,
it will equal the input value; if less, it will be zero. This ensures that the output will always
be non-negative. If x is positive, f(x) will be equal to x, but if x is negative, f(x) will be
zero. This helps address the vanishing gradient problem because the derivative of the
ReLU function is consistent for all positive values, thus ensuring efficient
backpropagation during training.
The decoder layer operates as a mechanism to extract the compressed representation
from the encoder and reconstruct the original expected output. This is the inverse process
of the encoder. The decoder architecture mirrors that of the encoder but in reverse order.
The main difference in its implementation is that it aims to gradually expand the succinct
representation from the encoder back to its original form that is more detailed and specific
to the prediction target.
Predictive Analysis of Indonesian Stock Market Prices Using Deep Learning: An Application of
Diffusion Variational Autoencoders
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2101
f(x) = x
The output layer consists of a single neuron with a linear activation function. This
function maintains the input value without any changes, allowing the model to predict
continuous values. In the context of stock price prediction, the model can produce a
prediction value that is sufficiently accurate for the stock's closing price.
Training and Evaluation of the Model
The Diffusion Variational Autoencoder (D-VAE) model is trained using normalised
data to ensure all features are on the same scale. This approach can improve the model's
ability to capture patterns and trends present in the data more effectively.
We employed the Adaptive Moment Estimation (Adam) algorithm to optimise.
Adam is an optimisation algoriththat calculates the learning rates from the scond moment
of grient using RMSPro. It computes adptive earning ratesfor eac parameter by cnsidering
the firt an second estimates of the the graie..
󰆚
θ
t+1
= θ
t
+
η
v
t
m
t
The value θ represents the model parameters or the weights of the model. These are
the values we aim to ooptimise Then, η represents the learning rate. When changing the
model parameters, this scalar value adjusts the step size during each iteration. The te m
t
represents the first estimate of the gradient. It is the average of the gradient of the loss
function concerning the model parameters. This helps to adjust the learning rate
adaptively for each parameter. Then, the te v
t
represents the second estimate of the
gradient or the uncentered variance of the gradient. The average of the squared gradient
provides an estimate of the gradient variability ofthe lvaluesunctilarto m
t
he value v
t
ed
to adjust the learning rate for each parameter while considering the scale of the gradient.
Finally, the value is a small constant added to prevent didivisiony zro when dividing b
thesquare root ftthe thehe
v
t
.. e employ Mean Squared Error (MSE), Mean Absolute
Error (MAE), and R-squared to evaluate the model used.
(y
i
-y
i
)
󰆚
n
i=1
MSE is calculated as the average of the squares of the differences between actual
and predicted values. It measures how close the predictions are to the actual values. The
value yi represents the stock's actual value being predicted. Then, y_i represents the
predicted value. Moreover, 'n' is the number of samples in tis experiment
1
n
|y
i
-y
i
|
n
i=1
MAE measures the average absolute error between predictions and actual values.
Unlike MSE, MAE provides a more linear perspective on prediction errors. The value yi
represents the stock's actual value being predicted. Then, y_i represents the predicted
value. Moreover, 'n' is the number of samples in this experiment.
Ardisurya
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2102
E represents the actual average value, model evaluation is performed by calculating
this metric on the test dataset. It provides a comprehensive picture of the model's
performance in predicting stock prices, considering various aspects of error and accuracy.
Results and Discussion
Model Evaluation Results
The Diffusion Variational Autoencoder (D-VAE) model has been tested on several
Indonesian stocks. The evaluation results show that the model can follow stock price
trends relatively well. The graphs presented are comparisons between the actual stock
prices and the predicted stock prices. These graphs visually represent several companies'
stock performance on the Indonesian stock market (Mukherjee et al., & De, 2023).
Fig 1 Comparison Chart of Actual 'Close' Stock Prices With Predicted 'Close' Stock
Prices in Several Companies Stocks
The graphs displayed compare the actual stock prices and those resulting from
predictions. These graphs visually represent the performance of several companies' stocks
Predictive Analysis of Indonesian Stock Market Prices Using Deep Learning: An Application of
Diffusion Variational Autoencoders
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2103
in the Indonesian stock market, such as PT Bank Central Asia Tbk (BBCA), PT Bank
Negara Indonesia (Persero) Tbk (BBNI), PT Bank Mandiri (Persero) Tbk (BBNI), PT
Adaro Energy Indonesia Tbk (ADRO), PT Aneka Tambang Tbk (ANTM), PT Bukit
Asam Tbk (PTBA). From these graphs, the model accurately follows the general market
trends. However, there are specific periods where the predictions do not align with the
actual values, particularly during periods of high market volatility.
Table 1
Comparison of MSE, MAE, and R-squared Values from Several Companies
The observed fluctuations in MSE and MAE values suggest that the model may
require more specific adjustments or tuning for each stock. In some cases, the model
predicts well, showing more minor errors and higher accuracy, while in others, more
significant prediction errors indicate areas where the model can be improved. This could
involve incorporating more features into the model or combining other machine-learning
techniques.
Consistently high R-squared values indicate that the model can reasonably explain
the variability in stock price data. Although our model is good at summarizing the data
explained, there are volatility periods where the model fails to capture price movements
accurately, indicating the need for more investigation into how the model can be adjusted
to be more sensitive to sudden market changes.
In analyzing the evaluation metrics, we found that although there were variations
in MSE and MAE among different stocks, the model consistently showed a high R2 value
across all the data examined. This indicates that the model accurately captures the
variances within the stock market data. However, the R-squared value does not always
reflect the variability of the actual stock market values. Hence, while it indicates the
model can capture the general trend, specific predictions may diverge from the actual
values, particularly during periods of market volatility.
The variation in MSE and MAE values points to the need for further refinement and
adjustment of the model, mainly when predicting during volatile periods, as discussed in
(Gangwar, Kumar, & Bijpuria, 2021), where hyperparameter tuning improved stock price
prediction accuracy. Similarly, the work by (Stoean, Paja, Stoean, & Sandita, 2019)
showed that integrating additional market sentiment data and indicators could make the
model more sensitive to market dynamics.
Stock MSE MAE R2
PT Bank Central Asia Tbk (XIDX:BBCA) 3155,4965 46,4066 0,9364
PT Bank Negara Indonesia (Persero) Tbk (XIDX:BBNI) 1119,1449 27,0061 0,9501
PT Bank Mandiri (Persero) Tbk (XIDX:BMRI) 2824,7450 93,7510 0,9401
PT Adaro Energy Indonesia Tbk (XIDX:ADRO) 1244,5671 29,2958 0,9425
PT Aneka Tambang Tbk (XIDX:ANTM) 378,9566 15,6345 0,9497
PT Bukit Asam Tbk (XIDX:PTBA) 902,4240 21,2658 0,9847
Average 1604,2223 38,8933 0,9506
Ardisurya
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2104
Further research by (Kumar et al., 2023) suggests that using different machine
learning algorithms that account for different aspects of the data can enhance model
responsiveness and improve predictions during volatile market conditions. This
reinforces the idea that various machine learning techniques can provide a deeper insight
into data analysis.
Given these findings, there are opportunities to further improve the D-VAE model
with ensemble methods, where the prediction of several models can be combined to
achieve a more robust outcome. Moreover, future studies may explore modifications in
the D-VAE architecture, such as adding or reducing the number of neuron layers or
applying techniques like regularization to prevent overfitting and enhance the model's
generalization.
Conclusion
The application of the Diffusion Variational Autoencoder (D-VAE) technique to
predict stock prices in the Indonesian stock market has demonstrated the potential of this
approach. With the implementation of deep learning and machine learning
methodologies, this research has contributed to exploring complex data within the volatile
market. The D-VAE model has shown significant capabilities in following the stock
market trends and has produced good prediction accuracy for various stocks. Evaluation
metrics such as MSE, MAE, and R-squared have varied between stocks, reflecting the
intrinsic stock market variability. Despite variations in MSE and MAE values across
different stocks, a consistently high R-squared value suggests that the model performs
well in capturing the trends within the market. However, a high R-squared value does not
directly reflect the precision of the stock price predictions, especially during periods of
high market volatility.
This study also identifies the need for further refinement and specificity in the
model for individual stocks and market conditions. Additional factors like economic
indicators and market sentiment should be integrated to enhance the model's predictions.
The value of D-VAE lies in its capacity for more detailed training and its potential to
provide a stronger foundation for investment decisions based on robust predictions.
Despite the need for further improvements, the existing model has demonstrated the
ability to provide valuable insights for financial analysts, aiding investors in making more
informed and accurate investment decisions based on stock price predictions.
Bibliography
Al-Alawi, Adel Ismail, & Alaali, Yusuf Ahmed. (2023). Stock Market Prediction using
Predictive Analysis of Indonesian Stock Market Prices Using Deep Learning: An Application of
Diffusion Variational Autoencoders
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2105
Machine Learning Techniques: Literature Review Analysis. 2023 International
Conference On Cyber Management And Engineering (CyMaEn), 153157. IEEE.
Alviyanil’Izzah, Nur, Martia, Dina Yeni, Imaculata, Maria, Hidayatullah, Moh Iqbal,
Pradana, Andhika Bagus, Setiyani, Diyah Ayu, & Sapuri, Enes. (2021). Analisis
Teknikal Pergerakan Harga Saham Dengan Menggunakan Indikator Stochastic
Oscillator Dan Weighted Moving Average. Keunis, 9(1), 3653.
https://doi.org/10.32497/keunis.v9i1.2307
Farild, Miftha, Sawaji, Muh Izzulhaq, & Poddala, Paramita. (2023). Analisis teknikal
sebagai dasar pengambilan keputusan dalam transaksi saham. FORUM EKONOMI:
Jurnal Ekonomi, Manajemen Dan Akuntansi, 25(4), 734739.
Gangwar, Abhinav, Kumar, Ayush, & Bijpuria, Eshikha. (2021). Stock Price Prediction
using Machine Learning. 2021 3rd International Conference on Advances in
Computing, Communication Control and Networking (ICAC3N), 189193. IEEE.
Islam, Mohammad Rafiqul, & Nguyen, Nguyet. (2020). Comparison of financial models
for stock price prediction. Journal of Risk and Financial Management, 13(8), 181.
Koa, Kelvin J. L., Ma, Yunshan, Ng, Ritchie, & Chua, Tat Seng. (2023). Diffusion
Variational Autoencoder for Tackling Stochasticity in Multi-Step Regression Stock
Price Prediction. Proceedings of the 32nd ACM International Conference on
Information and Knowledge Management, 10871096.
https://doi.org/10.1145/3583780.3614844
Kumar, Amodh, Hooda, Susheela, Gill, Rupali, Ahlawat, Deepak, Srivastva, Durgesh, &
Kumar, Raju. (2023). Stock Price Prediction Using Machine Learning. 2023
International Conference on Computational Intelligence and Sustainable
Engineering Solutions (CISES), 926932. IEEE.
Madhusudan, Desai Mitesh. (2020). Stock Closing Price Prediction Using Machine
Learning SVM Model. International Journal for Research in Applied Science and
Engineering Technology.
Mukherjee, Somenath, Sadhukhan, Bikash, Sarkar, Nairita, Roy, Debajyoti, & De,
Soumil. (2023). Stock market prediction using deep learning algorithms. CAAI
Transactions on Intelligence Technology, 8(1), 8294.
Nath, Om, & Shakhari, Swapan. (n.d.). Stock Market Prediction Techniques: A
Literature.
Patel, Vikas, Kumar, Ashwani, & Yadav, Deepak. (2023). Machine Learning Techniques
for Predicting Stock Closing Prices. 2023 3rd International Conference on
Pervasive Computing and Social Networking (ICPCSN), 447452.
https://doi.org/10.1109/ICPCSN58827.2023.00079
Qiu, Jiayu, Wang, Bin, & Zhou, Changjun. (2020). Forecasting stock prices with long-
Ardisurya
Jurnal Indonesia Sosial Teknologi, Vol. 5, No. 5, Mei 2024 2106
short term memory neural network based on attention mechanism. PloS One, 15(1),
e0227222.
Shen, Jingyi, & Shafiq, M. Omair. (2020). Short-term stock market price trend prediction
using a comprehensive deep learning system. Journal of Big Data, 7, 133.
Stoean, Catalin, Paja, Wiesław, Stoean, Ruxandra, & Sandita, Adrian. (2019). Deep
architectures for long-term stock price prediction with a heuristic-based strategy for
trading simulations. PloS One, 14(10), e0223593.