This tutorial performs a simple linear regression to build Capital Asset Pricing Model(CAPM), a classical model developed by William F. Sharpe and Harry Markowitz. This model yields alpha and beta for each asset and is traded by going long the stocks ranked with the highest alpha. This tutorial demonstrates how to use historical data, set an event handler, conduct linear regression and build your own functions in the QuantConnect Algorithm Lab. The implementation of the strategy demonstrates that stocks beat the market last month are likely to beat again in the subsequent month. This algorithm performs well when the market is smooth. However when the market volatility increases the model fails to capture alpha and it performs poorly. We conclude market fluctuations decrease the significance level of the linear regression coefficients, especially when we are using daily returns to fit the model.