Portfolio Optimization is an optimization problem in finance in which the aim is to maximize the return and minimize the risk of failure within the collection of assets, such as stocks, bonds, etc. This portfolio optimization problem has been of great concern to economic practitioners; since the risk cannot be completely eliminated, an appropriate risk management strategy for choosing and optimizing the portfolio, such that it will fulfill investors' expected risk criteria and returns, will be required. In this paper, we discuss stock portfolio optimization, where stock data based on financial parameters, such as P/E ratio and EPS ratio is converted to score parameters and then clustered by K-means clustering algorithm. After clustering, some stocks will be chosen for the portfolio. The weight of each stock portfolio will be determined such that the objective will be obtained. The Ant Colony Optimization algorithm is used to determine the weight of each stock. The portfolio performance will be evaluated based on some actual datasets. We show important facts that the value of a fitness function is key in choosing the corresponding weighted stock in a stock portfolio and the numerical results also suggest how to reduce the losses of the portfolio.