CountryRisk.io DSA Toolkit: From Prototype to Production-Grade Sovereign Debt Analytics

Bernhard Obenhuber
Jul 08, 2026

In last year’s post, we introduced the CountryRisk.io Debt Sustainability Analysis (DSA) Toolkit: a Python-based model for deterministic and stochastic sovereign debt analysis, integrated with CountryData.io and designed to move DSA beyond spreadsheet-only workflows.
The motivation has not changed. Debt sustainability analysis remains one of the most important tools in sovereign risk, public debt management, and macro-financial surveillance. It answers a deceptively simple question: can a sovereign meet its debt obligations without requiring unrealistic fiscal adjustment or drifting into distress?
What has changed is the toolkit.
Over the past year, we have moved the CountryRisk.io DSA model closer to the reporting standards and analytical workflows used by official institutions, while retaining the flexibility of a programmable Python model. The result is a more comprehensive, transparent, and production-ready DSA engine that will soon be available not only as a Python package, but also through an API and MCP interface.
This work is a joint collaboration with Lennard Welslau, Julián Szymanski, and Mathias Fussenegger.
Why DSA Still Needs Better Infrastructure
The IMF and World Bank remain the reference institutions for DSA. Their joint Debt Sustainability Framework for low-income countries is central to official risk ratings and lending decisions. The World Bank describes the LIC DSF as the main tool used by multilateral institutions and other creditors to assess debt-sustainability risks, and the official guidance describes the LIC DSF template as an Excel-based tool that analyzes scenarios from user inputs. The IMF’s DSA page provides LIC DSF Excel templates and links to MAC DSA templates.
The 2026 IMF-World Bank review of the LIC DSF reinforces the same point. The background note for public consultation is not just about recalibrating thresholds. It proposes a more modular and data-intensive framework: separate assessments of external debt stress, overall public debt stress, and unsustainable public debt; stronger diagnostics for domestic debt and liquidity pressures; expanded realism checks; recalibrated stress tests; long-term climate and development modules; and explicit confidence flags for debt data coverage, transparency, and reliability.
These templates are powerful and institutionally important. But they are not designed for the full range of modern analytical workflows.
Sovereign analysts increasingly need to run scenarios programmatically, compare countries at scale, reproduce model outputs, connect to live data, integrate results into dashboards, and expose analysis to AI-assisted research systems. Excel templates remain useful, but they are hard to version, automate, audit, and embed in production pipelines.
That is where CountryRisk.io is positioning itself: as the innovation leader in making debt sustainability analysis programmable, reproducible, API-accessible, and soon MCP-ready.
What We Improved
The latest version of the CountryRisk.io DSA model adds three important capabilities.
1. Exchange-Rate Valuation Effects Are Now Endogenous
For countries with foreign-currency-denominated debt, depreciation can raise the domestic-currency value of USD- or EUR-denominated obligations even without new borrowing.
The updated model now follows official DSA practice more closely by making the exchange-rate contribution to debt dynamics endogenous. As in the DDT, LIC DSF, and MAC SRDSF tools, the model calculates the FX valuation flow internally from debt-currency shares and exchange-rate changes. This is important because the debt stock, exchange-rate path, and stock-flow accounting need to be mutually consistent. The effect appears separately in the debt-driver decomposition as “Exchange rate valuation,” while other stock-flow adjustments remain visible.
This avoids misclassifying depreciation-driven debt increases as residuals. Depreciation can also raise vulnerability through a separate macro channel: imports become more expensive, adding pressure to inflation, fiscal costs, and external financing needs, especially in countries running persistent trade or current account deficits.
2. Output Tables Now Align More Closely with IMF/World Bank Reporting
We also improved the model’s reporting layer. DSA is not only a calculation engine; it is a communication framework. Analysts need outputs that can be read by ministries of finance, debt management offices, investors, multilaterals, and credit committees.
The updated toolkit now produces DDT-style overview tables that span historical and projection periods, including:
- key debt and macroeconomic indicators
- debt-driver decomposition tables
- scenario comparison tables
- deterministic primary-balance target tables
- stochastic summary tables with debt percentiles and probability-based fiscal targets
These tables are designed to map more naturally into the structure analysts know from IMF and World Bank reporting: headline debt indicators, contribution to changes in public debt, realism and stress-scenario checks, and stochastic risk summaries.
3. Debt Driver Decomposition Charts and Tables Are Now First-Class Outputs
The toolkit now includes debt-driver decomposition charts and tables that separate the contribution of:
- primary deficit
- interest expenditure
- real GDP growth
- inflation
- exchange-rate valuation
- stock-flow adjustments
- residuals
This is one of the most important improvements from a communication perspective. A debt path is useful, but a debt path with drivers is much more useful. It tells the analyst whether the deterioration is coming from weak growth, high effective interest costs, fiscal slippage, exchange-rate pressure, or below-the-line stock-flow items.
For example, in a Mexico stagnation scenario with near-zero real growth for three years, the model shows the debt ratio rising materially above baseline, while the driver table makes clear how the weaker growth path, interest bill, and inflation dynamics interact over the projection horizon. The same workflow can then be rerun under deterministic fiscal adjustment or stochastic uncertainty.
Deterministic and Stochastic Analysis in One Workflow
The core architecture remains the same:
- CountryRiskDataPrep: prepares macro, fiscal, interest-rate, exchange-rate, and debt-composition inputs.
- CountryRiskDSA: runs deterministic projections, scenarios, debt-driver decompositions, and primary-balance optimization.
- CountryRiskSDSA: extends the deterministic model with stochastic simulations based on historical debt-driver shocks.
Users can define a baseline, apply a custom scenario, compute a deterministic fiscal target, and then simulate the distribution of debt outcomes under uncertainty. This makes it possible to answer both deterministic and probabilistic questions:
- What happens to debt if growth stagnates for three years?
- What primary balance is needed to keep debt below a threshold?
- Which criterion is binding: debt reduction, deficit ceiling, interest burden, or debt threshold?
- What is the median debt path under stochastic shocks?
- What fiscal target gives a 75% probability of meeting a debt objective?
These are exactly the questions analysts ask in real sovereign risk work. The difference is that they can now be answered in a reproducible Python workflow instead of a manually maintained spreadsheet.
A Mexico Walkthrough: From Baseline to Stagnation Scenario
The Mexico example shows what the workflow looks like in practice. A full DSA run produces the standard artifacts an analyst needs: debt paths, growth charts, debt-driver tables, deterministic primary-balance targets, stochastic fancharts, and machine-readable summary outputs.
The process starts with a baseline. Using CountryRiskDataPrep, the model pulls macro-fiscal inputs, prepares the projection horizon, and sets assumptions for inflation convergence, interest rates, debt composition, average maturity, fiscal multipliers, and exchange-rate paths. In the Mexico setup, the projection runs from 2025 to 2035, with 75 percent of debt treated as domestic-currency debt and 25 percent as USD-denominated debt. If no scenario is defined, it runs the baseline using the prepared data and a constant primary balance equal to the starting value.
An illustrative baseline run using CountryData.io as data infrastructure shows the first step. With no scenario definition, Mexico's gross public debt ratio rises from about 61.8 percent of GDP in 2025 to about 76.5 percent of GDP in 2035. That baseline is the reference path: before asking what happens under stress, the analyst first checks whether the no-scenario projection is plausible. The baseline fanchart then adds uncertainty around that path. In this run, the stochastic median for 2035 is about 77.3 percent of GDP, while the 95th percentile is about 91.9 percent. The distribution chart makes the same point in another form: the baseline is not a single number, but a range of possible debt outcomes.


