Next Article in Journal
A Synergistic MOEA Algorithm with GANs for Complex Data Analysis
Previous Article in Journal
An Improved Coppersmith Algorithm Based on Block Preprocessing
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Mechanisms of Stock Selection and Its Capital Weighing in the Portfolio Design Based on the MACD-K-Means-Mean-VaR Model

1
Department of Mathematics, Faculty of Mathematics and Natural Sciences, Universitas Padjadjaran, Jatinangor, Sumedang 45363, Indonesia
2
Department of Mathematics, Faculty of Mathematics and Natural Sciences, Universitas Gadjah Mada, North Sekip, Yogyakarta 55281, Indonesia
3
Department of Statistics, Faculty of Sciences and Mathematics, Universitas Diponegoro, Tembalang, Semarang 50275, Indonesia
4
Doctoral Program of Mathematics, Faculty of Mathematics and Natural Sciences, Universitas Padjadjaran, Jatinangor, Sumedang 45363, Indonesia
*
Author to whom correspondence should be addressed.
Mathematics 2024, 12(2), 174; https://doi.org/10.3390/math12020174
Submission received: 5 December 2023 / Revised: 27 December 2023 / Accepted: 3 January 2024 / Published: 5 January 2024
(This article belongs to the Section Financial Mathematics)

Abstract

:
When designing a stock portfolio, investors must select stocks with different characteristics and increasing price trends and weigh each capital. Both are fundamental to diversifying loss and profit. Therefore, the mechanisms that accommodate both are needed. Based on this, this research aims to design a stock selection and capital weighing mechanism using the MACD-K-means-Mean-VaR model. The moving average convergence–divergence (MACD) is used to analyze stock buying time, providing trend, momentum, and potential price reversal insights. Then, stocks with increasing price trends are clustered using K-means, a grouping simple pattern data method based on specific characteristics. The best stocks from each cluster are capital weighted using the mean value at risk (mean-VaR), a portfolio optimization model adjusting loss possibility to the investor’s acceptance tolerance. The mechanism is then applied to Indonesia’s 100 stock index data to analyze variable sensitivities and compare it with another model. The application reveals that all variables significantly impact portfolio return mean and VaR, suggesting the need for clustering and analyzing stock price movements in stock portfolio design. This research academically develops a portfolio design mechanism by clustering stocks and analyzing price movement trends. It enables investors to practically diversify and choose stocks with increasing price trends, reducing losses and increasing profit opportunities.

1. Introduction

When selecting stocks in portfolio design, diversification should be carried out to manage investment risk wisely [1]. Stock diversification is a stock selection activity based on classifying different characteristics from different clusters. By selecting stocks in different clusters, the returns from the stocks in the portfolio are not highly correlated. It creates a return balance, where if one stock in the portfolio experiences a decline, the potential loss can be offset by positive performance stock in other clusters. In detail, it not only protects against losses but also increases the potential for stable and sustainable returns [2]. Apart from diversification through clustering, analyzing the timing of buying and selling stocks is also important in selecting stocks in portfolio design [3]. The stocks chosen should have buy indications so that the risk of loss can be minimized in the future. Analysis of when to buy and sell stocks can be conducted using daily price data or based on company fundamentals. After the selection of stocks in portfolio design is conducted, the next step is determining the capital weight of each stock within it. Stocks with a large mean of return are not always given a large capital weight, and vice versa. This is because it must be remembered that the mean and variance of returns have in-line properties [4]. Thus, this weighting needs to be conducted carefully. The weighting of stock capital in a portfolio should be carried out based on basic investment objectives, namely maximizing returns and minimizing the risk of loss.
Several studies have discussed the mechanism of stock selection using clusterization. Chen and Huang [5] introduced a clustering-based stock selection mechanism using the K-means algorithm, focusing on attributes such as average return, standard deviation of returns, Treynor index, and turnover rate. Sinha et al. [6] used a genetic algorithm to cluster stocks. Golosnoy and Okhrin [7] developed a mean-variance model involving shrinkage. Ren et al. [8] applied the K-means algorithm to cluster stocks with attribute correlation coefficients. Fleischhacker et al. [9] clustered stock data in the energy sector using the K-means algorithm with the attributes of heat demand, electricity demand, cooling demand, solar PV supply, and solar thermal collector supply. Using the average linkage algorithm and the distinctive features of the correlation coefficient between stock returns, Tola et al. [10] grouped stock data. Musmeci et al. [11] compared the K-medoids, linkage, and directed bubble hierarchical tree approaches using the correlation coefficient attributes of stocks. Hussain et al. [12] proposed two novel methods, namely the Adaptive Neuro-Fuzzy Inference System (ANFIS) and the Induced Ordered Weighted Averaging (IOWA) model, for cluster stocks. Chen et al. [13] and Cheong et al. [14] employed the K-means technique to cluster stock data based on the average return attribute. Khan and Mehlawat [15] employed fuzzy C-means clustering to group stocks into clusters. Then, Sáenz [16] investigated the application of clustering models for stocks to enhance the accuracy of stock price predictions and the performance of trading algorithms.
Meanwhile, several researchers have also analyzed stock price movements. Navarro et al. [17] conducted a price analysis using the moving average convergence–divergence (MACD) approach. Aheer et al. [18] examined price fluctuations using geometric Brownian motion. Subsequently, Sukono et al. [19] analyzed the stock price fluctuations using the ARIMA-GARCH model. Subsequently, Du and Tanaka-Ishii [20] analyzed the movement of stock prices using NEWS-STock space with Event Distribution (NESTED). Chang et al. [21] analyzed price fluctuations using behavioral stock (B-stock). Varga-Haszonits and Kondor [22] examined the price movement, assuming it adheres to the constant conditional correlation GARCH process model provided by Bollerslev. Thuankhonrak et al. [23] conducted a price analysis using the ARIMA and Holt Winter techniques.
Then, in capital weighting, Markowitz [24] introduced the mean-variance capital weighting model in portfolios, which was later transformed into a matrix form for better computing efficiency by Sharpe [25]. This model became the basis for future research, including the capital asset pricing model (CAPM) by Sharpe [26] and the minimax portfolio model by Young [27]. Other researchers have developed models for risk aversion by Björk et al. [28], portfolio mean-variance-skewness by Abdurakhman [29], equilibrium optimizer by Faramarzi et al. [30], multi-objective stochastic linear optimization by Zhou and Li [31], particle swarm optimization by Zhu et al. [32], mean absolute deviation by Kalfin et al. [33] and Ryoo [34], neurodynamic optimization by Wang and Gan [35], behavioral mean-variance and copula behavioral mean-variance by Mba et al. [36], portfolio optimization via deep learning by Du [37], and predictive control models of mean-variance by [38]. Each model has strengths and weaknesses, and their application in various scenarios has led to significant advances in the field. The mean-variance model has been a valuable tool for understanding and optimizing portfolio capital. Ranković [39] introduced a new mean-VaR optimization technique that utilizes a univariate Generalized Autoregressive Conditional Heteroscedasticity (GARCH) volatility model to estimate VaR. Then, Ashrafzadeh [40] presented a hybrid approach that combines a convolutional neural network (CNN) with optimized hyperparameters using particle swarm optimization (PSO) for stock pre-selection. A mean-variance with forecasting (MVF) model is employed for portfolio optimization.
Some gaps from previous research can be used as opportunities for further research. These gaps are considered novel in this research. These gaps are as follows:
(a)
In the clustering aspect, no one has used the K-means method with the mean and value at risk (VaR) attributes of returns from their stocks.
(b)
Regarding capital weighting, no one has used the mean-VaR model involving income tax and transaction cost variables.
(c)
No one has yet combined the MACD method for buying time analysis with the K-means method and the mean-VaR model.
Based on the introduction in this section, this research aims to develop stock selection and capital weighting mechanisms in designing stock portfolios based on clustering and analysis of stock buying times. Clustering was carried out using the K-means method. This method was chosen because of its fast iteration speed, timely efficiency, and simple ability to provide a clear and well-defined cluster solution to help investors understand the relationship patterns between stocks in a portfolio [41]. Then, the time to buy stocks is analyzed using the moving average convergence–divergence (MACD) indication. MACD was chosen for its ability to provide clear buy or sell signals through the intersection of the MACD line and the signal line, allowing investors to identify optimal points to enter or exit the market quickly [42]. Finally, the portfolio’s mechanism for weighting stock capital uses the mean value at risk (mean VaR) model involving transaction cost and income tax variables. The mean-VaR model was chosen because it can adjust investors’ courage in bearing risk by choosing return quantiles in the VaR calculation [43]. This research academically develops a portfolio design mechanism by clustering stocks and analyzing its price movement trends, enabling investors to practically diversify and choose stocks with increasing price trends, reducing losses, and increasing profit opportunities.

2. Model Framework for the Selection and Capital Weighting of Stocks

2.1. Algorithm

The mechanism algorithm is given first to make it easier to follow the more detailed explanation in the following subsections. The algorithm of the mechanism is given in Figure 1. In writing, the following is an explanation of Figure 1:
(a)
Price data for stocks is input first.
(b)
Stocks are selected first based on their mean return value. Stocks with a positive mean of return are selected.
(c)
Stocks with a positive return mean are analyzed for buying indications using MACD. If the stock has a buy indication currently, the stock is selected to enter the next stage.
(d)
Each stock that has passed stage (c) is clustered using the K-means method based on its attributes: the mean and VaR of returns.
(e)
The best stocks from each cluster are selected to be designed into the portfolio. It is the final stock selection stage.
(f)
Each share in the portfolio is weighted by capital. Weighting is carried out using the mean-VaR model.
Figure 1. Algorithm for selection and capital weighting of stocks in a portfolio design.
Figure 1. Algorithm for selection and capital weighting of stocks in a portfolio design.
Mathematics 12 00174 g001

2.2. Mathematical Notations

The mathematical notations for the designed mechanism are defined first as follows:
(a)
W represents the amount of capital in the portfolio in currency units. In this study, W is assumed to be one to facilitate modeling.
(b)
M represents the number of stocks selected at the beginning.
(c)
P m , t represents the price of the m -th stock at time t , where m 1 , 2 , ,   M and t 0 , .
(d)
N represents the number of stocks with a current buy indication that will be clustered later.
(e)
P represents the number of attributes of the stock used in clustering. In this case, because two stock attributes are used, namely mean and value at risk of return, the P value is two.
(f)
μ n represents the mean of return of the n -th stock, where n 1 , 2 , ,   N .
(g)
V a R n represents the value at risk of return of the n -th stock, where n 1 , 2 , , N .
(h)
σ n 1 , n 2 2 represents the covariance of returns from the n 1 -th and n 2 -th stocks, where n 1 , n 2 1 , 2 , , N
(i)
a n represents a vector of size two containing the mean and value at risk of return of the n -th stock, where n 1 , 2 , ,   N .
(j)
K represents the number of clusters.
(k)
v k represents the centroid of the kth cluster, where k 1 , 2 , , K .
(l)
S represents the final number of stocks selected in the portfolio.
(m)
w s represents the capital weight of the s -th stock in the portfolio, where s 1 , 2 , ,   S .

2.3. Stock Selection Using MACD

Moving average convergence–divergence (MACD) is a tool for checking indications of when to buy or sell stocks. It can provide clear buy or sell signals through the intersection of the MACD line and the signal line, allowing investors to identify optimal points to enter or exit the market quickly [42].
The MACD value is calculated by subtracting the exponential moving average (EMA) value of order p from the EMA value of order q of the stock price, where p and q represent the number of trading days for one month and two weeks, respectively. The MACD value is then compared with the signal value, which is the EMA value of order r of the MACD value, where r represents the number of trading days for 1.5 weeks. Mathematically, the MACD value at time t + 1 is expressed as follows [44]:
MACD t + 1 = EMA p t + 1 EMA p t + 1 ,
where
EMA p t + 1 = 2 p + 1   P m , t + 1 2 p + 1   EMA p t ,
and
EMA q t + 1 = 2 q + 1   P m , t + 1 2 q + 1 EMA q t .
In more detail, P m , t represents the price of m -th stock at time t . Then, the signal line at time t + 1 is mathematically expressed as follows [44]:
S i g r t + 1 = 2 r + 1 MACD t + 1 2 r + 1 S i g r t .
To start the calculation, the initial EMA value is given as the initial value of the actual data, and the initial signal value is the initial MACD value. In other words,
EMA p 1 = EMA p 1 = P m , 1
and
S i g r 1 = MACD 1 .
The use of MACD in determining buy and sell times is as follows [45]:
(a)
Buy time is indicated when MACD t > S i g r t . This condition represents that stock prices tend to rise, so demand for them also rises.
(b)
Sell time is indicated when MACD t S i g r t . This condition represents that stock prices tend to fall, so demand for them also falls.

2.4. Stock Clustering Using the K-Means Method

The K-means method is a data clustering method with fast iteration speed, timely efficiency, and simple ability to provide a clear and well-defined cluster solution to help investors understand the relationship patterns between stocks in a portfolio [41]. The method is based on the shortest distance between data attributes and cluster centroids. This distance can be calculated using certain norms. Norm 2, better known as Euclidean distance, is the most popular because it is intuitive [46]. In summary, a cluster of data is the cluster with the smallest distance between the data and its centroid. The algorithm of this method is given in more detail in Figure 2.
Based on Figure 2, the K-means method is iterative. In the first iteration, the number of clusters and their centroids are determined first. Practically, a lot can be determined by visualizing the data in a scatter plot. Then, determining many clusters can be conducted using several methods, such as the elbow, silhouette, and gap statistics methods. Then, members of the clusters are data with the smallest distance between the attribute and the cluster centroid [47]. Once the clusters are filled with data, new centroids are determined. The new centroid of a cluster is the average value of each attribute in it. After that, the second iteration was carried out by returning to the stage of determining the members of each cluster. An iteration is stopped if the members of each cluster from the current iteration are the same as the members of each cluster in the previous iteration [48].
There are two stock attributes used in clustering in this research. These two are the mean and VaR of returns, each of which produces the following [49]:
μ m = 1 T t = 1 T R m , t
and
VaR m = μ m + z α 1 T t = 1 T R m , t μ m 2 ,
where T is the period considered, R m , t is the price of the m -th stock at time t , and z α is the 1 α -th quantile of the standard normal cumulative distribution function.

2.5. Capital Weighing of Each Stock in Portfolios Using the Mean-VaR Model

