Finding Lows with PeakUtils
raoofhujairi opened this issue ยท 2 comments
raoofhujairi commented
Just wanted to command you for your great effort in comparing the options of finding peaks .
as to Peak utils not detecting lows, i found a quick solutions for that , by ๐
- Inverting the data set ( multiplying by -1)
- passing the data set/frame to peakutils.indexes( )
indexes returned are now actually the lows of the data set.
you could plot the lows along with the peaks by passing the indexes to mplot
as indexes for the same signal data.
Quick example
load the date and select columns
.
.
.
Dates = df['Date']
Close = df['Close'] # Second column data
Close_Inversed = df['Close'] * -1
peaks = peakutils.indexes(Close, thres=0.15, min_dist=50)
lows = peakutils.indexes(Close_Inversed, thres=0.15, min_dist=50)
print('Peaks are:\n %s' % (Dates[peaks]))
print('Lows are:\n %s' % (Dates[Lows]))
#plot closing price
plt.plot(col1,col2, lw=2 )
#plot peaks in green markers
plt.plot(Dates[peaks],Close[peaks], marker="8", markersize=10, color='G', ls="")
#plot buttoms in red markers
plt.plot(Dates[lows],Close[lows], marker="8", markersize=10, color='R', ls="")
.
.
.
.
plt.show()
note the plot below .
Raoof.
MonsieurV commented
matols commented
cool