June 2015
Beginner
348 pages
8h 44m
English
Let's smooth the close prices from the small AAPL stock prices data file:
blackman() function to form a window, and then use this window to smooth the price signal:closes=np.loadtxt('AAPL.csv', delimiter=',', usecols=(6,), converters={1:datestr2num}, unpack=True)
N = 5
window = np.blackman(N)
smoothed = np.convolve(window/window.sum(),
closes, mode='same')plt.plot(smoothed[N:-N], lw=2, label="smoothed") plt.plot(closes[N:-N], label="closes") plt.legend(loc='best') ...
Read now
Unlock full access