How to find tops and bottoms in time series?

匆匆过客 提交于 2019-12-03 08:46:26

问题


At first, this question can sound really stupid, but it is not in fundamental. Maybe, it can seem like unresolvable exactly by any algorithm, but I pretend to say it is.

So question. I have chart, for example gold. I need to find where are tops and bottoms on time axial. The problem is I need to find where major upturns and major downturns start. The problem is that there is lot of small irrelevant upturns and downturns.

Here is the picture for better understanding - the red spots are that I want to find(NOT EXACTLY, but in some way like this).

So I probably need to filter out small turnups and turndowns, but have no idea how to do it. I will be pleased by any ideas. I do not need algorithm in java etc, just in words it would be enough.


回答1:


  1. You could perform a smoothing or lowpass filtering operation first, and find the locations of the local minima/maxima from the smoothed data. Then get the values of the minima and the maxima from the original data.

  2. You could use a normal maximum/minimum filter, which finds all turning points, then filter the list of turning points by threshold.

  3. I think what you really want to do is remove the "long-term variation" from the signal and look only at the "short term variation". This is can be done using the empirical mode decomposition. See Sec 2.3.2 of my thesis. (Alernately, Google around for "Empirical Mode Decomposition", "EMD", or "Hilbert-Huang Transform".)

Here's the EMD in action:

Notice the increasing generality as the EMD algorithm extracts components of the signal, starting at "most detailed" and ending with "most general trend". (Note there are apparently nine components - only a few are shown.)




回答2:


You'll usually start with a moving average -- that is, averaging the N most recent points, where the degree of smoothing is roughly proportional to N (i.e., as yoy average more points, your result gets smoother).

Then you can take the differences between each averaged point and the next. Where the difference changes sign, you have a minimum or maximum (where it goes from positive to negative, you have a maximum, from negative to positive, a minimum).




回答3:


I might not fully understand but why can't you just take the lowest point for a specific time range? Most data providers do provide high/low of the day, can you not just store it and then simply get the lowest value for time range x?

By extending the range of your study you remove the small ups/downs. This is what I typically do. Another way is, you can use averages of the last X days to smooth out the results(moving averages) but then you'll lose accuracy(degree is dependent on range..if its a 2-3 days moving average than its not as bad a 2 year moving average).

EDIT: sorry, I miss understood, you are trying to find the range. Well if you have the data then why not find the lowest point(s) first and then go to the next day and figure out the % change, then the next, etc..and overwrite the day when you find a higher range. You'll need to add some more logic later(such as %down from that peak or something) otherwise you'll report will typically take the stock's ipo and take its all that high and say thats a single period.



来源:https://stackoverflow.com/questions/10169176/how-to-find-tops-and-bottoms-in-time-series

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!