Predict stock performance by using MLR

It is to use multi-linear regression(MLR) to study each individual factor contributing to the stock performance within 3 months’ time.

The code will be written in python language.

For stock data, we downloaded from, as it allows you to export the data to .csv file.

The selection criteria uses in our project is as follows:

Time as of Nov 30/2016

  1. Market Cap >= 100 million
  2. Avg Volume >= 10000
  3. Beta <= 3
  4. P/E(Trailing 12 Months) <= 150
  5. Current Ratio < 10
  6. Current ROE(TTM) >= -100
  7. 12 Mo Trailing EPS >= 0
  8. Price as a % of 52 Wk H-L Range > -100%
  9. % Price Change (12 Weeks) > -100%

There are 2718 stocks being screened out through the criteria. And we split the data into train data and test data with about 80% to 20% ratio.

We train the multi-linear regression model with train data and generate the pred data based on test set.

Meanwhile, we are trying to find out which are the most critical factors that would contribute most to the % Price Change (12 Weeks).

The method that we used to optimize our model is backward eliminination (

After optimized, the most critical factors are:

  • market cap (x1)
  • average volume within one day (x2)
  • current ratio (x3)
  • Price as a % of 52 Wk H-L Range (x4)



From the model, we can draw the multi-linear liquation as follows:

% Price Change (12 Weeks) = (-20.6866) + (-3.612e-05)*(market cap) + (2.037e-07)*(average volume within one day) + (-0.2819)*(current ratio) + (0.3669)*(Price as a % of 52 Wk H-L Range)

Definitely, this model will not be the best one and it is just for study and research purpose.


You can download the full code as github:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s