Documentation

Python packages / IMF reader

Special Drawing Rights

The Special Drawing Rights (SDR) is an international reserve asset the IMF created in 1969, exchangeable for usable currencies. Read more in the IMF's SDR factsheet.

The IMF publishes no API for the daily SDR valuation or the weekly interest rate. Those two are web-only. Allocations and holdings do exist on the IMF's API, at monthly frequency (IMF.STA:FA), but this package has not moved to it. The sdr module works by parsing pages on the IMF website for all four series, so it is sensitive to the IMF restructuring those pages.

Holdings and allocations

fetch_allocations_holdings() fetches the latest available month:

from imf_reader import sdr

df = sdr.fetch_allocations_holdings()

The returned frame is long-format, one row per entity per indicator:

ColumnHolds
entityThe reporting entity
indicatorholdings or allocations
valueThe reported amount
dateThe month the data covers

SDR holdings and allocations are published monthly. Pass a (year, month) tuple to fetch a specific one:

from imf_reader import sdr

df = sdr.fetch_allocations_holdings((2021, 4))

A date later than the latest available month raises ValueError, naming the latest available date.

Check the latest available month

from imf_reader import sdr

latest = sdr.fetch_latest_allocations_holdings_date()

Returns a (year, month) tuple.

Exchange rates

from imf_reader import sdr

df = sdr.fetch_exchange_rates()

fetch_exchange_rates() defaults to unit_basis="SDR", which returns 1 SDR expressed in USD. Pass "USD" for 1 USD expressed in SDR:

from imf_reader import sdr

df = sdr.fetch_exchange_rates("USD")

Both calls return the full historical series, up to the latest available date, in two columns: date and exchange_rate.

The SDR's value is the sum, in US dollars, of a basket of five currencies: the US dollar, euro, Japanese yen, pound sterling, and Chinese renminbi. The IMF calculates it daily except on IMF holidays, and reviews the basket every five years.

Interest rates

from imf_reader import sdr

df = sdr.fetch_interest_rates()

fetch_interest_rates() takes no arguments and returns the full historical series, with columns interest_rate, effective_from, and effective_to. The rate for the current week is released Sunday morning, Washington DC time.

Clearing SDR data

from imf_reader import cache

cache.clear_cache(scope="sdr")

sdr.clear_cache() still works. It emits a DeprecationWarning and is removed in 3.0. See Caching for the rest of the cache API.

Next steps

  • Caching - cache locations, TTLs, and the full cache API
  • World Economic Outlook - the package's other data source, with its own date-argument order
  • Why imf-reader - why the package parses web pages instead of calling an API

View as markdown