Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e64dedc

Browse files
Merge pull request #157 from MicroPyramid/dev
Dev
2 parents 679c096 + 6433f0a commit e64dedc

File tree

6 files changed

+144
-191
lines changed

6 files changed

+144
-191
lines changed

‎README.md‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# forex-python
2+
3+
[![travis-ci](https://travis-ci.org/MicroPyramid/forex-python.svg?branch=master)](https://travis-ci.org/MicroPyramid/forex-python)
4+
[![coveralls](https://coveralls.io/repos/github/MicroPyramid/forex-python/badge.svg?branch=master)](https://coveralls.io/github/MicroPyramid/forex-python?branch=master)
5+
[![Code Health](https://landscape.io/github/MicroPyramid/forex-python/master/landscape.svg?style=flat)](https://landscape.io/github/MicroPyramid/forex-python/master)
6+
[![pypi](https://img.shields.io/badge/python-3.6%2B-blue.svg)](https://pypi.python.org/pypi/forex-python)
7+
8+
**Forex Python** is a free library for foreign exchange rates and currency conversion, supporting Python 3.6 and above.
9+
10+
> **Note:** Install the latest version (`forex-python>=1.6`) to avoid `RatesNotAvailableError`.
11+
12+
## Features
13+
14+
- List all currency rates
15+
- Bitcoin price for all currencies
16+
- Convert amounts to and from Bitcoin
17+
- Get historical rates (since 1999)
18+
- Currency conversion (e.g., USD to INR)
19+
- Currency symbols and names
20+
21+
## Currency Source
22+
23+
[theratesapi.com](https://theratesapi.com) provides current and historical foreign exchange rates published by the European Central Bank. Rates are updated daily at 3PM CET.
24+
25+
## Bitcoin Price Source
26+
27+
Bitcoin prices are updated every minute. For more information, visit [CoinDesk](http://www.coindesk.com).
28+
29+
## Installation
30+
31+
Install via pip:
32+
```bash
33+
pip install forex-python
34+
```
35+
Or clone the repository and install manually:
36+
```bash
37+
git clone https://github.com/MicroPyramid/forex-python.git
38+
cd forex-python
39+
python3 setup.py install
40+
```
41+
42+
## Usage Examples
43+
44+
**Initialize the class:**
45+
```python
46+
from forex_python.converter import CurrencyRates
47+
c = CurrencyRates()
48+
```
49+
50+
**List all latest currency rates for "USD":**
51+
```python
52+
c.get_rates('USD')
53+
# Example output: {'INR': 83.12, 'EUR': 0.92, ...}
54+
```
55+
56+
**Get conversion rate from USD to INR:**
57+
```python
58+
c.get_rate('USD', 'INR')
59+
# Example output: 83.12
60+
```
61+
62+
**Convert amount from USD to INR:**
63+
```python
64+
c.convert('USD', 'INR', 10)
65+
# Example output: 831.2
66+
```
67+
68+
**Force use of Decimal:**
69+
```python
70+
from decimal import Decimal
71+
c = CurrencyRates(force_decimal=True)
72+
c.convert('USD', 'INR', Decimal('10.45'))
73+
# Example output: 868.75
74+
```
75+
76+
**Get latest Bitcoin price:**
77+
```python
78+
from forex_python.bitcoin import BtcConverter
79+
b = BtcConverter()
80+
b.get_latest_price('USD')
81+
# Example output: 67000.0
82+
```
83+
84+
**Convert amount to Bitcoins:**
85+
```python
86+
b.convert_to_btc(400, 'USD')
87+
# Example output: 0.00597
88+
```
89+
90+
**Get currency symbol using currency code:**
91+
```python
92+
from forex_python.converter import CurrencyCodes
93+
codes = CurrencyCodes()
94+
codes.get_symbol('GBP')
95+
# Example output: '£'
96+
```
97+
98+
For complete documentation, see the [forex-python docs](http://forex-python.readthedocs.org/en/latest/?badge=latest).
99+
100+
---
101+
102+
## Support & Feedback
103+
104+
- Found a bug? Please [open a GitHub issue](https://github.com/MicroPyramid/forex-python/issues).
105+
- Need a new feature or custom development? [Contact us here](https://micropyramid.com/contact-us/).
106+
- Visit our [Python Development Services](https://micropyramid.com/python-development-services/) page for more information.
107+
108+
---

‎README.rst‎

Lines changed: 0 additions & 162 deletions
This file was deleted.

‎docs/source/conf.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
# built documents.
6060
#
6161
# The short X.Y version.
62-
version = u'1.6'
62+
version = u'1.9.2'
6363
# The full version, including alpha/beta/rc tags.
64-
release = u'1.6'
64+
release = u'1.9.2'
6565

6666
# The language for content autogenerated by Sphinx. Refer to documentation
6767
# for a list of supported languages.

‎docs/source/currencysource.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
currency source
22
===============
33

4-
https://theforexapi.com
4+
https://theratesapi.com
55
--------
6-
https://theforexapi.com is a free API for current and historical foreign exchange rates published by European Central Bank. The rates are updated daily 3PM CET.
6+
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.
77

88
List of Supported Currency codes.
99
---------------------------------

‎forex_python/converter.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ def convert(self, base_cur, dest_cur, amount, date_obj=None):
9999
if not rate:
100100
raise RatesNotAvailableError("Currency {0} => {1} rate not available for Date {2}.".format(
101101
source_url, dest_cur, date_str))
102+
# Ensure rate is numeric
103+
if isinstance(rate, str):
104+
rate = Decimal(rate) if use_decimal else float(rate)
102105
try:
103106
converted_amount = rate * amount
104107
return converted_amount

‎setup.py‎

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,51 @@
22
import os
33
from setuptools import setup, find_packages
44

5-
VERSION = '1.6'
6-
long_description_text = """Forex Python is a Free Foreign exchange rates and currency conversion.
7-
Features:
8-
List all currency rates.
9-
BitCoin price for all curuncies.
10-
Converting amount to BitCoins.
11-
Get historical rates for any day since 1999.
12-
Conversion rate for one currency(ex; USD to INR).
13-
Convert amount from one currency to other.('USD 10$' to INR).
14-
Currency symbols.
15-
Currency names.
5+
# 1) Bump this version each release:
6+
VERSION = '1.9.2'
167

17-
Documentation: http://forex-python.readthedocs.io/en/latest/usage.html
18-
GitHub: https://github.com/MicroPyramid/forex-python
19-
20-
"""
8+
# 2) Pull your README.md in as long_description:
9+
here=os.path.abspath(os.path.dirname(__file__))
10+
withio.open(os.path.join(here, 'README.md'), encoding='utf-8') asf:
11+
long_description=f.read()
2112

2213
setup(
2314
name='forex-python',
2415
version=VERSION,
2516
author='Micro Pyramid Informatic Pvt. Ltd.',
2617
author_email='hello@micropyramid.com',
18+
description='Free foreign exchange rates and currency conversion.',
19+
long_description=long_description,
20+
long_description_content_type='text/markdown', # so PyPI renders your README properly
2721
url='https://github.com/MicroPyramid/forex-python',
28-
description='Foreign exchange rates and currency conversion.',
29-
long_description=long_description_text,
30-
packages=find_packages(exclude=['tests', 'tests.*']),
22+
packages=find_packages(exclude=['tests*']),
3123
include_package_data=True,
3224
install_requires=[
33-
'requests',
34-
'simplejson',
25+
'requests>=2.0',
26+
'simplejson>=3.0',
3527
],
28+
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4',
3629
classifiers=[
30+
# audience
3731
'Intended Audience :: Developers',
38-
'Operating System :: OS Independent',
32+
'Topic :: Software Development :: Internationalization',
33+
# license
3934
'License :: OSI Approved :: MIT License',
35+
# OS
36+
'Operating System :: OS Independent',
37+
# languages
4038
'Programming Language :: Python',
4139
'Programming Language :: Python :: 2.7',
4240
'Programming Language :: Python :: 3',
43-
'Programming Language :: Python :: 3.3',
44-
'Programming Language :: Python :: 3.4',
45-
'Programming Language :: Python :: 3.5',
46-
'Topic :: Software Development :: Internationalization',
41+
'Programming Language :: Python :: 3.6',
42+
'Programming Language :: Python :: 3.7',
43+
'Programming Language :: Python :: 3.8',
44+
'Programming Language :: Python :: 3.9',
45+
'Programming Language :: Python :: 3.10',
4746
],
47+
project_urls={ # these show up as "Project Links" on PyPI
48+
'Documentation': 'https://forex-python.readthedocs.io/',
49+
'Source': 'https://github.com/MicroPyramid/forex-python',
50+
'Tracker': 'https://github.com/MicroPyramid/forex-python/issues',
51+
},
4852
)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /