November 2019
Beginner
394 pages
10h 31m
English
Let's have a look at the following code, which demonstrates the implementation of standard derivatives.
We are going to import the statistics and the math library we need to perform basic mathematical operations. We are defining the loopback period with the variable time_period, and we will store the past prices in the list history, while we will store the SMA and the standard deviation in sma_values and stddev_values. In the code, we calculate the variance, and then we calculate the standard deviation. To finish, we append to the goog_data data frame that we will use to display the chart:
import statistics as statsimport math as mathtime_period = 20 # look back periodhistory = [] # history of pricessma_values ...