Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
forex-python
============

Free Foreign exchange rates, bitcoin prices and currency conversion.
Free foreign exchange rates, Bitcoin prices and currency conversion.

Features:
---------
- List all currency rates.
- BitCoin price for all currencies.
- Converting amount to BitCoins.
- Bitcoin price for all currencies.
- Converting amount to BitCoin.
- 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
- Conversion rate for one currency (e.g. USD to INR).
- Convert amount from one currency to another (e.g. 'USD $10' to INR)
- Currency symbols
- Currency names

Contents:
Expand Down
14 changes: 7 additions & 7 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,21 @@ Bitcoin Prices:
>>> b.get_previous_price('USD', date_obj) # get_previous_price('USD', date_obj)
453.378

3. Convert Amout to bitcoins::
3. Convert Amount to Bitcoin::
>>> b.convert_to_btc(5000, 'USD') # convert_to_btc(5000, 'USD')
9.36345369116708

4. Convert Amount to bitcoins based on previous date prices::
4. Convert Amount to Bitcoin based on previous date prices::
>>> date_obj
datetime.datetime(2016, 5, 18, 19, 39, 36, 815417)
>>> b.convert_to_btc_on(5000, 'USD', date_obj) # convert_to_btc_on(5000, 'USD', date_obj)
11.028325150316071

5. Convert Bitcoins to valid currency amount based on latest price::
5. Convert Bitcoin to valid currency amount based on latest price::
>>> b.convert_btc_to_cur(1.25, 'USD') # convert_btc_to_cur(1.25, 'USD')
668.1012499999999

6. Convert Bitcoins to valid currency amount based on previous date price::
6. Convert Bitcoin to valid currency amount based on previous date price::
>>> date_obj
datetime.datetime(2016, 5, 18, 19, 39, 36, 815417)
>>> b.convert_btc_to_cur_on(1.25, 'EUR', date_obj)
Expand All @@ -106,7 +106,7 @@ Bitcoin Prices:

Currency Symbols & Codes
-------------------------
1. Get Currency symbol Using currency code::
1. Get currency symbol using currency code::
>>> from forex_python.converter import CurrencyCodes
>>> c = CurrencyCodes()
>>> c.get_symbol('GBP')
Expand All @@ -116,8 +116,8 @@ Currency Symbols & Codes
>>> print c.get_symbol('EUR')

2. Get Currency Name using currency code::
2. Get currency name using currency code::
>>> c.get_currency_name('EUR')
u'European Euro'
>>> c.get_currency_name('INR')
u'Indian rupee'
u'Indian Rupee'
22 changes: 11 additions & 11 deletions forex_python/bitcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class BtcConverter(object):
"""
Get bit coin rates and convertion
Get Bitcoin rates and conversion
"""
def __init__(self, force_decimal=False):
self._force_decimal = force_decimal
Expand All @@ -20,7 +20,7 @@ def _decode_rates(self, response, use_decimal=False):

def get_latest_price(self, currency):
"""
Get Lates price of one bitcoin to valid Currency 1BTC => X USD
Get latest price of one Bitcoin to valid currency 1BTC => X USD
"""
url = 'https://api.coindesk.com/v1/bpi/currentprice/{}.json'.format(currency)
response = requests.get(url)
Expand All @@ -34,7 +34,7 @@ def get_latest_price(self, currency):

def get_previous_price(self, currency, date_obj):
"""
Get Price for one bit coin on given date
Get price for one Bitcoin on given date
"""
start = date_obj.strftime('%Y-%m-%d')
end = date_obj.strftime('%Y-%m-%d')
Expand All @@ -55,7 +55,7 @@ def get_previous_price(self, currency, date_obj):

def get_previous_price_list(self, currency, start_date, end_date):
"""
Get List of prices between two dates
Get list of Bitcoin prices between two dates
"""
start = start_date.strftime('%Y-%m-%d')
end = end_date.strftime('%Y-%m-%d')
Expand All @@ -74,7 +74,7 @@ def get_previous_price_list(self, currency, start_date, end_date):

def convert_to_btc(self, amount, currency):
"""
Convert X amount to Bit Coins
Convert X amount to Bitcoin
"""
if isinstance(amount, Decimal):
use_decimal = True
Expand All @@ -98,7 +98,7 @@ def convert_to_btc(self, amount, currency):

def convert_btc_to_cur(self, coins, currency):
"""
Convert X bit coins to valid currency amount
Convert X Bitcoin to valid currency amount
"""
if isinstance(coins, Decimal):
use_decimal = True
Expand All @@ -122,7 +122,7 @@ def convert_btc_to_cur(self, coins, currency):