The capital weighing model in investment portfolios generally applies the primary objectives of maximizing profits and minimizing losses. The mean of returns from the portfolio generally represents the profits from a portfolio. Then, there are several ways to represent losses from a portfolio. The first is the general one, where the negative value of the variance of returns represents losses. It is as introduced by Markowitz [24]. Second, losses can be represented by value at risk (VaR). VaR is the maximum loss tolerated by investors. VaR is considered more flexible than the variance of return because there is a tolerance for accepting losses from the investors involved [50]. This model with VaR is usually called the mean-VaR model.
Suppose a stock portfolio containing S stocks have total capital W in currency units. For practical reasons in modeling, the value of W is assumed to be one. Then, suppose that the capital weight of each stock is w s and the return is R S with s 1 , 2 , ,   S . For each s , R s is assumed to be a normal random variable with mean μ s and variance σ s 2 . Verbally, this assumption indicates that stock returns are independent of time because the mean and variance are constant. It can also be said that there is no jumping in the return. In other words, situations such as pandemics and chaos in the economic situation have not been resolved using this mechanism [51].
The return from a portfolio is defined as the sum of the multiplication of each stock weight and its return. Mathematically, this is defined as follows:
R S = s = 1 S w s R s ,
Costs must be incurred when buying and selling stocks. These costs are called transaction costs. The transaction cost for buying stocks in a portfolio is a percentage of the total buy transaction amount. The percentage of each stock-buying transaction cost is assumed to be the same. Mathematically, this is expressed as follows:
T S , B = η ,
where η is the transaction cost percentage of buying stocks. Then, the transaction costs for selling stocks from the portfolio are a percentage of the total selling transactions. The percentage of each stock-selling transaction cost is assumed to be the same. Mathematically, this is expressed as follows:
T S , S = θ 1 + s = 1 S w s R s ,
where θ is the transaction cost percentage of selling stocks. Thus, the total transaction costs for buying and selling stocks in the portfolio are as follows:
T S = T S , B + T S , S = η + θ 1 + s = 1 S w s R s .
Then, when the stocks in the portfolio are sold, there is also income tax that must be paid. This tax is paid if the return from the portfolio is nonnegative. Mathematically, this is expressed as follows:
T S = ζ s = 1 S w s R s ; s = 1 S w s R s > 0 0 ; s = 1 S w s R s 0 ,
where ζ is the income tax percentage. Thus, the portfolio return that has been reduced by transaction costs and income tax is as follows:
S = R S T S T S .
Next, the mean of return of portfolio P is calculated as the expectation of S . Mathematically, this is given in the following equation:
μ P = E S = E R S T S T S = s = 1 S w s μ s 1 θ ζ + ζ Pr s = 1 S w s R s 0 η .
In detail, s = 1 S w s R s ~ N s = 1 S w s μ s , s = 1 S w s σ s 2 . Thus,
Pr s = 1 S w s R s 0 = 1 2 π s = 1 S w s σ s 2 0 e 1 x s = 1 S w s μ s 2 2 s = 1 S w s σ s 2 d x .
Using Equation (9) to determine the maximum value of the mean of portfolio return in Equation (8) has complications. Therefore, the approach from Equation (9) can be used as an alternative. One such approach is the approximation method of Bowling et al. [52] as follows:
Pr s = 1 S w s R s 0 1 1 + e 1.702 s = 1 S w s μ s s = 1 S w s σ s 2 .
Thus, Equation (8) can be rewritten as follows:
μ P = s = 1 S w s μ s 1 θ ζ + ζ 1 1 + e 1.702 s = 1 S w s μ s s = 1 S w s σ s 2 η .
For reasons of simplicity in modeling, we assume that Pr s = 1 S w s R s 0 = 0.5 . Thus, Equation (11) can be rewritten as follows:
μ P = 1 θ 0.5 ζ s = 1 S w s μ s η θ .
Equation (12) can be written in the form of matrix and vector multiplication as follows:
μ P = 1 θ 0.5 ζ w T μ η θ .
where
w = w 1 w 2 w S   and   μ = μ 1 μ 2 μ S .
Then, the VaR of portfolio returns at level 1 α can be expressed as follows:
VaR P = E s = 1 S w s R s + z α s = 1 S k = 1 S w s w k R s μ s R k μ k , = s = 1 S w s E R s + z α s = 1 S k = 1 S w s w k E R s μ s R k μ k , = s = 1 S w s μ s + z α s = 1 S k = 1 S w s w k σ s k ,
where z α represents the 1 α -th quantile of a standard normal distribution random variable, and σ s k with s , k 1 , 2 , ,   S is the covariance between the s -th and k -th stock returns. Equation (14) can also be expressed as matrix multiplication. The expression is as follows:
VaR P = w T μ + z α w T Σ w ,
where Σ = σ s k S × S .
In a typical capital weighing problem, the constraint function is usually the total sum of the weights. The sum of the capital weights of all stocks is one. It is mathematically expressed as follows:
s = 1 S w s = 1 ,
or
w T e = 1 ,
where
e = 1 1 1 .
Thus, the problem of maximizing the mean of portfolio return and minimizing the VaR of portfolio return can be formulated as follows:
max .   2 τ μ P + VaR P = 2 τ 1 θ 0.5 ζ w T μ η θ w T μ z α w T Σ w s . t .   w T e = 1 ,   w 0
The τ value in Equation (18) represents the risk tolerance coefficient of investors. The smaller the value of the coefficient, the smaller the loss tolerated, and vice versa. In simple terms, if investors tolerate a small risk of loss, then the expected loss is also slight, and vice versa.
The solution of the mean-VaR model in Equation (18) can be determined using the Lagrange multiplier method. Through this method, the optimization model in Equation (18) is converted into an optimization model without constraint functions as follows:
max .   L w , λ = 2 τ 1 θ 0.5 ζ w T μ η θ z α w T Σ w + λ w T e 1 ,
where λ is positive Lagrange multiplier, and w 0 . w and λ estimators are solutions of the following equations:
w L w , λ = 2 τ 1 θ 0.5 ζ μ μ z α Σ w w T Σ w + λ e = 0 ,
and
λ L w , λ = w T e 1 = 0 .
Briefly, the solution of Equation (18) is as follows:
w = Σ 1 2 τ 1 θ 0.5 ζ 1 μ + λ e e T Σ 1 2 τ 1 θ 0.5 ζ 1 μ + λ e .
In detail,
λ = b ± b 2 4 a c 2 a ,
where a = e T Σ 1 e , b = 2 2 τ 1 θ 0.5 ζ 1 e T Σ 1 μ , and c = 2 τ 1 θ 0.5 ζ 1 2 μ T Σ 1 μ z α 2 . Note that the value of τ must cause w 0 dan λ > 0 .

3. Mechanism Application to Real Data

3.1. Description of Data Used

In applying the mechanisms to real data, we consider Indonesia a member of G20 countries, with the third most significant economic growth within it in the third quarter of 2023, after China and India. The stability and management of inflation, interest rates, and political events in 2023 are reassuring [53]. We utilize the finest capital market statistics for 2022 Southeast Asia, specifically the Indonesian Stock Exchange (BEI) [54]. The data provided are stock return data specifically for the Kompas 100 Index in Indonesia. The Kompas 100 Index comprises 100 stocks with the highest liquidity, most significant market capitalization value, vital fundamentals, and best performance in the Indonesian stock market. The determination of the 100 stocks is valid from August 2023 to January 2024. The mechanism can not only be used on Indonesian data, but in this case, we chose Indonesia because it has the best capital market in Southeast Asia, the region with the fastest economic growth worldwide in 2022. Then, the period considered is from 9 October 2022 to 9 October 2023. Data were obtained from the website https://yahoo.finance accessed on 9 October 2023 and summarized in the following link: https://bit.ly/100IndexStockDataIndonesia (accessed on 9 October 2023). These stocks are listed in Table 1 below based on their sector.
Table 1 shows that the sector with the most significant number of stocks in the 100 index is financial. In other words, the financial sector in Indonesia has the most considerable liquidity and capitalization among other sectors. Then, in second place is the energy sector, where the number of stocks differs from one with finance, namely 15. Meanwhile, the sector with the fewest stocks is the transportation and logistics sector, which has only two stocks. In other words, this sector has the smallest liquidity and capitalization among all sectors.

3.2. Clustered Data Selection

The data to be clustered are selected first. There are two stages of selection. The first selection is the selection of the mean return value of the stocks. Stocks with a positive mean of return are selected. After the examination, 40 out of 100 stocks had a positive mean of return, as shown in Figure 3, where the abscissa shows the alphabetical order of the stocks and the ordinate shows the mean of returns of the stocks. The 40 stocks were then selected in stage two. In stage two, stocks are selected based on buy indicators based on the MACD indicator. The p, q, and r orders used are 12, 26, and 9. These order values are the best in terms of statistical error. Stocks that have buy indications are selected. Of the 40 shares, there are 18 that have buy indications, as given in Table 2. These 18 stocks are then clustered using the K-means method.

