This repository is the pricing and return-hurdle layer in the commercial credit-risk stack. It uses synthetic facility-level risk inputs shaped like upstream PD, LGD, expected loss, and stress outputs to produce minimum margin tables, pricing recommendations, and risk-return summaries. The project shows how risk signals can be translated into explainable commercial lending pricing views for both bank-style risk-adjusted pricing and practical lending decisioning.
This project demonstrates a simplified pricing workflow for commercial lending. It is designed as a public portfolio project, so the pricing logic stays transparent and practical rather than trying to imitate a production treasury, credit policy, or governance stack in full detail.
Upstream inputs:
PD-and-scorecard-commercialLGD-commercialexpected-loss-engine-commercialstress-testing-commercial
Downstream consumers:
- pricing discussion and deal screening
- portfolio steering and profitability review
- management reporting and presentation material
This project can be applied in:
- Risk-adjusted pricing and return-hurdle review for lending opportunities
- Portfolio profitability analysis by segment, product, and risk grade
- Structured pricing discussion linked back to expected loss and stress outputs
- Approval strategy optimisation using margin, hurdle, and risk-return trade-offs
- Pricing guidance for originations teams and credit decisioning workflows
- Portfolio performance review by cohort, product, or borrower segment
data/raw/facility_risk_inputs.csv: synthetic facility-level pricing input set with PD, LGD, EAD, expected loss, stressed expected loss, tenor, and current margin fields.data/external/product_cost_assumptions.csv: product-level operating cost, margin floor, and capital addon assumptions.data/external/reference_rate_curve.csv: benchmark rate curve used to attach base pricing assumptions by tenor.
outputs/tables/price_recommendations.csvoutputs/tables/minimum_margin_table.csvoutputs/tables/risk_return_summary.csvoutputs/reports/validation_summary.csvoutputs/samples/facility_pricing_sample.csvdata/interim/pricing_inputs_enriched.csvdata/processed/pricing_engine_results.csv
outputs/tables/price_recommendations.csv: facility-level pricing action list showing hurdle status and recommended margin changes.outputs/tables/minimum_margin_table.csv: product and risk-grade view of minimum viable pricing by segment.outputs/tables/risk_return_summary.csv: aggregated risk-return view by segment, product, and grade.outputs/samples/facility_pricing_sample.csv: concise sample of priced facilities for quick review.outputs/reports/validation_summary.csv: validation checks covering missing inputs, pricing bounds, negative spreads, and reconciliation.data/interim/pricing_inputs_enriched.csv: pre-engine table after attaching product costs and reference curve inputs.data/processed/pricing_engine_results.csv: full priced facility dataset with recommended margin, all-in rate, and hurdle classification.
- Load the synthetic facility risk input table plus product assumptions and the reference rate curve.
- Attach pricing features such as funding spread, operating cost, and economic capital.
- Translate expected loss and stressed expected loss into cost-of-risk and buffer components.
- Calculate minimum margin, recommended pricing, and all-in rates at facility level.
- Aggregate outputs into minimum-margin tables, price recommendations, and segment-level risk-return summaries.
- Write validation, sample outputs, and processed datasets for reviewer inspection.
A credit team wants to know which facilities currently clear the return hurdle and which deals need repricing or renewed credit review. This repo surfaces that directly: the reviewer can open price_recommendations.csv to see margin actions, then use risk_return_summary.csv to understand whether the issue is concentrated in a product, segment, or risk-grade pocket.
portfolio-monitor-commercial:outputs/tables/price_recommendations.csvcan be treated as a repricing/watchlist input for monitoring packs.RWA-capital-commercial:outputs/tables/risk_return_summary.csvcan be paired with capital summaries to show “return vs capital” at segment level.- Presentation handoff:
outputs/samples/facility_pricing_sample.csvis a quick reviewer-friendly excerpt for slides or a deal screen example.
data/: raw, interim, processed, and external pricing inputssrc/: reusable pricing, return-hurdle, and validation modulesscripts/: wrapper scripts for pipeline executiondocs/: methodology, assumptions, data dictionary, and validation notesnotebooks/: walkthrough notebooks for reviewer contextoutputs/: exported tables, reports, and sample artifactstests/: validation and regression checks
Quick start:
pip install -r requirements.txt
python -m src.run_pipeline --refresh-inputsOr use the wrapper script:
python scripts/run_pipeline.py --refresh-inputsAfter the run, start with:
outputs/tables/price_recommendations.csvoutputs/tables/risk_return_summary.csvoutputs/reports/validation_summary.csv
Run tests:
python -m pytesttests/test_pipeline.pyruns the pipeline end to end and confirms the core output files are written.tests/test_raroc.pychecks that the pricing engine creates minimum-margin, recommended-margin, and hurdle-status fields.tests/test_validation.pyverifies that negative spreads and reconciliation breaks are caught by the validation layer.tests/test_ftp.pychecks that pricing features attach product cost assumptions, reference-curve inputs, and economic capital fields correctly.- The generated
outputs/reports/validation_summary.csvgives a concise reviewer-facing summary of the same practical control checks.
- All pricing inputs are synthetic and included for demonstration only.
- Funding, capital, operating-cost, and return-hurdle mechanics are intentionally simplified so the workflow remains easy to review.
- The repo is not a production bank pricing engine, treasury transfer pricing framework, or governance-approved pricing process.