With the rapid development of technology and the increasing maturity of financial markets, stock price prediction has become a hot topic and an important trend in the financial field. However, the stock market has complexity and volatility, in order to reduce the investment risk and ensure the maximization of benefits, selecting the optimal stock to predict the stock price and formulating the quantitative trading strategy are extremely important issues for financial academics and investors. For the research of stock price prediction and quantitative trading, firstly, the quantitative stock selection model combining XGBoost and multi-factor stock selection model is constructed, and four stocks are screened out, and then the CNN-BiLSTM-Attention model is proposed to predict the stock price trend of the selected stocks, and it is found from the prediction results of the four stocks that the prediction accuracies all reach more than 95%, which is higher than that of the single model prediction. accuracy and passed the validity test of the fitted model. Secondly, based on the quantitative investment portfolio given in the above analysis and the quantitative stock trading strategy of MACD, the prediction results are verified, and the total return of most stocks based on the strategy is higher than 40% at the highest, and the loss is controlled within 10%, which indicates that the trading strategy in this paper is effective and feasible. The study concludes that greater returns can be obtained by calculating the total returns of stock portfolios based on different portfolio approaches.