AI in Finance: Fraud, Trading, and Risk Systems
A bank does not need a language model to move money; it needs math that survives an audit. That distinction frames almost every financial AI project. Institutions that get real value treat models as decision components inside a regulated process: a fraud score triggers a card hold, a risk score reprices a loan, a surveillance alert opens a case file. Each outcome has an asymmetric cost when it is wrong. Declining a legitimate transaction annoys a customer and costs some goodwill; approving a fraudulent one costs cash, interchange revenue and reputation. So the emphasis in finance rarely sits on model novelty. It sits on label quality, latency budgets, feature freshness, and the audit trail that lets a regulator ask why a decision was made six months earlier and receive an answer precise enough to be useful.
Where the Money Actually Is
Different financial workloads differ sharply in how much error they tolerate, how fresh their data must be, and whether a human sits in the loop. The most common failure is a mismatch between workload and model class â teams reach for a large language model where a gradient-boosted tree over twenty numeric features would be faster, cheaper and far easier to explain.
| Workload | Typical model | Data freshness | Human in loop | Cost of a false positive |
|---|---|---|---|---|
| Card fraud scoring | Gradient boosting, isolation forest | Seconds | Optional auto-decline | Lost sale, customer friction |
| Credit underwriting | Scorecard, calibrated GBDT | Days to months | Usually required | Rejected good borrower, fair-lending risk |
| Trading signal research | Sequence models, factor models | Ticks to minutes | Research only | Capital loss, no direct customer harm |
| Transaction surveillance | Rules plus NLP clustering | Hours | Always required | Analyst fatigue, missed suspicious-activity filing |
| Support and advisory | Retrieval-augmented LLM | Current documents | Escalation path | Wrong guidance, regulatory exposure |
Notice that the two rows with the strictest regulatory exposure â underwriting and surveillance â are also the two where model output is most often a ranking or a flag rather than a final decision. That is deliberate. Supervisors care less about which algorithm scored a file than about whether the policy applied is consistent, disclosed, testable for disparate impact, and reproducible on demand.
Fraud Detection: Labels Lag Reality
Fraud data has a peculiar structure: negatives are immediate and positives arrive late. When a transaction is declined you learn quickly that it would have been fine. When one is approved and later disputed, the chargeback can arrive forty-five to ninety days afterward, so any model trained on last month's labels is quietly trained on an incomplete picture. Teams cope with a delayed-label pipeline that joins predictions to settled outcomes, and with features describing behavior rather than raw amounts, because an amount is only suspicious relative to how this card normally behaves.
import numpy as np
import pandas as pd
def build_fraud_features(tx: pd.DataFrame, hist: pd.DataFrame) -> pd.DataFrame:
hist = hist.sort_values("timestamp")
per_card = hist.set_index("timestamp").groupby("card_id")
feats = pd.DataFrame(index=tx.index)
feats["amount"] = tx["amount"]
med = per_card["amount"].transform("median").reindex(tx["timestamp"]).values
feats["amount_vs_card_median"] = tx["amount"] / np.maximum(med, 1.0)
feats["tx_count_24h"] = (
per_card["amount"].rolling("24h").count()
.reindex(tx.set_index("timestamp").index).values
)
feats["is_foreign"] = (tx["country"] != tx["home_country"]).astype(int)
feats["is_night_local"] = tx["local_hour"].between(1, 5).astype(int)
rare = hist.groupby(["card_id", "mcc"]).size().groupby("card_id").transform(
lambda s: s / s.sum()
)
feats["mcc_rare_for_card"] = tx.merge(
rare.rename("share"), left_on=["card_id", "mcc"], right_index=True, how="left"
)["share"].lt(0.05).astype(int)
return feats.fillna(0).loc[tx.index]
def choose_threshold(proba: np.ndarray, is_fraud: np.ndarray,
decline_cost: float, fraud_cost: float) -> float:
grid = np.linspace(0.02, 0.98, 97)
cost = [
decline_cost * np.sum((proba >= t) & ~is_fraud)
+ fraud_cost * np.sum((proba < t) & is_fraud)
for t in grid
]
return float(grid[int(np.argmin(cost))])
Two details deserve attention. The operating threshold is chosen by minimizing expected cost, not accuracy or F1, because a model with impressive accuracy and the wrong operating point still loses money. And the features are ratios and rates against the card's own history; a flat amount rule is trivially defeated by anyone spending just below it.
Credit Risk: The Explanation Is the Product
Underwriting models face a different constraint. In many jurisdictions a rejected applicant may demand the principal reasons for the decision, and the model must be tested for disparate impact across protected classes. A score that cannot be decomposed is therefore not merely inconvenient â it is unusable, no matter how well it ranks risk.
from dataclasses import dataclass
@dataclass
class Reason:
label: str
magnitude: float
class ExplainableScorecard:
def __init__(self, model, feature_names, bands):
self.model = model
self.feature_names = feature_names
self.bands = bands
def evaluate(self, applicant: dict) -> dict:
row = [applicant[f] for f in self.feature_names]
pd_default = float(self.model.predict_proba([row])[0][1])
score = int(round(300 + 550 * (1 - pd_default)))
reasons = []
for name, value in zip(self.feature_names, row):
low, high = self.bands[name]
if value < low:
reasons.append(Reason(f"{name} below typical range", low - value))
elif value > high:
reasons.append(Reason(f"{name} above typical range", value - high))
reasons.sort(key=lambda r: r.magnitude, reverse=True)
return {
"score": score,
"pd": round(pd_default, 4),
"reason_codes": [r.label for r in reasons[:3]],
"decision": "approve" if score >= 620 else "refer" if score >= 540 else "decline",
}
Reason codes are derived from the same inputs as the score, so they cannot drift out of sync with the model the way hand-written justifications do. Calibration matters equally: a predicted default probability of eight percent should mean eight defaults per hundred comparable applicants, otherwise the portfolio capital estimates built on those numbers are wrong even when the ranking is right.
Trading Signals: An Honest Accounting
Quantitative strategy research is where AI optimism meets arithmetic fastest. A backtest that ignores transaction costs, borrow fees, market impact and survivorship bias produces a strategy that looks spectacular and loses money the moment it is funded. The discipline separating research from fiction is a walk-forward protocol: fit on one window, trade the next window out of sample, roll forward, and aggregate only out-of-sample returns.
import numpy as np
import pandas as pd
def walk_forward_backtest(prices: pd.DataFrame, signal_fn, train: int = 252,
test: int = 63, cost_bps: float = 5.0) -> pd.Series:
"""Expand or roll a training window, trade only the held-out slice."""
returns = prices.pct_change().fillna(0)
equity, start = [], 0
while start + train + test <= len(prices):
window = prices.iloc[start:start + train]
model = signal_fn(window)
held = returns.iloc[start + train:start + train + test]
positions = model(held)
turned = positions.diff().abs().fillna(0)
net = positions * held.mean(axis=1) - turned * cost_bps / 1e4
equity.append(net)
start += test
curve = pd.concat(equity).sort_index()
sharpe = np.sqrt(252) * curve.mean() / max(curve.std(), 1e-9)
drawdown = (curve.cumsum().cummax() - curve.cumsum()).max()
return curve, {"sharpe": round(sharpe, 2), "max_drawdown": round(drawdown, 4)}
Practical teams also track decay. Signals fade as competitors discover them, so a monitoring job comparing rolling Sharpe against the backtest expectation tells you when to retire a strategy long before the loss does. Because most alpha is small, execution quality â basis points lost crossing the spread â often matters more than the last increment of model accuracy.
Reading, Not Deciding: Where LLMs Fit
Language models earn their place in finance where the task is reading rather than deciding. Surveillance systems cluster alerts so one analyst reviews a coherent case instead of fifty disconnected ones; know-your-customer document review extracts entities from filings; advisor copilots draft summaries that a licensed human then checks. In each case the model shortens a queue while a person stays accountable for the outcome.
Retrieval matters because policy changes and a model's parametric memory does not. An assistant that answers from the current compliance manual, cites the clause it used, and stays silent when the manual is silent is far more defensible than one that improvises. Grounded refusal is a feature: a system that declines an ambiguous request and routes it to a specialist costs a little speed and saves a lot of explanation later.
Serving Under Real Constraints
Production financial models live inside hard limits. A fraud scorer sits in the authorization path and has tens of milliseconds for the entire decision, which rules out anything that loads a large model at request time and pushes teams toward small models with warm caches and precomputed features. Batch credit decisions can afford minutes but demand reproducibility: the same application replayed a year later must return the same result, so feature stores freeze values at decision time rather than reading live tables.
| Constraint | Typical budget | Usual consequence |
|---|---|---|
| Fraud decision latency | 20 to 80 ms end to end | Small model, precomputed features, no network hops |
| Model refresh | Daily or weekly | Feature pipelines scheduled, not streaming |
| Reproducibility | Exact replay years later | Snapshot features, version models, log inputs |
| Explanation | On request, per decision | Reason codes computed with the score |
| Privacy | PII minimized and masked | Tokenize identifiers before they reach training code |
Monitoring closes the loop. Track score distributions, approval rates, chargeback rates joined to past predictions, and feature freshness on a dashboard someone actually reads. Model performance in finance degrades through data drift and through adversaries adapting to your rules, and both show up first in the distributions, not in the metrics that arrive a quarter later.
Common Mistakes
Training and scoring on features computed from future data
Fix: Point-in-time correct joins only; a feature must be reconstructible as of the decision moment
Optimizing accuracy instead of expected cost
Fix: Set the threshold from explicit decline and fraud costs, then review it monthly
Treating chargeback labels as immediately available
Fix: Join predictions to settled outcomes on a delay and evaluate against the settled set
Shipping an unexplainable model into underwriting
Fix: Generate reason codes from the same features, and test for disparate impact before launch
Letting an LLM improvise on policy questions
Fix: Ground answers in the current manual with citations and a refusal path
Best Practices
- Keep a point-in-time feature store so historical scores can be replayed exactly
- Pair every model score with the inputs, model version and threshold that produced it
- Separate the model that ranks from the policy that decides, and version the policy too
- Join predictions to delayed outcomes on a fixed cadence and re-evaluate the operating point
- Run shadow deployments against live authorization traffic before any score influences money
Key Takeaways
- Finance rewards the right operating point more than the fanciest architecture
- Labels arrive late in fraud, so evaluation must wait for settlements to catch up
- Explanations and calibration are product requirements in credit, not research extras
- Walk-forward backtests with explicit costs are the only backtests worth trusting
- LLMs shorten reading queues in compliance while humans keep the accountability