Hunting Political Debt in the Terminal: Inside cuantodeben_plot
How a solo developer built an OSINT pipeline to scrape, normalize, and expose the hidden financial liabilities of Argentine public officials.
- The project bypasses standard scraping limitations by using fuzzy heuristic matching to extract financial data from hostile, dynamic government DOMs.
- It treats debt tracking as a graph problem, recursively analyzing family members to uncover liabilities hidden away from the primary political subject.
- Algorithmic thresholds account for hyperinflation, isolating genuine spikes in leverage from the baseline erosion of the Argentine Peso.
The Mathematical Signature of Leverage
Most data visualization tools assume the data wants to be seen. cuantodeben_plot assumes the opposite. Built to audit the financial disclosures of Argentine politicians, legislators, and judicial members, the repository functions less like a plotting library and more like an automated investigative journalist.
The core logic inside analyze_debts.py operates on a simple premise: public officials often hide massive liabilities by shifting them to relatives. Instead of merely parsing a primary subject's debt, the extract_max_debt_per_person function recursively traverses a familiares array. It hunts for the mathematical signature of leverage across an entire household.
Once the household debt is aggregated, plot_debts.py applies a change-detection algorithm. It calculates month-over-month deltas. If a sudden spike exceeds a hardcoded 50 million ARS threshold, the system flags a "Loan Event," merging temporally proximate spikes to avoid double-counting refinanced loans.
Scraping a Hostile DOM
Extracting this data from the Banco de la Nación Argentina requires a multi-tiered offensive. Standard scraping pipelines rely on predictable CSS selectors. When targeting state-run Single Page Applications (SPAs) that actively resist automated extraction, that approach fails.
The ingestion layer splits the difference. scrape_debts.py attempts a fast, lightweight extraction using raw requests, hunting for embedded JSON within script tags using aggressive regex patterns like r'\[.*\]|\{.*\}'. When the DOM proves too dynamic, it falls back to a headless Selenium driver.
def extract_amount(text):
# Heuristic to handle Argentine currency formatting
cleaned = text.replace('.', '').replace(',', '.')
if 'M' in cleaned:
return float(cleaned.replace('M', '')) * 1000000
return float(cleaned)
Even with Selenium, the script relies on fuzzy keyword heuristics—searching for elements containing ['deuda', 'banco', 'nación']—rather than strict structural paths. It then normalizes the idiosyncratic Argentine currency formatting, converting "M" suffixes into clean floats ready for analysis.
The Hyperinflation Variable
Tracking wealth in Argentina carries an implicit, massive variable: hyperinflation. A nominal increase in debt might simply reflect the eroding value of the currency rather than new, potentially illicit leverage. To combat this, the pipeline integrates Consumer Price Index (IPC) data.
By differentiating between real and nominal debt, the tool ensures that its algorithmic triggers only fire when a public official is actually acquiring new capital, effectively filtering out the baseline noise of the Argentine economy.
OSINT Forensics vs. Standard Analytics
It is tempting to view cuantodeben_plot as just another Matplotlib wrapper. In reality, it represents a fundamental shift from standard data engineering to investigative data journalism.
| Feature | Standard Analytics Pipeline | OSINT Forensic Pipeline |
|---|---|---|
| Targeting | Direct subject analysis | Recursive graph traversal of relatives |
| Extraction | Fixed CSS selectors & APIs | Fuzzy keyword heuristics & DOM fallback |
| Metrics | Absolute values | Inflation-adjusted, threshold-based deltas |
By codifying journalistic intuition into reproducible Python scripts, the project democratizes financial oversight. It proves that with the right heuristics, a solo developer can build an automated auditing engine capable of piercing opaque institutional veils.