3.3. Data Clusterization and Stock Selection

Based on the data selection results, a description of the data to be clustered is given in Table 3. Table 3 shows that the 18 stocks to be clustered come from nine sectors: Non-primary Consumer Goods, Primary Consumer Goods, Basic Materials, Energy, Financials, Healthcare, Infrastructures, Properties and Real Estate, and Technology. There are no stocks from two sectors: Industrials and Transportation and Logistics. The Primary Consumer Goods sector stocks are the most numerous, with seven stocks. Then, the Energy, Basic Materials, Healthcare, Infrastructures, and Technology sectors each have one stock. Of the stocks to be clustered, the stock with the most significant mean of return is MAPI. MAPI also has the largest VaR of return. Then, SSMS and BELI each have the most minor mean of return and VaR of return.
Many clusters are determined first using the silhouette method. The practice is carried out using the help of R Studio software version 4.1.2 with the package “factoextra” and the function “fviz_nbclust(data, K-means, method = ‘silhouette’)”. The number of clusters selected is the one with the most significant average silhouette [55]. Briefly, the results of determining these many clusters are given visually in Figure 4.
Figure 4 shows that the most significant average silhouette width value occurs when the number of clusters is five. Therefore, the number of clusters selected based on these results is five. Next is determining the members of each cluster. This determination was carried out using the K-means method, as explained in Section 2.4. Cluster determination was carried out one hundred times to measure the accuracy of the clusterization results. The results of one hundred clusterization experiments are given in Table 4.
Table 4 shows that the average accuracy of the clusterization results of the data using the K-means method is 80.33%. This accuracy value is high. Hence, the results can be said to be accurate [56]. A summary of the results for the members and centroids of each cluster is given in Table 5.
The next step after the stock cluster is obtained is stock selection in preparing the final portfolio. The number of stocks selected is five, with one selected from each cluster. The stocks selected in a cluster have the most significant Sharpe ratio [57]. A list of Sharpe ratios for each stock in each cluster is given in Table 6. Based on Table 6, the stocks with the most significant Sharpe ratios from each cluster are MAPI, MYOR, TPIA, BSDE, and ICBP. Therefore, these stocks were chosen for the investment portfolio in this research. The five stocks come from four sectors, namely primary consumer goods, properties and real estate, basic materials, and non-primary consumer goods. MYOR and ICBP are in the same sector, while others differ. It means that the method used for selecting stocks in the portfolio in this research can be used for diversification. Statistically, this can be seen from the correlation between stock returns in the correlation matrix Ω in Equation (24), where the values are small. In fact, some have negative values.
Ω = 1 1.149 × 10 1 4.947 × 10 2 3.438 × 10 4 2.272 × 10 2 1.149 × 10 1 1 4.942 × 10 2 9.655 × 10 2 2.368 × 10 1 4.947 × 10 2 4.942 × 10 2 1 3.192 × 10 2 7.290 × 10 2 3.438 × 10 4 9.655 × 10 2 3.192 × 10 2 1 9.975 × 10 2 2.272 × 10 2 2.368 × 10 1 7.290 × 10 2 9.975 × 10 2 1 .

3.4. Capital Weighing

At the beginning of this stage, we first determine μ and Σ from the data obtained. Briefly, the results are given in the following equations:
μ = 2.952 × 10 3 1.313 × 10 3 5.164 × 10 4 7.272 × 10 4 8.772 × 10 4 ,
and
Σ = 8.216 × 10 4 6.832 × 10 5 2.589 × 10 5 1.631 × 10 7 8.341 × 10 6 6.832 × 10 5 4.301 × 10 4 1.871 × 10 5 3.313 × 10 5 6.291 × 10 5 2.589 × 10 5 1.871 × 10 5 3.334 × 10 4 9.643 × 10 6 1.705 × 10 5 1.631 × 10 7 3.313 × 10 5 9.643 × 10 6 2.738 × 10 4 2.115 × 10 5 8.341 × 10 6 6.291 × 10 5 1.705 × 10 5 2.115 × 10 5 1.641 × 10 4
After that, we determine the percentages of buying transaction costs η and selling transaction costs θ is 0.0.4%. Then, the income tax percentage ζ is 0.1%. Finally, the value of τ that causes the values w s 0 and λ > 0 is sought. For the lambda value in Equation (23), we use b + b 2 4 a c 2 a instead of b + b 2 4 a c 2 a because this gives a value of λ > 0 . Briefly, after the search is performed, we obtain that the values w s 0 and λ > 0 are satisfied when 0 < τ 5.112 . To select the most optimal weights, we use the Sharpe ratio measure. The weight that produces the most excellent Sharpe ratio is the one we choose. In short, it turns out that the optimal weight occurs when τ = 5.112 . A summary of the results of determining optimal weights accompanied by descriptive statistics for the portfolio is given in Table 7.

4. Discussion

4.1. Sensitivity Analyses

In this subsection, we first visually analyze the relationship between the mean and VaR of portfolio returns. The analysis was carried out on the interval 0 < τ 5.112 , obtained in Section 3.4. Briefly, the relationship between the mean and VaR of portfolio returns is given visually in Figure 5.
Figure 5 shows that the mean and VaR of portfolio returns have an in-line relationship. In other words, the greater the mean of portfolio return, the greater the VaR, and vice versa. It is logical because the more significant the loss we tolerate, the greater the return we will get, and vice versa.
Next, a sensitivity analysis of several variables involved in the mean and standard deviation of returns is carried out. The variables whose sensitivity analysis is analyzed are income tax, transaction tax, risk tolerance, z α on VaR, and loss probability. When a variable is analyzed for sensitivity, the values of other variables are considered constant. Briefly, the sensitivity analysis results of the variables on the mean of portfolio return are given visually in Figure 6. Then, the sensitivity analysis results of the variables on the standard deviation are given in Figure 7.
Figure 6 shows that buying transaction costs, selling transaction costs, income taxes, and the probability for portfolio losses have no in-line relationship with the mean of portfolio return. In other words, the greater the value of the four, the smaller the mean of portfolio return, and vice versa. It makes sense because when all four exist, this will reduce the mean of portfolio returns. Then, the z α value in the VaR calculation of portfolio returns appears to have an in-line relationship with the mean of portfolio returns. It also makes sense because the more significant the z α value, the greater the VaR value of the portfolio return, and vice versa. In other words, it will also cause the mean of portfolio return to be more significant. It also applies vice versa.
Meanwhile, Figure 7 shows that selling transaction costs, income taxes, and the probability of portfolio loss have no in-line relationship with the standard deviation of portfolio returns. It means that the greater the value of the three, the smaller the value of the standard deviation of portfolio returns, and vice versa. Practically, it makes sense because when all three values exist, the mean of portfolio return will be small, so the standard deviation will also be slight. Then, the z α value in the VaR calculation of portfolio returns appears to have an in-line relationship with the standard deviation of portfolio returns. It also makes sense because the more significant the z α value, the greater the VaR of the portfolio return, and vice versa. In other words, this will also cause the standard deviation of portfolio returns to become more prominent. It also applies vice versa.
Finally, we analyze the influence of risk tolerance on the mean and VaR of portfolio returns. The analysis was carried out visually; the results are in Figure 8. Figure 8 shows that risk tolerance has an in-line relationship with the mean and VaR of portfolio returns. In other words, the greater the investor’s tolerance for loss, the greater the mean and VaR of portfolio return. It is logical. The results of the sensitivity analysis in this section all seem logical. It indicates that the capital selection and weighting mechanism can describe the actual situation.

