# Measuring Stock Performance with MEAN Returns and STD of Returns A free video tutorial from Alexander Hagmann
Data Scientist | Finance Professional | Entrepreneur
4.6 instructor rating • 6 courses • 27,957 students

The Complete Pandas Bootcamp 2020: Data Science with Python

Pandas fully explained | 150+ Exercises | Must-have skills for Machine Learning & Finance | + Scikit-Learn and Seaborn

31:50:30 of on-demand video • Updated October 2020

• Bring your Data Handling & Data Analysis skills to an outstanding level.
• Learn and practice all relevant Pandas methods and workflows with Real-World Datasets
• Learn Pandas based on NEW Version 1.0 (the days of versions 0.x are over)
• Import, clean, and merge messy Data and prepare Data for Machine Learning
• Master a complete Machine Learning Project A-Z with Pandas, Scikit-Learn, and Seaborn
• Analyze, visualize, and understand your Data with Pandas, Matplotlib, and Seaborn
• Practice and master your Pandas skills with Quizzes, 150+ Exercises, and Comprehensive Projects
• Import Financial/Stock Data from Web Sources and analyze them with Pandas
• Learn and master the most important Pandas workflows for Finance
• Learn how to best transition from Versions 0.X to new Version 1.0
• Learn the Basics of Pandas and Numpy Coding (Appendix)
• Learn and master important Statistical Concepts with scipy
English [Auto] In this video we will get to the core of how to measure and compare performance of stocks and other financial securities and in the last video we have learned how to calculate absolute changes with the DIF method and relative changes with the percentage change method. And it's actually no surprise that the relative changes are more meaningful than absolute changes. So for example an increase of stock price by two dollars is better for stock with an original price of 50 than for a stock that starts at a price of one hundred and in percentage terms. It's a 4 percent change was a 2 percent change and this change is also quite return and the total return of a stock consists of the price increase or price return and the dividend payments. So we are still important pandas and we also important umpire. And here in this video we are working with the apple close prizes. So here we are from the data frame with the closing prices and if already learned that with the percentage change method we can calculate the price return or the return of the Apple stock price for example. And we also change the drop in a method and we can also save the data frame with the daily price returns and the variable read our returns and we can also have a look here with the info method. So in total we have two thousand two hundred eighty eight daily returns for the Apple stock and to get an intuition on the distribution of daily returns it might be a good idea to do this graphically with a histogram and therefore you're reducing the plot method on the returns data frame and pass history to the kind parameter and we select the 100 pins. So let's have a look. So this is the distribution of daily returns and it's actually no surprise uh that uh the majority of daily returns are here around 0 percent but we also have some extreme values here in the tail. So we had two days with minus 10 percent and also between 5 and plus 10 percent here and actually there are two major metrics how to summarize these distributions and this is the mean are the average return and uh the variance are the standard deviation of returns and the intuition behind the mean return is pretty simple and clear. So the higher the mean return the more value investors generate with this investment. But not only the mean return is important for investors but also the risk that is behind the investment and return and the risk of an investment is typically measured as the variability or the volatility of returns around the the mean value or the mean return and the volatility or risk of returns as measured as the variance. Us then that deviation of returns and it's pretty clear that investors prefer high return and low volatility or low risk but actually you can hardly meet both targets. So either you get the low returns with the low risk and the one example would be your savings account and your bank. So maybe the interest or the return is about 1 percent or one point five percent. And uh this is pretty much riskless or you invest in an Apple stock here and in the long run you expect the returns of 10 15 or 20 percent but also the risk is pretty high here. As you have days with daily returns of minus 10 percent and now let's go on here and our example. And the. So here we have the distribution of daily returns and we can also calculate that daily mean return. So this should be somewhere here. And of course we can do this with the mean method so the daily mean return a zero point 0 9 percent. And as a measure of variability our risk we can calculate also the variance of daily returns and we can do this with the VAR method so that's the variance of daily returns. And typically in finance we do not use the variance but the standard deviation. And as a short recap of high school math. So the standard deviation is simply the square root of the variance and therefore we use here the NUM pi function and put out the square root and we pass the variance of daily returns here and TBA for the standard deviation of daily returns. That's 0 point 0 1 6. And we can also directly calculate the standard deviation of daily returns with the method the standard deviation S t the. So the skips last year the same result and we can already see here with uh the daily mean return and uh the standard deviation of daily returns so that these numbers are quite small because they are based on daily returns but that might be more meaningful to have annualized returns. And standard deviation and we can actually annualize the daily mean return by multiplying the daily mean return with 252. And using 252 and not 365 because typically on average we have two hundred fifty two trading days. So without weekends and bank holidays and uh therefore we take here the daily mean and we multiply the daily mean with two hundred to fifty two. And by doing so we are getting the annualized the mean return based on daily returns and uh this is here for the Apple stock twenty two point seventy three percent. And this is definitely more meaningful and intuitive. So you might know from your savings account that you get an interest of maybe 1 percent one point five percent and this is always an annual interest and compared to one point five per year that you can get on your savings account. So twenty two point seven percent return on the Apple stock per years. Quite huge but there's definitely also more risk involved. And we can also annualize the risk and we can do this with the variance by also multiplying the variance by 252. So this would be the annualized variance of daily returns six point seven percent. And to get to the annualized standard deviation of returns we can again take the square root of the annualized variance of returns. So let's do this. And the skips last year and any less than that deviation of 26 percent. And we can also do this directly by calculating the standard deviation of daily returns and multiply it with the square root of two hundred fifty two. And this gives us actually the same result of course. And now finally we have two metrics here to describe the performance. So the historic performance of the Apple stock. So we have an annualized the return of twenty two point seven percent and we have an annualized the standard deviation of returns of 26 percent. And in our example our calculations are based on daily returns but we can also do this based on weekly returns or monthly returns. And that's actually no right or wrong. And it always depends on the specific case what you use. So for example if we have price data for a period of only one year then it might be pretty difficult to calculate the risk. The standard deviation based on only monthly returns or even annual returns. So in this case that might be better to have weekly returns for example. And it's also the case that the annualized the risk based on daily returns is higher than the annualized risk based on monthly returns our weekly returns. And it always depends on the specific case which returns to use or monthly returns or weekly returns. But for the time being here that's clearly beyond the scope of this video. And uh with this we are finished here and I hope to see you also in the next one by.