edgartools icon indicating copy to clipboard operation
edgartools copied to clipboard

Add CurrencyConverter utility for foreign filers (IFRS)

Open dgunning opened this issue 10 months ago • 4 comments

Summary

Foreign filers (like NVO, BNTX) report financials in their home currency (DKK, EUR, etc.) rather than USD. Users working with these filings need a way to convert values to USD for comparison with US companies.

The Good News

IFRS filings typically include exchange rate data that can be extracted:

  • ifrs-full:AverageForeignExchangeRate - For income statement items
  • ifrs-full:ClosingForeignExchangeRate - For balance sheet items

Example from NVO (Novo Nordisk) 20-F filing:

Exchange Rates (DKK per 100 USD):
  2022: avg=708.0, close=697.0
  2023: avg=689.0, close=674.0
  2024: avg=689.0, close=714.0

Proposed API

from edgar import Company
from edgar.xbrl.currency import CurrencyConverter

# Get foreign filer's XBRL
nvo = Company("NVO")
filing = nvo.get_filings(form="20-F").latest()
xbrl = filing.xbrl()

# Create converter (auto-detects home currency, extracts USD rates)
converter = CurrencyConverter(xbrl)

print(converter)
# CurrencyConverter(home=DKK, target=USD)
#   Rates (DKK per 100 USD):
#     2024: avg=689.0, close=714.0

# Convert values
dkk_revenue = 290_400_000_000
usd_revenue = converter.to_usd(dkk_revenue, '2024', rate_type='average')
# Returns: 42.1B USD

# For balance sheet items, use closing rate
usd_assets = converter.to_usd(dkk_assets, '2024', rate_type='closing')

Key Design Points

  1. Auto-detect home currency from the most common unit_ref in facts
  2. Extract rates from filing - no external API needed
  3. Two rate types:
    • average - For income statement / cash flow (period data)
    • closing - For balance sheet (point-in-time data)
  4. Rates stored as "home currency per 100 USD" - matches IFRS convention

Prototype

A working prototype was developed and tested with NVO:

class CurrencyConverter:
    def __init__(self, xbrl):
        self.xbrl = xbrl
        self.home_currency = self._detect_home_currency()
        self.exchange_rates = self._extract_exchange_rates()
    
    def _extract_exchange_rates(self):
        # Query ifrs-full:AverageForeignExchangeRate
        # Query ifrs-full:ClosingForeignExchangeRate
        # Filter for USD unit (e.g., 'dkkPerUSD')
        # Return {year: {'average': rate, 'closing': rate}}
    
    def to_usd(self, value, year, rate_type='average'):
        rate = self.exchange_rates[year][rate_type]
        return value / (rate / 100)

Output Example

NOVO NORDISK FINANCIALS - DKK to USD Conversion
=================================================================

INCOME STATEMENT (avg rate)
-----------------------------------------------------------------
Item                              2024         2023         2022
-----------------------------------------------------------------
Revenue                         $42.1B       $33.7B       $25.0B
Gross Profit                    $35.7B       $28.5B       $21.0B
Net Profit                      $14.7B       $12.1B        $7.8B

BALANCE SHEET (closing rate)
-----------------------------------------------------------------
Total Assets                    $65.2B       $46.7B          N/A

Limitations

  • Only works if filing includes IFRS exchange rate facts (most do)
  • Some filings may have complex dimensional structures for multi-currency
  • Fallback to external API could be added for filings without rates

Related

  • Issue #446: 20-F IFRS statement support (resolved)
  • User request from Paul regarding NVO analysis

dgunning avatar Jan 13 '26 00:01 dgunning

Moved to internal tracking (edgartools-vesl)

dgunning avatar Jan 13 '26 17:01 dgunning

@dgunning Is CurrencyConverter available in the current release of EdgarTools?

I am using xbrl presently searching on your strings (ifrs-full:AverageForeignExchangeRate - For income statement items ifrs-full:ClosingForeignExchangeRate - For balance sheet items)

NVO is a good actor. However, I am struggling with TSM and NICE.

miruddfan avatar Jan 16 '26 15:01 miruddfan

Not yet .. working on it this weekend

dgunning avatar Jan 16 '26 23:01 dgunning

Implemented in 5.11.0

dgunning avatar Jan 21 '26 15:01 dgunning