Let’s ignore the fact that you mocked me not only directly, but also by asking Rosanno for an explanation instead of me, and try to focus on a simpler suggestion. (By the way, DeepSeek understood my solution perfectly.)
Your current implementation is already pretty close to preventing stacked deals. It just needs the following tweak, for example.
Proposed Solution:
-
Remember the Last Deal’s Price:
- Track the price of the most recent deal (regardless of direction) as the reference point for the dynamic price filter. (That’s what Gainium already does.)
-
Check for Existing Deals in an Epsilon Range:
-
Before opening a new deal, check if there’s already an open deal within
-
either a small delta-epsilon range (e.g., 0.1% < currently relevant deviation
over
orunder
) around the proposed price. (This delta/epsilon (forunder
/over
) could even be configurable.) -
or the configured deviations for
under
andover
.
-
-
If such a deal exists, do not open a new deal. Instead, update the “last deal’s price” reference to this existing deal’s price.
-
-
Apply the Dynamic Filter:
- If no deal exists in the epsilon range, proceed with opening the new deal and update the “last deal’s price” reference to this new deal’s price.