1
📥
Ambil data kewanganTransaksi, ratio, tarikh tutup
2
🚩
Deteksi threshold breachBanding nilai vs had
3
📊
Kategorikan keparutanHigh, Medium, Low severity
📋
Hasilkan laporan risikoCadangan tindakan untuk setiap flag
import requests, json, pandas as pd
API_FINANCE = "https://api.finance.local/v1/transactions"
def fetch_financial_data():
resp = requests.get(API_FINANCE)
return resp.json().get("transactions", [])
def detect_red_flags(transactions):
flags = []
for t in transactions:
if t["amount"] > t.get("threshold", 5000):
flags.append({"type": t["type"], "value": t["amount"], "threshold": t["threshold"], "severity": "High", "action": "Investigate"})
elif t.get("ratio") and t["ratio"] < 1.5:
flags.append({"type": "Ratio Alert", "value": t["ratio"], "threshold": "<1.5", "severity": "Low", "action": "Monitor"})
return flags
report = detect_red_flags(fetch_financial_data())
print(json.dumps(report))