Plateau detection
Hi!
Thanks for your great work. I have some date which does not have a peak but several plateaus (consecutive peaks with the same value). Is there a possibility to detect them with your functions?
Comments (11)
-
repo owner -
repo owner - changed status to resolved
Fixed by pull request #2.
-
Was the above ever resolved? In my data plateaus are still not detected as peaks:
-
repo owner It was. Can you share the data and the exact code snippet use to generate this plot?
-
The data is real-time 1-minute ticks of EURUSD forex charts, using closing prices to draw the line graph. The data is collected through the Oanda API, but should be the same for any real-time source.
import peakutils from peakutils.peak import indexes import matplotlib.pyplot as plt col1 = df.index.values col2 = df['rates'] pkin = peakutils.indexes(col2, thres=0.05, min_dist=1) plt.plot(col1, col2, lw=0.4) plt.plot(col1[pkin], col2[pkin], 'ro') plt.show()
-
repo owner Can you get me a sample that is problematic for you?
-
Here is an example, I've managed to export it all as a csv, but I'm unsure if that is necessary?
ind. rates ... ... 24 1.16305 25 1.1631 26 1.1631 27 1.1631 28 1.163
As you can see index 25, 26, 27 in this example all have the same closing rate. I have an above average rate of repeating numbers because I take the close rates from bullish candlesticks and the open rate from bearish ones for a very specific purpose; normally I don't think forex data would have this many repeats, but they're still likely to happen.
What this looks like graphed is:
-
repo owner From the data points you suplied:
import peakutils as pu import peakutils.plot as p import numpy as np data = np.array([1.16305, 1.1631, 1.1631, 1.1631, 1.163]) x = np.arange(len(data)) ind = pu.indexes(data, thres=0.05, min_dist=1) p.plot(x, data, ind) p.plt.show()
-
Works fine for me with version 1.1.0 even with a plateau with 3 consecutives indexes with the exact same value.
Thank you for that very usefull library by the way!
-
Oh I see. It was not an issue with peakutils, but my fault as a beginner to python. While I thought imports always brought in the newest version of a module that was not the case, but chasing down the version and updating fixed the issue right away for me. Thank you so much for your help!
-
repo owner I'm glad that it is working now. Special thanks to Christophe Vestri for implementing the plateau detection.
- Log in to comment
Hi,
Currently no, as peakutils.indexes will not detect plateaus (with exact same values). I think this is a needed feature, and may be added.