def convert_to_btc_on(self, amount, currency, date_obj):
"""
Convert X amount to BTC based on given date rate
Convert X amount to Bitcoin based on a given date's rate
"""
if isinstance(amount, Decimal):
use_decimal = True
Expand All @@ -149,11 +149,11 @@ def convert_to_btc_on(self, amount, currency, date_obj):
return converted_btc
except TypeError:
raise DecimalFloatMismatchError("convert_to_btc_on requires amount parameter is of type Decimal when force_decimal=True")
raise RatesNotAvailableError("BitCoin Rates Source Not Ready For Given Date")
raise RatesNotAvailableError("Bitcoin rates source not ready for given date")

def convert_btc_to_cur_on(self, coins, currency, date_obj):
"""
Convert X BTC to valid currency amount based on given date
Convert X Bitcoin to valid currency amount based on given's date rate
"""
if isinstance(coins, Decimal):
use_decimal = True
Expand All @@ -180,11 +180,11 @@ def convert_btc_to_cur_on(self, coins, currency, date_obj):
return converted_btc
except TypeError:
raise DecimalFloatMismatchError("convert_btc_to_cur_on requires amount parameter is of type Decimal when force_decimal=True")
raise RatesNotAvailableError("BitCoin Rates Source Not Ready For Given Date")
raise RatesNotAvailableError("Bitcoin rates source not ready for given date")

def get_symbol(self):
"""
Here is Unicode symbol for bitcoin
Here is the Unicode symbol for Bitcoin:
"""
return "\u0E3F"

Expand Down
2 changes: 1 addition & 1 deletion forex_python/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class RatesNotAvailableError(Exception):
"""
Custome Exception when https://theforexapi.com is Down and not available for currency rates
Custom exception when https://theforexapi.com is down and not available for currency rates
"""
pass

Expand Down
14 changes: 7 additions & 7 deletions tests/test_bitcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def test_previous_price_list_with_invalid_currency(self):

class TestConvertBtc(TestCase):
"""
Test Converting amount to Bit coins
Test converting amount to Bitcoin
"""
def test_convet_to_btc_with_valid_currency(self):
coins = convert_to_btc(250, 'USD')
Expand All @@ -67,7 +67,7 @@ def test_convet_to_btc_with_invalid_currency(self):

class TestConvertBtcToCur(TestCase):
"""
Convert Bit Coins to Valid Currency amount
Convert Bitcoin to valid currency amount
"""
def test_convert_btc_to_cur_valid_currency(self):
amount = convert_btc_to_cur(2, 'USD')
Expand All @@ -79,7 +79,7 @@ def test_convert_btc_to_cur_invalid_currency(self):

class TestConvertToBtcOn(TestCase):
"""
Convert To bit coin based on previous dates
Convert to Bitcoin based on previous date
"""
def test_convert_to_btc_on_with_valid_currency(self):
date_obj = datetime.datetime.today() - datetime.timedelta(days=15)
Expand All @@ -93,7 +93,7 @@ def test_convert_to_btc_on_with_invalid_currency(self):

class TestConvertBtcToCurOn(TestCase):
"""
Convert BitCoins to valid Currency
Convert Bitcoin to valid currency
"""
def test_convert_to_btc_on_with_valid_currency(self):
date_obj = datetime.datetime.today() - datetime.timedelta(days=15)
Expand All @@ -107,7 +107,7 @@ def test_convert_to_btc_on_with_invalid_currency(self):

class TestBitCoinSymbol(TestCase):
"""
Bit Coin symbol
Bitcoin symbol
"""
def test_bitcoin_symbol(self):
self.assertEqual(get_btc_symbol(), "\u0E3F")
Expand Down Expand Up @@ -218,11 +218,11 @@ def test_previous_price_list_with_invalid_currency(self):
self.assertFalse(price_list)
self.assertEqual(type(price_list), dict)

def test_convet_to_btc_with_valid_currency(self):
def test_convert_to_btc_with_valid_currency(self):
coins = self.b.convert_to_btc(Decimal('250'), 'USD')
self.assertEqual(type(coins), Decimal)

def test_convet_to_btc_with_invalid_currency(self):
def test_convert_to_btc_with_invalid_currency(self):
self.assertRaises(RatesNotAvailableError, self.b.convert_to_btc, Decimal('250'), 'XYZ')

def test_convert_btc_to_cur_valid_currency(self):
Expand Down