The formation of an optimal portfolio is one of the strategies of investors in allocating their funds so as to minimize risk while maximizing profits. The optimal portfolio formation method has evolved over the years, ranging from simple calculation methods, to using complex optimization algorithms. This study aims to group LQ-45 stocks through a clustering algorithm, then determine the right weighting of representative shares of each cluster through the combination of GA-PSO so that an optimal portfolio is produced. The research begins with data pre-processing which includes transformation and reduction of data dimensions. The data from the dimension reduction is used to group stocks into clusters based on the best clustering algorithm. The stocks with the highest Sharpe ratio in each cluster are used to form the portfolio. The performance of the weighted portfolio using GA-PSO will be compared with the weighted portfolio using PSO. The results of the study showed that the K-Means algorithm became the clustering method with the highest silhouette score, which was 0.3614, and the optimal number of clusters produced was 6. Based on the results of the K-Means algorithm, the cluster representative stocks used for portfolio formation are ANTM, BRPT, EXCL, MDKA, MEDC, and PTBA. Furthermore, the results showed that the Sharpe ratio of stock portfolios using GA-PSO combined was greater than that of portfolios that used PSO alone for weighting. The K-Means algorithm is more suitable for grouping stocks than the DBSCAN and Agglomerative algorithms with Average Linkage. Furthermore, the combination of genetic algorithms and particle swarm optimization complements each other in weighting stocks so that it produces a portfolio with more optimal performance when compared to only using particle swarm optimization.