|
1 | | -# forex-python |
| 1 | +forex-python |
| 2 | +============ |
| 3 | + |
| 4 | +Foreign exchange rates and currency conversion. |
| 5 | + |
| 6 | +Features: |
| 7 | +--------- |
| 8 | +- List all currency rates. |
| 9 | +- Get historical rates for any day since 1999. |
| 10 | +- Conversion rate for one Currency(ex; USD to INR). |
| 11 | +- Convert amount from one currency to other.('USD 10$' to INR) |
| 12 | + |
| 13 | +Currency Source: |
| 14 | +--------------- |
| 15 | +Fixer.io is a free API for current and historical foreign exchange rates published by European Central Bank. |
| 16 | +The rates are updated daily 3PM CET. |
| 17 | + |
| 18 | +Installation: |
| 19 | +------------ |
| 20 | + |
| 21 | +Install using python package |
| 22 | + |
| 23 | +.. code-block:: bash |
| 24 | + |
| 25 | + $ pip install forex-python |
| 26 | + |
| 27 | +Or directly cloning the repo: |
| 28 | + |
| 29 | +.. code-block:: bash |
| 30 | + |
| 31 | + $ python setup.py install |
| 32 | + |
| 33 | +Examples: |
| 34 | +------------------ |
| 35 | + |
| 36 | +Initialize class |
| 37 | + |
| 38 | +.. code-block:: python |
| 39 | + |
| 40 | + >>> from forex_python.converter import CurrencyRates |
| 41 | + >>> c = CurrencyRates() |
| 42 | + |
| 43 | +list all latest currency rates for "USD" |
| 44 | + |
| 45 | +.. code-block:: python |
| 46 | + |
| 47 | + >>> c.get_rates('USD') |
| 48 | + {'EUR':19.22} |
| 49 | + |
| 50 | +Get Conversion rate from USD to INR |
| 51 | + |
| 52 | +.. code-block:: python |
| 53 | + |
| 54 | + >>> c.get_rate('USD', 'INR') |
| 55 | + 67.32 |
| 56 | + |
| 57 | +Convert amount from USD to INR: |
| 58 | +.. code-block:: python |
| 59 | + |
| 60 | + >>> c.convert('USD', 'INR', 10) |
| 61 | + 673.25 |
| 62 | + |
| 63 | +Convert amount from USD to INR based on 2010-03-01 rates |
| 64 | + |
| 65 | +.. code-block:: python |
| 66 | + |
| 67 | + >>> c.convert(100, 'EUR', 'USD', 10, "2010-03-01") |
| 68 | + 632.60 |
| 69 | + |
| 70 | +RatesNotAvailableError for invalid currency codes and missing currency code from source: |
| 71 | + |
| 72 | +.. code-block:: python |
| 73 | + |
| 74 | + >>> c.get_rate('XYZ', 'INR') |
| 75 | + Traceback (most recent call last): |
| 76 | + RatesNotAvailableError: Currency XYZ => INR rate not available for Date latest. |
| 77 | + |
| 78 | +Compleate `documentation`_ |
| 79 | + |
| 80 | +We welcome your feedback and support. found bug raise github issue. |
| 81 | + |
| 82 | +.. _documentation: http://forex-python.readthedocs.org/en/latest/?badge=latest |
0 commit comments