This paper presents a method for optimal portfolio selection in Tehran's stock market using the Cuckoo Optimization Algorithm (COA). By analyzing annual stock return data from 81 active companies, the study compares the effectiveness of COA with genetic algorithms in maximizing investment returns. The findings demonstrate the advantages of COA in achieving optimal portfolio allocations while considering financial constraints.