Skip to content

Finding Lows with PeakUtils #3

@raoofhujairi

Description

@raoofhujairi

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 😀

  1. Inverting the data set ( multiplying by -1)
  2. 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.

2017-01-03

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions