Sub topic 14
Worked examples: simple detection rules for structuring and pass-through activity
This chapter turns two red flags from earlier chapters into code. The first is structuring, a placement-stage pattern. The second is pass-through activity, a layering-stage pattern. You should already know how cash deposits and wire transfers appear in an account's transaction history. You should also know that banks must monitor accounts and report suspicious activity. You need basic Python: functions, tuples, loops, and the datetime module.
The goal is to show how a written red flag becomes a rule with parameters, and how those parameters decide which cases the rule catches and which it misses.
From red flag to rule
A red flag in a policy document is a sentence such as "frequent cash deposits just below the reporting threshold." A rule must be specific enough for a computer to check. To get there, answer four questions for each red flag:
- Which transactions are in scope (cash only, one account, one direction)?
- What counts as "just below" or "almost all"? This is a number.
- Over what time window should the pattern be measured?
- How many occurrences are needed before the rule fires?
Each answer becomes a parameter. The two rules below expose their parameters as function arguments, so you can see how they change the result.
An alert is not an accusation. It is a prompt for a person to look at the account and its context.
Rule 1: structuring near a reporting threshold
Structuring means splitting cash into amounts that stay under a reporting threshold, so that no single deposit triggers a report. Placement is the stage where this happens, as covered in the placement chapters. The rule looks for several deposits that sit just under the threshold in a short window.
from datetime import date, timedelta
REPORTING_THRESHOLD = 10_000 # example cash reporting threshold
def looks_like_structuring(deposits, window_days=3, near_ratio=0.8, min_count=3):
"""Return True if several cash deposits just under the threshold
occur within a short window.
deposits: list of (date, amount) tuples for one account.
"""
lower = near_ratio * REPORTING_THRESHOLD
near = sorted((d, a) for d, a in deposits if lower <= a < REPORTING_THRESHOLD)
for i, (start, _) in enumerate(near):
count = sum(1 for d, _ in near[i:] if d - start <= timedelta(days=window_days))
if count >= min_count:
return True
return False
deposits = [
(date(2026, 3, 2), 9_500),
(date(2026, 3, 3), 9_200),
(date(2026, 3, 4), 9_800),
(date(2026, 3, 20), 1_200),
]
print(looks_like_structuring(deposits)) # TrueHow the rule works
The function does three things:
- Filter. It keeps only deposits with
8,000 <= amount < 10,000. A deposit of exactly 10,000 would already be reported, so it is not "under" the threshold. A deposit of 1,200 is ordinary and is ignored. - Sort. Sorting the tuples puts them in date order, so the loop can look forward from each deposit.
- Slide a window. For each near-threshold deposit, it counts how many near-threshold deposits fall within
window_daysof it, itself included. If any count reachesmin_count, the rule fires.
In the sample data, the deposits on 2 March, 3 March, and 4 March are all within three days of the first. That gives a count of 3, so the function returns True.
Tuning the parameters
| Parameter | Default | Raising it | Lowering it |
|---|---|---|---|
| `window_days` | 3 | Catches slower splitting, but more ordinary customers match | Catches only rapid bursts |
| `near_ratio` | 0.8 | Narrows the band to amounts very close to the threshold | Widens the band and adds more alerts |
| `min_count` | 3 | Fewer alerts, and a patient launderer slips under | More alerts, many of them innocent |
The window is inclusive. With window_days=3, deposits on day 0 and day 3 count as inside the window, so the rule covers a span of four calendar days.
Testing the edges
A rule is only trustworthy once you have tried cases that should and should not fire. Run these against the function above:
from datetime import date
# Two near-threshold deposits only: below min_count.
print(looks_like_structuring([
(date(2026, 3, 2), 9_500),
(date(2026, 3, 3), 9_200),
])) # False
# Three near-threshold deposits, but spread over ten days each.
print(looks_like_structuring([
(date(2026, 3, 1), 9_500),
(date(2026, 3, 11), 9_200),
(date(2026, 3, 21), 9_800),
])) # False
# Deposits at exactly the threshold are not "just under" it.
print(looks_like_structuring([
(date(2026, 3, 2), 10_000),
(date(2026, 3, 3), 10_000),
(date(2026, 3, 4), 10_000),
])) # FalseAll three print False. The first has too few deposits. The second fails the time window. The third fails the amount band.
Rule 2: pass-through activity
Layering moves money away from its origin through a series of transfers. One simple signature is an account that behaves like a pipe. A large amount arrives and nearly all of it leaves in the same period. A normal business account keeps some balance, pays costs, and shows a mix of counterparties. A conduit account shows little of that.
def is_pass_through(total_in, total_out, min_in=50_000, out_ratio=0.9):
"""Flag an account that receives a large amount and sends almost all of it
onward within the same review period, a common layering pattern.
"""
if total_in < min_in:
return False
return total_out / total_in >= out_ratio
print(is_pass_through(total_in=120_000, total_out=117_500)) # True
print(is_pass_through(total_in=120_000, total_out=40_000)) # FalseHow the rule works
The rule has two gates:
- Minimum volume. If
total_inis belowmin_in, the function returnsFalsestraight away. Small accounts pass money through all the time, such as a shared rent payment forwarded to a landlord, and flagging them would bury analysts in noise. - Outflow ratio. For large accounts, it computes
total_out / total_in. In the first example, 117,500 / 120,000 is about 0.979, which is at least 0.9, so the account is flagged. In the second, 40,000 / 120,000 is about 0.333, so it is not.
The early return also protects the division. As long as min_in is greater than zero, total_in is never zero when the division runs. If you set min_in=0, an account with no inflows would raise ZeroDivisionError.
Computing the totals from transactions
Real data arrives as individual transactions, not totals. This helper builds the two numbers for a review period, then reuses the rule:
from datetime import date
def totals_for_period(transactions, start, end):
"""transactions: list of (date, direction, amount); direction is 'in' or 'out'."""
total_in = total_out = 0
for d, direction, amount in transactions:
if start <= d <= end:
if direction == "in":
total_in += amount
else:
total_out += amount
return total_in, total_out
def is_pass_through(total_in, total_out, min_in=50_000, out_ratio=0.9):
if total_in < min_in:
return False
return total_out / total_in >= out_ratio
transactions = [
(date(2026, 4, 1), "in", 70_000),
(date(2026, 4, 2), "out", 66_000),
(date(2026, 4, 9), "in", 50_000),
(date(2026, 4, 10), "out", 51_500),
]
total_in, total_out = totals_for_period(transactions, date(2026, 4, 1), date(2026, 4, 30))
print(total_in, total_out) # 120000 117500
print(is_pass_through(total_in, total_out)) # TrueNote that total_out can exceed total_in if the account held a balance before the period. The ratio test still fires, because it checks >= out_ratio and has no upper limit.
What the ratio does not tell you
The ratio ignores timing. An account that receives 120,000 on 1 April and sends 117,500 on 28 April looks the same as one that forwards each payment within hours. Speed is a stronger signal for layering, so a refined rule would also measure how long funds stay in the account. The ratio also ignores who sent and received the money. A payroll provider, a payment processor, or a lawyer's client account can legitimately show a high ratio.
Combining rules and choosing thresholds
Two habits make simple rules more useful:
- Run several rules and score the results. An account that triggers both the structuring rule and the pass-through rule deserves more attention than one that triggers either alone. This matches the stage-overlap point from earlier chapters: real laundering rarely stays inside one stage.
- Measure before you tune. Count how many alerts each setting produces, and how many of those an analyst judged worth escalating. A threshold that yields thousands of alerts per week, almost none useful, is a design problem, even if it technically catches every case.
Rules are also easy for a determined launderer to learn. A person who knows the ratio is 0.9 can leave 15% in the account. Rules work best as one layer, next to customer due diligence, other monitoring methods, and human judgment.
Exercise
Using lookslikestructuring with the defaults (threshold 10,000, nearratio 0.8, windowdays 3, min_count 3), an account receives four cash deposits on four consecutive days: 7,900, 8,000, 9,999, and 10,000. Does the rule fire? Explain which deposits are counted.
Show answer
No, it does not fire. The near-threshold band is 8,000 <= amount < 10,000. The 7,900 deposit is below the band and the 10,000 deposit is not under the threshold, so both are excluded. Only 8,000 and 9,999 are counted. That gives a count of 2, which is below min_count of 3, so the function returns False.
Exercise
An account receives 60,000 in a month and sends out 52,000. With ispassthrough defaults (minin 50,000, outratio 0.9), is it flagged? What out_ratio value would be the highest that still flags it?
Show answer
It is not flagged. The ratio is 52,000 / 60,000, which is about 0.867, below 0.9. The highest out_ratio that would still flag it is about 0.867, so any value of 0.86 or lower would flag the account.