Inspiration
The SME Credit Gap in Kenya is a structural crisis. In simple terms, small businesses are often too large for micro-loans (like those from mobile apps) but are viewed as too risky or complex for standard commercial bank loans.
Currently, Kenyan banks often apply a "one-size-fits-all" interest rate (e.g., 16%) to all Small and Medium Enterprises (SMEs). This happens because assessing individual risk is manually intensive and expensive. As a result, a stable, low-risk pharmacy in Nairobi is forced to pay the same high rate as a volatile new tech startup.
I was inspired by the Robert Geske Compound Option Model, used on Wall Street to price debt for massive corporations, I asked: "Why can't I bring this mathematical precision to a hardware shop in Nairobi?" My goal was to replace "gut-feeling" lending with risk-adjusted rates that accurately reflect an SME’s actual health.
What it does
DebtOptimizer is a financial engineering engine that transforms SME lending from a guessing game into a calculated science:
- Sector Mapping: It categorizes businesses into one of 10 key Kenyan economic sectors (e.g., Agriculture, Manufacturing) to understand their specific environment.
- Volatility Calibration: The system pulls 5+ years of historical data from the Kenya National Bureau of Statistics (KNBS). This allows the model to factor in how "unstable" or "volatile" a specific industry is within the Kenyan context.
- The Geske Calculation: It treats the firm's equity as a Compound Option on its assets. The Simple Logic: I view a loan as a series of hurdles. To get the "option" to stay in business and reach the final payment, the business must first "win" the first payment period. It is a "compound" risk because each payment depends on the success of the previous one.
- Tenor Optimization: The engine calculates the Optimal Loan Tenor, the specific length of time (e.g., 18 months vs 24 months) that minimizes the Probability of Default.
How I built it
The core engine is a Python implementation of the Geske Compound Option Model.
The Technology:
- Computational Engine: For simple loans, I use the analytical Geske formula. However, for monthly installments (where n > 2), the math becomes too complex for standard equations. I solved this by building a Monte Carlo Simulation engine using NumPy. This allows the computer to run 10,000 "what-if" scenarios in milliseconds to find the most likely outcome.
- Optimization: I used scipy.optimize to find the Critical Firm Value (V^*) the exact "break-even" point where a business is considered solvent versus insolvent.
- Data Pipeline: I processed 68 months of KNBS Consumer Price Index (CPI) data to calculate the Annualized Standard Deviation (the mathematical measure of risk) for different Kenyan sectors.
Challenges I ran into
- The Multi-Payment Barrier: Standard financial models work well for one or two payments. When dealing with 24 or 36 monthly installments, the computation becomes exponentially heavier. I pivoted to vectorized simulations to ensure the app stays fast and responsive.
- Data Noise: Raw economic data from emerging markets is often "noisy" or inconsistent. I had to perform significant data cleaning to ensure the Volatility (\sigma) used in the model reflected true Kenyan market risks rather than data entry errors.
- Numerical Convergence: Finding the "Solvency Threshold" (V^*) for a business in deep financial distress can cause mathematical solvers to get stuck. I implemented robust error-handling to ensure the model provides a "Survival Probability" even in extreme cases. Accomplishments I’m proud of
- Bespoke Implementation: I didn't use a pre-made financial library; I coded the Stochastic Calculus of the Geske model from scratch.
- Localized Calibration: The model isn't using generic global data. It uses actual Kenyan sector volatilities (e.g., Agriculture at \sigma = 25\%), making it a practical tool for local banks.
- Real-Time Speed: My optimized engine can simulate thousands of possible economic futures for a business in under a second.
What I learned
- The Precision of Geske: I learned that treating equity as a compound option provides a far more accurate picture of risk than traditional credit scoring, especially when a business has multiple debt obligations over time.
- The Importance of Visuals: High-level math is useless if a loan officer can't read it. I spent time creating Survival Probability Curves to make the "Default Risk" intuitive at a glance.
Built With
- python
- streamlit
Log in or sign up for Devpost to join the conversation.