creforge 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ${{ matrix.os }}
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ os: [ubuntu-latest, macos-latest, windows-latest]
15
+ python: ["3.10", "3.11", "3.12", "3.13"]
16
+ steps:
17
+ - uses: actions/checkout@v5
18
+ - uses: actions/setup-python@v6
19
+ with:
20
+ python-version: ${{ matrix.python }}
21
+ - run: python -m pip install -e ".[dev]"
22
+ - run: ruff check .
23
+ - run: python -m pytest -m "not slow"
24
+
25
+ calibration:
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - uses: actions/checkout@v5
29
+ - uses: actions/setup-python@v6
30
+ with:
31
+ python-version: "3.12"
32
+ - run: python -m pip install -e ".[dev]"
33
+ - run: python -m pytest -m slow
@@ -0,0 +1,35 @@
1
+ name: Release
2
+
3
+ # Publishes to PyPI when a GitHub release is published. Uses PyPI trusted
4
+ # publishing (OIDC), so no API token is stored in the repository.
5
+ on:
6
+ release:
7
+ types: [published]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v5
14
+ - uses: actions/setup-python@v6
15
+ with:
16
+ python-version: "3.12"
17
+ - run: python -m pip install build
18
+ - run: python -m build
19
+ - uses: actions/upload-artifact@v4
20
+ with:
21
+ name: dist
22
+ path: dist/
23
+
24
+ publish:
25
+ needs: build
26
+ runs-on: ubuntu-latest
27
+ environment: pypi
28
+ permissions:
29
+ id-token: write
30
+ steps:
31
+ - uses: actions/download-artifact@v4
32
+ with:
33
+ name: dist
34
+ path: dist/
35
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,8 @@
1
+ __pycache__/
2
+ *.egg-info/
3
+ .pytest_cache/
4
+ .ruff_cache/
5
+ .hypothesis/
6
+ /out/
7
+ /bureau/
8
+ dist/
creforge-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.5
2
+ Name: creforge
3
+ Version: 0.1.0
4
+ Summary: PII-safe synthetic credit bureau data from explicit behavioural rules.
5
+ Project-URL: Homepage, https://github.com/chowkuanlaw/creforge
6
+ Author: creforge contributors
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Keywords: credit-bureau,credit-risk,privacy,synthetic-data,test-data
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Financial and Insurance Industry
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Office/Business :: Financial
16
+ Classifier: Topic :: Software Development :: Testing
17
+ Requires-Python: >=3.10
18
+ Requires-Dist: click>=8.1
19
+ Requires-Dist: numpy>=1.26
20
+ Requires-Dist: polars>=1.0
21
+ Requires-Dist: pyarrow>=14
22
+ Requires-Dist: pydantic>=2.5
23
+ Requires-Dist: pyyaml>=6
24
+ Provides-Extra: dev
25
+ Requires-Dist: hypothesis>=6.100; extra == 'dev'
26
+ Requires-Dist: pytest>=8; extra == 'dev'
27
+ Requires-Dist: ruff>=0.5; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # creforge
31
+
32
+ **PII-safe synthetic credit bureau data, generated from explicit behavioural rules.**
33
+
34
+ creforge generates realistic, linked credit-bureau-shaped datasets: borrowers, credit
35
+ inquiries, accounts and monthly payment histories. The data has real delinquency
36
+ dynamics, vintage curves and stress scenarios, and **no real data ever goes in**. There
37
+ is no model fitted to real records, so there is nothing to memorise or leak.
38
+
39
+ Use it to test credit data pipelines, demo dashboards, teach credit-risk analytics,
40
+ benchmark warehouses, or give contractors and vendors a realistic dataset without a
41
+ data-sharing agreement.
42
+
43
+ ```console
44
+ $ pip install creforge
45
+ $ creforge generate --subjects 1000000 --months 36 --seed 42 --out ./bureau --workers 4
46
+ $ creforge validate ./bureau --strict
47
+ ```
48
+
49
+ ## Why not SDV / Faker?
50
+
51
+ | | Faker-style | Fit-to-real (SDV, GAN, ...) | **creforge** |
52
+ |---|---|---|---|
53
+ | Needs real data | No | **Yes**: privacy review, leakage risk | No |
54
+ | Delinquency dynamics | None | Learned; can break the rules | Explicit Markov model |
55
+ | Can a loan jump from current to 90+? | n/a | Yes | **Never** (tested invariant) |
56
+ | Referential integrity across tables | Manual | Often approximate | Guaranteed and validated |
57
+ | Reproducible | Mostly | Rarely byte-identical | **Byte-identical per seed**, any worker count |
58
+ | Explainable parameters | n/a | No | Every probability is in a commented YAML file |
59
+
60
+ ## The data
61
+
62
+ | Table | One row per | Highlights |
63
+ |---|---|---|
64
+ | `subject` | borrower | Latent `risk_grade` A–E is exported, so it doubles as ground truth for testing scorecards. No names, IDs or addresses. |
65
+ | `inquiry` | credit application | Approval odds fall as a borrower makes more applications ("credit hungry" behaviour). |
66
+ | `account` | credit facility | `credit_card`, `personal_loan`, `mortgage`, `auto_loan`, `overdraft`, `bnpl`. New accounts link to their approved inquiry. Older accounts start part-way through their life. |
67
+ | `account_month` | account × month | Balance, amount due, amount paid, DPD bucket (`0` … `120+`), months in arrears, status. |
68
+
69
+ Output is one Parquet or CSV part file per chunk per table, plus a `manifest.json`
70
+ recording the version, seed, full resolved config and its SHA-256.
71
+
72
+ ## How it works
73
+
74
+ Every month, each open account draws one event: **roll** (miss a payment, move one
75
+ bucket worse), **cure** (pay all arrears), **back** (pay one installment of arrears),
76
+ **restructure**, **close**, or **stay**. The probabilities are
77
+
78
+ ```
79
+ base[product, state] × grade multiplier × seasoning(months on book) × macro(month)
80
+ ```
81
+
82
+ The DPD bucket is derived from months in arrears. Balances and payments are derived
83
+ from the event. So an account can never skip a bucket, pay while rolling forward, or
84
+ show a DPD that disagrees with its arrears. Accounts that already exist when the window
85
+ opens start in a state drawn from the model's own age-conditional distribution, so the
86
+ first month shows no warm-up artefact.
87
+
88
+ ## Validation
89
+
90
+ `creforge validate` reports:
91
+
92
+ - **Integrity** (hard guarantees; any failure is a bug): unique ids, every foreign key
93
+ resolves, the account opens on or after its approved inquiry, month histories are
94
+ contiguous and end at closure, no rows after write-off, no skipped buckets, no
95
+ payment on a roll-forward, no negative amounts.
96
+ - **Calibration** (against the profile's `targets`): 30+ DPD share and annual
97
+ write-off rate per product; 12-month bad rate increasing across grades; the seasoning
98
+ peak falls at 6–35 months on book; no artefact at the start of the window.
99
+ - **Privacy statement**, with the config hash, to attach to data-handling approvals.
100
+
101
+ Baseline, 50k subjects × 36 months:
102
+
103
+ | Product | 30+ DPD share | Annual write-off rate |
104
+ |---|---|---|
105
+ | credit_card | 3.9% | 3.7% |
106
+ | personal_loan | 4.6% | 3.8% |
107
+ | mortgage | 1.1% | 0.4% |
108
+ | auto_loan | 3.1% | 2.2% |
109
+ | overdraft | 2.9% | 2.5% |
110
+ | bnpl | 6.3% | 0.8% |
111
+
112
+ 12-month bad rate by grade: A 0.03% · B 0.5% · C 1.2% · D 6.7% · E 18%.
113
+
114
+ ## Python API
115
+
116
+ ```python
117
+ import creforge as cf
118
+
119
+ cfg = cf.Config.from_profile("stressed", subjects=100_000, months=48, seed=7)
120
+ ds = cf.generate(cfg) # in memory; ds.account_month is a polars DataFrame
121
+ report = cf.validate(ds)
122
+ print(report.to_markdown())
123
+
124
+ cf.write_dataset(cfg, "out/", workers=4) # streaming, bounded memory, for big runs
125
+ ```
126
+
127
+ ## Profiles
128
+
129
+ `baseline` (flat economy) and `stressed` (roll rates ramp to 1.8× around month 15,
130
+ then recover) are built in. `creforge profiles show baseline` prints every parameter.
131
+ To make your own, write a YAML file that starts with `extends: baseline` and override
132
+ only what you need:
133
+
134
+ ```yaml
135
+ extends: baseline
136
+ name: subprime_cards
137
+ grades:
138
+ E: {share: 0.20} # fields merge; this assumes you rebalance the other shares
139
+ ```
140
+
141
+ All built-in parameters are **illustrative**. They are hand-set to land in the right
142
+ order of magnitude compared with publicly published aggregate statistics (sources are
143
+ cited in the YAML). They do not describe any real lender's or bureau's portfolio.
144
+
145
+ ## Performance
146
+
147
+ | Run | Time | Peak memory per worker | Parquet size |
148
+ |---|---|---|---|
149
+ | 200k subjects × 36 months, 1 worker | 15 s | < 1 GB | 0.16 GB |
150
+ | 1M subjects × 36 months, 4 workers | 24 s | 0.9 GB | 0.78 GB |
151
+
152
+ Measured on a 4-vCPU Linux container. Run `python benchmarks/bench_generate.py` to
153
+ measure your own machine.
154
+
155
+ ## Roadmap
156
+
157
+ 1. **v1.1:** guarantor and joint-account links (`account_party`), including
158
+ contingent liabilities.
159
+ 2. Business subjects, directors and shareholding graphs.
160
+ 3. Collateral and legal/litigation records.
161
+ 4. Clearly marked synthetic PII for UI testing.
162
+ 5. Calibration to *published aggregate* statistics.
163
+ 6. Scripted scenarios (moratoria, rate shocks).
164
+ 7. DuckDB/Postgres/Iceberg loaders; dbt and Glue catalog integration.
165
+ 8. Country flavour packs built only from public specifications.
166
+
167
+ ## Contributing
168
+
169
+ ```console
170
+ $ pip install -e ".[dev]"
171
+ $ ruff check . && pytest -m "not slow" # fast suite
172
+ $ pytest -m slow # calibration suite
173
+ ```
174
+
175
+ CI runs on Linux, macOS and Windows with Python 3.10–3.13. Design notes are in
176
+ [`docs/superpowers/specs`](docs/superpowers/specs).
177
+
178
+ **Clean-room rule:** contributions must not contain parameters, code sets or schemas
179
+ derived from any employer's or institution's non-public systems or data.
180
+
181
+ ## License
182
+
183
+ Apache-2.0
@@ -0,0 +1,154 @@
1
+ # creforge
2
+
3
+ **PII-safe synthetic credit bureau data, generated from explicit behavioural rules.**
4
+
5
+ creforge generates realistic, linked credit-bureau-shaped datasets: borrowers, credit
6
+ inquiries, accounts and monthly payment histories. The data has real delinquency
7
+ dynamics, vintage curves and stress scenarios, and **no real data ever goes in**. There
8
+ is no model fitted to real records, so there is nothing to memorise or leak.
9
+
10
+ Use it to test credit data pipelines, demo dashboards, teach credit-risk analytics,
11
+ benchmark warehouses, or give contractors and vendors a realistic dataset without a
12
+ data-sharing agreement.
13
+
14
+ ```console
15
+ $ pip install creforge
16
+ $ creforge generate --subjects 1000000 --months 36 --seed 42 --out ./bureau --workers 4
17
+ $ creforge validate ./bureau --strict
18
+ ```
19
+
20
+ ## Why not SDV / Faker?
21
+
22
+ | | Faker-style | Fit-to-real (SDV, GAN, ...) | **creforge** |
23
+ |---|---|---|---|
24
+ | Needs real data | No | **Yes**: privacy review, leakage risk | No |
25
+ | Delinquency dynamics | None | Learned; can break the rules | Explicit Markov model |
26
+ | Can a loan jump from current to 90+? | n/a | Yes | **Never** (tested invariant) |
27
+ | Referential integrity across tables | Manual | Often approximate | Guaranteed and validated |
28
+ | Reproducible | Mostly | Rarely byte-identical | **Byte-identical per seed**, any worker count |
29
+ | Explainable parameters | n/a | No | Every probability is in a commented YAML file |
30
+
31
+ ## The data
32
+
33
+ | Table | One row per | Highlights |
34
+ |---|---|---|
35
+ | `subject` | borrower | Latent `risk_grade` A–E is exported, so it doubles as ground truth for testing scorecards. No names, IDs or addresses. |
36
+ | `inquiry` | credit application | Approval odds fall as a borrower makes more applications ("credit hungry" behaviour). |
37
+ | `account` | credit facility | `credit_card`, `personal_loan`, `mortgage`, `auto_loan`, `overdraft`, `bnpl`. New accounts link to their approved inquiry. Older accounts start part-way through their life. |
38
+ | `account_month` | account × month | Balance, amount due, amount paid, DPD bucket (`0` … `120+`), months in arrears, status. |
39
+
40
+ Output is one Parquet or CSV part file per chunk per table, plus a `manifest.json`
41
+ recording the version, seed, full resolved config and its SHA-256.
42
+
43
+ ## How it works
44
+
45
+ Every month, each open account draws one event: **roll** (miss a payment, move one
46
+ bucket worse), **cure** (pay all arrears), **back** (pay one installment of arrears),
47
+ **restructure**, **close**, or **stay**. The probabilities are
48
+
49
+ ```
50
+ base[product, state] × grade multiplier × seasoning(months on book) × macro(month)
51
+ ```
52
+
53
+ The DPD bucket is derived from months in arrears. Balances and payments are derived
54
+ from the event. So an account can never skip a bucket, pay while rolling forward, or
55
+ show a DPD that disagrees with its arrears. Accounts that already exist when the window
56
+ opens start in a state drawn from the model's own age-conditional distribution, so the
57
+ first month shows no warm-up artefact.
58
+
59
+ ## Validation
60
+
61
+ `creforge validate` reports:
62
+
63
+ - **Integrity** (hard guarantees; any failure is a bug): unique ids, every foreign key
64
+ resolves, the account opens on or after its approved inquiry, month histories are
65
+ contiguous and end at closure, no rows after write-off, no skipped buckets, no
66
+ payment on a roll-forward, no negative amounts.
67
+ - **Calibration** (against the profile's `targets`): 30+ DPD share and annual
68
+ write-off rate per product; 12-month bad rate increasing across grades; the seasoning
69
+ peak falls at 6–35 months on book; no artefact at the start of the window.
70
+ - **Privacy statement**, with the config hash, to attach to data-handling approvals.
71
+
72
+ Baseline, 50k subjects × 36 months:
73
+
74
+ | Product | 30+ DPD share | Annual write-off rate |
75
+ |---|---|---|
76
+ | credit_card | 3.9% | 3.7% |
77
+ | personal_loan | 4.6% | 3.8% |
78
+ | mortgage | 1.1% | 0.4% |
79
+ | auto_loan | 3.1% | 2.2% |
80
+ | overdraft | 2.9% | 2.5% |
81
+ | bnpl | 6.3% | 0.8% |
82
+
83
+ 12-month bad rate by grade: A 0.03% · B 0.5% · C 1.2% · D 6.7% · E 18%.
84
+
85
+ ## Python API
86
+
87
+ ```python
88
+ import creforge as cf
89
+
90
+ cfg = cf.Config.from_profile("stressed", subjects=100_000, months=48, seed=7)
91
+ ds = cf.generate(cfg) # in memory; ds.account_month is a polars DataFrame
92
+ report = cf.validate(ds)
93
+ print(report.to_markdown())
94
+
95
+ cf.write_dataset(cfg, "out/", workers=4) # streaming, bounded memory, for big runs
96
+ ```
97
+
98
+ ## Profiles
99
+
100
+ `baseline` (flat economy) and `stressed` (roll rates ramp to 1.8× around month 15,
101
+ then recover) are built in. `creforge profiles show baseline` prints every parameter.
102
+ To make your own, write a YAML file that starts with `extends: baseline` and override
103
+ only what you need:
104
+
105
+ ```yaml
106
+ extends: baseline
107
+ name: subprime_cards
108
+ grades:
109
+ E: {share: 0.20} # fields merge; this assumes you rebalance the other shares
110
+ ```
111
+
112
+ All built-in parameters are **illustrative**. They are hand-set to land in the right
113
+ order of magnitude compared with publicly published aggregate statistics (sources are
114
+ cited in the YAML). They do not describe any real lender's or bureau's portfolio.
115
+
116
+ ## Performance
117
+
118
+ | Run | Time | Peak memory per worker | Parquet size |
119
+ |---|---|---|---|
120
+ | 200k subjects × 36 months, 1 worker | 15 s | < 1 GB | 0.16 GB |
121
+ | 1M subjects × 36 months, 4 workers | 24 s | 0.9 GB | 0.78 GB |
122
+
123
+ Measured on a 4-vCPU Linux container. Run `python benchmarks/bench_generate.py` to
124
+ measure your own machine.
125
+
126
+ ## Roadmap
127
+
128
+ 1. **v1.1:** guarantor and joint-account links (`account_party`), including
129
+ contingent liabilities.
130
+ 2. Business subjects, directors and shareholding graphs.
131
+ 3. Collateral and legal/litigation records.
132
+ 4. Clearly marked synthetic PII for UI testing.
133
+ 5. Calibration to *published aggregate* statistics.
134
+ 6. Scripted scenarios (moratoria, rate shocks).
135
+ 7. DuckDB/Postgres/Iceberg loaders; dbt and Glue catalog integration.
136
+ 8. Country flavour packs built only from public specifications.
137
+
138
+ ## Contributing
139
+
140
+ ```console
141
+ $ pip install -e ".[dev]"
142
+ $ ruff check . && pytest -m "not slow" # fast suite
143
+ $ pytest -m slow # calibration suite
144
+ ```
145
+
146
+ CI runs on Linux, macOS and Windows with Python 3.10–3.13. Design notes are in
147
+ [`docs/superpowers/specs`](docs/superpowers/specs).
148
+
149
+ **Clean-room rule:** contributions must not contain parameters, code sets or schemas
150
+ derived from any employer's or institution's non-public systems or data.
151
+
152
+ ## License
153
+
154
+ Apache-2.0
@@ -0,0 +1,39 @@
1
+ """Throughput benchmark: python benchmarks/bench_generate.py --subjects 1000000 --workers 8"""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import shutil
7
+ import tempfile
8
+ import time
9
+ from pathlib import Path
10
+
11
+ import creforge as cf
12
+
13
+
14
+ def main() -> None:
15
+ ap = argparse.ArgumentParser()
16
+ ap.add_argument("--subjects", type=int, default=200_000)
17
+ ap.add_argument("--months", type=int, default=36)
18
+ ap.add_argument("--workers", type=int, default=1)
19
+ ap.add_argument("--chunk-size", type=int, default=50_000)
20
+ ap.add_argument("--keep", type=Path, help="Write here instead of a temp dir")
21
+ args = ap.parse_args()
22
+
23
+ out = args.keep or Path(tempfile.mkdtemp(prefix="creforge-bench-"))
24
+ cfg = cf.Config.from_profile("baseline", subjects=args.subjects, months=args.months,
25
+ seed=1, chunk_size=args.chunk_size)
26
+ t0 = time.perf_counter()
27
+ manifest = cf.write_dataset(cfg, out, workers=args.workers)
28
+ secs = time.perf_counter() - t0
29
+ rows = manifest["row_counts"]["account_month"]
30
+ size = sum(p.stat().st_size for p in out.rglob("*.parquet"))
31
+ print(f"subjects={args.subjects:,} months={args.months} workers={args.workers}")
32
+ print(f"account_month rows={rows:,} time={secs:.1f}s rows/s={rows / secs:,.0f} "
33
+ f"parquet={size / 1e9:.2f} GB")
34
+ if not args.keep:
35
+ shutil.rmtree(out)
36
+
37
+
38
+ if __name__ == "__main__":
39
+ main()