Section 2: Daily Returns

In this lesson, the daily returns of different stocks are calculated.

Daily returns

The price of stock changes on a daily basis. Daily return calculations tell us how much the current day stock value is different from the previous day stock value. A positive change indicates a rise in the value of the stock while a negative change indicates a fall in the value of the stock. A stock with minimal positive or negative change is considered to be a stable and good stock.

As seen in the previous lesson, only Systems Ltd and Avanceon stocks provide promising results for the year 2018. So, daily returns of Systems Ltd will be calculated and visualized in this lesson as this company had a higher value compared to Avanceon. Results for any company can be obtained by simply changing the name for the company file as discussed before.

Calculating daily returns

We don’t need to figure out the formula or steps for calculating the daily returns because pandas already provides a built-in function for it. The pct_change function is called from a Series object, and it calculates the daily return for all rows based on the current and previous row value. This function returns a new Series with the calculated daily returns. The first row has no, or NaN, value as there is no previous value for it.

Get hands-on with 1000+ tech skills courses.