Clustering Defensive Shariah-compliant Stocks Using Financial Performance as the Indicator

Nur Sara Zainudin - Multimedia University, Persiaran Multimedia, Cyberjaya, 63100, Malaysia
Choo-Yee Ting - Multimedia University, Persiaran Multimedia, Cyberjaya, 63100, Malaysia
Kok-Chin Khor - Universiti Tunku Abdul Rahman, Jalan Sungai Long, Kajang, 43000, Malaysia
Keng-Hoong Ng - Universiti Tunku Abdul Rahman, Jalan Sungai Long, Kajang, 43000, Malaysia
Gee-Kok Tong - Multimedia University, Persiaran Multimedia, Cyberjaya, 63100, Malaysia
Suraya Nurain Kalid - Multimedia University, Persiaran Multimedia, Cyberjaya, 63100, Malaysia

Citation Format:



Malaysian stocks, including Shariah-compliant stocks, have experienced turbulence last year. Although there are defensive stocks, the well-performing ones are not easily identified. Researchers have proposed various metrics to identify defensive stocks. However, most of the approaches require human intervention. In this study, we focus on Shariah-compliant stocks and propose to automate the labeling of stocks in terms of their financial performance via clustering. The study aims to identify the optimal clustering method to label the clusters. This was achieved by first employing k-Means, Agglomerative, and Mean Shift clustering to group similar stocks before labeling. When labeling, the criteria to distinguish well-performing defensive Shariah-compliant stocks were high dividend yield, low price-earnings ratio, low Beta value, and low price-to-book value. After labelling each stock with its financial performance (Low, Medium, High), we performed classification using Logistic Regression, k-Nearest Neighbors, Support Vector Machine, Decision Tree, and Random Forest to verify the credibility of the labels. Based on the results, the clusters created by k-Means clustering outperformed the rest in matching accuracy. Further investigation was conducted on the k-Means data set by dividing the data according to sector and classifying each sector’s data separately. Logistic Regression outperformed other classification algorithms with an accuracy of 71.5%. The findings also suggested accuracy increased when stocks were classified according to sectors. Further considerations include performing outlier analysis on the data to select well-performing stocks.


Defensive shariah-compliant stocks; clustering; weighted scores; profiling; classification

Full Text:



H. Chung, ‘Bursa expects short-term market volatility in 2023’, The Edge Markets. Accessed: Sep. 01, 2023. [Online]. Available:

J. Shasitiran, ‘Bursa turnaround only in second half of 2023’, Free Malaysia Today. Accessed: Sep. 01, 2023. [Online]. Available:

S. Tajdini, M. Mehrara, and R. Tehrani, ‘Double-sided balanced conditional Sharpe ratio’, Cogent Economics & Finance, vol. 7, no. 1, Jan. 2019, doi: 10.1080/23322039.2019.1630931.

R. Subekti, Abdurakhman, and D. Rosadi, ‘Toward the Black–Litterman with Shariah-compliant asset pricing model: a case study on the Indonesian stock market during the COVID-19 pandemic’, International Journal of Islamic and Middle Eastern Finance and Management, vol. 15, no. 6, pp. 1150–1164, Nov. 2022, doi: 10.1108/IMEFM-12-2020-0633/FULL/XML.

M. H. Musa, F. A. Razak, J. S. Matematik, F. Sains, and D. Teknologi, ‘Directed network of Shariah-compliant stock in Bursa Malaysia’, J Phys Conf Ser, vol. 1988, no. 1, p. 012019, Jul. 2021, doi: 10.1088/1742-6596/1988/1/012019.

F. Shear and B. N. Ashraf, ‘The performance of Islamic versus conventional stocks during the COVID-19 shock: Evidence from firm-level data’, Res Int Bus Finance, vol. 60, p. 101622, Apr. 2022, doi: 10.1016/J.RIBAF.2022.101622.

M. W. Raza, B. Said, and A. Elshahat, ‘Covid-19 and informational efficiency in Asian emerging markets: a comparative study of conventional and Shariah-compliant stocks’, International Journal of Islamic and Middle Eastern Finance and Management, vol. 16, no. 3, pp. 576–592, Apr. 2023, doi: 10.1108/IMEFM-01-2022-0041/FULL/XML.

M. M. Tan, D. D. Reidpath, R. S. K. Ting, P. Allotey, and T. T. Su, ‘Religiousness and Quality of Life Among Older Adults of Different Ethnic Groups in Malaysia: A Five-Year Follow-up Study’, J Relig Health, vol. 61, no. 2, pp. 1548–1563, Apr. 2022, doi: 10.1007/S10943-021-01371-X/TABLES/5.

R. Mestre, ‘Stock profiling using time–frequency-varying systematic risk measure’, Financial Innovation, vol. 9, no. 1, pp. 1–29, Dec. 2023, doi: 10.1186/S40854-023-00457-7/FIGURES/2.

V. Chang, X. Man, Q. Xu, and C. H. Hsu, ‘Pairs trading on different portfolios based on machine learning’, Expert Syst, vol. 38, no. 3, p. e12649, May 2021, doi: 10.1111/EXSY.12649.

K. Raed, ‘Dividend Policy and Companies’ Financial Performance’, Journal of Asian Finance, Economics and Business, vol. 7, no. 10, pp. 531–542, 2020, doi: 10.13106/JAFEB.2020.VOL7.NO10.531.

A. Insana, ‘Does systematic risk change when markets close? An analysis using stocks’ beta’, Econ Model, vol. 109, p. 105782, Apr. 2022, doi: 10.1016/J.ECONMOD.2022.105782.

Y. Indrayono, ‘Predicting returns with financial ratios: Evidence from Indonesian Stock Exchange’, Management Science Letters, vol. 9, no. 11, pp. 1901–1908, 2019, doi: 10.5267/J.MSL.2019.6.003.

J. A. Enriquez, M. P. Doblas, and Ma. C. P. Lagaras, ‘Price to Earnings and Price to Book Ratios as Determinants of Stock Return: The Case of Financial Institutions Listed in Bahrain Bourse’, Journal of Applied Economic Sciences (JAES), vol. XV, no. 69, pp. 532–539, 2020, doi: 10.14505/jaes.v15.3(69).02.

K. Agudze and O. Ibhagui, ‘DO FUNDAMENTALS DRIVE RELATIVE VALUATION? EVIDENCE FROM GLOBAL STOCK MARKET INDICES’, Journal of Financial Management, Markets and Institutions, vol. 8, no. 2, Dec. 2020, doi: 10.1142/S2282717X20500024.

J. A. Cardinali and R. Yasenchak, ‘How a New Benchmark Adds to the Evaluation of a Defensive Equity Strategy’, The Journal of Index Investing, vol. 11–12, no. 4–1, pp. 6–17, Jun. 2021, doi: 10.3905/JII.2021.1.103.

G. Hengky Wirawan, E. Sumirat, and W. Buffett, ‘Performance Analysis of Investment Portfolio Strategy Using Warren Buffett, Benjamin Graham, and Peter Lynch Method in Indonesia Stock Exchange’, European Journal of Business and Management Research, vol. 6, no. 4, pp. 394–401, Aug. 2021, doi: 10.24018/EJBMR.2021.6.4.1040.

J. Chen, M. Lasfer, W. Song, and S. Zhou, ‘Recession managers and mutual fund performance’, Journal of Corporate Finance, vol. 69, p. 102010, Aug. 2021, doi: 10.1016/J.JCORPFIN.2021.102010.

G. De Rossi, J. Kolodziej, and G. Brar, ‘A recommender system for active stock selection’, Computational Management Science, vol. 17, no. 4, pp. 517–547, Dec. 2020, doi: 10.1007/S10287-018-0342-9/TABLES/14.

S. S. Sharma, P. K. Narayan, K. Thuraisamy, and N. Laila, ‘Is Indonesia’s stock market different when it comes to predictability?’, Emerging Markets Review, vol. 40, p. 100623, Sep. 2019, doi: 10.1016/J.EMEMAR.2019.100623.

V. Dhingra, A. Sharma, and S. K. Gupta, ‘Sectoral portfolio optimization by judicious selection of financial ratios via PCA’, Optimization and Engineering 2023, pp. 1–38, Jun. 2021, doi: 10.1007/S11081-023-09849-1/TABLES/13.

A. Backhaus, A. Z. Isiksal, and M. Bausch, ‘What Financial Conditions Affect Dynamic Equity Risk Factor Allocation?’, Economies, vol. 10, no. 2, p. 42, Feb. 2022, doi: 10.3390/ECONOMIES10020042.

Y. Liao, J. Coakley, and N. Kellard, ‘Index tracking and beta arbitrage effects in comovement’, International Review of Financial Analysis, vol. 83, p. 102330, Oct. 2022, doi: 10.1016/J.IRFA.2022.102330.

A. Ahmed Bukar, C. Ogohi Daniel, and A. Ahmed, ‘Nature of Beta in the Nigerian Stock Market-Challenges and Prospects’, Soc Sci, vol. 9, no. 3, pp. 92–98, 2020, doi: 10.11648/

A. L. Loviscek and K. Xie, ‘In Search of Market Outperformance: Another Look at Berkshire Hathaway’, The Journal of Wealth Management, vol. 24, no. 4, pp. 90–108, Feb. 2022, doi: 10.3905/JWM.2021.1.163.

