Skip to main content

A module to make it easier to handle historical exchange rates.

Since version 0.3.5, rates are downloaded from a separate scraper hosted by Code for IATI. You can find the code for that scraper on Github: https://github.com/codeforiati/imf-exchangerates

The data from that scraper is made available here: https://codeforiati.org/imf-exchangerates/imf_exchangerates.csv

Instructions

Install from PyPI:

pip install exchangerates

Create a CurrencyConverter object:

import exchangerates
converter = exchangerates.CurrencyConverter(update=True)

Note: update=True will lead to fresh exchange rates being downloaded.

Usage

Get a list of the available currencies:

print converter.known_currencies()

Get the conversion rate for a specific currency and date:

print converter.closest_rate("USD", datetime.date(2012,7,20))
print converter.closest_rate("EUR", datetime.date(2014,7,20))
print converter.closest_rate("EUR", datetime.date(2014,7,20))

You can also just generate a consolidated file of exchange rates:

python get_rates.py

Result will be at data/consolidated_rates.csv.

Metadata

Release files for exchangerates 0.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for exchangerates 0.3.5
File Size Uploaded Provenance
exchangerates-0.3.5.tar.gz 4.7 kB Without provenance Details

Release files / exchangerates-0.3.5.tar.gz

Download URL exchangerates-0.3.5.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
80cd13f8791171e1dac23b524c8f9ed9fd3fa922ab6229132c21c7c066a103de
BLAKE2b-256 checksum
How to use checksums
590fba7b52539939d520ffed3ccba2acf2fb723cd46d88654b37f66e3554f58e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.18

Security for exchangerates 0.3.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page