Sub topic 6
Thresholds and parameters that control a scenario
This chapter assumes you know what a scenario is: a rule that turns a typology such as structuring into logic over transactions. It also assumes you can read basic Python.
Logic versus parameters
A scenario has two parts. The logic is the shape of the rule: "count cash deposits just under a limit inside a rolling window." The parameters are the numbers the logic reads: the window length, the count, and the amount band.
Keeping them apart has two practical benefits:
- Compliance teams can change parameters without a software release.
- The same logic can run with different numbers for different customer segments.
The structuring scenario from the earlier chapters reads four parameters:
| Parameter | Meaning | Effect of raising it |
|---|---|---|
| `lookback_days` | Length of the rolling window | More history is counted, so more alerts |
| `min_count` | Qualifying deposits needed to alert | Fewer alerts |
| `floor` | Lowest amount that counts as "just under" | Fewer alerts |
| `ceiling` | The reporting limit the deposits stay below | More amounts qualify, so more alerts |
Thresholds trade misses against noise
Every threshold sets a balance between two errors. A loose threshold, such as min_count of 2, catches more real structuring. It also buries analysts in alerts about ordinary customers. A tight threshold keeps volume low but misses launderers who stay just under it.
Launderers can also learn thresholds, so values are not secret forever. This is why institutions review them on a schedule.
Same logic, different segments
A weekly cash business can legitimately deposit just under the limit several times a week. A retail customer rarely does. Parameters are therefore stored per segment, and each customer is evaluated with the values for their segment.
from datetime import datetime, timedelta
PARAMS = {
"retail": {"lookback_days": 7, "min_count": 3, "floor": 8000, "ceiling": 10000},
"business": {"lookback_days": 7, "min_count": 5, "floor": 8000, "ceiling": 10000},
}
def max_hits(deposits, params):
"""Largest number of qualifying deposits inside any rolling window."""
window = timedelta(days=params["lookback_days"])
qualifying = sorted(
ts for ts, amount in deposits
if params["floor"] <= amount < params["ceiling"]
)
best = 0
start = 0
for end, ts in enumerate(qualifying):
while ts - qualifying[start] > window:
start += 1
best = max(best, end - start + 1)
return best
deposits = [
(datetime(2026, 3, 2, 10, 0), 9500),
(datetime(2026, 3, 3, 15, 30), 9200),
(datetime(2026, 3, 5, 9, 15), 9800),
(datetime(2026, 3, 6, 9, 0), 9400),
]
for segment, params in PARAMS.items():
hits = max_hits(deposits, params)
print(segment, hits, hits >= params["min_count"])
# retail 4 True
# business 4 FalseThe four deposits are identical in both runs. The retail parameters produce an alert and the business parameters do not, because min_count is 3 for retail and 5 for business.
Common errors
- Boundary mistakes. The code uses
floor <= amount < ceiling. A deposit of exactly 10000 does not qualify, because a deposit at the limit is not "under" it. Write down whether each bound is inclusive. Mixing up>and>=silently changes which transactions alert. - Hard-coded values. A number buried in the logic cannot be tuned or audited. Read it from the parameter set instead.
- Unvalidated parameters. A
flooraboveceilingmakes the scenario match nothing, and no error appears. Check parameter sets when they are loaded. - Unversioned changes. Regulators and auditors ask why a threshold was 3 in March and 4 in June. Record who changed each value, when, and with what justification.
Exercise
A scenario currently alerts when a retail customer makes 3 or more deposits between 8000 and 10000 inside 7 days. Analysts close nearly every alert as unsuspicious. Name two parameters you could change to reduce alert volume, and the direction of each change.
Show answer
Raise min_count (for example from 3 to 4), or raise floor (for example from 8000 to 9000) so fewer deposits qualify. Shortening lookback_days also reduces volume. Test any change on historical data first, because a tighter threshold can also hide real structuring.