Nowadays, investing in stocks is in great demand, especially among young people in Indonesia. In investing, investors will be faced with various problems in developing a good portfolio, including determining the assets for investment and determining the amount of capital required. Therefore, this study aims to determine how to choose stocks and the proportion of capital to invest in order to form an optimal portfolio. In this study, the Markowitz model is used to specifically minimize variance by constraining the number of weights and profit targets. An analysis of the closing prices of stocks included in the IDX30 index for the period August 2021 to January 2021 was carried out with data taken from September 11, 2020 to September 9, 2021, sourced from https://finance.yahoo.com/. The results of the study show that from 30 stocks, 7 stocks were selected that were categorized as good performers in each sector. Seven shares with the proportion of capital allocated for each share, namely BMRI (8.92051%), BRPT (3.718450%), ANTM (12.80686%), TBIG (23.30450%), MIKA (17.98822%), KLBF (7.96699%), and ASII (25.29447%).