# Reproduce average-daily-balance interest with all helpers Extract the complete public reproduction kit, run `npm ci --ignore-scripts --no-audit --no-fund` at its root, then enter `topic/`. Use Python 3.11+ and Node 22+. It supplies `implementations/python/algorithm.py` and `implementations/python/interest_calendar.py`, plus `implementations/typescript/algorithm.ts` and `implementations/typescript/interest_calendar.ts`. Keep each language pair together: the main module imports its local helper. Complete `datasets/cases.json`, actual reference tests/runners and exact toolchain locks are included; no repository checkout or global compiler is required. ## Python Save as `demo.py`, run `python demo.py` from extracted `topic/`: ```python import json import sys from pathlib import Path sys.path.insert(0, "implementations/python") from algorithm import calculate_average_daily_balance_interest cases = json.loads(Path("datasets/cases.json").read_text(encoding="utf-8"))["cases"] request = next(c["request"] for c in cases if c["id"] == "A03-full35-changing-rate") result = calculate_average_daily_balance_interest(request) for s in result["segments"]: f = s["earned_exact"] print(s["period_start"], s["period_end"], s["rate_ppm"], f["numerator"] + "/" + f["denominator"]) a = result["accrual"] c = a["closing_carry"] print(a["rounded_amount_minor"], c["numerator"] + "/" + c["denominator"]) ``` ## TypeScript and Node The kit's root lock installs the exact compiler. A minimal standalone package declaration is: ```json {"type":"module","devDependencies":{"typescript":"7.0.2"}} ``` Save as `tsconfig.json`; compile from `topic/` with `node ../node_modules/typescript/bin/tsc -p tsconfig.json`: ```json {"compilerOptions":{"target":"ES2022","module":"NodeNext","moduleResolution":"NodeNext","strict":true,"skipLibCheck":true,"rootDir":"implementations/typescript","outDir":"dist"},"include":["implementations/typescript/*.ts"]} ``` Save as `demo.mjs`, then run `node demo.mjs`: ```javascript import { readFile } from 'node:fs/promises'; import { calculateAverageDailyBalanceInterest } from './dist/algorithm.js'; const cases = JSON.parse(await readFile('datasets/cases.json', 'utf8')).cases; const request = cases.find(c => c.id === 'A03-full35-changing-rate').request; const result = calculateAverageDailyBalanceInterest(request); for (const s of result.segments) console.log(s.period_start, s.period_end, s.rate_ppm, s.earned_exact.numerator + '/' + s.earned_exact.denominator); console.log(result.accrual.rounded_amount_minor, result.accrual.closing_carry.numerator + '/' + result.accrual.closing_carry.denominator); ``` Both demos print exactly: ```text 2026-10-01 2026-10-24 50000 22952/73 2026-10-24 2026-11-05 60000 55632/365 467 -63/365 ``` The article's dictionary display expresses that same final carry. From extracted `topic/`, `python -B tests/test_algorithm.py` and `python -B tests/run_parity.py` execute all 101 independent expected cases and exact daily-simple common-fact equality through the included pinned helper. Helpers are supporting source files, not replacements for the public main API. These are synthetic pure calculations and uncommitted accrual proposals; receipt authenticity, product applicability and durable journal acceptance remain host responsibilities.