Skip to main content

forex-python

travis-ci coveralls Code Health pypi

Forex Python is a free library for foreign exchange rates and currency conversion, supporting Python 3.6 and above.

Note: Install the latest version (forex-python>=1.6) to avoid RatesNotAvailableError.

Features

  • List all currency rates
  • Bitcoin price for all currencies
  • Convert amounts to and from Bitcoin
  • Get historical rates (since 1999)
  • Currency conversion (e.g., USD to INR)
  • Currency symbols and names

Currency Source

theratesapi.com provides current and historical foreign exchange rates published by the European Central Bank. Rates are updated daily at 3PM CET.

Bitcoin Price Source

Bitcoin prices are updated every minute. For more information, visit CoinDesk.

Installation

Install via pip:

pip install forex-python

Or clone the repository and install manually:

git clone https://github.com/MicroPyramid/forex-python.git
cd forex-python
python3 setup.py install

Usage Examples

Initialize the class:

from forex_python.converter import CurrencyRates
c = CurrencyRates()

List all latest currency rates for "USD":

c.get_rates('USD')
# Example output: {'INR': 83.12, 'EUR': 0.92, ...}

Get conversion rate from USD to INR:

c.get_rate('USD', 'INR')
# Example output: 83.12

Convert amount from USD to INR:

c.convert('USD', 'INR', 10)
# Example output: 831.2

Force use of Decimal:

from decimal import Decimal
c = CurrencyRates(force_decimal=True)
c.convert('USD', 'INR', Decimal('10.45'))
# Example output: 868.75

Get latest Bitcoin price:

from forex_python.bitcoin import BtcConverter
b = BtcConverter()
b.get_latest_price('USD')
# Example output: 67000.0

Convert amount to Bitcoins:

b.convert_to_btc(400, 'USD')
# Example output: 0.00597

Get currency symbol using currency code:

from forex_python.converter import CurrencyCodes
codes = CurrencyCodes()
codes.get_symbol('GBP')
# Example output: '£'

For complete documentation, see the forex-python docs.


Support & Feedback


Metadata

Release files for forex-python 1.9.2

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

Source distribution (sdist)

Source distribution for forex-python 1.9.2
File Size Uploaded
forex_python-1.9.2.tar.gz 12.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for forex-python 1.9.2
File Interpreter ABI Platform
forex_python-1.9.2-py3-none-any.whl Python 3 none any Details

Total release size: 21.8 kB

Release files / forex_python-1.9.2.tar.gz

Download URL forex_python-1.9.2.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f56c91300818daae629c9b55a980b7c223e1fc075fc60b12355bfae959aba0c3
BLAKE2b-256 checksum
How to use checksums
1af0edfaf24f9daf087f12d657877c132b69b3a3515af64042e2050f95e3e741
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / forex_python-1.9.2-py3-none-any.whl

Download URL forex_python-1.9.2-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7fa5f98305d9afee8bef5e05dcdc439137476827086cd5c13b45d5ffc97eb19
BLAKE2b-256 checksum
How to use checksums
cc67c56f18aa20ba4d5a5e41290c67ac0c8024391fabc8356dbfb9625d15e2d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.9.2 This release

2 release files

1.9.1

2 release files

1.9

2 release files

1.8

2 release files

1.7

2 release files

1.6

3 release files

1.5

1 release file

1.4

1 release file

1.3

2 release files

1.2

2 release files

1.1

2 release files

1.0.0

2 release files

0.3.3

2 release files

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2

1 release file

0.1

1 release file

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