4.2. Comparation with Another Mechanism

In this subsection, we will compare experimental data results using the first and second mechanisms. The first mechanism (MI) is the mechanism that was introduced. In contrast, the second mechanism (MII) is the mean-VaR mechanism without the involvement of clusterization and analysis of stock price movements. The experimental results that are compared are the mean of portfolio returns from each mechanism. After that, each result of the mechanism is also compared with the actual reality the next day. Without clustering and analyzing stock price movements, we selected five stocks from the Kompas 100 Index with the most significant Sharpe ratios. MAPI, ISAT, BRPT, JSMR, and ICBP are the five stocks. Only two shares are the same from MI and MII, MAPI and ICBP. Briefly, the comparison results between the two mechanisms are given in Table 8.
Table 8 shows that the mean of portfolio return from MII is greater than MI. However, if the two mean portfolio returns are compared with the actual one the next day, the mean portfolio return from MI is achieved or even exceeds it. In contrast, the mean of portfolio return from MII is not achieved and is even negative. These results indicate that clustering and analysis of stock price movements should be carried out in forming a stock portfolio.

5. Conclusions

This research develops the stock selection and capital weighting mechanisms for portfolio design. The stock selection mechanism is based on clustering analysis and analysis of the timing of buying and selling stocks. Clustering is conducted to select stocks with different characteristics to diversify risks. Then, an analysis of buying and selling times is carried out to reduce the chance of a decline in stock prices in the short term, thereby reducing the chance of loss from the portfolio. Clustering was carried out using the K-means method. This method was chosen because it is suitable for grouping shares based on mean and VaR characteristics. This suitability can be seen from its application, where the accuracy of using this method is above eighty percent. Then, the time to buy and sell stocks is analyzed using the moving average convergence–divergence (MACD) indication. MACD can describe stock price movements better than other indications because it uses two indication lines at once, namely the MACD line and the signal line. Finally, the portfolio’s mechanism for weighting stock capital uses the mean value at risk (mean VaR) model involving transaction cost and income tax variables. The mean-VaR model was chosen because it can adjust investors’ courage in bearing risk by choosing return quantiles in the VaR calculation.
The designed mechanism is then applied to Indonesia’s 100 stock index data. Experimental data also present the sensitivity of the critical variables involved. The results of the sensitivity analysis in this section all seem logical. It indicates that the stock selection and capital weighting mechanisms can describe the actual situation. Finally, we also compared the mechanism of this research (MI) with another mechanism, traditional mean-VaR (MII). Mean portfolio return from MI is achieved or even exceeds it. In contrast, the mean of portfolio return from MII is not achieved and is even negative. These results indicate that clustering and analysis of stock price movements should be carried out in forming a stock portfolio.
As a suggestion for future mechanism development, the loss probability value in Equation (11) can be involved theoretically without being assumed to be a constant value in the actual number interval between zero and one. However, this will make determining the solution of the mean-VaR model more complex. This solution can be sought using the genetic algorithm method as a further suggestion. Then, the use of MACD can be combined with other indicators to estimate rising stock price trends more accurately. In addition, MACD also needs to be used for conditional conditions, such as when economic chaos occurs. In other words, the jumping effect on stock returns, which often occurs in stocks in large stock markets such as in the United States of America, can be considered. The jumping effect can be accommodated using the jumping process.
This research academically develops a portfolio design mechanism by clustering stocks and analyzing its price movement trends, enabling investors to practically diversify and choose stocks with increasing price trends, reducing losses, and increasing profit opportunities.

Author Contributions

Conceptualization, S. and D.R.; methodology, D.A.I.M. and M.D.J.; software, R.A.I.; validation, S., D.R. and D.A.I.M.; formal analysis, S.; investigation, R.A.I.; resources, S.; data curation, R.A.I.; writing—original draft preparation, R.A.I.; writing—review and editing, S.; visualization, R.A.I.; supervision, D.R.; project administration, M.D.J.; funding acquisition, S. All authors have read and agreed to the published version of the manuscript.

Funding

Universitas Padjadjaran for the ACADEMIC LEADERSHIP GRANT (ALG) with contract number: 1549/UN6.3.1/PT.00/2023; and Department of Mathematics, Universitas Gajah Mada for “Hibah Matching Research 2023”.

Data Availability Statement

Data are available within the article.

Acknowledgments

