Lesson 10 of 14
Already have access? Sign in here
Already have access? Sign in here
Ask questions about this lesson and get instant answers.
We will use functions from numpy package to calculate the mean and variance of daily returns. Variance as we know, is the square of standard deviation (Volatility).
1# Calculate Mean and Standard Deviation
2
3import numpy as np
4
5# Daily returns
6daily_returns = stock_data['Simple Returns']
7
8# Calculate statistics
9mean_daily_returns = np.mean(daily_returns)
10std_dev_daily_returns = np.std(daily_returns)
11variance_daily_returns = np.var(daily_returns)
12Premium membership required
Upgrade to premium to unlock all videos and courses