Skip to main content

forex-python

travis-ci

coveralls

Code Health

pypi

Forex Python is a Free Foreign exchange rates and currency conversion.

Note: Install latest forex-python==1.6 to avoid RatesNotAvailableError

RunCode

Features of Forex Python: ---------- List all currency rates. - BitCoin price for all currencies. - Converting amount to BitCoins. - Get historical rates for any day since 1999. - Conversion rate for one currency(ex; USD to INR). - Convert amount from one currency to other.('USD 10$' to INR). - Currency symbols. - Currency names.

Currency Source:

https://theratesapi.com is a free API for current and historical foreign exchange rates published by European Central Bank. The rates are updated daily 3PM CET.

BitCoin Price Source:

Bitcoin prices calculated every minute. For more information visit [CoinDesk](http://www.coindesk.com).

Installation

  • Install using python package

    pip install forex-python
    
        Or directly cloning the repo:
    
    python setup.py install
    

Usage Examples:

  • Initialize class

    python
    >>> from forex_python.converter import CurrencyRates
    >>> c = CurrencyRates()
    
  • list all latest currency rates for "USD"

    python
    >>> c.get_rates('USD')
    {u'IDR': 13625.0, u'BGN': 1.7433, u'ILS': 3.8794, u'GBP': 0.68641, u'DKK': 6.6289, u'CAD': 1.3106, u'JPY': 110.36, u'HUF': 282.36, u'RON': 4.0162, u'MYR': 4.081, u'SEK': 8.3419, u'SGD': 1.3815, u'HKD': 7.7673, u'AUD': 1.3833, u'CHF': 0.99144, u'KRW': 1187.3, u'CNY': 6.5475, u'TRY': 2.9839, u'HRK': 6.6731, u'NZD': 1.4777, u'THB': 35.73, u'EUR': 0.89135, u'NOK': 8.3212, u'RUB': 66.774, u'INR': 67.473, u'MXN': 18.41, u'CZK': 24.089, u'BRL': 3.5473, u'PLN': 3.94, u'PHP': 46.775, u'ZAR': 15.747}
    
  • Get conversion rate from USD to INR

    python
    >>> c.get_rate('USD', 'INR')
    67.473
    
  • Convert amount from USD to INR

    python
    >>> c.convert('USD', 'INR', 10)
    674.73
    
  • Force use of Decimal

    python
    >>> from forex_python.converter import CurrencyRates
    >>> c = CurrencyRates(force_decimal=True)
    >>> c.convert('USD', 'INR', Decimal('10.45'))
    705.09
    >>> c.convert('USD', 'INR', 10)
    DecimalFloatMismatchError: convert requires amount parameter is of type Decimal when use_decimal=True
    
  • Detect use of Decimal

    python
    >>> from forex_python.converter import CurrencyRates
    >>> c = CurrencyRates()
    >>> c.convert('USD', 'INR', Decimal('10.45'))
    705.09
    >>> c.convert('USD', 'INR', 10)
    674.73
    
  • Get latest Bitcoin price.

    python
    >>> from forex_python.bitcoin import BtcConverter
    >>> b = BtcConverter() # force_decimal=True to get Decimal rates
    >>> b.get_latest_price('USD')
    533.913
    
  • Convert Amount to Bitcoins based on latest exchange price.

    python
    >>> b.convert_to_btc(400, 'USD')
    0.7492699301118473
    
  • Get currency symbol using currency code

    python
    >>> from forex_python.converter import CurrencyCodes
    >>> c = CurrencyCodes()
    >>> print c.get_symbol('GBP')
    £
    

You can view the complete Documentation Here

Visit our Python Development page Here

We welcome your feedback and support, raise github ticket if you want to report a bug. Need new features? Contact us here

Metadata

Release files for forex-python 1.9

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
File Size Uploaded
forex_python-1.9.tar.gz 13.0 kB Details

Built distribution (wheel)

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

Total release size: 22.9 kB

Release files / forex_python-1.9.tar.gz

Download URL forex_python-1.9.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2214a4ee99d8ff7855b1830c7f446dac9914ed91dc99046ff4e38b889f97108d
BLAKE2b-256 checksum
How to use checksums
8827c9624322928b41c69fdf14560138215000864e6f10c85ab22710e7314424
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-py3-none-any.whl

Download URL forex_python-1.9-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
06924dc80c356fbb05855200b58f84236377d92b928774c3a36bff001e342e45
BLAKE2b-256 checksum
How to use checksums
f07b1edbea912be717a8232fd303af59a244a4c6776dbd56a7dcc416d58f47a2
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

1.9.2

2 release files

1.9.1

2 release files

This release

1.9 This release

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