Portfolio optimization is the selection of the optimal portfolio from all the portfolios considered. This paper uses diversified data, including technology, medicine, real estate and so on, to make the data more referential. In the process, five stocks with better performance in the corresponding fields were selected. In this paper, the CAPM and FF3F model are used to select the optimal portfolio. This paper also uses Sharpe ratio and weight to measure whether the portfolio can achieve the optimal. The results show that except for ‘VLO’, the covariance of other assets is below 0.01, which can perform better in the minimization of variance. And ‘MDT’ has the highest weight in the CAPM model, followed by ‘JLL’, which can maximize the Sharpe ratio. But in the FF3F model, ‘JLL’ has the highest weight and ‘WMT’ has zero weight to maximize the Sharpe ratio. The results of this paper will enable investors in related industries to get a better portfolio paradigm.