<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nwankwo Frank</title>
    <description>The latest articles on DEV Community by Nwankwo Frank (@nwankwo_frank_06b8711e1fb).</description>
    <link>https://dev.to/nwankwo_frank_06b8711e1fb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4098038%2F7d0523ae-fac1-4bc8-b148-56b649150053.png</url>
      <title>DEV Community: Nwankwo Frank</title>
      <link>https://dev.to/nwankwo_frank_06b8711e1fb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nwankwo_frank_06b8711e1fb"/>
    <language>en</language>
    <item>
      <title>Why scraping 10-K HTML gave me fabricated country revenue (and how I fixed it with XBRL)</title>
      <dc:creator>Nwankwo Frank</dc:creator>
      <pubDate>Sun, 22 Nov 2026 00:45:28 +0000</pubDate>
      <link>https://dev.to/nwankwo_frank_06b8711e1fb/why-scraping-10-k-html-gave-me-fabricated-country-revenue-and-how-i-fixed-it-with-xbrl-4517</link>
      <guid>https://dev.to/nwankwo_frank_06b8711e1fb/why-scraping-10-k-html-gave-me-fabricated-country-revenue-and-how-i-fixed-it-with-xbrl-4517</guid>
      <description>&lt;p&gt;I'm building &lt;a href="https://metricshour.com/" rel="noopener noreferrer"&gt;MetricsHour&lt;/a&gt;, a financial data platform that tracks where public companies actually earn their revenue, by country, straight from SEC 10-K filings.&lt;/p&gt;

&lt;p&gt;My first parser was a mistake: it scraped the rendered HTML of the filing. When I audited it, only about 9% of tracked stocks had correct and complete data. The rest had:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fabricated country rows&lt;/li&gt;
&lt;li&gt;Currency misreads&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wrong period&lt;br&gt;
Every 10-K ships with an XBRL instance document, and it already holds the structure I was trying to guess at. The rewrite pulls each field from where it's defined:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Currency&lt;/strong&gt; from &lt;code&gt;unitRef&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Period&lt;/strong&gt; from &lt;code&gt;contextRef&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Geography&lt;/strong&gt; from explicit dimension members&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I also had to add a third strategy for vertical fact tables. After that, AMT resolved 21 countries cleanly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to see it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Browse stock pages with geographic exposure: &lt;a href="https://metricshour.com/markets/" rel="noopener noreferrer"&gt;metricshour.com/markets/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Open source package: &lt;a href="https://metricshour.github.io/edgar-geo-revenue/" rel="noopener noreferrer"&gt;edgar-geo-revenue on GitHub&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's also on PyPI and Hugging Face, and there's a Kaggle dataset.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;If a structured source exists, never parse the rendered version.&lt;/li&gt;
&lt;li&gt;Audit against known-good tickers before trusting any pipeline.&lt;/li&gt;
&lt;li&gt;Ticker drift is real. I had to fix six aliases (BLL, WRK, RE/EG, PARA, BK, MMC) and mark 10 delistings inactive.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Issues and PRs welcome. If you've worked with XBRL dimensions, I'd like to hear what edge cases you've hit.&lt;/p&gt;

</description>
      <category>python</category>
      <category>opensource</category>
      <category>datascience</category>
      <category>fintech</category>
    </item>
    <item>
      <title>I audited 463 SEC filers to figure out why nobody parses geographic revenue correctly</title>
      <dc:creator>Nwankwo Frank</dc:creator>
      <pubDate>Tue, 01 Sep 2026 18:06:10 +0000</pubDate>
      <link>https://dev.to/nwankwo_frank_06b8711e1fb/i-audited-463-sec-filers-to-figure-out-why-nobody-parses-geographic-revenue-correctly-4oh4</link>
      <guid>https://dev.to/nwankwo_frank_06b8711e1fb/i-audited-463-sec-filers-to-figure-out-why-nobody-parses-geographic-revenue-correctly-4oh4</guid>
      <description>&lt;p&gt;“How much of Apple’s revenue comes from China?” The answer is in a 10-K somewhere — but ask a scraper to find it programmatically across hundreds of tickers and you hit a wall. EDGAR has no standard location, table shape, or label vocabulary for geographic revenue disclosures.&lt;br&gt;
I built &lt;a href="https://metricshour.github.io/edgar-geo-revenue/" rel="noopener noreferrer"&gt;edgar-geo-revenue&lt;/a&gt;, a pure-Python library (two dependencies, no API key) that extracts geographic revenue breakdowns from 10-K filings. It’s a general-purpose extraction layer — the version behind &lt;a href="https://metricshour.com" rel="noopener noreferrer"&gt;MetricsHour&lt;/a&gt; adds ticker-specific tuning on top of this.&lt;/p&gt;

&lt;p&gt;Python&lt;br&gt;
import edgar_geo_revenue as egr&lt;/p&gt;

&lt;p&gt;egr.set_user_agent("Your Name &lt;a href="mailto:your@email.com"&gt;your@email.com&lt;/a&gt;")  # SEC requires a real contact&lt;br&gt;
egr.fetch_geo_revenue("AAPL")&lt;/p&gt;

&lt;h1&gt;
  
  
  {'fiscal_year': 2025,
&lt;/h1&gt;

&lt;h1&gt;
  
  
  'total_revenue_usd': 416161000000,
&lt;/h1&gt;

&lt;h1&gt;
  
  
  'segments': [['US', 36.47], ['CN', 15.47]],
&lt;/h1&gt;

&lt;h1&gt;
  
  
  'region_segments': [['INTL', 48.06]],
&lt;/h1&gt;

&lt;h1&gt;
  
  
  'pct_coverage': 100.0}
&lt;/h1&gt;

&lt;p&gt;Why it’s harder than it looks&lt;br&gt;
    • XBRL tagging is often incomplete. Many filers disclose the split in rendered statements but tag little in XBRL — an XBRL-only approach silently returns nothing for companies that clearly disclosed a breakdown.&lt;br&gt;
    • The table lives in an unpredictable R-file, anywhere from R1.htm to R200.htm.&lt;br&gt;
    • Label vocabulary is unbounded — “U.S.,” “US and Canada,” “EMEA,” “Greater China,” with or without footnotes or abbreviations.&lt;br&gt;
    • Neighboring tables look nearly identical — long-lived assets, deposits, and pension assets by geography all reuse the revenue note’s row labels.&lt;br&gt;
Run against 463 filers: 262 had a usable disclosure. The rest largely don’t disclose one at all — a legitimate outcome, not a parsing failure.&lt;br&gt;
What it deliberately doesn’t do&lt;br&gt;
The more interesting part is what got tried, shipped, produced wrong numbers, and got ripped out.&lt;br&gt;
    • No splitting a region into per-country estimates. “Europe: 30%” never gets apportioned by GDP weighting or similar — only what’s actually disclosed becomes a row.&lt;br&gt;
    • Combined labels resolve to a set, not a string match. “Europe, the Middle East and Africa” → {EUROPE, MEA}, which is EMEA. One resolution pass catches every punctuation variant.&lt;br&gt;
    • No heuristic for the “Total” row. Positional or label guesses produced wrong denominators too often — the total always comes from the filing’s own reported revenue.&lt;br&gt;
    • The R-file scan doesn’t stop at the first miss. An early version did, and cut the search off before reaching the note in longer filings.&lt;br&gt;
    • A partition that doesn’t sum to 100% gets rejected, not rescaled. Overlapping subtotals aren’t a clean partition, and scaling them down would invent a split that was never disclosed.&lt;/p&gt;

&lt;p&gt;Magnitude gets sanity-checked independently. Every wrong-table bug I hit — deposits mistaken for revenue, pension assets, PP&amp;amp;E — was off by 3x or more. Wide bounds catch these without flagging normal YoY growth.&lt;/p&gt;

&lt;p&gt;Install &lt;/p&gt;

&lt;p&gt;pip install requests beautifulsoup4&lt;br&gt;
git clone&lt;/p&gt;

&lt;p&gt;&lt;a href="https://metricshour.github.io/" rel="noopener noreferrer"&gt;https://metricshour.github.io/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;cd edgar-geo-revenue &amp;amp;&amp;amp; pip install -e .&lt;/p&gt;

&lt;p&gt;SEC rate-limits to ~10 req/sec and requires a User-Agent with a real contact — call set_user_agent() first or requests get blocked.&lt;br&gt;
MIT licensed. Repo: &lt;a href="https://metricshour.github.io/" rel="noopener noreferrer"&gt;https://metricshour.github.io/&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fky6zmma33kw7uhvwv1rk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fky6zmma33kw7uhvwv1rk.png" alt=" " width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>opensource</category>
      <category>agents</category>
      <category>blockchain</category>
    </item>
  </channel>
</rss>
