# Reference Implementations

Complete, runnable examples demonstrating Orxaq's core use cases. Each example uses
the built-in 19-variable credit ontology and synthetic data — no external data required.

## Use Cases

| Example | Regulatory Context | Script |
|---------|-------------------|--------|
| [CECL Pipeline](cecl.md) | ASC 326, lifetime expected credit loss | `examples/cecl_pipeline.py` |
| [CCAR Stress Test](ccar.md) | CCAR/DFAST, macroeconomic scenarios | `examples/ccar_stress_test.py` |
| [Fair Lending Audit](fair-lending.md) | ECOA/CFPB, disparate impact | `examples/fair_lending_audit.py` |

## Quick Start

All examples run with zero configuration:

```bash
# CECL lifetime loss estimation
python examples/cecl_pipeline.py

# CCAR multi-scenario stress test
python examples/ccar_stress_test.py

# Fair lending compliance audit
python examples/fair_lending_audit.py
```

Or via the CLI:

```bash
orxaq credit ecl             # CECL computation
orxaq credit ecl --json      # JSON output
orxaq credit fairness        # Fair lending decomposition
```

## Architecture

Each reference implementation follows the same pattern:

1. **Build ontology** — Load the 19-variable credit DAG
2. **Generate data** — Synthetic portfolio with known causal structure (seed=42)
3. **Fit models** — Causal PD model using backdoor adjustment
4. **Compute results** — ECL, stress PD, or fairness metrics
5. **Export** — JSON output for downstream systems

All examples are stdlib-only and use deterministic seeds for reproducibility.