Thank you to Universitas Padjadjaran for providing the Aticle Processing Charge (APC), and thank you to Department of Mathematics, Universitas Gajah Mada for its collaboration through “Hibah Matching Research 2023”.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Boyle, P.; Garlappi, L.; Uppal, R.; Wang, T. Keynes Meets Markowitz: The Trade-Off Between Familiarity and Diversification. Manag. Sci. 2012, 58, 253–272. [Google Scholar] [CrossRef]
  2. Kirby, C.; Ostdiek, B. It’s All in the Timing: Simple Active Portfolio Strategies That Outperform Naïve Diversification. J. Financ. Quant. Anal. 2012, 47, 437–467. [Google Scholar] [CrossRef]
  3. Xiong, J.; Zhou, X.Y. Mean-Variance Portfolio Selection under Partial Information. SIAM J. Control Optim. 2007, 46, 156–175. [Google Scholar] [CrossRef]
  4. Chan, K.; Hameed, A. Stock Price Synchronicity and Analyst Coverage in Emerging Markets. J. Financ. Econ. 2006, 80, 115–147. [Google Scholar] [CrossRef]
  5. Chen, L.-H.; Huang, L. Portfolio Optimization of Equity Mutual Funds with Fuzzy Return Rates and Risks. Expert Syst. Appl. 2009, 36, 3720–3727. [Google Scholar] [CrossRef]
  6. Sinha, P.; Chandwani, A.; Sinha, T. Algorithm of Construction of Optimum Portfolio of Stocks Using Genetic Algorithm. Int. J. Syst. Assur. Eng. Manag. 2015, 6, 447–465. [Google Scholar] [CrossRef]
  7. Golosnoy, V.; Okhrin, Y. Flexible Shrinkage in Portfolio Selection. J. Econ. Dyn. Control 2009, 33, 317–328. [Google Scholar] [CrossRef]
  8. Ren, F.; Lu, Y.-N.; Li, S.-P.; Jiang, X.-F.; Zhong, L.-X.; Qiu, T. Dynamic Portfolio Strategy Using Clustering Approach. PLoS ONE 2017, 12, e0169299. [Google Scholar] [CrossRef]
  9. Fleischhacker, A.; Lettner, G.; Schwabeneder, D.; Auer, H. Portfolio Optimization of Energy Communities to Meet Reductions in Costs and Emissions. Energy 2019, 173, 1092–1105. [Google Scholar] [CrossRef]
  10. Tola, V.; Lillo, F.; Gallegati, M.; Mantegna, R.N. Cluster Analysis for Portfolio Optimization. J. Econ. Dyn. Control 2008, 32, 235–258. [Google Scholar] [CrossRef]
  11. Musmeci, N.; Aste, T.; Di Matteo, T. Relation between Financial Market Structure and the Real Economy: Comparison between Clustering Methods. PLoS ONE 2015, 10, e0116201. [Google Scholar] [CrossRef] [PubMed]
  12. Hussain, W.; Merigó, J.; Raza, M.; Gao, H. A New QoS Prediction Model Using Hybrid IOWA-ANFIS with Fuzzy C-Means, Subtractive Clustering and Grid Partitioning. Inf. Sci. 2022, 584, 280–300. [Google Scholar] [CrossRef]
  13. Chen, B.; Zhong, J.; Chen, Y. A Hybrid Approach for Portfolio Selection with Higher-Order Moments: Empirical Evidence from Shanghai Stock Exchange. Expert Syst. Appl. 2020, 145, 113104. [Google Scholar] [CrossRef]
  14. Cheong, D.; Kim, Y.M.; Byun, H.W.; Oh, K.J.; Kim, T.Y. Using Genetic Algorithm to Support Clustering-Based Portfolio Optimization by Investor Information. Appl. Soft Comput. 2017, 61, 593–602. [Google Scholar] [CrossRef]
  15. Khan, A.Z.; Mehlawat, M.K. Dynamic Portfolio Optimization Using Technical Analysis-based Clustering. Int. J. Intell. Syst. 2022, 37, 6978–7057. [Google Scholar] [CrossRef]
  16. Vásquez Sáenz, J.; Quiroga, F.M.; Bariviera, A.F. Data vs. Information: Using Clustering Techniques to Enhance Stock Returns Forecasting. Int. Rev. Financ. Anal. 2023, 88, 102657. [Google Scholar] [CrossRef]
  17. Navarro, M.M.; Young, M.N.; Prasetyo, Y.T.; Taylar, J.V. Stock Market Optimization amidst the COVID-19 Pandemic: Technical Analysis, K-Means Algorithm, and Mean-Variance Model (TAKMV) Approach. Heliyon 2023, 9, e17577. [Google Scholar] [CrossRef] [PubMed]
  18. Aheer, A.K.; Pradhan, A.K.; Srivastava, R. Application of Feedforward Neural Network in Portfolio Optimization and Geometric Brownian Motion in Stock Price Prediction. In Proceedings of the 2023 4th International Conference on Electronics and Sustainable Communication Systems (ICESC), Coimbatore, India, 6–8 July 2023; IEEE: Piscataway, NJ, USA, 2023; pp. 1494–1503. [Google Scholar]
  19. Hasbullah, E.S.; Halim, N.B.A.; Sukono; Putra, A.S.; Bon, A.T. Mean-Variance Portfolio Optimization on Islamic Stocks by Using Non Constant Mean and Volatility Models and Genetic Algorithm. Int. J. Eng. Technol. 2018, 7, 366. [Google Scholar] [CrossRef]
  20. Du, X.; Tanaka-Ishii, K. Stock Portfolio Selection Balancing Variance and Tail Risk via Stock Vector Representation Acquired from Price Data and Texts. Knowl.-Based Syst. 2022, 249, 108917. [Google Scholar] [CrossRef]
  21. Chang, R.-H.; Young, M.N.; Hildawa, M.I.; Santos, I.J.R.; Pan, C.-H. Portfolio Selection Problem Considering Behavioral Stocks. In Proceedings of the World Congress on Engineering (WCE) 2015, London, UK, 1–3 July 2015; Lecture Notes in Engineering and Computer Science. pp. 685–690. [Google Scholar]
  22. Varga-Haszonits, I.; Kondor, I. Noise Sensitivity of Portfolio Selection in Constant Conditional Correlation GARCH Models. Phys. A Stat. Mech. Appl. 2007, 385, 307–318. [Google Scholar] [CrossRef]
  23. Thuankhonrak, P.; Rattagan, E.; Phoomvuthisarn, S. Machine Trading by Time Series Models and Portfolio Optimization. In Proceedings of the 2019 4th International Conference on Information Technology (InCIT), Bangkok, Thailand, 24–25 October 2019; IEEE: Piscataway, NJ, USA; pp. 217–222. [Google Scholar]
  24. Markowitz, H. Portfolio Selection. J. Financ. 1952, 7, 77–91. [Google Scholar] [CrossRef]
  25. Sharpe, W.F. A Simplified Model for Portfolio Analysis. Manag. Sci. 1963, 9, 277–293. [Google Scholar] [CrossRef]
  26. Sharpe, W.F. A Linear Programming Approximation for the General Portfolio Analysis Problem. J. Financ. Quant. Anal. 1971, 6, 1263. [Google Scholar] [CrossRef]
  27. Young, M.R. A Minimax Portfolio Selection Rule with Linear Programming Solution. Manag. Sci. 1998, 44, 673–683. [Google Scholar] [CrossRef]
  28. Björk, T.; Murgoci, A.; Zhou, X.Y. Mean-Variance Portfolio Optimization with State-Dependent Risk Aversion. Math. Financ. 2014, 24, 1–24. [Google Scholar] [CrossRef]
  29. Abdurakhman, A. Asset Allocation in Indonesian Stocks Using Portfolio Robust. Math. Stat. 2022, 10, 1313–1319. [Google Scholar] [CrossRef]
  30. Faramarzi, A.; Heidarinejad, M.; Stephens, B.; Mirjalili, S. Equilibrium Optimizer: A Novel Optimization Algorithm. Knowl.-Based Syst. 2020, 191, 105190. [Google Scholar] [CrossRef]
  31. Zhou, X.Y.; Li, D. Continuous-Time Mean-Variance Portfolio Selection: A Stochastic LQ Framework. Appl. Math. Optim. 2000, 42, 19–33. [Google Scholar] [CrossRef]
  32. Zhu, H.; Wang, Y.; Wang, K.; Chen, Y. Particle Swarm Optimization (PSO) for the Constrained Portfolio Optimization Problem. Expert Syst. Appl. 2011, 38, 10161–10169. [Google Scholar] [CrossRef]
  33. Kalfin, S.; Carnia, E. Portfolio Optimization of the Mean-Absolute Deviation Model of Some Stocks Using the Singular Covariance Matrix. Int. J. Recent Technol. Eng. 2019, 8, 7818–7822. [Google Scholar] [CrossRef]
  34. Ryoo, H.S. A Compact Mean-Variance-Skewness Model for Large-Scale Portfolio Optimization and Its Application to the NYSE Market. J. Oper. Res. Soc. 2007, 58, 505–515. [Google Scholar] [CrossRef]
  35. Wang, J.; Gan, X. Neurodynamics-Driven Portfolio Optimization with Targeted Performance Criteria. Neural Netw. 2023, 157, 404–421. [Google Scholar] [CrossRef] [PubMed]
  36. Mba, J.C.; Ababio, K.A.; Agyei, S.K. Markowitz Mean-Variance Portfolio Selection and Optimization under a Behavioral Spectacle: New Empirical Evidence. Int. J. Financ. Stud. 2022, 10, 28. [Google Scholar] [CrossRef]
  37. Du, J. Mean–Variance Portfolio Optimization with Deep Learning Based-Forecasts for Cointegrated Stocks. Expert Syst. Appl. 2022, 201, 117005. [Google Scholar] [CrossRef]
  38. Li, X.; Uysal, A.S.; Mulvey, J.M. Multi-Period Portfolio Optimization Using Model Predictive Control with Mean-Variance and Risk Parity Frameworks. Eur. J. Oper. Res. 2022, 299, 1158–1176. [Google Scholar] [CrossRef]
  39. Ranković, V.; Drenovak, M.; Urosevic, B.; Jelic, R. Mean-Univariate GARCH VaR Portfolio Optimization: Actual Portfolio Approach. Comput. Oper. Res. 2016, 72, 83–92. [Google Scholar] [CrossRef]
  40. Ashrafzadeh, M.; Taheri, H.M.; Gharehgozlou, M.; Hashemkhani Zolfani, S. Clustering-Based Return Prediction Model for Stock Pre-Selection in Portfolio Optimization Using PSO-CNN+MVF. J. King Saud Univ.-Comput. Inf. Sci. 2023, 35, 101737. [Google Scholar] [CrossRef]
  41. Jain, A.K. Data Clustering: 50 Years beyond K-Means. Pattern Recognit. Lett. 2010, 31, 651–666. [Google Scholar] [CrossRef]
  42. Chong, T.T.-L.; Ng, W.-K. Technical Analysis and the London Stock Exchange: Testing the MACD and RSI Rules Using the FT30. Appl. Econ. Lett. 2008, 15, 1111–1114. [Google Scholar] [CrossRef]
  43. Hidayat, Y.; Purwandari, T.; Sukono; Prihanto, I.G.; Hidayana, R.A.; Ibrahim, R.A. Mean-Value-at-Risk Portfolio Optimization Based on Risk Tolerance Preferences and Asymmetric Volatility. Mathematics 2023, 11, 4761. [Google Scholar] [CrossRef]
  44. Rosillo, R.; de la Fuente, D.; Brugos, J.A.L. Technical Analysis and the Spanish Stock Exchange: Testing the RSI, MACD, Momentum and Stochastic Rules Using Spanish Market Companies. Appl. Econ. 2013, 45, 1541–1550. [Google Scholar] [CrossRef]
  45. Wang, J.; Kim, J. Predicting Stock Price Trend Using MACD Optimized by Historical Volatility. Math. Probl. Eng. 2018, 2018, 9280590. [Google Scholar] [CrossRef]
  46. Purwandari, T.; Riaman; Hidayat, Y.; Sukono; Ibrahim, R.A.; Hidayana, R.A. Selecting and Weighting Mechanisms in Stock Portfolio Design Based on Clustering Algorithm and Price Movement Analysis. Mathematics 2023, 11, 4151. [Google Scholar] [CrossRef]
  47. Madhulatha, T.S. An Overview on Clustering Methods. IOSR J. Eng. 2012, 2, 719–725. [Google Scholar] [CrossRef]
  48. Kanungo, T.; Mount, D.M.; Netanyahu, N.S.; Piatko, C.D.; Silverman, R.; Wu, A.Y. An Efficient K-Means Clustering Algorithm: Analysis and Implementation. IEEE Trans. Pattern Anal. Mach. Intell. 2002, 24, 881–892. [Google Scholar] [CrossRef]
  49. Hidayana, R.A.; Napitupulu, H.; Sukono, S. An Investment Decision-Making Model to Predict the Risk and Return in Stock Market: An Application of ARIMA-GJR-GARCH. Decis. Sci. Lett. 2022, 11, 235–246. [Google Scholar] [CrossRef]
  50. Rankovic, V.; Drenovak, M.; Stojanovic, B.; Kalinic, Z.; Arsovski, Z. The Mean-Value at Risk Static Portfolio Optimization Using Genetic Algorithm. Comput. Sci. Inf. Syst. 2014, 11, 89–109. [Google Scholar] [CrossRef]
  51. Ibrahim, R.A.; Sukono; Napitupulu, H.; Ibrahim, R.I. How to Price Catastrophe Bonds for Sustainable Earthquake Funding? A Systematic Review of the Pricing Framework. Sustainability 2023, 15, 7705. [Google Scholar] [CrossRef]
  52. Bowling, S.R.; Khasawneh, M.T.; Kaewkuekool, S.; Cho, B.R. A Logistic Approximation to the Cumulative Normal Distribution. J. Ind. Eng. Manag. 2009, 2, 114–127. [Google Scholar] [CrossRef]
  53. Sukono; Ibrahim, R.A.; Saputra, M.P.A.; Hidayat, Y.; Juahir, H.; Prihanto, I.G.; Halim, N.B.A. Modeling Multiple-Event Catastrophe Bond Prices Involving the Trigger Event Correlation, Interest, and Inflation Rates. Mathematics 2022, 10, 4685. [Google Scholar] [CrossRef]
  54. Sinaga, J.; Wu, T.; Chen, Y. Impact of Government Interventions on the Stock Market during COVID-19: A Case Study in Indonesia. SN Bus. Econ. 2022, 2, 136. [Google Scholar] [CrossRef] [PubMed]
  55. Rousseeuw, P.J. Silhouettes: A Graphical Aid to the Interpretation and Validation of Cluster Analysis. J. Comput. Appl. Math. 1987, 20, 53–65. [Google Scholar] [CrossRef]
  56. Tibshirani, R.; Walther, G.; Hastie, T. Estimating the Number of Clusters in a Data Set Via the Gap Statistic. J. R. Stat. Soc. Ser. B Stat. Methodol. 2001, 63, 411–423. [Google Scholar] [CrossRef]
  57. Lo, A.W. The Statistics of Sharpe Ratios. Financ. Anal. J. 2002, 58, 36–52. [Google Scholar] [CrossRef]
