Standard deviation details

Could you please explain why do we don't just use the standard deviation formule like data.std().

In your case you add the number of trading day 252 and 0,5 which is I guess the number of trading hours ? then multiplie by 100

I get normal results for some commodities but USOIL is display a very huge value, so I'm trying to understand it hide the other value in a bar chat.

Thanks!

Sorry for double message this is the course:

Course Name: Momentum Trading Strategies, Section No: 7, Unit No: 5, Unit type: Notebook

Yes, you can directly use data_pc.std() without 252 and 0.5 etc. That will not impact the strategy outcome. 



But then why it is done in the course. In the course, we are doing that to annualise the volatility value so that it is easy to interpret.



The steps followed are as follows:


  1. Compute the standard deviation. This will be daily standard deviation if you are working with daily data. In the course, we are working with daily data so it is daily standard deviation value.



    data_std = data_pc.std()


  2. To convert daily standard deviation to annual standard deviation, we multiply the daily std dev value with the square root of the number of trading days in a year. This is 252^0.5. You can also use np.sqrt(252).



    data_std = data_pc.std()*(252**0.5)




  3. The standard deviation after this will be 0.05 for 5%. To convert that into percentage terms (0.05 –> 5%), again for ease of interpretation, we multiply the value by 100.





    data_std = data_pc.std()*(252**0.5)*100

I get normal results for some commodities but USOIL is display a very huge value, so I'm trying to understand it hide the other value in a bar chat.


To hide the first value from bar chart you can use the below code. 
top_decile_new = top_decile[1:]
top_decile_new.plot.bar(figsize=(16,7),color='green',ylim=top_decile.min()*0.9)

Or you can simply print the top decile dataframe
print(top_decile)

I hope this helps.

It's very clear now, thanks a lot for your long answer :slight_smile: