SENIORCHAPTER 53

Clearing and settlement at the switch: files, netting and settlement risk

A settlement file that nets to zero is arithmetic, not safety. Build one, roll sponsored participants into their sponsor, then make one bank unable to pay and see who is out of pocket

55 MINPAYMENTSUPDATED 2026-11-18
PREDICT

A settlement bank cannot pay its net debit of ₦69,572,405 at the 14:00 session. Its collateral is ₦40,000,000. Hours earlier, other banks credited their customers for transfers from its customers, relying on the switch's 'successful'. What decides who bears the missing ₦29,572,405?

Earlier chapters taught what clearing and settlement are (how money moves), how a company settles with its partner bank (settlement and payouts), and why a system might settle gross or net (a history of payments). This chapter stands at the other end: the switch (here, the operator of a national instant-payment service such as NIBSS Instant Payment, NIP; see Nigeria’s rails) that has the week’s 17,798 successful transfers filed into settlement sessions and has to turn them into one instruction per settlement bank. The banks’ own sides are separate chapters: the sending bank, the receiving bank and debited but not credited. How banks settle with each other tells the same week from a bank’s treasury, so the two chapters share the sessions, B13’s collateral and the three controls (prefunding, limit with collateral, loss sharing). One difference of basis: that chapter counts cash by participant (34.3% for the week, 84.3% for Friday’s session), this one by settlement bank (33.4% and 84.1%), because a sponsor funds its sponsored participants.

Clearing, then settlement, and where the switch sits

Two words carry the chapter. Clearing is collecting the instructions, checking them and working out what each party owes or is owed. Settlement is the movement of money that discharges those amounts, in an asset both sides accept, normally a balance at the central bank.

On an instant-payment network the customer’s side is over in seconds. The receiving bank has credited the customer, and the switch has said “successful”. The banks have not yet settled. The switch does the clearing: it files each successful transfer under the settlement session whose cut-off follows it, and at the cut-off it adds up what each participant sent and received. It then sends each settlement bank a file stating that bank’s net position. The money moves later, between the banks’ own accounts. The Central Bank of Nigeria (CBN) page on large-value payments, as search results summarise it (the page is undated and carries launch-era wording), describes NIBSS as an approved external system that passes banks’ net settlement positions from clearing into the CBN’s RTGS (real-time gross settlement) system for settlement at a designated time, and says the CBN would provide a collateralised intraday credit facility when a participant cannot fund its net position (the search showed that sentence cut off, so the terms are not confirmed)as of 2026-11. That is the shape the lab copies: the switch computes and instructs, and the central bank moves the money.

The times are illustrative. The lab has four sessions on each business day, with cut-offs at 04:00, 10:00, 14:00 and 18:00 and settlement an hour later, and traffic after the last cut-off on Friday waits for Monday. Real settlement times are where sources part: the history chapter lists a NIBSS help article that, as summarised, gives two cut-overs a day, another NIBSS page that refers to 12 settlement sessions, and a 2025 case study that describes four a day. Do not design against the lab’s clock, and read a history of payments before you quote a real one.

Three terms from the lab’s tables:

  • A participant is anything that sends and receives through the switch: banks, payment service banks, microfinance banks, mobile money operators and Owoleaf.
  • A settlement bank is a participant whose own account is settled. In the lab that is every direct participant, and each sponsored participant settles through its sponsor. The column settles_via in settlement_positions holds the settlement bank.
  • A position is one participant’s sent, received and net amount in one session. Net is received minus sent: a negative net is a debit, which the participant must pay.

The settlement file

A settlement file is a message from the switch to a settlement bank that says: for this session, these are the figures, and this is your net. It is not the money. It is the instruction from which the money is moved, so an error in it becomes an error in someone’s account. A good one has five parts.

  1. A header naming the session, the cut-off and the addressee, so a file cannot be applied to the wrong window or the wrong bank.
  2. One line per participant the bank settles for: sent, received and net. The settlement bank needs the lines, not only the total, because it must be able to charge each sponsored participant its own share. In the lab P01’s lines arrive inside B05’s file.
  3. A trailer with the line count and the totals, so a truncated file is detected.
  4. A digest, a hash of the header and lines. If the switch must resend the file after a failure, the same inputs give the same bytes and the same digest, and the bank can see that it is the same file and not a new one. A hash is an integrity check, not a signature: say who signs the file and how, separately.
  5. Money as integers. The lab writes kobo, never a float. A file is summed by machines at both ends and any rounding rule that differs between them shows up as a difference nobody can explain.

The layout in the lab is its own, with pipe-separated lines. The real file formats of NIBSS and the CBN were not found in any search result, and this chapter does not claim the lab’s resembles them.

Two decisions belong to the file’s builder and are easy to get wrong. First, which session a transfer belongs to. The lab assigns it by the time of the transfer’s final status, not the time of its first answer. A transfer that timed out, was requeried and then found to have succeeded is credited late and settles in the session after the one its first answer would suggest. Second, which transfers are in at all: only those whose final status is 00. A transfer that finally failed has no settlement line, because no money was credited that must be repaid.

Before the file leaves, three checks run, and you should know what each can and cannot catch.

Check Catches Does not catch
The nets of all files add to zero a line or a sign wrong on only one side a transfer missing from both sides, or wrong by the same amount on both
Every line equals a fresh recomputation from the transfers a bug in the builder’s arithmetic a transfer that should be in and is not in the ledger either
The digest matches the trailer a file damaged after it was built a file built wrongly and then hashed

The zero-sum check is the one people trust most and it is the weakest. A settlement is a closed system: every kobo one participant sends, another receives, so any error that treats both sides alike leaves the sum at zero. You will build one such error in the break step.

Multilateral netting, rolled up by settlement bank

The history chapter separated bilateral netting, each pair of banks against each other, from multilateral netting, each participant against the whole group. At a switch the second is natural: the switch is the one party that sees everyone’s flows, so each participant ends the session with one figure, and the cash to be found is the total of the debits, not the total of the payments.

The lab does it in two stages. First the participants’ positions, from the transfers. Then the roll-up by settles_via, so a sponsor’s figure includes the participants it settles for. The roll-up can only help the cash need, because a sponsored participant that is a net creditor offsets its sponsor’s debit. It also moves risk onto the sponsor, because the sponsor now owes the whole figure and must fund it. Over the week the cash needed by participant is ₦118,003,802 and by settlement bank ₦114,803,928: 2.7% less, from the roll-up alone (11,800,380,237 and 11,480,392,800 kobo in step 3).

What netting does for the whole week is clear in the lab’s own table, and so is what it does not do. Of ₦343,902,244 gross, the settlement banks need cash for ₦114,803,928, which is 33.4%. That is a poor summary. Take out the Friday 14:00 session and the other twenty sessions need ₦45,207,938 against ₦261,195,049 gross: 17.3%. The Friday session itself needs 84.1%, because one bank is paying suppliers in one direction and almost nothing comes back. Netting saves liquidity where payments run both ways. A single large one-way payer gets nothing from it, and also becomes the credit risk.

A second effect is the one to remember. 17,798 transfers become 542 settlement instructions, 3.0%. The settlement system sees 26 banks, not 17,798 payments. That is also why a mistake in the file is expensive: each line stands for hundreds of customers.

What a balanced file does not prove

A file that nets to zero has told you its arithmetic works. It has not told you that every transfer is in it exactly once, or that it agrees with what the banks did. The lab plants three kinds of disagreement, and a settlement team finds them by comparing the file with each bank’s own log.

  • A credit with no settlement. A receiving bank credited its customer, but the transfer timed out, no status query was recorded, and the switch’s final status stayed 97. The transfer is in no file, so the receiver is never paid for a credit it has given.
  • A reversal after a late success. The sender timed out, reversed its customer, and the transfer was then found to have succeeded. The file settles it, so the sender pays for a transfer whose customer it has already refunded. The debited-but-not-credited chapter in this module is the customer’s side of this; the settlement file is where the sender finds out.
  • A transfer left out by a rule. A builder that uses the first answer rather than the final status omits every late success, from both sides, and the sum is still zero.

None of these breaks the zero-sum check. Each is found only by reconciliation, the practice the reconciliation lesson describes, here between the switch’s file and a bank’s log.

Settlement risk: the credit inside the file

The gap between “the customer was credited” and “the banks have settled” is not free. Two risks live in it, and they need separate names.

Credit risk is the risk that a participant that owes money at settlement does not pay it, so that the participants owed are left short. Liquidity risk is the risk that a participant has the means but not the cash at the moment it is due, which still leaves others short for a while. A file can carry both at once: a bank with ample assets and no cash on the day is a liquidity problem, and a bank that has failed is a credit problem. The switch’s work looks the same in each, because the figure in the file is the figure.

How long the gap lasts is a measurable thing. In the lab, 17,798 settled transfers wait a median of 3.9 hours from their final status to the settlement time, 43.8 hours at the 95th percentile and 59.0 at the longest (step 4). The long ones are the weekend: nothing settles on a Saturday or Sunday in the lab, so a transfer made on Friday evening waits until Monday morning, and the receiving bank’s customer already has the money. The Principles for financial market infrastructures (PFMI, April 2012), from the Committee on Payments and Market Infrastructures (CPMI, formerly CPSS) and the International Organization of Securities Commissions (IOSCO), include, as the report’s headline statements read (search results confirmed the wording of 7 and 8 and the titles of 13 and 19; check the others against the report) Principle 4 (an FMI should effectively measure, monitor and manage its credit exposures to participants and those arising from its payment, clearing and settlement processes), Principle 7 (it should manage liquidity risk, with stress tests that cover the default of the participant and its affiliates that would generate the largest aggregate liquidity obligation), Principle 8 (final settlement at a minimum by the end of the value date, and intraday or in real time where necessary or preferable), Principle 9 (money settlements in central bank money where practical and available) Principle 13 (effective and clearly defined rules and procedures to manage a participant default) and Principle 19 (tiered participation, the risks that indirect participants, the clients of direct ones, can pose to the system)as of 2026-11. An FMI is a financial market infrastructure, the PFMI’s term for a system such as a payment system or a clearing house. The numbering follows the report as search results gave it; national rulebooks that adopt the principles sometimes renumber them, so cite the report’s number with the report’s name.

Principle 7’s stress test is the one to take into the lab. It tells an operator to ask the same question as Chiemeka did, about the participant whose failure would cost the most, and not about a typical one.

When a participant cannot pay

The order in which losses are met is called a waterfall, and the sensible first rung is the defaulter’s own resources. In the lab that is collateral_kobo in participants: an amount lodged in advance that the operator may use if the participant fails to pay. Step 4 puts every session’s net debit against it.

What Nigerian rules say about collateral and responsibility rests, in this chapter, on search summaries. The CBN’s Exposure Draft for Nigerian Clearing System Rules, 2016 (Revised), is a draft that came before the final 2018 rules below, and a draft is not the ruleas of 2026-11. The CBN’s Nigerian Bankers’ Clearing System Rules (Revised), dated May 2018, state in search results that they take effect on 1 September 2018; an excerpt of section 6.1.5 makes a settlement bank financially accountable for settling its own payment instruments and those of the non-settlement banks it settles for, and section 6.1.6 requires a settlement bank to keep with the CBN the minimum collateral the CBN prescribesas of 2026-11. A CBN exposure circular for indirect participants, dated 2018 and described in search results as a draft for comment, is summarised as requiring an indirect participant to pledge collateral, in an amount agreed with its settlement bank, as security for its settlement obligations. The same results show the CBN’s 2019 Circular and Regulation for the Operation of Indirect Participants in the Payment System as the later document, which this chapter did not readas of 2026-11. A regulatory-alert mirror of CBN circular BPS/DIR/CIR/GEN/02/039, dated 10 November 2017, is summarised in search results as announcing that the settlement-bank arrangement would extend to all clearing sessions from 1 January 2018, with net obligations from NIP and other instruments settled through settlement banks’ accounts onlyas of 2026-11. A mirror of the follow-up circular BPS/DIR/CIR/GEN/02/041, December 2017, is summarised as suspending that extension until further notice, and the two circulars give different start dates (1 and 2 January)as of 2026-11. So the 2017 circular is evidence of the direction, not of a rule in force; the 2018 rules above are the later text. This chapter read neither circular on the CBN’s own site, and press reports of them were used only to find them.

Press reports give figures for these collateral minimums. This chapter does not quote them: a figure that comes from a press report of a rule is not the rule, and the amounts may have been reviewed since. If you build collateral logic, read the current text and the figure in it.

Two things this chapter could not find. First, a published guarantee fund or loss-sharing rule specific to NIP: the results showed collateral, a collateralised intraday facility whose terms were not confirmed, and suspension, but not what happens when the collateral is not enough. Second, any statement that the CBN has designated NIBSS or NIP as a systemically important payment system or a financial market infrastructure. The CBN’s Payments System Vision 2025 document (launched 24 November 2022, per the CBN’s page) has a table-of-contents entry, section 6.1, on conformance with the Principles for Financial Market Infrastructure; the results do not show the section’s text or which systems it coversas of 2026-11. Where you work for a switch or a bank, ask the regulator and your sponsor for the written rules, because a guess about who bears the loss is the one guess that is expensive.

The lab does not pretend to know them either. It builds the question and tries three simple rules on one session. Step 4 first finds the worst case in the week: B13 in the Friday 14:00 session, net debit ₦69,572,405 against ₦40,000,000. The shortfall is 69,572,405 less 40,000,000: ₦29,572,405, which is 2,957,240,500 kobo. The week’s data shows B13 sending ₦150,000,000 to the CBN as settlement funding at 12:19 that day, so in the lab’s week it did pay, and how banks settle with each other reads the same close as 36.6% of collateral plus top-up, not a breach. What follows is a what-if: B13 fails and the top-up is left out of the cover, to see what the rules would have had to absorb if collateral alone stood behind the position. The ratio of 173.9% is a measure of the collateral alone.

Note a modelling choice in rails.py too. Before the top-up, the switch declined a B13 supplier payment with response 51 when its net debit in the open settlement session, counting that payment, would pass its collateral, a rule that is the lab’s own: four payments worth ₦6,820,004, recorded from 12:16:16 to 12:18:13, all before the 12:19:00 top-up. Small payments in the same minutes still went through, because they did not push the net debit past ₦40,000,000. The first large payment accepted after the top-up is at 12:19:04. After the top-up the cap is gone. The generator treats a top-up as lifting the limit. Whether a top-up of cash should raise the limit, or only more collateral should, is a design decision with exactly the consequence that Friday shows.

Three rules for the uncovered ₦29,572,405, each worked in step 4:

Rule What happens Who bears the ₦29,572,405 What it costs
A. Unwind Take the failed bank’s transfers out of the session and net the rest again Every bank that was due money from it receives less, and some banks now pay more 21 of 25 other banks get a new figure, all 21 get less or pay more by ₦69,572,405 in all, and 10 flip from receiving to paying, which they must fund
B. Survivors share Pay the creditors in full only up to what came in; cut each net creditor in proportion to its credit The 24 net creditors, in proportion to what they were owed Nobody is surprised with a payment, but each creditor loses money it was told it had
C. The operator pays The switch covers the shortfall from its own resources The switch’s owners The whole week’s switch fees in the lab are ₦156,975, 0.53% of the gap

None of these is NIBSS’s rule. They are the three simplest answers, and each is a real design in some system. The unwind gives certainty to nobody until it is finished, and it asks the survivors for cash they did not expect to need, which is a liquidity risk, Principle 7 again. Loss-sharing spreads the cost but makes every participant a guarantor of every other, which is a reason participants may want a say in who is admitted. An operator that pays needs a fund that is large relative to the largest participant, and the week’s fees do not come close. The numbers show what each choice costs, and that it must be made before the day.

Where this goes wrong

  • Trusting the zero. A file that nets to zero can still miss a transfer from both sides. Reconcile against each bank’s log, not only against itself.
  • Choosing the session by the first answer. A late success belongs to the session of its final status. Using the first answer leaves 38 transfers out of the files in the lab.
  • Forgetting the sponsor carries the sponsored. A sponsor’s figure includes its participants. The collateral against it is the sponsor’s, since in the lab sponsored participants lodge none.
  • Assuming the central bank covers a shortfall. No source found says so. The rules are the collateral, the loans against it, and what the scheme has written.
LAB Write a switch's settlement files, net them by settlement bank, and make one bank fail ~50 MIN
YOU NEEDPython 3.9 or later (standard library only)labs/finance with the rails week generatedNo Docker, no packages, no mock services, no sqlite3 command-line tool

You work in labs/finance and create five small files there. Every script only reads data/rails.sqlite and uses Python’s own sqlite3 module. Money is integer kobo; the naira helper only formats. Every code, cut-off, collateral figure and fee in this week is invented by the generator, and the three loss rules in step 4 are this chapter’s, not NIBSS’s or the CBN’s. Step 4 is a what-if: it pretends the biggest debtor fails.

1. Generate the week and check it. About a second.

cd labs/finance
python3 rails.py
python3 check.py --rails-only

rails.py prints:

32 participants, 22,835 accounts, 17,998 transfers, 12,158 name enquiries, 136 status queries
21 settlement sessions, 125 batch files, 193 RTGS payments, 3,412 USSD sessions, 3,453 PSB postings
planted (answers/rails_truth.csv): credited_without_settlement 4, customer_fee_not_charged 6, customer_reversed_twice 3, levy_not_charged 5, mmo_trust_shortfall 1, participant_limit 4, participant_outage 1, psb_cash_out_fee_not_posted 1, psb_cash_out_posted_twice 1, reversed_after_late_success 4, same_number_two_banks 8, switch_incident 1, telco_record_missing 12

and check.py ends with:

rails week: 17,998 transfers, 21 settlement sessions, 22,835 accounts; checks 21-25 run
OK: all invariants hold

Seed 42 gives the same week every time. Invariant 22 is the one this chapter lives on: every session’s positions sum to zero.

2. Write the settlement files for one session. Save this as settlement_file.py. It recomputes the positions from transfers (not from the position table), writes one file per settlement bank to out/<session>/, and then compares its figures with settlement_positions.

"""Build the settlement files a switch would send, one per settlement bank, for one session.
Money is integer kobo. The file layout is this lab's own, not NIBSS's or the CBN's."""
import hashlib, os, sqlite3, sys

session = sys.argv[1] if len(sys.argv) > 1 else "20260616-3"
db = sqlite3.connect("data/rails.sqlite")
via = {code: (sponsor or code) for code, sponsor in db.execute("SELECT code, sponsor FROM participants")}
cutoff, = db.execute("SELECT cutoff_at FROM settlement_sessions WHERE id = ?", (session,)).fetchone()

# 1. Clearing: add up what each participant sent and received in this session.
pos = {}
for src, dest, amount in db.execute(
        "SELECT src, dest, amount_kobo FROM transfers WHERE settlement_session = ?", (session,)):
    pos.setdefault(src, [0, 0])[0] += amount
    pos.setdefault(dest, [0, 0])[1] += amount

# 2. Group by settlement bank and write one file each.
by_bank = {}
for p in sorted(pos):
    by_bank.setdefault(via[p], []).append(p)
os.makedirs(f"out/{session}", exist_ok=True)
control, total_lines = [], 0
for bank in sorted(by_bank):
    lines = [f"LINE|{p}|{pos[p][0]}|{pos[p][1]}|{pos[p][1] - pos[p][0]}" for p in by_bank[bank]]
    sent = sum(pos[p][0] for p in by_bank[bank])
    got = sum(pos[p][1] for p in by_bank[bank])
    body = [f"HDR|{session}|{cutoff}|{bank}"] + lines
    digest = hashlib.sha256("\n".join(body).encode()).hexdigest()[:12]
    body.append(f"TRL|lines={len(lines)}|sent={sent}|received={got}|net={got - sent}|sha256={digest}")
    with open(f"out/{session}/{bank}.txt", "w") as f:
        f.write("\n".join(body) + "\n")
    control.append((bank, got - sent))
    total_lines += len(lines)

print(f"session {session}, cut-off {cutoff}")
print(f"{len(pos)} participants on {len(by_bank)} settlement banks, {total_lines} lines in {len(by_bank)} files")
print(f"sum of the files' nets: {sum(n for _, n in control)} kobo")
print(f"pay: {sum(1 for _, n in control if n < 0)}, receive: {sum(1 for _, n in control if n > 0)}, nil: {sum(1 for _, n in control if n == 0)}")

# 3. Check the files against the position table the switch kept.
table = {(p, s, r) for p, s, r in db.execute(
    "SELECT participant, sent_kobo, received_kobo FROM settlement_positions WHERE session = ?", (session,))}
mine = {(p, pos[p][0], pos[p][1]) for p in pos}
print("matches settlement_positions:", table == mine)
python3 settlement_file.py
cat out/20260616-3/B05.txt
session 20260616-3, cut-off 2026-06-16T14:00:00+01:00
32 participants on 26 settlement banks, 32 lines in 26 files
sum of the files' nets: 0 kobo
pay: 12, receive: 14, nil: 0
matches settlement_positions: True
HDR|20260616-3|2026-06-16T14:00:00+01:00|B05
LINE|B05|109615000|74312300|-35302700
LINE|P01|16920800|17907000|986200
TRL|lines=2|sent=126535800|received=92219300|net=-34316500|sha256=d43daf74c16d

Thirty-two participants settle through twenty-six banks, so there are 26 files and 32 lines. The nets of the 26 files add to zero, and the recomputation equals the switch’s own position table. B05’s file holds two lines: B05 itself, net -35,302,700 kobo (a debit of ₦353,027), and P01, its sponsored participant, net +986,200 (₦9,862). The trailer’s net is the sum of the two lines, -34,316,500 kobo, a debit of ₦343,165: P01 offsets a small part of its sponsor’s debit. The digest is a hash of the header and lines, so yours matches if your lines are the same.

Now the Friday session, the 14:00 one on 19 June:

python3 settlement_file.py 20260619-3
cat out/20260619-3/B13.txt
session 20260619-3, cut-off 2026-06-19T14:00:00+01:00
32 participants on 26 settlement banks, 32 lines in 26 files
sum of the files' nets: 0 kobo
pay: 2, receive: 24, nil: 0
matches settlement_positions: True
HDR|20260619-3|2026-06-19T14:00:00+01:00|B13
LINE|B13|6983350100|26109600|-6957240500
TRL|lines=1|sent=6983350100|received=26109600|net=-6957240500|sha256=88cf0b648924

Still zero in total, with two banks to pay and twenty-four to receive. B13’s file has one line: it sent ₦69,833,501 and received ₦261,096 (6,983,350,100 and 26,109,600 kobo), a net debit of ₦69,572,405. Of the session’s ₦82,707,195 gross, B13 sent 84.4%.

3. Net every session, by participant and by settlement bank. Save this as netting.py.

"""Multilateral netting per session, by participant and by settlement bank. Integer kobo."""
import sqlite3

db = sqlite3.connect("data/rails.sqlite")
rows = db.execute("""SELECT session, participant, settles_via, SUM(sent_kobo), SUM(received_kobo)
                     FROM settlement_positions GROUP BY session, participant""").fetchall()
count = dict(db.execute("SELECT settlement_session, COUNT(*) FROM transfers WHERE settlement_session <> '' GROUP BY 1"))
sessions = {}
for s, p, v, sent, got in rows:
    d = sessions.setdefault(s, {"gross": 0, "part": {}, "bank": {}})
    d["gross"] += sent
    d["part"][p] = d["part"].get(p, 0) + got - sent
    d["bank"][v] = d["bank"].get(v, 0) + got - sent

def debits(nets):
    return sum(-n for n in nets.values() if n < 0)

print(f"{'session':<11} {'transfers':>9} {'gross':>14} {'cash, by participant':>21} {'cash, by bank':>14} {'share':>6} {'files':>5}")
tot = dict(n=0, gross=0, part=0, bank=0, ins=0)
for s in sorted(sessions):
    d = sessions[s]
    ins = sum(1 for n in d["bank"].values() if n != 0)
    print(f"{s:<11} {count[s]:>9,} {d['gross']:>14,} {debits(d['part']):>21,} {debits(d['bank']):>14,} {100 * debits(d['bank']) / d['gross']:>5.1f}% {ins:>5}")
    tot["n"] += count[s]; tot["gross"] += d["gross"]; tot["part"] += debits(d["part"])
    tot["bank"] += debits(d["bank"]); tot["ins"] += ins
print(f"{'week':<11} {tot['n']:>9,} {tot['gross']:>14,} {tot['part']:>21,} {tot['bank']:>14,} {100 * tot['bank'] / tot['gross']:>5.1f}% {tot['ins']:>5}")
print(f"{tot['ins']} settlement instructions replace {tot['n']:,} transfers ({100 * tot['ins'] / tot['n']:.1f}%)")
python3 netting.py
session     transfers          gross  cash, by participant  cash, by bank  share files
20260615-1         74    116,030,500            57,656,400     49,806,900  42.9%    22
20260615-2        881  1,332,353,700           240,387,300    220,178,200  16.5%    26
20260615-3        855  1,229,318,700           207,031,100    201,604,300  16.4%    26
20260615-4        681    967,379,700           223,987,900    214,569,700  22.2%    26
20260616-1        553    866,954,000           201,534,800    159,783,700  18.4%    26
20260616-2        855  1,181,090,600           306,399,300    273,255,100  23.1%    26
20260616-3        867  1,510,451,294           369,117,400    362,925,600  24.0%    26
20260616-4        688  1,000,984,300           199,458,600    191,586,600  19.1%    26
20260617-1        571    859,728,899           150,860,900    145,115,401  16.9%    26
20260617-2        861  1,170,650,000           177,124,200    170,952,000  14.6%    26
20260617-3        863  1,307,496,700           237,284,400    195,503,300  15.0%    26
20260617-4        665    974,175,000           189,305,600    181,908,400  18.7%    26
20260618-1        542  1,192,480,914           315,784,252    294,626,514  24.7%    26
20260618-2        832  1,257,211,800           211,541,700    194,852,100  15.5%    26
20260618-3        837  1,280,855,111           256,931,100    233,435,400  18.2%    26
20260618-4        711  1,107,036,700           286,724,000    271,452,800  24.5%    26
20260619-1        569    861,212,800           185,109,800    162,344,500  18.9%    26
20260619-2        878  1,319,553,600           191,754,600    191,754,600  14.5%    26
20260619-3        850  8,270,719,500         6,969,224,100  6,959,599,000  84.1%    26
20260619-4        699  1,025,355,136           169,142,202    162,948,802  15.9%    26
20260622-1      3,466  5,559,185,528           654,020,583    642,189,883  11.6%    26
week           17,798 34,390,224,482        11,800,380,237 11,480,392,800  33.4%   542
542 settlement instructions replace 17,798 transfers (3.0%)

The “cash” columns are the total of the debits: what the participants, or the settlement banks, must find. The share is cash by bank over gross. Redo two numbers by hand. Week: 11,480,392,800 over 34,390,224,482 is 33.4%. Without the Friday row: (11,480,392,800 - 6,959,599,000) over (34,390,224,482 - 8,270,719,500) is 4,520,793,800 over 26,119,504,982, or 17.3%. Rolling participants into their settlement banks takes the cash from 11,800,380,237 to 11,480,392,800 kobo, 2.7% less. The Monday session carries the weekend and shows the lowest share, 11.6%.

4. Make B13 fail and price the loss. Save this as stress.py. Part 1 ranks every session’s net debit against collateral. Part 2 takes the worst and tries three rules. Part 3 measures how long a credit waits for settlement.

"""Who bears it when a settlement bank cannot pay? A model, not NIBSS's or the CBN's rules. Integer kobo."""
import datetime as dt, sqlite3, statistics

db = sqlite3.connect("data/rails.sqlite")
naira = lambda k: f"₦{k // 100:,}"
part = {c: (s, col) for c, s, col in db.execute("SELECT code, sponsor, collateral_kobo FROM participants")}
via = {c: (s or c) for c, (s, _) in part.items()}

# 1. Every settlement bank's net debit in every session against the collateral behind it.
nets = {}
for s, p, n in db.execute("SELECT session, participant, net_kobo FROM settlement_positions"):
    nets[(s, via[p])] = nets.get((s, via[p]), 0) + n
rows = sorted(((-n / part[b][1], s, b, -n) for (s, b), n in nets.items() if n < 0), reverse=True)
print("1. largest net debits against collateral (illustrative collateral)")
print(f"   {'session':<11} {'bank':<5} {'net debit':>14} {'collateral':>14} {'debit/collateral':>17}")
for ratio, s, b, d in rows[:4]:
    print(f"   {s:<11} {b:<5} {naira(d):>14} {naira(part[b][1]):>14} {100 * ratio:>16.1f}%")

# 2. Stress: the worst one cannot fund its position. Who bears the uncovered part?
_, session, bank, debit = rows[0]
collateral = part[bank][1]
short = max(0, debit - collateral)
print(f"\n2. what-if: {bank} cannot pay {naira(debit)} in {session}")
print(f"   collateral absorbs {naira(min(debit, collateral))}; uncovered {naira(short)} ({short:,} kobo)")

topup = db.execute("SELECT at, amount_kobo FROM rtgs WHERE sender = ? AND purpose = 'settlement_funding' AND substr(at, 1, 10) = ? ORDER BY amount_kobo DESC LIMIT 1",
                   (bank, session[:4] + "-" + session[4:6] + "-" + session[6:8])).fetchall()
if topup:
    print(f"   the data shows {bank} sending {', '.join(f'{naira(a)} to the CBN as settlement funding at ' + t[11:16] for t, a in topup)} that day: it did pay, so this is a what-if")

# 2a. Rule A, unwind: take every transfer of the failed bank out and net again.
sent, got = {}, {}
for src, dest, amt in db.execute("SELECT src, dest, amount_kobo FROM transfers WHERE settlement_session = ?", (session,)):
    if bank in (via[src], via[dest]):
        continue
    sent[via[src]] = sent.get(via[src], 0) + amt
    got[via[dest]] = got.get(via[dest], 0) + amt
new = {b: got.get(b, 0) - sent.get(b, 0) for b in set(sent) | set(got)}
old = {b: n for (s, b), n in nets.items() if s == session and b != bank}
moved = {b: new.get(b, 0) - old[b] for b in old if new.get(b, 0) != old[b]}
worse = {b: d for b, d in moved.items() if d < 0}
flip = [b for b in old if old[b] > 0 and new.get(b, 0) < 0]
print(f"   A. unwind: {len(moved)} of {len(old)} other banks get a different figure; {len(worse)} get less or pay more, "
      f"by {naira(-sum(worse.values()))} in all; {len(flip)} flip from receiving to paying")
print(f"      new figures sum to {sum(new.values())} kobo (zero again)")

