In this paper, we have modeled and optimized the multi-period stock portfolio by considering variance heterogeneity and determining the optimal number of stock packages. This model seeks to maximize the return and minimize the risk of the investment portfolio using the squared value at risk. Due to the investment portfolio in this research is based on predicted values; therefore, autoregressive modeling and variance heterogeneity have been used to predict stocks returns. Prediction is done with Python software. The linearized mathematical model for optimizing the portfolio in each period was solved using GAMS software. Furthermore, three stock portfolio designs, including predicting returns and optimizing periodic portfolio, a random portfolio, and a combination of low-risk and high-yield cases have been investigated. In two designs, the random portfolio and the portfolio with 5 high-return and 5 low-risk stocks, with the increase in the risk rate level, the annual return increases, which indicates the consistent relation between risk and return. In the periodic portfolio, this trend has been observed up to 20% risk level, while at 25% risk, there has been a decrease in return. The periodic portfolio has shown more fluctuations in profitability, while the combined approach and the random portfolio have had a more stable trend in increasing profitability with increasing risk.