Python Forum
Can someone help me solve this programming problem?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can someone help me solve this programming problem?
#1
Let's say I have a list of values like this:

100
99
90
79
62
94
88
75
80
72
74
87
84
90

I would like to look for the peaks and troughs in the numbers. However, I want to ignore small movements because the data may not go down consecutively until it reaches the trough and I would like to remove the ‘noise’ from the data.

I want to ignore small changes in price that are 10% or lower than the original peak or trough. This 10% move could span over several rows, it's a cumulative move.

It’s easy to see from the data that the first trough comes at 62. That is because there is no movement that goes in the opposite direction that is over 10%

It is also easy to see the next peak because 94 is way higher than 10% and it starts moving back down after that.

However the tricky part is after 75 it goes upwards to 80 which I’d like to ignore because the next row finally reaches a trough of 72. This small upward movement isn't enough to invalidate the trend.

Then it goes to 74, 87, 84 & 90 which qualifies for a new peak because it is over 10% and doesn’t get invalidated by a 10% movement in the opposite direction.

So if I were a great programmer, I’d like to make a printout of the data like this:

First peak = 100
First trough = 62
Second peak = 94
Second trough = 72
Third peak = 90

It’s quite easy to do this as a human but I’m having a lot of trouble programming it in python. I would be extremely grateful if anyone could help me with this problem.
Reply


Messages In This Thread
Can someone help me solve this programming problem? - by SuchUmami - Nov-13-2023, 07:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  A simple problem, how best to solve it? SuchUmami 2 1,419 Sep-01-2023, 05:36 AM
Last Post: Pedroski55
Question Linear Programming Problem Axel_LF 0 1,346 Feb-23-2023, 11:03 PM
Last Post: Axel_LF
  How to solve this simple problem? Check if cvs first element is the same in each row? thesquid 2 1,990 Jun-14-2022, 08:35 PM
Last Post: thesquid
  How do I solve the second problem? Cranberry 1 1,760 May-16-2022, 11:56 AM
Last Post: Larz60+
  Try to solve GTG multiplication table problem. Frankduc 6 3,397 Jan-18-2022, 08:26 PM
Last Post: Frankduc
  Sudoku Solver, please help to solve a problem. AdithyaR 5 3,336 Oct-28-2021, 03:15 PM
Last Post: deanhystad
Lightbulb Object Oriented programming (OOP) problem OmegaRed94 6 4,327 May-31-2021, 07:19 PM
Last Post: OmegaRed94
  python 3 raspberry pi 4 dual control motor programming problem yome 0 2,670 Mar-21-2021, 05:17 PM
Last Post: yome
  General list size question to solve problem Milfredo 3 3,169 Sep-27-2020, 08:42 AM
Last Post: Milfredo
  I want to solve the following problem srisrinu 4 7,648 May-09-2020, 01:07 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020