# 2b. Rule B, survivors share: the uncovered part is cut from net creditors in proportion to their credit.
credit = {b: n for b, n in old.items() if n > 0}
tc = sum(credit.values())
cut = {b: short * c // tc for b, c in credit.items()}
cut[max(credit, key=credit.get)] += short - sum(cut.values())
top = sorted(cut.items(), key=lambda x: -x[1])[:3]
print(f"   B. survivors share: {len(credit)} net creditors lose {naira(short)} in all; "
      f"largest: " + ", ".join(f"{b} {naira(c)}" for b, c in top) + f"; cuts sum to {sum(cut.values()):,} kobo")

# 2c. Rule C, the switch covers it from its own fees.
fees, = db.execute("SELECT SUM(switch_fee_kobo) FROM transfers").fetchone()
print(f"   C. the switch pays: the whole week's switch fees are {naira(fees)}, "
      + (f"{100 * fees / short:.2f}% of the uncovered part" if short else "and there is nothing uncovered to pay"))

# 3. How long does a credit sit unsettled?
settled = dict(db.execute("SELECT id, settled_at FROM settlement_sessions"))
hrs = sorted((dt.datetime.fromisoformat(settled[s]) - dt.datetime.fromisoformat(t)).total_seconds() / 3600
             for t, s in db.execute("SELECT final_at, settlement_session FROM transfers WHERE settlement_session <> ''"))
print(f"\n3. hours from final status to settlement, {len(hrs):,} transfers: "
      f"median {statistics.median(hrs):.1f}, 95th percentile {hrs[int(0.95 * len(hrs))]:.1f}, longest {hrs[-1]:.1f}")
python3 stress.py
1. largest net debits against collateral (illustrative collateral)
   session     bank       net debit     collateral  debit/collateral
   20260619-3  B13      ₦69,572,405    ₦40,000,000            173.9%
   20260618-1  B14       ₦1,388,146     ₦2,500,000             55.5%
   20260616-3  B23       ₦1,029,769     ₦2,500,000             41.2%
   20260622-1  B24         ₦876,831     ₦2,500,000             35.1%

2. what-if: B13 cannot pay ₦69,572,405 in 20260619-3
   collateral absorbs ₦40,000,000; uncovered ₦29,572,405 (2,957,240,500 kobo)
   the data shows B13 sending ₦150,000,000 to the CBN as settlement funding at 12:19 that day: it did pay, so this is a what-if
   A. unwind: 21 of 25 other banks get a different figure; 21 get less or pay more, by ₦69,572,405 in all; 10 flip from receiving to paying
      new figures sum to 0 kobo (zero again)
   B. survivors share: 24 net creditors lose ₦29,572,405 in all; largest: B01 ₦3,255,058, B02 ₦3,187,429, B19 ₦2,723,679; cuts sum to 2,957,240,500 kobo
   C. the switch pays: the whole week's switch fees are ₦156,975, 0.53% of the uncovered part

3. hours from final status to settlement, 17,798 transfers: median 3.9, 95th percentile 43.8, longest 59.0

Part 1 finds one bank over its collateral, and it is the Friday session. Every other net debit in the week is at most 55.5% of the collateral behind it. Part 2’s gap is 69,572,405 less 40,000,000, which is ₦29,572,405 (the what-if ignores the ₦150,000,000 top-up; the query picks the largest funding payment that day, as B13 also sent ₦24,970,000 at 11:10). Rule A’s “less or pay more” total, ₦69,572,405, equals what B13 owed. Some banks that sent B13 transfers do gain when those drop out, but each of them also received more from B13 than it sent, so in this week no bank ends better off; with other data the total could exceed the debit. Rule B’s cuts sum to exactly the gap. Rule C’s 0.53% is 156,975 over 29,572,405. Part 3’s long waits are weekend and Friday-evening transfers.

5. Reconcile the files against the banks’ own logs. Save this as reconcile.py. It compares the switch’s settlement with bank_log, which holds each bank’s own record.

"""Reconcile the settlement file against what the banks say they did. Integer kobo."""
import sqlite3

db = sqlite3.connect("data/rails.sqlite")
rows = db.execute("""SELECT l.institution, l.session_id, l.amount_kobo FROM bank_log l
                     JOIN transfers t ON t.session_id = l.session_id
                     WHERE l.direction = 'in' AND l.status = 'credited' AND t.settlement_session = ''""").fetchall()
print(f"credited by the receiver, in no settlement file: {len(rows)}")
for inst, sid, amt in rows:
    print(f"  {inst} {sid} {amt} kobo")
rows = db.execute("""SELECT l.institution, l.session_id, l.amount_kobo, t.settlement_session FROM bank_log l
                     JOIN transfers t ON t.session_id = l.session_id
                     WHERE l.direction = 'out' AND l.status = 'reversed' AND t.settlement_session <> ''
                       AND l.amount_kobo > 0""").fetchall()
print(f"reversed by the sender, but settled in a file: {len(rows)}")
for inst, sid, amt, s in rows:
    print(f"  {inst} {sid} {amt} kobo in {s}")
python3 reconcile.py
credited by the receiver, in no settlement file: 4
  B19 900824260616074648336718609909 633600 kobo
  B07 900824260618153249853770689905 1820000 kobo
  B07 900758260619121540683004570876 181400 kobo
  B23 900806260619190215950367601939 302400 kobo
reversed by the sender, but settled in a file: 4
  B11 900998260617152952529806270881 1629500 kobo in 20260617-4
  S02 900905260618061004744264397192 1382200 kobo in 20260618-2
  B22 900981260619113823153390654102 401300 kobo in 20260619-3
  B17 900996260619124219371078727283 951700 kobo in 20260619-3

Every file nets to zero and these eight transfers are still wrong: four receivers credited a customer and will never be settled for them, and four senders refunded a customer and will still pay for the transfer. They match the generator’s planted credited_without_settlement (4) and reversed_after_late_success (4) breaks, which you can confirm in answers/rails_truth.csv now that you have found them.

Build the file the easy way, from first answers, and watch the zero stay. Save this as break.py and run it:

"""The break: build the file from the switch's first answers instead of the final statuses."""
import sqlite3

db = sqlite3.connect("data/rails.sqlite")
via = {c: (s or c) for c, s in db.execute("SELECT code, sponsor FROM participants")}
mine = {}
for t, s, src, dest, amt in db.execute("""SELECT session_id, settlement_session, src, dest, amount_kobo FROM transfers
                                          WHERE first_response = '00' AND settlement_session <> ''"""):
    pos = mine.setdefault((s, src), [0, 0]); pos[0] += amt
    pos = mine.setdefault((s, dest), [0, 0]); pos[1] += amt
net = {}
for (s, p), (o, i) in mine.items():
    net[s] = net.get(s, 0) + i - o
print("sessions that do not net to zero:", sum(1 for v in net.values() if v != 0))
kept = {(s, p): (o, i) for s, p, o, i in db.execute("SELECT session, participant, sent_kobo, received_kobo FROM settlement_positions")}
diff = [k for k in kept if mine.get(k, [0, 0]) != list(kept[k])]
print(f"positions that differ from the switch's own: {len(diff)} of {len(kept)}")
missing = db.execute("""SELECT COUNT(*), COALESCE(SUM(amount_kobo), 0) FROM transfers
                        WHERE first_response <> '00' AND final_status = '00'""").fetchone()
print(f"transfers left out: {missing[0]}, worth {missing[1]} kobo")
ex = db.execute("""SELECT session_id, src, dest, amount_kobo FROM transfers WHERE first_response <> '00' AND final_status = '00' LIMIT 1""").fetchone()
print("one of them:", ex)
python3 break.py

Output:

sessions that do not net to zero: 0
positions that differ from the switch's own: 62 of 668
transfers left out: 38, worth 43969300 kobo
one of them: ('900769260615001715788806967323', 'B20', 'B03', 1644500)

Every session still nets to zero, because each omitted transfer is missing from its sender’s line and its receiver’s line alike. Sixty-two of 668 positions are nonetheless wrong: 38 late successes worth ₦439,693 are out of the files. Now change the question: which check would have caught this before the file left? The comparison at the end of step 2, run against a file built from final statuses, would print False; the zero-sum check cannot. Then change rows[0] to rows[1] in stress.py and run it again: the second-worst debit, B14 at 55.5%, is fully covered, the uncovered part is ₦0, and rules B and C have nothing to do. Rule A still prints a figure, because it assumes the collateral is not used. That is what collateral that covers the debit buys.

ARTEFACT Write a settlement default playbook ~50 MIN
YOU PRODUCESettlement default playbook

Template

# Settlement default playbook: <switch or scheme>
Written by <settlement manager> · Approved by <head of settlement> and <head of risk> · Version <n>, <date>
Decision needed: <what the approvers must decide, by when>

## 1. Scope and rules relied on
Covers: <sessions, participants, sponsored participants>. Not covered: <list>.
Written rule that decides who bears a loss: <name, version, date> or NONE FOUND.

## 2. How we know a participant cannot pay
Early warning: <net debit against collateral, checked when, by whom>
Non-payment signal: <what the scheme's rules define, and the time>
What we cannot see: <list>

## 3. Options and who may use them
| Option | Source of the rule | Confirmed or modelled | Who may invoke | Cost shown by the lab |
|---|---|---|---|---|
| Collateral | | | | |
| Intraday facility | | | | |
| Unwind the session | | | | |

## 4. Decision steps
| # | Step | Time | Owner | Deputy | Evidence kept |
|---|---|---|---|---|---|

## 5. What other participants are told
| Audience | Message | When | Sent by | Never say |
|---|---|---|---|---|

## 6. After-action review
Held within <n> days. Attendees: <list>. Questions: <list>. Output: <changes, owners, dates>.

## 7. Open questions
<what the rules do not say, and who we asked>
WORKED EXAMPLE

At a national payment switch, Bosede, the settlement manager, writes the playbook; the head of settlement and the head of risk approve it. Her draft uses the lab’s Friday what-if, which did not happen: B13 pays in the real week.

Decision needed: whether the head of risk accepts this order of steps before the next quarter’s review.

Section 2: at the 13:55 file check, B13’s net debit is ₦69,572,405 against ₦40,000,000 of collateral, 173.9%. Non-payment is confirmed only by the scheme’s written signal, which this draft marks not found. The playbook cannot see B13’s top-up: the lab shows ₦150,000,000 sent to the CBN at 12:19.

Section 3: collateral absorbs ₦40,000,000, leaving ₦29,572,405 (2,957,240,500 kobo). The CBN intraday facility is listed as unconfirmed, because the chapter’s source gives no terms. Unwind is modelled: 21 of 25 other banks get a new figure and 10 flip from receiving to paying. Survivors-share would cut 24 net creditors, B01 most at ₦3,255,058. The operator paying is marked unfunded: a week of fees is ₦156,975, 0.53% of the gap.

Section 4: Bosede confirms the figure and calls B13’s treasury (deputy: the on-call analyst). Chiemeka reruns the file from final statuses and shows the match. The head of risk decides the option, the head of settlement signs release.

Section 5: all 24 creditors hear the same message at the same time from the head of settlement, and it never states which loss rule applies until it is confirmed in writing.

Section 6: review within five working days, with a written list of changes.

Now you

A month later, the same switch admits a second sponsored participant to settle through B05, which already carries P01 and holds the collateral for both: P01 lodges none. You are the settlement manager and must write the playbook for this case. Use the file from step 2: in session 20260616-3 B05’s file shows B05 at -35,302,700 kobo, P01 at +986,200 and a trailer net of -34,316,500. Assume the new participant sends and receives about what P01 does, and that B05’s collateral is ₦20,000,000 (confirm it in participants.collateral_kobo); state the trailer debit as a share of it. Decide who calls whom if the sponsored participant is the one that cannot pay, and what the sponsor and the other banks are told. Mark every rule the chapter could not confirm. Your head of settlement and head of risk read it and decide whether the sponsored arrangement may go live.

Self-check

DECIDE

Bosede and Chiemeka have the Friday numbers: one bank's net debit reached 174% of its collateral (in the what-if that ignores its top-up), the uncovered part was 0.53% covered by a week of fees, and an unwind would change 21 of 25 other banks' figures. The head of the switch's risk committee asks them for one control to build first, in the lab's model, before any default rule is debated. Each option has a cost that the Friday data shows.

READING
  1. DOC
    Principles for financial market infrastructures (CPMI and IOSCO, April 2012) CPMI and IOSCO, 2012

    The international standard for payment, clearing and settlement systems. Read Principles 4 (credit risk), 7 (liquidity risk), 8 (settlement finality), 9 (money settlements) and 13 (participant default), and the explanatory notes with each. Skip the sections on securities depositories and central counterparties on a first pass. The numbering used here is the report's. Read: Principles 4, 7, 8, 9, 13 and 19.

  2. DOC
    Nigerian Bankers' Clearing System Rules (Revised) (CBN, 2018) Central Bank of Nigeria, 2018

    The CBN's own rules on settlement banks, their accountability for the banks they settle for, and collateral. Read sections 6.1.4 to 6.1.6 and everything on suspension. This chapter saw it through search summaries only, so check each rule and every figure against the text.

  3. DOC
    Large Value Payments (Inter-Bank Fund Transfer System) (CBN) Central Bank of Nigeria

    The CBN's description of how net positions from NIBSS reach RTGS and what happens when an account cannot cover its position. Read it with the history chapter, because the session times in other sources differ and this page is undated.

  4. DOC
    Exposure Circular for Indirect Participants (CBN, 2018) Central Bank of Nigeria, 2018

    The collateral an indirect participant pledges to its settlement bank. It is an exposure draft: check whether a final circular replaced it, and read its 2019 successor, Circular and Regulation for the Operation of Indirect Participants in the Payment System, listed on the same CBN site.

  5. DOC
    Circular and Regulation for the Operation of Indirect Participants in the Payment System (CBN, 2019) Central Bank of Nigeria, 2019

    The later CBN text on indirect participants and their settlement agreements with a direct participating bank. This chapter saw it by title only, so read it for the collateral and settlement terms before relying on the 2018 draft.

  6. DOC
    Payments System Vision 2025 (CBN) Central Bank of Nigeria, 2022

    The CBN's payments strategy. Read the section on conformance with the financial market infrastructure principles to see how the regulator frames oversight. Skip the market statistics, which date quickly.

All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.
NEXT: Running a switch: uptime, success rates per bank and connecting to other switches →