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 a test on transactions. It also assumes you can read basic Python. Here you will see how the numbers inside a scenario decide how many alerts it creates and which ones. You will also see how to store, validate and vary those numbers safely.
Logic and parameters are separate things
A scenario has two parts.
- The logic says what to look for. For example: "cash deposits just below a limit, repeated inside a window."
- The parameters say how much, how many and how long. For example: "at least 3 deposits, between 8,000 and 10,000, inside 7 days."
Keep the two apart. Changing the logic means changing code, and that needs development, testing and release. Changing a parameter means changing a stored value. That is much cheaper, but it changes alert volume just as directly. Most day-to-day tuning happens on parameters, so the system should store them outside the rule code, give each change a version number, and record who approved it.
Kinds of parameters
Scenarios use a small number of parameter types. Knowing the type tells you what a change will do.
| Parameter type | Example | What raising it does |
|---|---|---|
| Amount threshold | `floor`, `ceiling`, `min_total_amount` | Fewer alerts for a floor or minimum total. For a ceiling, more transactions qualify. |
| Count threshold | `min_count` | Fewer alerts |
| Time window | `lookback_days` | More alerts, because more history is combined |
| Ratio or percentage | `min_pass_through_ratio` (share of incoming funds sent out) | Fewer alerts |
| List membership | high-risk country list, product list | Depends on whether items are added or removed |
| Exclusion | trusted-customer exemption, account types to skip | Fewer alerts, with a risk of blind spots |
Two things follow from the table.
First, parameters interact. A longer window combined with a higher count can produce about the same alerts as a shorter window with a lower count. Tuning one parameter alone is rarely meaningful, so evaluate parameters together.
Second, not every parameter moves volume in the same direction. A floor that is too low pulls in ordinary deposits. A ceiling set too high pulls in deposits that already trigger a separate cash-reporting obligation, which a structuring rule should not duplicate.
Why parameters differ by segment
A threshold that makes sense for a salaried retail customer is too low for a cash-intensive business such as a restaurant. The business deposits cash every day, so a "3 cash deposits in 7 days" rule would fire on most of them. Segmentation (covered in an earlier chapter) lets the same scenario run with a different parameter set per segment. The scenario logic stays identical.
Storing and validating parameter sets
The following code keeps parameters in a registry keyed by scenario and segment. It validates them before use. A parameter set that is missing, malformed or inconsistent should stop the run. It should not quietly fall back to a default, because a silent default can leave a segment monitored by the wrong numbers for months.
REQUIRED = {"lookback_days", "min_count", "floor", "ceiling"}
PARAMETER_SETS = {
("structuring_cash", "retail"): {
"version": 3, "lookback_days": 7, "min_count": 3,
"floor": 8000, "ceiling": 10000,
},
("structuring_cash", "small_business"): {
"version": 2, "lookback_days": 7, "min_count": 5,
"floor": 8000, "ceiling": 10000,
},
}
def validate(params):
missing = REQUIRED - params.keys()
if missing:
raise ValueError(f"missing parameters: {sorted(missing)}")
if params["lookback_days"] <= 0:
raise ValueError("lookback_days must be positive")
if params["min_count"] < 2:
raise ValueError("min_count must be at least 2")
if not 0 <= params["floor"] < params["ceiling"]:
raise ValueError("floor must be below ceiling")
def get_params(scenario, segment):
params = PARAMETER_SETS.get((scenario, segment))
if params is None:
raise KeyError(f"no parameter set for {scenario} / {segment}")
validate(params)
return params
print(get_params("structuring_cash", "retail")["min_count"]) # 3The version field matters later. When the scenario creates an alert, it should copy the version into the alert record. Months afterward, a reviewer or auditor can then see which numbers produced that alert, even if the parameters have changed since.
Boundaries and units
Many parameter bugs are boundary bugs. Decide and document these points for every scenario:
- Inclusive or exclusive limits. In the structuring rule, the test is
floor <= amount < ceiling. A deposit of exactly 10,000 is not counted, and a deposit of exactly 8,000 is counted. Writing<=for the ceiling by mistake changes which customers alert. - Window edges. The rule drops a transaction only when the gap is strictly greater than the window (
> window). A deposit exactly 7 days after the first one is still inside the window. A window described as "7 days" may mean a rolling 168 hours or seven calendar days. These give different results near midnight. - Currency. An amount threshold in one currency applied to transactions in another produces wrong results. Convert to a reporting currency before comparing, and record the rate date.
- Time zone. If timestamps are stored in UTC and the business thinks in local days, late-evening deposits fall into the wrong day.
Trying parameters before you change them
Before changing a parameter in production, run the scenario on historical data with several candidate values and compare alert counts. The following example runs the structuring rule from the earlier chapter over four customers and varies two parameters.
from collections import defaultdict
from datetime import datetime, timedelta
def structuring_alerts(transactions, params):
window = timedelta(days=params["lookback_days"])
by_customer = defaultdict(list)
for t in transactions:
if t["type"] == "cash_deposit" and params["floor"] <= t["amount"] < params["ceiling"]:
by_customer[t["customer_id"]].append(t)
alerts = []
for customer_id, txns in by_customer.items():
txns.sort(key=lambda t: t["timestamp"])
start = 0
for end, current in enumerate(txns):
while current["timestamp"] - txns[start]["timestamp"] > window:
start += 1
hits = txns[start:end + 1]
if len(hits) >= params["min_count"]:
alerts.append({"customer_id": customer_id, "txn_count": len(hits)})
break
return alerts
def dep(customer, amount, day, hour=10):
return {"customer_id": customer, "type": "cash_deposit", "amount": amount,
"timestamp": datetime(2026, 3, day, hour, 0)}
transactions = [
dep("C1", 9500, 2), dep("C1", 9200, 3), dep("C1", 9800, 5),
dep("C2", 9500, 2),
dep("C3", 8500, 2), dep("C3", 8300, 4),
dep("C4", 7500, 2), dep("C4", 7600, 3), dep("C4", 7800, 4), dep("C4", 7900, 5),
]
base = {"lookback_days": 7, "min_count": 3, "floor": 8000, "ceiling": 10000}
for floor in (8000, 7000):
for min_count in (2, 3, 4):
params = dict(base, floor=floor, min_count=min_count)
alerts = structuring_alerts(transactions, params)
print(f"floor={floor} min_count={min_count} alerts={len(alerts)}")
# floor=8000 min_count=2 alerts=2
# floor=8000 min_count=3 alerts=1
# floor=8000 min_count=4 alerts=0
# floor=7000 min_count=2 alerts=3
# floor=7000 min_count=3 alerts=2
# floor=7000 min_count=4 alerts=1Customer C4 shows why the floor matters. All four of C4's deposits are below 8,000, so the current settings never see them. Lowering the floor to 7,000 brings C4 in, but it also changes the whole population the rule examines. On real data, the lower floor would add many ordinary customers as well.
Above the line and below the line
Teams usually describe this kind of experiment with two terms.
- Above the line means the alerts the scenario produces at the current thresholds.
- Below the line means the activity that falls just short of the thresholds. Examples are customers with two deposits when the rule needs three, or deposits between 7,000 and 8,000.
Analysts sample below-the-line cases to check that nothing suspicious sits just under the cutoff. If the sample contains suspicious activity, the threshold is too high. If a sample of above-the-line alerts is almost all clearly innocent, the threshold is too low. Either result is evidence you can give the approver of a parameter change.
Governance of parameter changes
A parameter change should follow a short, repeatable path:
- Record the reason, such as a high false-positive rate in one segment or a new typology.
- Run the candidate values on historical data and compare above-the-line and below-the-line results.
- Obtain approval from the people responsible for the monitoring program.
- Release the new parameter set with a new version number. Do not edit the old version in place.
- Watch alert volume and precision for the first weeks and compare them with the test results.
Versioning gives you two things. You can roll back quickly, and every alert can be explained by the parameter set that produced it.
Common errors
- One parameter set for all segments. Business customers flood the queue while retail customers are barely covered.
- Hard-coded values in rule code. Every tuning request then becomes a software release.
- Silent defaults. A missing segment gets generic numbers and nobody notices.
- Changing several parameters at once. You cannot tell which change caused the volume shift.
- Setting a floor near a reporting limit. Structuring rules need a band below the limit, not a number tuned to the exact limit. A threshold of 9,999 would miss deposits of 9,000 to 9,900, which are typical structured amounts.
- No version in the alert. Alerts become unexplainable once parameters change.
Exercise
A scenario for retail customers uses lookbackdays = 7 and mincount = 3. An analyst proposes changing lookback_days to 30 "to catch slower structuring" without changing anything else. Which direction will alert volume move, and what should be done before approving the change?
Show answer
Volume will rise, because a longer window combines more transactions per customer, so more customers reach mincount. Before approving, run the scenario on historical data with both window lengths, compare above-the-line counts, and sample the added alerts to see whether they are suspicious or ordinary activity. It may also be necessary to raise mincount at the same time, since the two parameters interact. Release the result as a new parameter version.
Exercise
The structuring rule tests floor <= amount < ceiling with ceiling = 10000. A customer makes three cash deposits of exactly 10,000 in two days. Does this scenario alert? Why might a team still want these deposits reviewed?
Show answer
No. The amount 10,000 is not less than the ceiling, so none of the deposits qualify for this scenario. The team may still want review because deposits at or above the limit can trigger other obligations or other scenarios, such as a large cash activity rule. The structuring scenario is only designed for amounts just below the limit.