Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Flagging Suspicious Patterns | Automating Compliance Checks
Practice
Projects
Quizzes & Challenges
Quizer
Challenges
/
Python for Compliance Officers

bookFlagging Suspicious Patterns

Sveip for å vise menyen

Compliance officers use automated systems to detect suspicious activity in transaction data. Common suspicious patterns include rapid repeated transactions from the same account, which may indicate structuring or attempts to avoid detection thresholds. Unusually large or round-number transactions can also raise red flags, as these might be linked to money laundering or fraud. Identifying such patterns is essential for regulatory compliance and helps prevent financial crime.

123456789101112131415161718192021222324252627282930313233
def flag_rapid_transactions(transactions, time_window_seconds=60): """ Flags transactions that occur from the same account within a short time window. Args: transactions (list of dict): Each dict contains 'account_id' and 'timestamp' (as integer seconds). time_window_seconds (int): Time window in seconds to consider as 'rapid'. Returns: list of dict: Transactions flagged as suspicious. """ flagged = [] # Sort transactions by account and timestamp transactions_sorted = sorted(transactions, key=lambda x: (x['account_id'], x['timestamp'])) for i in range(1, len(transactions_sorted)): current = transactions_sorted[i] previous = transactions_sorted[i - 1] if current['account_id'] == previous['account_id']: if current['timestamp'] - previous['timestamp'] <= time_window_seconds: flagged.append(current) return flagged # Example usage: transactions = [ {'account_id': 'A123', 'timestamp': 1700000000}, {'account_id': 'A123', 'timestamp': 1700000030}, # 30 seconds later, same account {'account_id': 'B222', 'timestamp': 1700000100}, {'account_id': 'A123', 'timestamp': 1700000500}, # 470 seconds later, same account {'account_id': 'B222', 'timestamp': 1700000160}, # 60 seconds later, same account ] flagged = flag_rapid_transactions(transactions) print(flagged)
copy

The logic behind detecting rapid repeated transactions involves comparing each transaction's timestamp and account ID to others in the dataset. By using loops, you can iterate through the list of transactions, and with conditionals, check if two consecutive transactions are from the same account and occur within a specified short time window. This approach allows you to programmatically flag patterns that may require further investigation by compliance teams.

123456789101112
transactions = [ {'account_id': 'C789', 'timestamp': 1700001000}, {'account_id': 'C789', 'timestamp': 1700001020}, # 20 seconds later, same account {'account_id': 'D456', 'timestamp': 1700002000}, {'account_id': 'C789', 'timestamp': 1700001300}, # 300 seconds later, same account {'account_id': 'D456', 'timestamp': 1700002060}, # 60 seconds later, same account ] flagged = flag_rapid_transactions(transactions, time_window_seconds=60) print("Flagged suspicious transactions:") for t in flagged: print(t)
copy

1. What is a suspicious pattern that compliance officers often look for?

2. Which Python statement is used to check if two transactions are from the same account?

3. How can time-based patterns be detected in transaction data?

question mark

What is a suspicious pattern that compliance officers often look for?

Select the correct answer

question mark

Which Python statement is used to check if two transactions are from the same account?

Select the correct answer

question mark

How can time-based patterns be detected in transaction data?

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 3

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

Seksjon 1. Kapittel 3
some-alt