Figure 2. K-means clustering method algorithm.
Figure 2. K-means clustering method algorithm.
Mathematics 12 00174 g002
Figure 3. Stocks with a positive mean of return on the Kompas 100 Index in Indonesia.
Figure 3. Stocks with a positive mean of return on the Kompas 100 Index in Indonesia.
Mathematics 12 00174 g003
Figure 4. Average silhouette width value of each cluster.
Figure 4. Average silhouette width value of each cluster.
Mathematics 12 00174 g004
Figure 5. Relationship between mean and VaR of portfolio return.
Figure 5. Relationship between mean and VaR of portfolio return.
Mathematics 12 00174 g005
Figure 6. Sensitivity of buy transaction costs (a), sell transaction costs (b), income tax (c), portfolio loss probability (d), and z α (e) to the mean of portfolio return.
Figure 6. Sensitivity of buy transaction costs (a), sell transaction costs (b), income tax (c), portfolio loss probability (d), and z α (e) to the mean of portfolio return.
Mathematics 12 00174 g006aMathematics 12 00174 g006b
Figure 7. Sensitivity of selling transaction costs (a), income tax (b), portfolio loss opportunities (c), and z α (d) to the standard deviation of portfolio returns.
Figure 7. Sensitivity of selling transaction costs (a), income tax (b), portfolio loss opportunities (c), and z α (d) to the standard deviation of portfolio returns.
Mathematics 12 00174 g007
Figure 8. Sensitivity of risk tolerance to mean (a) and VaR (b) of portfolio returns.
Figure 8. Sensitivity of risk tolerance to mean (a) and VaR (b) of portfolio returns.
Mathematics 12 00174 g008
Table 1. List of stock codes in each sector on the 100 Kompas Index in Indonesia.
Table 1. List of stock codes in each sector on the 100 Kompas Index in Indonesia.
SectorFrequencyStock Code
Financials16AGRO, ARTO, BBCA, BBKP, BBNI, BBRI, BBTN, BDMN, BFIN, BMRI, BRIS, BTPS, PNBN, PNIN, PNLF, STRG
Energy15ADMR, ADRO, AKRA, DOID, ELSA, ENRG, BSSR, HRUM, INDY, ITMG, MEDC, PGAS, PTBA, RAJA, RMKE
Basic Materials14AGII, ANTM, AVIA, BRMS, BRPT, ESSA, INCO, INKP, INTP, MDKA, SMGR, TINS, TKIM, TPIA
Primary Consumer Goods14AALI, AMRT, CPIN, DSNG, GGRM, HMSP, ICBP, INDF, JPFA, LSIP, MYOR, SSMS, TAPG, UNVR
Infrastructures11ADHI, EXCL, ISAT, JKON, JSMR, MTEL, PTPP, TBIG, TLKM, TOWR, WIKA
Nonprimary Consumer Goods8ACES, ERAA, LPPF, MAPI, MNCN, MPMX, MSIN, SCMA
Healthcare7HEAL, KLBF, MIKA, MMIX, MTMH, OMED, SIDO
Industrials5ABMM, ASII, BMTR, EMTK, UNTR
Properties and Real Estate4BSDE, CTRA, PWON, SMRA
Technology4BELI, BUKA, GOTO, WIFI
Transportation and Logistics2ASSA, SMDR
Total100
Table 2. Checking buy indications on 40 stocks in the Kompas 100 Index with a positive mean of return using MACD.
Table 2. Checking buy indications on 40 stocks in the Kompas 100 Index with a positive mean of return using MACD.
Stock Code MACD ( t ) S i g r ( t ) Does the Stock Have a Buy Indication?
ABMM−19.60−1.39No
ACES6.6810.07No
AKRA9.4819.36No
AMRT−8.9311.93No
BBCA−26.36−39.07Yes
BBNI143.26124.69Yes
BBRI−86.91−75.08No
BELI−0.28−0.37Yes
BFIN−36.64−33.46No
BMRI37.1848.76No
BRIS−31.41−21.16No
BRMS−2.812.80No
BRPT53.7689.07No
BSDE−13.41−20.68Yes
CPIN134.6259.03Yes
CTRA−19.13−21.58Yes
DOID27.8122.70Yes
DSNG5.324.43Yes
ELSA−2.232.06No
ENRG−1.683.20No
ERAA−14.68−12.09No
EXCL5.3910.70No
GGRM15.24−127.52Yes
HRUM6.3936.78No
ICBP15.88−29.46Yes
INDF−35.69−71.16Yes
INKP160.60352.62No
INTP−191.78−186.63No
ISAT206.66157.69Yes
JSMR14.2260.31No
MAPI11.77−11.27Yes
MEDC39.7788.66No
MIKA−10.58−20.79Yes
MPMX−4.14−3.26No
MYOR16.98−1.11Yes
RAJA−1.889.60No
SMRA−16.79−17.73Yes
SSMS15.536.84Yes
TKIM193.69429.13No
TPIA126.52122.84Yes
Table 3. Description of 18 data to be clustered.
Table 3. Description of 18 data to be clustered.
Stock CodeSectorMean of ReturnVaR of Return
MAPINon-primary Consumer Goods 2.952 × 10 3 5.010 × 10 2
CPINPrimary Consumer Goods 4.287 × 10 4 3.008 × 10 2
DSNGPrimary Consumer Goods 8.042 × 10 4 3.813 × 10 2
GGRMPrimary Consumer Goods 1.775 × 10 3 4.266 × 10 2
ICBPPrimary Consumer Goods 3.986 × 10 4 2.195 × 10 2
INDFPrimary Consumer Goods 2.754 × 10 4 2.106 × 10 2
MYORPrimary Consumer Goods 8.772 × 10 4 3.543 × 10 2
SSMSPrimary Consumer Goods 6.665 × 10 4 5.099 × 10 2
TPIABasic Materials 5.550 × 10 4 3.055 × 10 2
DOIDEnergy 1.953 × 10 3 4.328 × 10 2
BBCAFinancials 1.983 × 10 4 1.906 × 10 2
BBNIFinancials 2.829 × 10 4 2.296 × 10 2
MIKAHealthcare 1.313 × 10 3 4.265 × 10 2
ISATInfrastructures 1.092 × 10 3 3.466 × 10 2
BSDEProperties and Real Estate 7.175 × 10 4 2.794 × 10 2
CTRAProperties and Real Estate 5.164 × 10 4 2.996 × 10 2
SMRAProperties and Real Estate 7.272 × 10 4 3.602 × 10 2
BELITechnology 6.019 × 10 5 1.494 × 10 2
Table 4. Results of one hundred experiments in determining clusters from 18 stocks.
Table 4. Results of one hundred experiments in determining clusters from 18 stocks.
Stock CodeFrequency of Appearance in ClustersChosen ClusterAccuracy
(%)
12345
MAPI100----1100
DOID8119---181
GGRM100----1100
MIKA8317---183
SSMS100----1100
MYOR98110--281
DSNG-85114-285
ISAT-8911--289
SMRA-955--295
TPIA--68257368
CTRA--7327-373
CPIN--7030-370
BSDE--66727467
ICBP--52966566
INDF--21484584
BBNI--52768568
BBCA---3169569
BELI---3367567
Average of Accuracy (%)80.33
Table 5. The final results of the five stock clusters.
Table 5. The final results of the five stock clusters.
ClusterCentroidMember of Cluster
1 1.145 × 10 3 4.594 × 10 2 MAPI, GGRM, SSMS, DOID, MIKA
2 1.139 × 10 3 3.606 × 10 2 DSNG, MYOR, ISAT, SMRA
3 4.069 × 10 4 3.019 × 10 2 CPIN, TPIA, CTRA
4 7.272 × 10 4 2.794 × 10 2 BSDE
5 5.390 × 10 4 1.999 × 10 2 ICBP, INDF, BBCA, BBNI, BELI
Table 6. List of Sharpe ratios of each stock in each cluster.
Table 6. List of Sharpe ratios of each stock in each cluster.
ClusterStock CodeSharpe Ratio
1MAPI 1.030 × 10 1
DOID 9.821 × 10 2
GGRM 7.033 × 10 2
MIKA 6.331 × 10 2
SSMS 2.150 × 10 5
2MYOR 6.847 × 10 2
DSNG 5.971 × 10 2
ISAT 4.849 × 10 2
SMRA 4.395 × 10 2
3TPIA 4.452 × 10 2
CTRA 2.828 × 10 2
CPIN 2.388 × 10 2
4BSDE 2.814 × 10 2
5ICBP 3.513 × 10 2
INDF 1.520 × 10 2
BBNI 1.098 × 10 2
BBCA 9.105 × 10 3
BELI 6.655 × 10 3
Table 7. Results of determining optimal weights accompanied by descriptive statistics from the portfolio.
Table 7. Results of determining optimal weights accompanied by descriptive statistics from the portfolio.
VariableValue
τ 5.112
λ 1.196 × 10 6
w 1 2.434 × 10 1
w 2 1.175 × 10 1
w 3 1.120 × 10 1
w 4 1.947 × 10 1
w 5 3.324 × 10 1
s = 1 6 w s 1
Mean of Portfolio Return 5.626 × 10 4
Deviation Standard of Portfolio Return 9.800 × 10 3
Value at Risk of Portfolio Return 1.748 × 10 2
Sharpe ratio 5.741 × 10 2
Table 8. Mean of portfolio return from two compared mechanisms and actual mean of portfolio return on the next day.
Table 8. Mean of portfolio return from two compared mechanisms and actual mean of portfolio return on the next day.
MechanismMean of Portfolio ReturnReal Mean of Portfolio Return
MI 5.626 × 10 4 7.149 × 10 4
MII 1.889 × 10 3 1.394 × 10 3
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Sukono; Rosadi, D.; Maruddani, D.A.I.; Ibrahim, R.A.; Johansyah, M.D. Mechanisms of Stock Selection and Its Capital Weighing in the Portfolio Design Based on the MACD-K-Means-Mean-VaR Model. Mathematics 2024, 12, 174. https://doi.org/10.3390/math12020174

AMA Style

Sukono, Rosadi D, Maruddani DAI, Ibrahim RA, Johansyah MD. Mechanisms of Stock Selection and Its Capital Weighing in the Portfolio Design Based on the MACD-K-Means-Mean-VaR Model. Mathematics. 2024; 12(2):174. https://doi.org/10.3390/math12020174

Chicago/Turabian Style

Sukono, Dedi Rosadi, Di Asih I Maruddani, Riza Andrian Ibrahim, and Muhamad Deni Johansyah. 2024. "Mechanisms of Stock Selection and Its Capital Weighing in the Portfolio Design Based on the MACD-K-Means-Mean-VaR Model" Mathematics 12, no. 2: 174. https://doi.org/10.3390/math12020174

APA Style

Sukono, Rosadi, D., Maruddani, D. A. I., Ibrahim, R. A., & Johansyah, M. D. (2024). Mechanisms of Stock Selection and Its Capital Weighing in the Portfolio Design Based on the MACD-K-Means-Mean-VaR Model. Mathematics, 12(2), 174. https://doi.org/10.3390/math12020174

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop