The purpose of this study is to utilize the Markowitz Model to build an optimal portfolio of stocks on the Indonesia Stock Exchange in 2019 to 2023, focusing on stocks in the IDX30 index. Based on information from KSEI, the public premium in capital market speculation continues to increase. On that basis, this study is important to be conducted in order to provide a reference for the public to invest. The IDX30 index was chosen as the subject of the study because it includes stocks with large market capitalization, high liquidity, and stable financial conditions. This study determines the optimal fund allocation for each stock and examines stocks in the IDX30 index from 2019 to 2023 that are worthy of consideration for inclusion in the optimal portfolio. In this test, it produces four stocks that become the optimal portfolio with the most extreme profits, namely ADRO 16.12%, BBCA 65.97%, BBRI 4.13%, and ICBP 13.76% with a return of 1.01% and a risk of 0.22%. In contrast, the minimum risk consists of ADRO of 5.29%, BBCA of 26.14%, CPIN of 13.91%, ICBP of 16.17%, INDF of 8%, KLBF of 0.48%, TLKM of 13.47%, and UNVR of 16.55%, with a risk of 0.1% and an expected portfolio return of 0.11%.