I. Palupi, B. A. Wahyudi, and I. Indwiarti, ‘The clustering algorithms approach for decision efficiency in investment portfolio diversification’, in 2019 7th International Conference on Information and Communication Technology (ICoICT 2019), Institute of Electrical and Electronics Engineers Inc., Jul. 2019. doi: 10.1109/ICOICT.2019.8835314.

P. Vilas, L. Andreu, and J. L. Sarto, ‘Cluster analysis to validate the sustainability label of stock indices: An analysis of the inclusion and exclusion processes in terms of size and ESG ratings’, J Clean Prod, vol. 330, p. 129862, Jan. 2022, doi: 10.1016/J.JCLEPRO.2021.129862.

Y. E. Putra, D. Saepudin, and A. Aditsania, ‘Portfolio Selection of KOMPAS-100 Stocks Index Using B-Spline Based Clustering’, Procedia Comput Sci, vol. 179, pp. 375–382, Jan. 2021, doi: 10.1016/J.PROCS.2021.01.019.

P. Dziuba, D. Glukhova, and K. Shtogrin, ‘RISK, RETURN AND INTERNATIONAL PORTFOLIO DIVERSIFICATION: K-MEANS CLUSTERING DATA’, Baltic Journal of Economic Studies, vol. 8, no. 3, pp. 53–64, Sep. 2022, doi: 10.30525/2256-0742/2022-8-3-53-64.

L. Owen and F. Oktariani, ‘SENN: Stock Ensemble-based Neural Network for Stock Market Prediction using Historical Stock Data and Sentiment Analysis’, in 2020 International Conference on Data Science and Its Applications (ICoDSA 2020), Institute of Electrical and Electronics Engineers Inc., Aug. 2020. doi: 10.1109/ICODSA50139.2020.9212982.

Y. Xu, C. Yang, S. Peng, and Y. Nojima, ‘A hybrid two-stage financial stock forecasting algorithm based on clustering and ensemble learning’, Applied Intelligence, vol. 50, no. 11, pp. 3852–3867, Nov. 2020, doi: 10.1007/S10489-020-01766-5/FIGURES/10.

K. Nakagawa, M. Imamura, and K. Yoshida, ‘Stock price prediction using k-medoids clustering with indexing dynamic time warping’, Electronics and Communications in Japan, vol. 102, no. 2, pp. 3–8, Feb. 2019, doi: 10.1002/ECJ.12140.

S. N. Z. Abidin, S. H. Jaaman, M. Ismail, and A. S. A. Bakar, ‘Clustering Stock Performance Considering Investor Preferences Using a Fuzzy Inference System’, Symmetry (Basel), vol. 12, no. 7, p. 1148, Jul. 2020, doi: 10.3390/SYM12071148.

M. Buszko, W. Orzeszko, and M. Stawarz, ‘COVID-19 pandemic and stability of stock market—A sectoral approach’, PLoS One, vol. 16, no. 5, p. e0250938, May 2021, doi: 10.1371/JOURNAL.PONE.0250938.

J. E. Salgado-Hernández and M. Vyas, ‘Non-linear correlation analysis in financial markets using hierarchical clustering’, J Phys Commun, vol. 7, no. 5, p. 055003, May 2023, doi: 10.1088/2399-6528/ACD618.

K. Chaudhari and A. Thakkar, ‘Neural network systems with an integrated coefficient of variation-based feature selection for stock price and trend prediction’, Expert Syst Appl, vol. 219, p. 119527, Jun. 2023, doi: 10.1016/J.ESWA.2023.119527.

J. M. Chen and M. U. Rehman, ‘A Pattern New in Every Moment: The Temporal Clustering of Markets for Crude Oil, Refined Fuels, and Other Commodities’, Energies (Basel), vol. 14, no. 19, p. 6099, Sep. 2021, doi: 10.3390/EN14196099.

E. Umargono, J. E. Suseno, and S. K. V. Gunawan, ‘K-Means Clustering Optimization Using the Elbow Method and Early Centroid Determination Based on Mean and Median Formula’, in The 2nd International Seminar on Science and Technology (ISSTEC 2019), Atlantis Press, Oct. 2020, pp. 121–129. doi: 10.2991/ASSEHR.K.201010.019.

S. Y. Ong, C. Y. Ting, H. N. Goh, A. Quek, and C. L. Cham, ‘Workplace Preference Analytics Among Graduates’, Journal of Informatics and Web Engineering, vol. 2, no. 2, pp. 233–248, Sep. 2023, doi: 10.33093/JIWE.2023.2.2.17.