Python quantitative stock trading (10) --- using machine learning algorithms to predict the rise and fall of stocks

Preface

The previous 9 blog posts have explained the various graphical drawing and calculation formulas of quantitative trading more clearly. Here, let's play another interesting quantitative transaction, which is to use the algorithm in machine learning to predict the stocks' rise and fall next day. I believe this article is the most anticipated by everyone, so let's read on.

Random forest algorithm

Random Forest (Random Forest) is a classic Bagging model. The Bagging algorithm is similar to voting. It is a weak learner decision tree. Each weak learner (can be regarded as everyone, in stock prediction, can be regarded as training Each grouping of the model has one vote, and finally we will produce the final prediction result based on the principle of "the minority obeys the majority".

For example, the original data set: Goertek shares. There is a year's rise and fall. We use the random forest algorithm to predict. It will first divide all the data into samples 1, 2, 3, 4, etc. for training, and then you import The stock data details of a certain day, then each sample will predict the ups and downs based on the data you import, and whichever predicts the result is the most.

Build a stock forecast model

Here, we need to get the historical ups and downs of stocks for training. Therefore, the first thing we have to do is to obtain the stock data, here we obtain Muyuan shares 2019

Guess you like

Origin blog.csdn.net/liyuanjinglyj/article/details/113443968