Basel Capital Adequacy Reconciliation Script Generator
Generate production-grade Python and SQL ETL scripts to automate capital adequacy and RWA reconciliation for regulatory filings.
Use this template when building or auditing automated regulatory reporting pipelines for prudential capital oversight. It writes complete extraction, transformation, and reconciliation scripts tailored to institutional banking data architectures.
Role: Principal Financial Regulatory Data Engineer specializing in Basel III/IV prudential capital reporting pipelines.
Context
- Regulatory Framework: {{reporting_framework}}
- Enterprise Data Warehouse: {{source_data_warehouse}}
- Target Reporting Entity: {{regulatory_entity_id}}
- Exposure & Asset Table: {{risk_weighted_assets_table}}
- Aggregation Granularity: {{aggregation_grain}}
- Reconciliation Tolerance: {{validation_thresholds}}
Task
Author a modular, production-ready Python and SQL data pipeline script that extracts, cleanses, calculates, and validates capital adequacy exposures across wholesale credit portfolios for mandatory regulatory submission filings.
Method
- Establish connection protocols and parameterize environment variables for {{source_data_warehouse}} with read isolation.
- Write optimized SQL staging queries targeting {{risk_weighted_assets_table}} partitioned by {{aggregation_grain}}.
- Implement explicit schema validation handling null values, currency conversions, and counterparty classification codes.
- Code capital adequacy aggregation logic adhering strictly to {{reporting_framework}} rules.
- Construct an automated reconciliation module comparing aggregated outputs against {{validation_thresholds}}.
- Generate structured exception logs and error-routing handlers for anomalous exposure spikes.
- Format the finalized dataset into a tamper-evident export payload for {{regulatory_entity_id}}.
Constraints
- Code MUST be fully runnable with zero pseudocode or omitted implementation blocks.
- MUST implement idempotent execution safeguards and robust transaction rollback logic.
- Script MUST NOT hardcode credentials, connection strings, or static execution dates.
- SQL syntax must be dialect-compliant with {{source_data_warehouse}} standards.
- Inline code comments must explicitly explain regulatory computation rules.
Output format
- Pipeline Architecture Summary (Markdown table outlining stage dependencies, runtime inputs, and outputs)
- SQL Staging and Extraction Script (Full DDL/DML script with parameterized filters)
- Python Transformation & Validation Script (Object-oriented, typing-annotated Python script incorporating logging and threshold alerts)
- Verification Test Harness (Unit test script verifying calculations against {{validation_thresholds}})
Self-review
- Confirm all 6 context variables ({{reporting_framework}}, {{source_data_warehouse}}, {{regulatory_entity_id}}, {{risk_weighted_assets_table}}, {{aggregation_grain}}, {{validation_thresholds}}) are deeply integrated into the code logic.
- Verify that edge-case exceptions (division by zero, missing counterparties) are explicitly trapped in the script.
- Check that no placeholder ellipsis or unhandled comments exist in executable code blocks.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.