Loan Pricing Engine Design
Overview
The Loan Pricing Engine (LPE) is a modular, scalable system that dynamically prices loans by balancing profitability, risk, costs, competition, and constraints. It outputs an optimal interest rate (or APR) for a loan offer, ensuring the lender meets return hurdles while remaining competitive.
- Core Objective: Maximize expected return on economic capital (ROEC) subject to constraints.
- Key Inputs:
- Borrower data (credit score, income, DTI, etc.).
- Loan details (amount, term, product type).
- Market data (competitor rates, funding curves).
- Internal data (cost curves, risk models, constraints).
- Key Outputs:
- Recommended APR.
- Breakdown of components (e.g., risk premium, capital cost).
- Sensitivity analysis (e.g., "what-if" rate changes).
- Approval flags (e.g., violates constraints?).
The engine is real-time (sub-second latency) for digital lending, with batch mode for portfolios.
Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Data Inputs │───▶│ Pricing Core │───▶│ Outputs & UI │
│ - Borrower │ │ - Risk Module │ │ - APR Offer │
│ - Loan Details │ │ - Cost Module │ │ - Breakdown │
│ - Market/Comp │ │ - Competition │ │ - Sensitivities │
│ - Constraints │ │ - Constraints │ │ - Flags │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ ML Risk Model │ │ Rule Engine │ │ API/Dashboard │
│ (PD/LGD/EAD) │ │ (Optimizers) │ │ (Integrations) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
- Tech Stack:
- Backend: Python (FastAPI), Pandas/NumPy for calcs, Scikit-learn/PyTorch for risk ML.
- Data: Feature store (e.g., Feast), real-time streams (Kafka for market data).
- Orchestration: Airflow for batch, Celery for async.
- Deployment: Kubernetes, with A/B testing for pricing strategies.
- Monitoring: Prometheus for latency/accuracy, drift detection on risk models.
Pricing Model
The all-in APR is computed as:
APR = Base Funding Rate + Risk Premium + Capital Cost + Liquidity Cost + OpEx Margin + Competition Adjustment + Profit Target
Subject to constraints (e.g., APR ≤ Max Regulated Rate).
1. Risk-Based Pricing
Quantifies expected and unexpected losses.
- Expected Loss (EL):
EL = PD × LGD × EAD
- PD (Probability of Default): ML model (e.g., logistic regression/XGBoost on credit bureau, app data). Output: 0-100%.
- LGD (Loss Given Default): Regression model (e.g., 40% average for unsecured).
- EAD (Exposure at Default): Loan amount × drawdown factor.
- Unexpected Loss (UL)/Economic Capital:
Capital = EL + VaR(99.9%) (via Basel IRB or Monte Carlo simulation).
- Risk Premium:
RP = (EL / Term) / (1 - EL) + UL buffer (e.g., 2-5% over EL).
Example: PD=2%, LGD=50%, EAD=10k,3yrterm→EL=300/yr → RP≈1.0%.
2. Capital & Liquidity Costs
- Capital Cost:
- RWA (Risk-Weighted Assets) = EAD × Risk Weight (from PD/LGD via Basel formula).
Capital Required = RWA × CET1 Ratio (e.g., 8-12%).
Capital Cost = Capital Required × Cost of Equity (e.g., 10-15%) / EAD.
- Liquidity Cost:
Liq Cost = (Liquidity Coverage Ratio cost + Funding Curve premium).
- Use yield curve (e.g., SOFR + spread) matched to loan term.
- Total Cost Component:
Cost = Capital Cost + Liq Cost (typically 2-4%).
Example: $10k loan, RWA=150%, CET1=10%, CoE=12% → Capital Cost≈1.8%.
3. Competition Adjustment
Dynamically benchmarks against market.
- Sources: Real-time competitor scraping/API (e.g., Bankrate, LendingTree), internal win-rate data.
- Adjustment:
Comp Adj = f(Competitor APR Percentile, Elasticity).
- Use quantile regression: If we're at 75th percentile, shave 0.25-0.5% to win volume.
- ML elasticity model: Predict conversion rate vs. price delta.
Example: Market median=8.5%, our calc=9.2% → Adj=-0.4% → Final=8.8%.
4. Constraints & Optimization
Hard/soft rules enforced via optimizer (e.g., linear programming with PuLP).
- Constraints:
| Type | Example | Enforcement |
|---|
| Regulatory | APR ≤ 36% (NCUA/UDAAP) | Hard reject |
| Internal | Min ROEC ≥ 15%; Max LTV=90% | Soft (warn/reprice) |
| Portfolio | Vintage concentration ≤10% | Dynamic limits |
| Profit | Margin ≥ OpEx (1-2%) | Floor on APR |
- Optimizer: Minimize
|Target ROEC - Calc ROEC| or maximize volume subject to ROEC ≥ hurdle.
- Fallbacks: If unconstrained price fails, apply tiered pricing (e.g., Prime=5%, Subprime=12%).
Pseudocode Implementation
def price_loan(borrower_data, loan_details, market_data, constraints):
# 1. Risk
pd, lgd, ead = risk_model.predict(borrower_data, loan_details)
el = pd * lgd * ead / loan_details['term_years']
rwa = basel_irb(pd, lgd, ead)
capital_req = rwa * constraints['cet1_ratio']
risk_premium = (el + capital_req * constraints['cost_equity']) / ead
# 2. Costs
funding_rate = yield_curve(loan_details['term_months']) # e.g., SOFR + spread
liq_cost = funding_rate + liquidity_premium(loan_details)
capital_cost = (capital_req * constraints['cost_equity']) / ead
total_cost = funding_rate + liq_cost + capital_cost
# 3. Base Price
base_apr = total_cost + risk_premium + constraints['opex_margin'] + constraints['profit_target']
# 4. Competition
comp_median = market_data['competitor_apr']
elasticity = competition_model.predict(borrower_data)
comp_adj = max(-0.5, (base_apr - comp_median) * elasticity * -0.1) # Cap adjustment
# 5. Optimize w/ Constraints
candidate_apr = base_apr + comp_adj
optimized_apr = optimizer.optimize(candidate_apr, constraints, target_roec=0.15)
# 6. Validate & Output
if violates_constraints(optimized_apr, constraints):
return {"status": "REJECT", "reason": "Constraint violation"}
breakdown = {
"apr": optimized_apr,
"components": {"risk": risk_premium, "capital": capital_cost, "comp": comp_adj},
"roec": calculate_roec(optimized_apr),
"sensitivities": sensitivity_analysis(optimized_apr)
}
return breakdown
Validation & Rollout
- Backtesting: Replay historical loans; target 95%+ ROEC attainment.
- A/B Testing: Test pricing variants on 10% traffic.
- Edge Cases: Zero-risk (e.g., mortgages), high-risk declines.
- Scalability: Handles 1M+ req/day; GPU for ML inference.
This design ensures compliant, profitable, competitive pricing. For production tweaks (e.g., specific regs), provide more details!