Created
February 4, 2020 23:17
-
-
Save henryrossiter/6da6c5bea75590142ed17e99cb66ce36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def moving_average(a, n=3) : | |
ret = np.cumsum(a, dtype=float) | |
ret[n:] = ret[n:] - ret[:-n] | |
return ret[n - 1:] / n | |
n = 12 | |
plt.plot(moving_average(btc_data, n=n)) | |
plt.plot(btc_data[n - 1:]) | |
plt.title('Daily Low Bitcoin Prices - 1 Year') | |
plt.legend(['{} day moving average of low prices'.format(n), 'daily low price']) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment