06-26-2018, 05:24 AM
Digital Signal Processing is an important subject that is taught in Electrical Engineering degree courses. There are many books that try to apply digital signal processing to financial market prediction and algorithmic trading. I have started this thread in which I would discuss whether we can apply digital signal processing techniques in predicting the financial market. First we read the 1 minute GBPUSD price data and then use the scipy signal package to determine the peaks/valleys.
Below is the screenshot of the valleys identified by scipy.signal.find_peaks_cwt package. This package first uses a wavelet transform and then determines the peaks.
These were the valleys. We can also determine the peaks also very easily with the above code.
Looking at the above two screenshots, you can judge how good is the algorithm in determining the peaks/valleys.
Code:
import scipy.signal
from peakutils.plot import plot as pplot
print('Detect peaks without any filters.')
df2=np.array(df['Close'])
df2=df2[-300:]
#indexes = scipy.signal.find_peaks_cwt(df2, np.arange(1, 30),\
# max_distances=np.arange(1, 30)*2)
indexes = scipy.signal.find_peaks_cwt(-df2, np.arange(1, 20))
indexes = np.array(indexes) - 1
print('Peaks are: %s' % (indexes))
x=np.arange(0,len(df2))
y=df2
plt.figure(figsize=(40,40))
plt.title("Price")
plt.plot(x,y)
plt.show()
print(x[indexes], y[indexes])
plt.figure(figsize=(20,20))
pplot(x, y, indexes)
plt.title('Peaks')
#determine the peaks easily with this code
indexes = scipy.signal.find_peaks_cwt(df2, np.arange(1, 20))
These were the valleys. We can also determine the peaks also very easily with the above code.
Looking at the above two screenshots, you can judge how good is the algorithm in determining the peaks/valleys.
Subscribe My YouTube Channel:
https://www.youtube.com/channel/UCUE7VPo...F_BCoxFXIw
Join Our Million Dollar Trading Challenge:
https://www.doubledoji.com/million-dolla...challenge/