The next output is the DDT-style indicator table. It gives the reader the macro-fiscal context behind the path: public debt, real growth, inflation, nominal growth, and the effective interest rate across the historical and projection periods. The debt-creating-flows chart then decomposes the change in the debt ratio into the primary deficit, interest expenditure, real GDP growth, inflation, exchange-rate valuation, stock-flow adjustments, and residuals. This is where the model becomes useful for diagnosis: debt rises not just because one headline variable moves, but because several drivers interact over time.



The second step is to define the scenario. In the stagnation case, real GDP growth is pushed close to zero for 2026-2028, while other assumptions remain on the baseline path. The scenario is then passed back into the same projection engine. In the illustrative run, debt reaches 82.2 percent of GDP by 2035 versus 76.5 percent in the matching baseline, a gap of about 5.7 percentage points.


The third step is interpretation. The debt path chart shows the headline result, but the driver table explains why it happens. In the stagnation run, weaker real growth reduces the denominator effect that normally helps stabilize debt, while interest expenditure remains a large positive contributor to debt accumulation. The driver decomposition separates that growth effect from the primary balance, inflation, exchange-rate valuation, and other stock-flow adjustments.
The fourth step is fiscal targeting and uncertainty. The realism and fiscal-adjustment table asks what primary balance would be needed to satisfy specific criteria, such as keeping debt below 60 percent of GDP, keeping the deficit below 3 percent of GDP, or limiting interest payments to 5 percent of GDP. It also compares debt outcomes under the baseline, a historical-primary-balance scenario, a growth shock, a financial stress shock, and an adverse interest-growth differential shock. In the baseline run, the deterministic primary-balance target for debt below 60 percent of GDP is about 3.0 percent of GDP, while the target for keeping interest below 5 percent of GDP is about 5.0 percent of GDP.




The stochastic summary table and optimized fanchart ask a more demanding question: what adjustment gives a high probability of meeting the objective under simulated shocks? In the illustrative run, the overall stochastic optimization moves the primary balance from about 1.2 percent of GDP in 2025 to about 3.6 percent of GDP by 2030 and then holds it there. Under that adjustment path, projected debt falls to about 54.4 percent of GDP by 2035. The post-adjustment fanchart shows how the distribution shifts once policy responds rather than simply accepting the baseline path.
This is the value of moving DSA into Python. The analyst can run a baseline, introduce a scenario, inspect debt drivers, calculate fiscal targets, simulate uncertainty, and regenerate the output tables from one reproducible workflow.
What the 2026 LIC DSF Review Makes Clear
The IMF-World Bank review also shows where official DSA is heading. Debt sustainability analysis is no longer just a debt-ratio projection with a few stress tests attached. It is becoming a structured analytical system that combines mechanical risk signals, liquidity indicators, realism checks, country-specific stress tests, data-quality diagnostics, and documented judgment.
Three implications stand out.
First, liquidity and refinancing risk need to be treated as first-class outputs. The proposed LIC DSF reforms add more attention to gross financing needs, interest-to-revenue, domestic public debt service, and the realism of domestic borrowing assumptions. This is especially important for countries where stress may show up through market access, rollover pressure, or rising domestic interest costs before it appears as a simple solvency problem.
Second, stress testing needs to be modular. The review discusses recalibrated standardized stress tests, updated natural disaster shocks, a banking crisis stress test, and a new domestic financing stress test. A programmable DSA engine is well suited to this direction because stress scenarios can be versioned, parameterized, reused across countries, and extended without breaking a spreadsheet workbook.
Third, judgment needs an audit trail. The review emphasizes structured and transparent use of judgment, supported by auxiliary modules and debt data confidence flags. That is exactly where code-based infrastructure matters: assumptions, overrides, input data, model outputs, and final analytical judgments can be stored, inspected, and reproduced.
That point is also central to Teal Emery's response to the consultation. Teal argues that the operational challenge is not only the quality of the proposed reforms, but whether lean Fund teams and finance ministries can actually run them at scale. Their proposed answer is to "write the framework down to a standard," so the template's inputs, logic, and model connections are documented in a way that people, deterministic software, and AI systems can all read. That is the missing bridge between official DSA methodology and modern analytical infrastructure.
Toward API and MCP Access
The Python package and API endpoints are only the first layers. CountryRisk.io is preparing to make the DSA model also available through an MCP interface.
The package can also be used locally from a command-line workflow. An analyst working with a CLI coding agent such as Codex or Claude Code can inspect the model, modify assumptions, run scenarios, regenerate tables and charts, and document the changes without sending the working files to a hosted analytical service. That matters for institutions that want AI-assisted analysis but still need data, code, and outputs to remain inside their own environment.
That opens up a different kind of workflow:
- dashboards can request a fresh DSA run for a country;
- analysts can trigger standardized stress scenarios from internal tools;
- AI agents can query the model, run scenarios, and retrieve structured tables;
- country-risk platforms can integrate DSA outputs directly into reports and monitoring systems;
- institutional users can connect sovereign debt analysis to their own data, rating, and early-warning pipelines.
This is where the DSA model becomes infrastructure. Not a static workbook. Not a one-off chart. A callable analytical service.
Why CountryRisk.io Is Different
The public DSA ecosystem remains dominated by official Excel templates. Those templates are essential benchmarks, but they are not built for modern software workflows.
The direction of official reform makes the case for this infrastructure layer stronger, not weaker. If DSA is expected to combine domestic debt diagnostics, liquidity indicators, long-term scenarios, realism tools, stress tests, data confidence checks, and structured judgment, then the underlying workflow needs to be reproducible, inspectable, and callable by software. Excel can remain a familiar interface where users need it, but it should not be the only implementation standard.
CountryRisk.io is building a different layer:
- Python-native for analysts and researchers;
- data-connected through CountryData.io;
- deterministic and stochastic in the same model;
- scenario-native by design;
- explicit about FX valuation effects;
- aligned with standard DSA reporting structures;
- ready for API and MCP deployment.
Debt sustainability analysis will always require expert judgment. No model can replace institutional knowledge, political assessment, financing-market context, or the analyst’s view of policy credibility. But the mechanics of DSA should be easier to run, easier to audit, and easier to integrate.
That is the direction CountryRisk.io is taking: turning DSA from a spreadsheet exercise into modern sovereign risk infrastructure.
Sources
- CountryRisk.io, “Introducing the CountryRisk.io Debt Sustainability Analysis (DSA) Toolkit”: https://www.countryrisk.io/blog/introducing-the-countryrisk.io-debt-sustainability
- IMF and World Bank, “Review of the Bank-Fund Debt Sustainability Framework for Low Income Countries: Background Note,” June 2, 2026.
- Teal Insights, “Clearing the Clogs: A Plumber’s Guide to Making the Reformed LIC-DSF Run at Scale,” consultation response, July 2, 2026.
- IMF, Debt Sustainability Analysis: Low-Income Countries: https://www.imf.org/en/publications/dsa
- World Bank, Debt Sustainability Framework: https://www.worldbank.org/en/programs/debt-toolkit/dsf
