Project: a launch plan for a lending business
Assemble product, credit policy, tech stack, unit economics, funding and licence into one plan, then test it on the lab's book: the gate picks the product, the covenant trips before the equity does
This is a project, not a lesson. You assemble a launch plan for Owoleaf’s lending from the ideas of this module, then run it on the lab’s scale 1 loan book (data1) and check it against ten acceptance figures. Other chapters of this module teach the pieces in depth: getting customers profitably, writing a credit policy, funding a loan book, treasury for a lender, licences and structures and unit economics of a lending business, with the lending tech stack alongside them. This page defines every term where it first appears and its code is complete, so you can work from it alone. The lab’s four products are written SAL (salary advance), PL (personal loan), BNPL (buy now, pay later) and SME (loan to a small or medium business). Everything is standard-library Python, money is integer kobo (one hundredth of a naira), and every number is illustrative: Owoleaf is fictional, and nothing here is a regulator’s rule, a funder’s term or any lender’s method. The book stands in for the record of Owoleaf’s small-scale lending: the closest test the plan has. Replaying what the lab’s customers did is the closest test a plan can have before it lends a naira.
The assignment
You play two people. As Nkoyo you write the plan. As Ukeme you try to break it: you check that every figure in it comes from code, that nothing in it was read off a young loan, and that the funder’s tests are run on the month that hurts most.
Four things come out.
- A product decision made by a rule written down before the numbers are seen: the gate.
- A credit policy that is code, uses the 90-day definition of monthly inflow a funder can rebuild, lists the approved loans that definition would have refused or cut, and lists the approved loans that the plan’s own stricter rules would have refused.
- Unit economics of the launched product, by cohort and per loan, and the volume that pays the fixed cost.
- A funding ladder month by month with a stress at the peak, against a facility, covenants and a licence-capital check.
The checks come first, because a bar written after you have seen the figure is a description and not a test. The reference plan passes all ten. Your figures should match to the kobo if you keep the inputs.
| # | Check |
|---|---|
| 1 | The snapshot code reproduces the loan table’s days past due and balance for every loan at the cut-off |
| 2a | The engine replay reproduces the book: the rule, fed the engine’s inflow, returns every recorded decision and amount for all 8,386 applications (the weakest test, as the credit-policy chapter explains) |
| 2b | The 90-day policy’s exceptions are counted and listed with a cause |
| 3 | Income in the P&L equals income in repayments.csv and loans.csv |
| 4 | Cohort rows add to the product rows |
| 5 | The launched set follows from the gate rule as written and computed |
| 6 | The plan book is the launched products’ loans less the stated exclusions |
| 7 | The draw never exceeds the borrowing base or the facility limit, and equity covers the need, every month |
| 8 | No covenant is breached at any month-end to 30 September |
| 9 | In the stress, the PAR30 covenant trips before the equity runs out |
| 10 | Equity covers the minimum capital of the chosen licence route |
The plan on one page
Each section of the plan is a decision, a number that supports it and the check that tests it.
| Section | The decision | The input in plan.py or policy.py |
Tested by |
|---|---|---|---|
| Product | Launch only a product whose matured contribution after acquisition, per loan, is above zero: income less losses, funding, serving and acquiring | GATE_MIN_CONTRIBUTION_PER_LOAN |
5 |
| Credit policy | The lab lender’s rule, plus four rules of the plan’s own | SCORE_CUTOFF, MAX_STACKING_ENQUIRIES_7D, SME_SINGLE_LOAN_CAP, and the 90-day inflow window in monthly_inflows() |
2a, 2b, 6 |
| Tech stack | Build the decision rules (they are the policy as code); buy the loan system | the replay | 1, 2a |
| Unit economics | Cost of funds at the blend of debt and equity; ₦6,000 to serve an SME loan; acquisition per application; a fixed monthly cost | BLENDED_COST_BPS, COST_TO_SERVE, CAC_PER_APPLICATION, FIXED_COST_PER_MONTH |
3, 4 |
| Funding | A warehouse facility at 75% of eligible receivables, plus ₦150,000,000.00 of equity | ADVANCE_BPS, EQUITY, covenants |
7, 8, 9 |
| Licence | A route chosen by the board with counsel; the plan carries its minimum capital as an input | ROUTE, ROUTE_MIN_CAPITAL |
10 |
The plan does not say which licence, funder or partner Owoleaf should pick. That is a decision for its board and its lawyers. The plan makes the choice an input and tests whether the rest still holds.
Product: a gate written first
The most dangerous slide in a launch deck is the one that says which product to start with, because it is usually the product people like. Write the rule first. Here it is: a product launches only if the average of what its matured loans left after everything is above zero. “Everything” is five lines, the four that the economics of a loan introduced plus acquisition:
net = income received − principal lost − cost of funds − cost to serve − acquisition cost
Acquisition cost is what it costs to get an application. The plan charges it per application, approved or declined, then spreads the total over the approved loans, so declines are paid for by the loans that were approved, the method of getting customers profitably. The plan’s inputs are ₦400 an application through the app, ₦250 by USSD (a phone-menu channel that needs no data) and ₦700 at a merchant’s checkout. They are this plan’s own and are not the figures that chapter uses.
Be careful with the word contribution. Unit economics of a lending business calls income less funding, losses and serving a loan’s contribution, and subtracts acquisition afterwards to get the figure “after acquisition”. The gate uses the stricter figure, after acquisition, and so does the break-even in the thin-spots list below, as that chapter does. For SME the contribution before acquisition is ₦39,597.04 a loan and after it ₦39,001.52. Serving is a flat cost per loan here, as in the first module; that chapter measures it from the collections work instead.
Two traps sit in this sum. The first is the young book. A loan is matured when its last instalment fell due on or before the cut-off, 28 October 2026. A salary advance matures in 30 days and a four-instalment BNPL in 56, but a twelve-month personal loan disbursed in March has not, and its income so far is not its result. The plan judges a loan only once it matured, which leaves 304 of 469 SME loans and 124 of 451 personal loans. The cost is a lean towards short tenors, a bias the plan states instead of hiding. The second trap is the cost of funds. Funding is not 18% because a funder says 18%. It is the blend of what debt and equity cost, weighted by how the book is funded: 75% debt at 22% and 25% equity at 30% gives 0.75 × 22 + 0.25 × 30 = 24% a year. Equity costs more because owners take the first losses. The blend is a fixed input. Funding a loan book shows that the share actually funded by debt falls below the advance rate once loans turn ineligible, which pushes the true blend up.
Run on the four products the gate prints this (step 4 of the lab):
| Product | Matured loans | Net | Net per loan | Gate |
|---|---|---|---|---|
| SAL | 1,959 | −₦8,814,545.15 | −₦4,499.52 | fail |
| PL | 124 | −₦586,546.90 | −₦4,730.22 | fail |
| BNPL | 766 | −₦5,223,768.69 | −₦6,819.55 | fail |
| SME | 304 | ₦11,856,464.74 | ₦39,001.52 | pass |
Redo the SME row by hand: ₦29,307,291.85 of income, less ₦1,057,851.81 lost, ₦14,387,937.22 of funding, ₦1,824,000.00 to serve (304 × ₦6,000) and ₦181,038.08 of acquisition, is ₦11,856,464.74, and ÷ 304 is ₦39,001.52 (the code rounds down to the kobo). The salary advance loses because ₦6,848,659.00 of principal is lost against ₦2,896,610.00 of income. BNPL loses because the customer pays nothing and the lab has no merchant income; embedded lending and BNPL partnerships models that missing line. Cheaper money does not change the verdict: at a 12% blend personal loans still lose ₦942.16 a loan. The plan launches SME, and it names the others as later products with entry conditions: a salary advance needs a loss rate it has not shown, and BNPL needs a merchant fee.
Credit policy: rules you can replay
A credit policy is the written statement of whom the lender lends to, how much, and who may make exceptions. Writing a credit policy covers its contents. The test here is narrower: can the policy be run? decide() in policy.py is the lab lender’s rule in order: a score cut-off by product, no more than six bureau enquiries in 90 days, fewer than two delinquencies in 12 months, at least ₦5,000 of monthly wallet inflows (not for BNPL), an amount capped by inflows, thin files capped at ₦50,000, then the product minimum.
The rule needs one number the plan must define: monthly wallet inflow. The lab lender’s engine measured it as all the money a wallet ever received, to the cut-off date, divided by the months since sign-up. That sum includes money that arrived after the customer applied, so a funder cannot rebuild it from what was known on the day. The plan’s policy uses the definition the credit-policy chapter teaches: money funded into the wallet by transfer or card in the 90 days before the application, divided by the days of history (at least 30, at most 90), as integer kobo a month. Two checks follow, and they are different tests.
- 2a, the engine replay. Fed the engine’s figure,
decide()returns the recorded decision and amount for all 8,386 applications. That shows the code describes the engine, and it is the weakest test the policy can pass, as the credit-policy chapter explains: it shows nothing about whether a funder could check the figures it reads. - 2b, the 90-day policy’s exceptions. Fed the 90-day figure, the same rule disagrees with the book on 460 of the 3,645 approved loans: 203 above the policy’s cap, 138 below the product minimum once the cap is recomputed, and 119 with too little inflow. The plan counts them and lists each with its cause in
policy_exceptions.csv. It would also approve 1,152 applications the engine declined, so the policy is a different rule from the engine and not a stricter copy of it. Of the 449 loans in the plan book, 24 are among the 460 (19 above the cap, 5 below the minimum); they stay in the book, disclosed with their cause, because they were lent. The lab cannot say what the book would have been under the 90-day rule, since it holds no outcome for applications the engine declined.
A policy whose exceptions are counted, with a cause, can be audited. One that only reproduces the past is a description of intentions.
The plan then adds four rules the lab lender never had.
- P1 refuses an application whose identity check name did not match.
- P2 refuses an applicant other lenders enquired about more than twice in the last seven days: loan stacking, borrowing from many lenders at once.
- P3 refuses a device shared by more than one customer.
- P4 caps a single SME loan at ₦3,000,000.00, which is also a concentration limit for the funder.
Running them on the approved book lists the exceptions, the approved loans the plan would have refused: 272 of 3,645. The table is more interesting than the count.
272 of 3,645 approved loans break at least one plan rule
rule SAL PL BNPL SME lent lost
P1 identity name mismatch 104 12 29 13 ₦19,451,000.00 ₦1,498,426.00
P2 other-lender enquiries in 7 days 63 5 5 1 ₦2,881,000.00 ₦1,336,192.76
P3 device shared by customers 83 1 6 0 ₦2,791,000.00 ₦2,746,474.00
P4 SME loan above single-loan cap 0 0 0 6 ₦24,014,000.00 ₦0.00
SME: 20 of 469 loans break a rule; they lent ₦37,143,000.00 and lost ₦0.00
P1 to P3 were built to catch fraud, and they do: P3 touches 90 loans that lost ₦2,746,474.00 of the ₦2,791,000.00 lent. In SME they are nearly idle. The 20 SME loans that break a rule lent ₦37,143,000.00 and lost nothing. Refusing them costs income and prevents no loss, so the plan keeps them in the rulebook for the consumer products it may launch later and carries the 449 other SME loans as its book. That is the policy test doing its job: it says what each rule would have cost, so a committee argues with figures. The tests above can only remove loans from the book. A rule that adds borrowers, such as a lower cut-off, cannot be tested this way, because the lab holds no outcome for people it declined.
Tech stack: build the rules, buy the plumbing
The lending tech stack names the parts: origination (the application journey), identity and bureau integrations, a decision engine, a loan management system, servicing and collections, and accounting. The plan’s position is short. The decision rules are Owoleaf’s own advantage and its regulator’s question, so it builds them, and policy.py is the specification. The loan management system, which holds schedules and balances, is plumbing, so it buys one, with one requirement taken from this lab: it must reproduce the lab’s balances and days past due from schedule and repayments. Check 1 is that requirement written as a test. The snapshot never reads the loan table’s status or balance columns. It rebuilds them, and at the cut-off it agrees with all 3,645 loans. A system that cannot do that cannot be trusted with the books.
Funding: the borrowing base, the covenant and the peak
A warehouse facility is a credit line from a funder against a pool of loans. It has four terms the plan models.
- Eligible receivables are the loans the funder will count: here, open loans no more than 30 days past due. A loan past that line is out of the pool.
- Advance rate: the share of eligible receivables the funder lends, 75%. The borrowing base is the advance rate times the eligible receivables, and the draw may not exceed it.
- Covenants are promises tested at each month-end, and a breach is an event of default unless the funder waives it. The plan’s pool covenants are the ones in the funding chapter: PAR30 (principal more than 30 days past due, over gross principal) at most 8% and NPL90 (principal 90 or more days past due, over gross principal) at most 4%. The plan adds a third, that at least 25% of gross principal is funded by equity, which is a plan input and a test on Owoleaf, not on the pool. The funding chapter’s SME concentration cap is not modelled here; P4 limits a single loan instead.
- A limit: ₦300,000,000.00 in all.
Equity funds what the facility does not. Funding a loan book covers the instruments, eligibility and the borrowing base certificate, and the definitions below follow it; here the ladder is arithmetic. Each month-end you rebuild the plan book, sum gross principal and eligible principal, compute the base, and the equity need is the gap. The ladder peaks on 30 June, when lending stops and ₦309,149,464.74 is out: the base is ₦231,862,098.55 and Owoleaf must fund ₦77,287,366.19 itself, against ₦150,000,000.00 of equity. The two tests the plan sets are the ones a funder reads first: no month needs more equity than there is, and no covenant is breached.
Then comes the stress, which exists because a plan that has only been run on a good month proves nothing. At the peak, a share of the eligible book slips past 30 days overdue, pro rata. Nothing has defaulted yet, so no loss shows. But each slipped naira leaves the pool, the base falls, and the funder asks for the difference back at once. A 2.5% slip means repaying ₦5,796,552.46. The stress steps the slip in half-points, and the PAR30 covenant first trips at 8.5%, the first step above the 8% line, when ₦19,708,278.37 must be repaid and ₦53,004,355.44 of the equity is still unspent. The equity would run out only at a slip near 31%, where 0.75 × (1 − slip) × ₦309,149,464.74 leaves a gap of ₦150,000,000.00 to fund. The binding constraint is the funder’s test, not the owners’ money, which is why the plan negotiates the covenant, not only the equity.
A last finding is in the ladder. At the 28 October cut-off, with no new lending since June, PAR30 is 13.29% and NPL90 is 4.64%: both breach. Nothing new went wrong: the denominator shrank. A plan that has no answer to “what if we stop lending” has a covenant it cannot keep, and treasury for a lender is where liquidity at that point is worked through. Check 8 stops at 30 September, and the plan states the October breach.
Licence: an input, not a choice
Lending in Nigeria needs the right permission, and which one depends on the structure. The plan does not pick. It holds the minimum capital of each route under consideration as a number, with the route chosen as an input, and tests that equity covers it. The three figures in plan.py are placeholders, not any regulator’s amounts; Licences and structures covers the real routes and where their figures come from. R1 to R3 here are not those figures, and a round number in a placeholder is not a finding.
The Federal Competition and Consumer Protection Commission’s announcement of its Digital, Electronic, Online or Non-Traditional Consumer Lending Regulations 2025 says they set up a registration regime for consumer lending through electronic and mobile channels, with existing lenders to register within 90 days of commencement and new entrants to be approved before they start operating. The Commission’s notice gives 21 July 2025 as the start, while law-firm summaries also give 25 July and 3 September 2025. Press and law-firm reports say the Commission later set 5 January 2026 as the deadline for full compliance and then removed non-compliant operators from its published register; the notices themselves were not opened here. Summaries say banks and financial institutions licensed by the Central Bank of Nigeria are treated differently, and that microfinance banks must apply for a waiveras of 2026-11. This rests on search-result summaries and the Commission’s announcement. The Regulations’ text could not be read here, so read it and the Commission’s current notices before relying on any date. A launch plan lists registration as a gate before the first disbursement, next to the licence.
Where the plan is thin
An honest plan says where it is weak, and Ukeme’s list is short.
- Volume. Fixed costs of ₦2,500,000.00 a month over a contribution after acquisition of ₦34,623.64 a matured loan need 72.2 loans a month. The book made 74.8 a month over six months. The margin is thin, and over those six months the fixed cost, ₦15,000,000.00, exceeds the ₦9,971,609.34 contributed by the 288 matured plan loans, with 161 loans still maturing. The plan does not claim profit on this book; it claims the volume to reach it.
- Cohorts. Per ₦100 lent, the matured loans of February to April return ₦4.18 to ₦5.33 after every cost, and those of May and June about ₦3.4. January returns ₦0.72 on five loans, one of which was lost. The later cohorts are matured only where they were short, so the pattern may be selection, not decline. Treat it as a question for module 3’s vintage tools, such as portfolio metrics.
- Almost no recoveries. The lab’s outside agency recovered ₦37,364 in all, none on SME, so losses count in full. The SME loss is small (₦1,057,851.81 on ₦283,505,000.00 lent), and a plan should not lean on a number that rests on 304 matured loans of which five were lost.
- Illustrative inputs. Every cost, rate and covenant is invented. The value of the exercise is in what moves when you change them, which the last step of the lab does.
You work in a new folder, labs/finance/launch. Run every command from inside it. The data is data1 at seed 42 and scale 1, and nothing here writes to it. Each script prints what it found, and accept.py states the ten checks.
1. Check the data.
cd labs/finance
ls data1/loans.csv data1/applicant_signals.csv data1/finance.sqlite 2>/dev/null || \
(python3 generate.py --scale 1 --out data1 && python3 loans.py --out data1 \
&& python3 cards.py --out data1 && python3 collect.py --out data1 && python3 book3.py --out data1)
python3 check.py --db data1/finance.sqlite | tail -1
mkdir -p launch && cd launchIf data1 exists, ls prints three paths and nothing is built. The check takes about 30 seconds and ends with:
OK: all invariants hold2. The plan’s inputs and the shared library. plan.py holds every input in one place, so a change is one line. lib.py loads the book and rebuilds the position at any date from the schedule and repayments.
cat > plan.py <<'EOF'
"""The launch plan's inputs. Every number is ILLUSTRATIVE: not Owoleaf's, a funder's or a regulator's.
Money is integer kobo (100 kobo = 1 naira); rates are basis points (100 bps = 1%)."""
NAIRA = 100
CUT_OFF = "2026-10-28" # the lab's cut-off: the book is observed to here
# --- product: which of the lab's four products the plan launches is decided by the gate in unit.py
GATE_MIN_CONTRIBUTION_PER_LOAN = 0 # after cost of funds, losses, serving and acquisition
# --- unit costs
COST_TO_SERVE = {"SAL": 800 * NAIRA, "PL": 2_500 * NAIRA, "BNPL": 1_200 * NAIRA, "SME": 6_000 * NAIRA} # per loan
CAC_PER_APPLICATION = {"app": 400 * NAIRA, "ussd": 250 * NAIRA, "merchant_checkout": 700 * NAIRA} # per application, approved or not
FIXED_COST_PER_MONTH = 2_500_000 * NAIRA # the lending team, tools and compliance, whatever the volume
# --- funding: a warehouse facility (debt) plus Owoleaf's equity
ADVANCE_BPS = 7_500 # the funder lends 75% of eligible receivables
DEBT_COST_BPS = 2_200 # a year
EQUITY_COST_BPS = 3_000 # a year: what the owners require
BLENDED_COST_BPS = (ADVANCE_BPS * DEBT_COST_BPS + (10_000 - ADVANCE_BPS) * EQUITY_COST_BPS) // 10_000 # 24%
FACILITY_LIMIT = 300_000_000 * NAIRA
EQUITY = 150_000_000 * NAIRA # what the owners put in before the first loan
ELIGIBLE_MAX_DPD = 30 # a loan more than 30 days past due is not eligible
# Covenants, tested at each month-end on the whole book (gross principal, written-off loans excluded)
COVENANT_PAR30_MAX_BPS = 800 # principal more than 30 days past due, over gross principal
COVENANT_NPL90_MAX_BPS = 400 # principal 90 or more days past due, over gross principal
COVENANT_MIN_EQUITY_FUNDED_BPS = 2_500 # equity-funded share of gross principal, at least
# --- licence route: an input the board sets with counsel. PLACEHOLDERS: not any regulator's figure.
ROUTE = "R1"
ROUTE_MIN_CAPITAL = {"R1": 100_000_000 * NAIRA, "R2": 500_000_000 * NAIRA, "R3": 2_000_000_000 * NAIRA}
EOF
cat > lib.py <<'EOF'
"""Shared loader, snapshot and money formatting. Standard library only; money is integer kobo.
The snapshot rebuilds days past due and principal outstanding at any date from the schedule and
the repayments, and never reads loans.status, days_past_due or any outstanding_/paid_ column."""
import collections, csv, datetime as dt, os
DATA = os.environ.get("DATA", "../data1/")
d = dt.date.fromisoformat
WRITE_OFF_DPD = 180
def naira(k):
sign = "-" if k < 0 else ""
k = abs(k)
return f"{sign}₦{k // 100:,}.{k % 100:02d}"
def rows(name):
with open(os.path.join(DATA, name + ".csv"), newline="") as f:
return list(csv.DictReader(f))
def load():
loans = {r["id"]: r for r in rows("loans")}
sched, reps = collections.defaultdict(list), collections.defaultdict(list)
for r in rows("schedule"):
sched[r["loan_id"]].append((int(r["instalment"]), d(r["due_date"]), int(r["total_kobo"])))
for r in rows("repayments"):
reps[r["loan_id"]].append((d(r["paid_at"]), int(r["instalment"]), int(r["amount_kobo"]) - int(r["late_fee_kobo"]),
int(r["principal_kobo"])))
return loans, sched, reps
def snapshot(loans, sched, reps, asof):
"""The book at the close of asof: a payment counts if dated asof or earlier; an instalment is late
only if it fell due before asof. {loan_id: (dpd, outstanding principal, state)}."""
out = {}
for lid, l in loans.items():
if d(l["disbursed_at"]) > asof:
continue
rec, paid_p = collections.Counter(), 0
for paid, n, pi, p in reps[lid]:
if paid <= asof:
rec[n] += pi
paid_p += p
unpaid = [due for n, due, tot in sched[lid] if due < asof and rec[n] < tot]
dpd = (asof - min(unpaid)).days if unpaid else 0
o = int(l["principal_kobo"]) - paid_p
out[lid] = (dpd, o, "closed" if o == 0 else ("written_off" if dpd >= WRITE_OFF_DPD else "open"))
return out
EOFNothing is printed. Read plan.py before you run anything else and write down what you expect the gate to do.
3. Prove the snapshot. It rebuilds days past due and principal outstanding at the cut-off and compares them with the loan table.
cat > snapcheck.py <<'EOF'
from lib import d, load, snapshot
import plan
loans, sched, reps = load()
snap = snapshot(loans, sched, reps, d(plan.CUT_OFF))
bad = 0
for lid, (dpd, out, state) in snap.items():
l = loans[lid]
want_state = {"closed": "closed", "written_off": "written_off"}.get(l["status"], "open")
if (dpd, out, state) != (int(l["days_past_due"]), int(l["outstanding_principal_kobo"]), want_state):
bad += 1
print(f"{len(snap):,} loans rebuilt at {plan.CUT_OFF}; {bad} differ from loans.csv")
EOF
python3 snapcheck.py3,645 loans rebuilt at 2026-10-28; 0 differ from loans.csv4. Run the gate. unit.py computes each loan’s P&L and totals the matured loans by product. An optional argument changes the cost of funds in basis points.
cat > unit.py <<'EOF'
"""Per-loan P&L from the book: income received, principal lost, cost of funds, cost to serve, acquisition.
A loan is judged only once its last instalment was due on or before the cut-off ('matured'), so a young
loan's income-so-far is never read as its result. Money is integer kobo."""
import collections, sys
from lib import d, load, naira, rows
import plan
PRODUCTS = ("SAL", "PL", "BNPL", "SME")
LOST = ("default", "written_off")
def acquisition_per_loan(apps, loans, by="product"):
"""CAC of every application (approved or not) in a group, spread over that group's approved loans."""
cost, n = collections.Counter(), collections.Counter()
key = (lambda p, month: p) if by == "product" else (lambda p, month: (p, month))
for a in apps:
cost[key(a["product"], a["applied_at"][:7])] += plan.CAC_PER_APPLICATION[a["channel"]]
appmonth = {a["id"]: a["applied_at"][:7] for a in apps}
for l in loans.values():
n[key(l["product"], appmonth[l["application_id"]])] += 1
return {k: cost[k] // n[k] for k in n}
def pnl(loans, sched, reps, apps, cof_bps=plan.BLENDED_COST_BPS):
"""{loan_id: dict(...)} for every loan, with matured True or False."""
cut = d(plan.CUT_OFF)
acq = acquisition_per_loan(apps, loans)
out = {}
for lid, l in loans.items():
pdays = int(l["principal_kobo"]) * (cut - d(l["disbursed_at"])).days
for paid, n, pi, p in reps[lid]:
pdays -= p * (cut - paid).days
income = int(l["fee_kobo"]) + int(l["paid_interest_kobo"]) + int(l["paid_late_fees_kobo"])
lost = int(l["outstanding_principal_kobo"]) if l["status"] in LOST else 0
funds = pdays * cof_bps // (10_000 * 365)
serve = plan.COST_TO_SERVE[l["product"]]
a = acq[l["product"]]
out[lid] = dict(product=l["product"], month=l["disbursed_at"][:7], lent=int(l["principal_kobo"]),
income=income, lost=lost, funds=funds, serve=serve, acq=a,
net=income - lost - funds - serve - a, matured=sched[lid][-1][1] <= cut)
return out
def gate(pl, threshold=plan.GATE_MIN_CONTRIBUTION_PER_LOAN):
"""The gate as one function: the products whose matured loans average more than the threshold per loan
after every cost. Returns (launched products, {product: totals})."""
per = {p: total(r for r in pl.values() if r["product"] == p and r["matured"]) for p in PRODUCTS}
return [p for p in PRODUCTS if per[p]["n"] and per[p]["net"] // per[p]["n"] > threshold], per
def total(rows_):
t = collections.Counter()
for r in rows_:
t["n"] += 1
for k in ("lent", "income", "lost", "funds", "serve", "acq", "net"):
t[k] += r[k]
return t
if __name__ == "__main__":
loans, sched, reps = load()
apps = rows("applications")
cof = int(sys.argv[1]) if len(sys.argv) > 1 else plan.BLENDED_COST_BPS
pl = pnl(loans, sched, reps, apps, cof)
print(f"cost of funds {cof / 100:.1f}% a year; matured loans only")
print(f"{'':5}{'loans':>6}{'lent':>17}{'income':>15}{'lost':>15}{'funds':>15}{'serve':>14}{'acquire':>14}{'net':>16}{'net/loan':>12}{'gate':>6}")
launch = []
for p in PRODUCTS:
t = total(r for r in pl.values() if r["product"] == p and r["matured"])
per = t["net"] // t["n"]
ok = per > plan.GATE_MIN_CONTRIBUTION_PER_LOAN
if ok:
launch.append(p)
print(f"{p:5}{t['n']:>6}{naira(t['lent']):>17}{naira(t['income']):>15}{naira(t['lost']):>15}{naira(t['funds']):>15}"
f"{naira(t['serve']):>14}{naira(t['acq']):>14}{naira(t['net']):>16}{naira(per):>12}{'PASS' if ok else 'fail':>6}")
print("the plan launches:", ", ".join(launch) or "nothing")
EOF
python3 unit.py
python3 unit.py 1200At the plan’s 24% blend only SME passes:
cost of funds 24.0% a year; matured loans only
loans lent income lost funds serve acquire net net/loan gate
SAL 1959 ₦52,161,000.00 ₦2,896,610.00 ₦6,848,659.00 ₦1,699,964.91 ₦1,567,200.00 ₦1,595,331.24 -₦8,814,545.15 -₦4,499.52 fail
PL 124 ₦16,227,000.00 ₦1,986,101.93 ₦1,236,026.02 ₦939,438.41 ₦310,000.00 ₦87,184.40 -₦586,546.90 -₦4,730.22 fail
BNPL 766 ₦35,984,000.00 ₦112,500.00 ₦1,775,883.00 ₦1,017,886.15 ₦919,200.00 ₦1,623,299.54 -₦5,223,768.69 -₦6,819.55 fail
SME 304 ₦283,505,000.00 ₦29,307,291.85 ₦1,057,851.81 ₦14,387,937.22 ₦1,824,000.00 ₦181,038.08 ₦11,856,464.74 ₦39,001.52 PASS
the plan launches: SMEAt 12% (1,200 bps) the SME line improves to ₦62,665.90 a loan and the others still fail, so the verdict does not depend on the funding input.
5. Write the policy and replay it. policy.py holds the lab lender’s rule, the two definitions of monthly inflow and the plan’s four additions. replay.py runs the rule over every application twice: 2a with the engine’s inflow, 2b with the plan’s 90-day inflow, and it writes the 2b exceptions to policy_exceptions.csv.
cat > policy.py <<'EOF'
"""The credit policy as code. decide() is the lab's own lending rule, written out so it can be replayed;
extra_rules() are the launch plan's additions (v2). ILLUSTRATIVE, like every number in the lab."""
import collections, sqlite3, os
from lib import DATA, d, naira, rows
import plan
SCORE_CUTOFF = {"SAL": 580, "PL": 620, "BNPL": 560, "SME": 600}
MAX_ENQUIRIES_90D = 6
MIN_MONTHLY_INFLOW = 5_000 * plan.NAIRA
MIN_AMOUNT = {"SAL": 10_000, "PL": 50_000, "BNPL": 20_000, "SME": 200_000} # naira
THIN_FILE_CAP = 50_000 * plan.NAIRA
# plan v2 additions
MAX_STACKING_ENQUIRIES_7D = 2 # three or more other lenders in a week: refer, do not lend
MAX_CUSTOMERS_PER_DEVICE = 1 # a device shared by several customers: refer
SME_SINGLE_LOAN_CAP = 3_000_000 * plan.NAIRA
def engine_monthly_inflows():
"""Monthly inflow as the lab lender's engine (loans.py) measured it: all succeeded transfer and card
fundings, ever, over the months from sign-up to the cut-off (at least one). It includes money that
arrives after the application, so a funder cannot reproduce it. Used only for check 2a. {customer_id: float}."""
db = sqlite3.connect(os.path.join(DATA, "finance.sqlite"))
cut = d(plan.CUT_OFF)
inflow = dict(db.execute("""SELECT customer_id, SUM(amount_kobo) FROM transactions
WHERE status='succeeded' AND kind IN ('funding_transfer','funding_card') GROUP BY customer_id"""))
out = {}
for cid, signup in db.execute("SELECT id, signup_at FROM customers"):
months = max(1, (cut - d(signup[:10])).days / 30)
out[str(cid)] = inflow.get(cid, 0) / months
return out
def monthly_inflows():
"""The plan's policy definition, the one Writing a credit policy teaches: money funded into the wallet by
transfer or card in the 90 days before the application date, over the days of history (at least 30,
at most 90), as integer kobo a month. Nothing after the application counts. {application_id: int}."""
db = sqlite3.connect(os.path.join(DATA, "finance.sqlite"))
out = {}
for aid, applied, signup, inflow in db.execute("""
SELECT a.id, a.applied_at, substr(c.signup_at, 1, 10),
(SELECT COALESCE(SUM(t.amount_kobo), 0) FROM transactions t
WHERE t.customer_id = a.customer_id AND t.status = 'succeeded'
AND t.kind IN ('funding_transfer', 'funding_card')
AND t.created_at >= date(a.applied_at, '-90 days') AND t.created_at < a.applied_at)
FROM applications a JOIN customers c ON c.id = a.customer_id"""):
history = max(30, min(90, (d(applied) - d(signup)).days))
out[str(aid)] = inflow * 30 // history
return out
def decide(app, bureau, monthly_in):
"""-> (decision, reason, approved_kobo). The rule in order: score cut-off, enquiries, delinquency,
income evidence, then an amount capped by inflows, then the product minimum."""
code, n, requested = app["product"], int(app["instalments"]), int(app["requested_kobo"])
hit = bureau["hit"] == "1"
if hit and int(bureau["score"]) < SCORE_CUTOFF[code]:
return "declined", "score_below_cutoff", 0
if int(bureau["enquiries_90d"]) > MAX_ENQUIRIES_90D:
return "declined", "too_many_recent_enquiries", 0
if hit and int(bureau["delinquent_12m"]) >= 2:
return "declined", "recent_delinquency", 0
if monthly_in < MIN_MONTHLY_INFLOW and code != "BNPL":
return "declined", "insufficient_income_evidence", 0
# monthly_in is a float of kobo when it is the engine's figure (loans.py measured it so, and the replay
# must match it) and integer kobo when it is the policy's; the cap is rounded down to a whole ₦1,000 at once
cap = int(monthly_in * (1.0 if code in ("SAL", "BNPL") else 2.0 * n / 3)) // 100_000 * 100_000
if not hit:
cap = min(cap, THIN_FILE_CAP)
approved = max(0, min(requested, cap))
if approved < MIN_AMOUNT[code] * plan.NAIRA:
return "declined", "amount_below_product_minimum", 0
return "approved", None, approved
def extra_rules(app, signal, customers_on_device, approved_kobo):
"""The plan's own rules, which the lab's lender did not apply. Returns the rule ids a loan breaches."""
hits = []
if signal["name_match"] == "0":
hits.append("P1 identity name mismatch")
if int(signal["other_lender_enquiries_7d"]) > MAX_STACKING_ENQUIRIES_7D:
hits.append("P2 other-lender enquiries in 7 days")
if customers_on_device > MAX_CUSTOMERS_PER_DEVICE:
hits.append("P3 device shared by customers")
if app["product"] == "SME" and approved_kobo > SME_SINGLE_LOAN_CAP:
hits.append("P4 SME loan above single-loan cap")
return hits
def customers_per_device(signals, apps):
dev = collections.defaultdict(set)
for a in apps:
dev[signals[a["id"]]["device_id"]].add(a["customer_id"])
return {k: len(v) for k, v in dev.items()}
EOF
cat > replay.py <<'EOF'
"""2a: the engine's definition of inflow reproduces the recorded book. 2b: the plan's 90-day definition does not,
and every approved loan it would not have approved as lent is an exception with a cause."""
import collections, csv
from lib import rows
from policy import decide, engine_monthly_inflows, monthly_inflows
def engine_misses(apps, bureau):
"""Applications where the policy rule, fed the engine's inflow, differs from the recorded decision."""
inflow = engine_monthly_inflows()
differ = []
for a in apps:
got = decide(a, bureau[a["bureau_report_id"]], inflow[a["customer_id"]])
taken = a["decision"] in ("approved", "withdrawn") # 6% of approved offers are not taken up
same = (got[0] == "approved") == taken
if same and taken and a["decision"] == "approved":
same = got[2] == int(a["approved_kobo"]) # the amount offered
if same and not taken:
same = got[1] == a["decline_reason"] # the reason given
if not same:
differ.append(a["id"])
return differ
def policy_exceptions(apps, bureau):
"""Approved applications that the policy, with the 90-day inflow, would have declined or cut.
Returns [(application_id, product, approved_kobo, policy_allows_kobo, cause)] and the count of
declined applications the policy would have approved."""
inflow = monthly_inflows()
out, would_approve = [], 0
for a in apps:
got = decide(a, bureau[a["bureau_report_id"]], inflow[a["id"]])
if a["decision"] == "approved":
if got[0] == "declined":
out.append((a["id"], a["product"], int(a["approved_kobo"]), 0, got[1]))
elif got[2] < int(a["approved_kobo"]):
out.append((a["id"], a["product"], int(a["approved_kobo"]), got[2], "amount_above_90_day_cap"))
elif a["decision"] == "declined" and got[0] == "approved":
would_approve += 1
return out, would_approve
if __name__ == "__main__":
apps = rows("applications")
bureau = {r["id"]: r for r in rows("bureau_reports")}
differ = engine_misses(apps, bureau)
print(f"2a. engine definition: {len(apps):,} applications replayed: {len(apps) - len(differ):,} match the recorded decision, {len(differ)} differ")
exc, would = policy_exceptions(apps, bureau)
approved = sum(a["decision"] == "approved" for a in apps)
print(f"2b. 90-day definition: {len(exc):,} of {approved:,} approved loans are exceptions to the policy; "
f"it would also approve {would:,} declined applications")
by_cause = collections.Counter((c, p) for _, p, _, _, c in exc)
for cause in sorted({c for c, _ in by_cause}):
print(f" {sum(v for (c, _), v in by_cause.items() if c == cause):>4} {cause}: "
+ ", ".join(f"{p} {by_cause[(cause, p)]}" for p in ("SAL", "PL", "BNPL", "SME") if by_cause[(cause, p)]))
with open("policy_exceptions.csv", "w", newline="") as f:
w = csv.writer(f)
w.writerow(["application_id", "product", "approved_kobo", "policy_allows_kobo", "cause"])
w.writerows(exc)
print(f" listed in policy_exceptions.csv ({len(exc)} rows)")
EOF
python3 replay.py2a. engine definition: 8,386 applications replayed: 8,386 match the recorded decision, 0 differ
2b. 90-day definition: 460 of 3,645 approved loans are exceptions to the policy; it would also approve 1,152 declined applications
203 amount_above_90_day_cap: SAL 112, PL 31, BNPL 38, SME 22
138 amount_below_product_minimum: SAL 54, PL 11, BNPL 68, SME 5
119 insufficient_income_evidence: SAL 106, PL 13
listed in policy_exceptions.csv (460 rows)Withdrawn offers (6% of approvals) count as approved in 2a: the borrower walked away after the decision. 2b looks only at approved loans and declines. Part 2a is the weakest possible test and it passes. Part 2b changes one definition, and the same rule then disagrees with 460 loans, each with a stated cause. 27 of them are SME loans.
6. List the exceptions. The approved loans that break a plan rule.
cat > exceptions.py <<'EOF'
"""Test the book against the plan's policy: which approved loans would the plan's own rules have refused?"""
import collections
from lib import load, naira, rows
from policy import customers_per_device, extra_rules
from unit import LOST, PRODUCTS, pnl
import plan
def exception_map(loans, apps, signals):
"""{loan_id: [rule ids]} for every approved loan that breaks a plan rule."""
by_id = {a["id"]: a for a in apps}
per_dev = customers_per_device(signals, apps)
out = {}
for lid, l in loans.items():
a = by_id[l["application_id"]]
hits = extra_rules(a, signals[a["id"]], per_dev[signals[a["id"]]["device_id"]], int(l["principal_kobo"]))
if hits:
out[lid] = hits
return out
if __name__ == "__main__":
loans, sched, reps = load()
apps = rows("applications")
signals = {r["application_id"]: r for r in rows("applicant_signals")}
ex = exception_map(loans, apps, signals)
print(f"{len(ex)} of {len(loans):,} approved loans break at least one plan rule\n")
cnt = collections.defaultdict(collections.Counter)
for lid, rules in ex.items():
l = loans[lid]
lost = int(l["outstanding_principal_kobo"]) if l["status"] in LOST else 0
for rule in rules:
c = cnt[rule]
c[l["product"]] += 1
c["lent"] += int(l["principal_kobo"])
c["lost"] += lost
print(f"{'rule':<40}" + "".join(f"{p:>6}" for p in PRODUCTS) + f"{'lent':>18}{'lost':>16}")
for rule in sorted(cnt):
c = cnt[rule]
print(f"{rule:<40}" + "".join(f"{c[p]:>6}" for p in PRODUCTS) + f"{naira(c['lent']):>18}{naira(c['lost']):>16}")
sme = [l for l in loans.values() if l["product"] == "SME"]
hit = [l for l in sme if l["id"] in ex]
print(f"\nSME: {len(hit)} of {len(sme)} loans break a rule; they lent {naira(sum(int(l['principal_kobo']) for l in hit))} "
f"and lost {naira(sum(int(l['outstanding_principal_kobo']) for l in hit if l['status'] in LOST))}")
EOF
python3 exceptions.py272 of 3,645 approved loans break at least one plan rule
rule SAL PL BNPL SME lent lost
P1 identity name mismatch 104 12 29 13 ₦19,451,000.00 ₦1,498,426.00
P2 other-lender enquiries in 7 days 63 5 5 1 ₦2,881,000.00 ₦1,336,192.76
P3 device shared by customers 83 1 6 0 ₦2,791,000.00 ₦2,746,474.00
P4 SME loan above single-loan cap 0 0 0 6 ₦24,014,000.00 ₦0.00
SME: 20 of 469 loans break a rule; they lent ₦37,143,000.00 and lost ₦0.00A loan that breaks two rules appears in both rows, so the rows add to more than 272.
7. Run the funding ladder and the stress. The plan book is the launched product’s loans (the gate computes it) less the loans that break a plan rule.
cat > funding.py <<'EOF'
"""The funding ladder and the stress. The plan book is the loans of the products the gate launches, less the loans that
break a plan rule. At each month-end: gross principal, eligible principal, borrowing base, draw, equity needed,
covenants. Then a stress: a share of the eligible book slips past 30 days overdue at the peak month."""
from lib import d, load, naira, rows, snapshot
from exceptions import exception_map
from unit import gate, pnl
import plan
MONTH_ENDS = ["2026-01-31", "2026-02-28", "2026-03-31", "2026-04-30", "2026-05-31", "2026-06-30",
"2026-07-31", "2026-08-31", "2026-09-30", "2026-10-28"]
def launched():
"""The products the gate launches, computed from the book, not typed in."""
loans, sched, reps = load()
return gate(pnl(loans, sched, reps, rows("applications")))[0]
def plan_book():
loans, sched, reps = load()
apps = rows("applications")
signals = {r["application_id"]: r for r in rows("applicant_signals")}
ex = exception_map(loans, apps, signals)
launch = launched()
keep = {k: v for k, v in loans.items() if v["product"] in launch and k not in ex}
return keep, sched, reps
def position(snap):
gross = eligible = par30 = npl90 = 0
for dpd, out, state in snap.values():
if state != "open":
continue
gross += out
if dpd <= plan.ELIGIBLE_MAX_DPD:
eligible += out
else:
par30 += out
if dpd >= 90:
npl90 += out
return gross, eligible, par30, npl90
def facility(eligible):
return min(plan.ADVANCE_BPS * eligible // 10_000, plan.FACILITY_LIMIT)
def ladder(keep, sched, reps):
out = []
for m in MONTH_ENDS:
gross, elig, par30, npl90 = position(snapshot(keep, sched, reps, d(m)))
bb = facility(elig)
out.append(dict(month=m, gross=gross, eligible=elig, par30=par30, npl90=npl90, bb=bb, equity=gross - bb))
return out
def breaches(r):
b = []
if r["gross"] and r["par30"] * 10_000 > plan.COVENANT_PAR30_MAX_BPS * r["gross"]:
b.append("PAR30")
if r["gross"] and r["npl90"] * 10_000 > plan.COVENANT_NPL90_MAX_BPS * r["gross"]:
b.append("NPL90")
if r["gross"] and r["equity"] * 10_000 < plan.COVENANT_MIN_EQUITY_FUNDED_BPS * r["gross"]:
b.append("EQUITY")
return b
def stress(r, s_bps):
"""A share s of the eligible principal slips past 30 days overdue (pro rata). The facility was drawn to
the old base; the new base is lower, and the gap is repaid at once from equity."""
slip = r["eligible"] * s_bps // 10_000
new = dict(r, eligible=r["eligible"] - slip, par30=r["par30"] + slip)
new["bb"] = facility(new["eligible"])
deficiency = max(0, r["bb"] - new["bb"])
new["equity"] = r["gross"] - new["bb"]
return new, deficiency
if __name__ == "__main__":
keep, sched, reps = plan_book()
L = ladder(keep, sched, reps)
print(f"plan book: {len(keep)} {'/'.join(launched())} loans; advance {plan.ADVANCE_BPS / 100:.0f}%, facility limit {naira(plan.FACILITY_LIMIT)}, equity {naira(plan.EQUITY)}")
print(f"{'month-end':<12}{'gross':>17}{'eligible':>17}{'base':>17}{'equity need':>17}{'PAR30':>7}{'NPL90':>7} breaches")
for r in L:
print(f"{r['month']:<12}{naira(r['gross']):>17}{naira(r['eligible']):>17}{naira(r['bb']):>17}{naira(r['equity']):>17}"
f"{r['par30'] / max(r['gross'], 1):>7.2%}{r['npl90'] / max(r['gross'], 1):>7.2%} {','.join(breaches(r)) or '-'}")
peak = max(L, key=lambda r: r["equity"])
print(f"\npeak equity need {naira(peak['equity'])} at {peak['month']}; headroom {naira(plan.EQUITY - peak['equity'])}")
print(f"\nstress at {peak['month']}: a share of the eligible book slips past 30 days")
print(f"{'share':>6}{'PAR30':>8}{'base':>17}{'repay now':>17}{'equity need':>17}{'headroom':>17} breaches")
first = {}
for s in range(0, 2501, 50):
n, defi = stress(peak, s)
br = breaches(n)
if plan.EQUITY < n["equity"]:
br.append("EQUITY SHORT")
for b in br:
first.setdefault(b, s)
if s % 250 == 0:
print(f"{s / 100:>5.1f}%{n['par30'] / n['gross']:>8.2%}{naira(n['bb']):>17}{naira(defi):>17}{naira(n['equity']):>17}{naira(plan.EQUITY - n['equity']):>17} {','.join(br) or '-'}")
print("first slip share that breaches:", {k: f"{v / 100:.1f}%" for k, v in sorted(first.items())})
EOF
python3 funding.pyplan book: 449 SME loans; advance 75%, facility limit ₦300,000,000.00, equity ₦150,000,000.00
month-end gross eligible base equity need PAR30 NPL90 breaches
2026-01-31 ₦5,709,000.00 ₦5,709,000.00 ₦4,281,750.00 ₦1,427,250.00 0.00% 0.00% -
2026-02-28 ₦20,763,448.74 ₦20,763,448.74 ₦15,572,586.55 ₦5,190,862.19 0.00% 0.00% -
2026-03-31 ₦55,705,978.73 ₦55,705,978.73 ₦41,779,484.04 ₦13,926,494.69 0.00% 0.00% -
2026-04-30 ₦109,484,610.65 ₦109,484,610.65 ₦82,113,457.98 ₦27,371,152.67 0.00% 0.00% -
2026-05-31 ₦186,050,244.45 ₦186,050,244.45 ₦139,537,683.33 ₦46,512,561.12 0.00% 0.00% -
2026-06-30 ₦309,149,464.74 ₦309,149,464.74 ₦231,862,098.55 ₦77,287,366.19 0.00% 0.00% -
2026-07-31 ₦222,266,489.05 ₦221,692,489.05 ₦166,269,366.78 ₦55,997,122.27 0.26% 0.00% -
2026-08-31 ₦143,591,598.33 ₦140,527,920.09 ₦105,395,940.06 ₦38,195,658.27 2.13% 0.00% -
2026-09-30 ₦86,127,742.22 ₦80,940,870.90 ₦60,705,653.17 ₦25,422,089.05 6.02% 0.67% -
2026-10-28 ₦55,458,290.89 ₦48,087,116.05 ₦36,065,337.03 ₦19,392,953.86 13.29% 4.64% PAR30,NPL90
peak equity need ₦77,287,366.19 at 2026-06-30; headroom ₦72,712,633.81
stress at 2026-06-30: a share of the eligible book slips past 30 days
share PAR30 base repay now equity need headroom breaches
0.0% 0.00% ₦231,862,098.55 ₦0.00 ₦77,287,366.19 ₦72,712,633.81 -
2.5% 2.50% ₦226,065,546.09 ₦5,796,552.46 ₦83,083,918.65 ₦66,916,081.35 -
5.0% 5.00% ₦220,268,993.63 ₦11,593,104.92 ₦88,880,471.11 ₦61,119,528.89 -
7.5% 7.50% ₦214,472,441.16 ₦17,389,657.39 ₦94,677,023.58 ₦55,322,976.42 -
10.0% 10.00% ₦208,675,888.70 ₦23,186,209.85 ₦100,473,576.04 ₦49,526,423.96 PAR30
12.5% 12.50% ₦202,879,336.23 ₦28,982,762.32 ₦106,270,128.51 ₦43,729,871.49 PAR30
15.0% 15.00% ₦197,082,783.77 ₦34,779,314.78 ₦112,066,680.97 ₦37,933,319.03 PAR30
17.5% 17.50% ₦191,286,231.31 ₦40,575,867.24 ₦117,863,233.43 ₦32,136,766.57 PAR30
20.0% 20.00% ₦185,489,678.85 ₦46,372,419.70 ₦123,659,785.89 ₦26,340,214.11 PAR30
22.5% 22.50% ₦179,693,126.38 ₦52,168,972.17 ₦129,456,338.36 ₦20,543,661.64 PAR30
25.0% 25.00% ₦173,896,573.92 ₦57,965,524.63 ₦135,252,890.82 ₦14,747,109.18 PAR30
first slip share that breaches: {'PAR30': '8.5%'}The equity need is 25% of gross principal in every month with no overdue loans, which is what a 75% advance rate means. The covenants hold to September and breach in October, in the run-off.
8. Run the plan book’s unit economics. Cohorts are loans grouped by disbursement month, matured only.
cat > planpnl.py <<'EOF'
"""The plan book's unit economics: matured loans by disbursement month, per loan and per ₦100 lent,
and the volume that pays the fixed cost."""
import collections
from lib import load, naira, rows
from funding import plan_book
from unit import pnl, total
import plan
if __name__ == "__main__":
loans, sched, reps = load()
apps = rows("applications")
allp = pnl(loans, sched, reps, apps)
keep, _, _ = plan_book()
mat = {k: v for k, v in allp.items() if k in keep and v["matured"]}
print(f"plan book: {len(keep)} loans, {len(mat)} matured\n")
print(f"{'cohort':<9}{'loans':>6}{'lent':>17}{'income':>15}{'lost':>14}{'funds':>15}{'serve+acq':>15}{'net':>15}{'net/loan':>12}{'net per ₦100':>14}")
by = collections.defaultdict(list)
for r in mat.values():
by[r["month"]].append(r)
for m in sorted(by):
t = total(by[m])
print(f"{m:<9}{t['n']:>6}{naira(t['lent']):>17}{naira(t['income']):>15}{naira(t['lost']):>14}{naira(t['funds']):>15}"
f"{naira(t['serve'] + t['acq']):>15}{naira(t['net']):>15}{naira(t['net'] // t['n']):>12}{t['net'] * 100 / t['lent']:>14.2f}")
t = total(mat.values())
per = t["net"] // t["n"]
print(f"{'all':<9}{t['n']:>6}{naira(t['lent']):>17}{naira(t['income']):>15}{naira(t['lost']):>14}{naira(t['funds']):>15}"
f"{naira(t['serve'] + t['acq']):>15}{naira(t['net']):>15}{naira(per):>12}{t['net'] * 100 / t['lent']:>14.2f}")
print(f"\nfixed cost {naira(plan.FIXED_COST_PER_MONTH)} a month / contribution {naira(per)} a loan "
f"= {plan.FIXED_COST_PER_MONTH / per:.1f} loans a month to break even")
months = len(by)
print(f"the plan book made {len(keep) / 6:.1f} loans a month over the six lending months")
print(f"six months of fixed cost {naira(6 * plan.FIXED_COST_PER_MONTH)} against matured contribution {naira(t['net'])}")
EOF
python3 planpnl.pyplan book: 449 loans, 288 matured
cohort loans lent income lost funds serve+acq net net/loan net per ₦100
2026-01 5 ₦5,709,000.00 ₦770,501.99 ₦285,944.68 ₦410,353.20 ₦32,977.60 ₦41,226.51 ₦8,245.30 0.72
2026-02 16 ₦15,641,000.00 ₦1,777,116.64 ₦0.00 ₦868,295.06 ₦105,528.32 ₦803,293.26 ₦50,205.82 5.14
2026-03 36 ₦39,720,000.00 ₦4,669,736.71 ₦0.00 ₦2,317,201.85 ₦237,438.72 ₦2,115,096.14 ₦58,752.67 5.33
2026-04 69 ₦67,178,000.00 ₦7,632,283.56 ₦577,302.24 ₦3,789,560.61 ₦455,090.88 ₦2,810,329.83 ₦40,729.41 4.18
2026-05 65 ₦50,886,000.00 ₦4,499,159.19 ₦194,604.89 ₦2,137,840.89 ₦428,708.80 ₦1,738,004.61 ₦26,738.53 3.42
2026-06 97 ₦70,590,000.00 ₦5,998,322.87 ₦0.00 ₦2,894,898.44 ₦639,765.44 ₦2,463,658.99 ₦25,398.54 3.49
all 288 ₦249,724,000.00 ₦25,347,120.96 ₦1,057,851.81 ₦12,418,150.05 ₦1,899,509.76 ₦9,971,609.34 ₦34,623.64 3.99
fixed cost ₦2,500,000.00 a month / contribution ₦34,623.64 a loan = 72.2 loans a month to break even
the plan book made 74.8 loans a month over the six lending months
six months of fixed cost ₦15,000,000.00 against matured contribution ₦9,971,609.34Check the last row by hand. Income ₦25,347,120.96, less ₦1,057,851.81 lost, ₦12,418,150.05 of funding and ₦1,899,509.76 of serving and acquisition (288 × ₦6,000 is ₦1,728,000.00, the rest is acquisition), leaves ₦9,971,609.34, and ÷ 288 is ₦34,623.64. Then ₦2,500,000.00 ÷ ₦34,623.64 is 72.2 loans a month.
9. Run the acceptance checks.
cat > accept.py <<'EOF'
"""The acceptance checks. Each prints PASS or FAIL with the figure it rests on."""
import collections, sys
from lib import d, load, naira, rows, snapshot
from replay import engine_misses, policy_exceptions
from exceptions import exception_map
from funding import breaches, facility, ladder, launched, plan_book, stress
from unit import PRODUCTS, pnl, total
import plan
results = {} # check number -> passed; check 2 has two parts and counts once
def check(n, text, ok, figure):
key = int(str(n).rstrip("ab"))
results[key] = results.get(key, True) and ok
print(f"{n:>2} {'PASS' if ok else 'FAIL'} {text}: {figure}")
loans, sched, reps = load()
apps = rows("applications")
signals = {r["application_id"]: r for r in rows("applicant_signals")}
snap = snapshot(loans, sched, reps, d(plan.CUT_OFF))
bad = sum(1 for k, (dpd, o, st) in snap.items()
if (dpd, o) != (int(loans[k]["days_past_due"]), int(loans[k]["outstanding_principal_kobo"])))
check(1, "snapshot reproduces loans.csv at the cut-off", bad == 0, f"{len(snap):,} loans, {bad} differ")
bureau = {r["id"]: r for r in rows("bureau_reports")}
miss = engine_misses(apps, bureau)
check("2a", "the engine replay reproduces the book (the weakest test, as the credit-policy chapter explains)", not miss,
f"{len(apps):,} applications, {len(miss)} differ")
exc, would = policy_exceptions(apps, bureau)
in_book = {l["application_id"] for l in loans.values()}
causes = collections.Counter(e[4] for e in exc)
check("2b", "the 90-day policy's exceptions are counted and listed with a cause",
all(e[0] in in_book and e[4] for e in exc) and sum(causes.values()) == len(exc),
f"{len(exc)} of {len(loans):,} approved loans; " + ", ".join(f"{k} {v}" for k, v in sorted(causes.items())))
ri = sum(int(r["interest_kobo"]) for r in rows("repayments"))
rl = sum(int(r["late_fee_kobo"]) for r in rows("repayments"))
allp = pnl(loans, sched, reps, apps)
li = sum(int(l["paid_interest_kobo"]) for l in loans.values())
ll = sum(int(l["paid_late_fees_kobo"]) for l in loans.values())
fees = sum(int(l["fee_kobo"]) for l in loans.values())
check(3, "income in the P&L equals income in repayments.csv and loans.csv",
(ri, rl) == (li, ll) and sum(r["income"] for r in allp.values()) == fees + ri + rl,
f"fees {naira(fees)} + interest {naira(ri)} + late fees {naira(rl)}")
mat = {k: v for k, v in allp.items() if v["matured"]}
per_p = {p: total(r for r in mat.values() if r["product"] == p) for p in PRODUCTS}
by_m = collections.defaultdict(list)
for r in mat.values():
by_m[(r["product"], r["month"])].append(r)
cohort_net = sum(total(v)["net"] for v in by_m.values())
check(4, "cohort rows add to the product rows", cohort_net == sum(t["net"] for t in per_p.values()), naira(cohort_net))
launch = [p for p in PRODUCTS if per_p[p]["n"] and per_p[p]["net"] // per_p[p]["n"] > plan.GATE_MIN_CONTRIBUTION_PER_LOAN]
net_per = ", ".join(f"{p} {naira(per_p[p]['net'] // per_p[p]['n'])}" for p in PRODUCTS if per_p[p]["n"])
check(5, "the launched set follows from the gate rule as written and computed", launch == launched(),
f"launch {launch or 'nothing'}; per loan, matured: {net_per}")
ex = exception_map(loans, apps, signals)
keep, _, _ = plan_book()
gated = {k for k, l in loans.items() if l["product"] in launch}
excluded = gated & set(ex)
check(6, "the plan book is the launched products' loans less the stated exclusions",
set(keep) == gated - excluded and all(ex[k] for k in excluded), f"{len(gated)} - {len(excluded)} = {len(keep)}")
L = ladder(keep, sched, reps)
ok7 = all(r["bb"] <= plan.FACILITY_LIMIT and r["equity"] <= plan.EQUITY and r["gross"] - r["equity"] == r["bb"] for r in L)
peak = max(L, key=lambda r: r["equity"])
check(7, "the draw never exceeds the base or the limit; equity covers the need", ok7,
f"peak equity need {naira(peak['equity'])} of {naira(plan.EQUITY)} at {peak['month']}")
early = [r for r in L if r["month"] <= "2026-09-30"]
check(8, "no covenant breach at any month-end to 30 September", all(not breaches(r) for r in early),
f"worst PAR30 {max(r['par30'] / max(r['gross'], 1) for r in early):.2%}")
first = next((s for s in range(0, 10_001, 50) if breaches(stress(peak, s)[0])), None)
n, defi = stress(peak, first or 0)
check(9, "stress: PAR30 trips before equity runs out", first is not None and plan.EQUITY >= n["equity"],
f"breach at a {first / 100:.1f}% slip; repay {naira(defi)}; headroom left {naira(plan.EQUITY - n['equity'])}" if first is not None else "no breach found")
cap = plan.ROUTE_MIN_CAPITAL[plan.ROUTE]
check(10, f"equity covers the placeholder minimum capital of route {plan.ROUTE} (not a regulator's figure)", plan.EQUITY >= cap,
f"{naira(plan.EQUITY)} against {naira(cap)}")
print(f"\n{sum(results.values())} of {len(results)} checks pass")
sys.exit(0 if all(results.values()) else 1)
EOF
python3 accept.py 1 PASS snapshot reproduces loans.csv at the cut-off: 3,645 loans, 0 differ
2a PASS the engine replay reproduces the book (the weakest test, as the credit-policy chapter explains): 8,386 applications, 0 differ
2b PASS the 90-day policy's exceptions are counted and listed with a cause: 460 of 3,645 approved loans; amount_above_90_day_cap 203, amount_below_product_minimum 138, insufficient_income_evidence 119
3 PASS income in the P&L equals income in repayments.csv and loans.csv: fees ₦8,005,450.00 + interest ₦57,296,968.87 + late fees ₦442,500.00
4 PASS cohort rows add to the product rows: -₦2,768,396.00
5 PASS the launched set follows from the gate rule as written and computed: launch ['SME']; per loan, matured: SAL -₦4,499.52, PL -₦4,730.22, BNPL -₦6,819.55, SME ₦39,001.52
6 PASS the plan book is the launched products' loans less the stated exclusions: 469 - 20 = 449
7 PASS the draw never exceeds the base or the limit; equity covers the need: peak equity need ₦77,287,366.19 of ₦150,000,000.00 at 2026-06-30
8 PASS no covenant breach at any month-end to 30 September: worst PAR30 6.02%
9 PASS stress: PAR30 trips before equity runs out: breach at a 8.5% slip; repay ₦19,708,278.37; headroom left ₦53,004,355.44
10 PASS equity covers the placeholder minimum capital of route R1 (not a regulator's figure): ₦150,000,000.00 against ₦100,000,000.00
10 of 10 checks passThe figure on check 4 is the net of all four products’ matured loans, which is negative because three products lose. Checks 5 and 6 print the figures they rest on but test the process: change an input so the gate launches a different set, and they still pass if the plan follows the gate and the plan book is that set less the stated exclusions. Check 2 counts once, with its two parts. The command exits with 0 when every check passes and 1 otherwise.
Change one input at a time and run python3 accept.py again. Set ROUTE = "R2" in plan.py: check 10 fails, because ₦150,000,000.00 of equity is short of the ₦500,000,000.00 placeholder (an invented figure, not a regulator’s), and the other nine still pass. The plan is only as good as its weakest assumption, and the failure names it. Set ROUTE back. Then change ADVANCE_BPS to 8,500: the funder lends more, the equity share falls to 15%, below the covenant’s 25%, and check 8 fails in every month from the first to September. Check 9 then passes in a misleading way, with a breach at a 0.0% slip, because the equity covenant is already broken before anything slips, and the blend of 23.2% changes the gate’s figures a little. A bigger advance rate looks like cheaper money and is a covenant breach. Set it back to 7,500 before you finish.
Template
# Launch go/no-go: <business line>, gate of <date>
Prepared by <name, role>. Figures checked by <name, role>. Decision by <board or named approver>.
## 1. Conditions
| # | Condition (a yes/no test) | Evidence (check, file or figure) | Owner | Status: met, open or failed | If open: due |
## 2. Open risks
| # | Risk | Likelihood (low, medium or high, and why) | Impact (₦ or consequence) | Mitigant | Owner | What would show it |
## 3. How this gate could be wrong
<one way, and what would show it>
## 4. Decision
<Go, No-go, or Go on conditions <#>>. Rests on: <conditions>. Out of scope: <what this gate does not test>. Review: <date>.
Prepared <name, date>. Approved <name, date>. WORKED EXAMPLE
Nkoyo, who would run the lending line, writes this page. Ukeme checks the figures, and the board signs the decision. It is the gate of Monday 30 November 2026, from the plan’s figures at the 28 October cut-off.
Conditions.
| # | Condition | Evidence | Owner | Status |
|---|---|---|---|---|
| 1 | Only gate-passing products launch | Check 5: SME ₦39,001.52 a matured loan; SAL −₦4,499.52, PL −₦4,730.22, BNPL −₦6,819.55 | Nkoyo | met: SME only |
| 2 | The policy replays; exceptions are listed | Checks 2a, 2b: 8,386 decisions, 0 differ; 460 of 3,645 approved loans listed with a cause | Nkoyo | met |
| 3 | The loan system rebuilds balances and days past due | Check 1: 3,645 loans, 0 differ | engineering lead | met |
| 4 | Equity covers the peak; no covenant breach to 30 September | Checks 7, 8: need ₦77,287,366.19 of ₦150,000,000.00; worst PAR30 6.02% | Ukeme | met |
| 5 | The cash call at the first covenant trip can be met | Check 9: 8.5% slip, repay ₦19,708,278.37, headroom ₦53,004,355.44 | Ukeme | met |
| 6 | Equity covers the licence route’s minimum capital | Check 10 uses a placeholder, ₦100,000,000.00 | counsel | open: real figure |
| 7 | Registration is in place before the first disbursement | None in the lab | counsel | open |
Risks.
| # | Risk | Likelihood | Impact | Mitigant | Owner |
|---|---|---|---|---|---|
| R1 | Lending stops and the covenants breach | High: it happens in the lab | PAR30 13.29%, NPL90 4.64% at 28 October | Agree the run-off terms with the funder first | Ukeme |
| R2 | Volume falls short | Medium: 74.8 loans a month against 72.2 needed | Fixed cost ₦15,000,000.00 against ₦9,971,609.34 contributed | Claim no profit; review monthly | Nkoyo |
Could be wrong. SME’s result rests on 304 matured loans, five of them lost. One more loss in the next cohort would show it.
Decision. No-go for the first disbursement until conditions 6 and 7 are met, with counsel’s written evidence. Out of scope: the other three products. Review when counsel reports.
Now you
A month later, Owoleaf’s funder offers an 85% advance rate, and counsel says the board should plan on route R2, whose placeholder minimum capital is ₦500,000,000.00 (an invented figure, not a regulator’s). Nkoyo asks you to rewrite the gate. To check, copy the lab folder, open plan.py in any text editor, change ADVANCE_BPS = 7_500 to 8_500 or ROUTE = "R1" to "R2", save, and run python3 accept.py. These are the results. At 85% alone, 9 of 10 pass: check 8 fails, check 9 shows a breach at a 0.0% slip, the peak equity need is ₦46,372,419.72, and SME makes ₦40,579.15 a matured loan. On R2 alone, 9 of 10 pass: check 10 fails, ₦150,000,000.00 against ₦500,000,000.00. With both, 8 of 10 pass; checks 8 and 10 fail. List which conditions now fail, which depend on a placeholder and which are open for lack of evidence. Write at least two risks, with likelihood, impact and mitigant, and keep the run-off breach in the register. The board reads your page, and it supports one decision: go, no-go, or go on named conditions for the first disbursement.
Self-check
All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.