Skip to content

Commit b85dd7f

Browse files
author
Ravi kumar
committed
Merge pull request #16 from ravigadila/bitcoin
documentation Bitcoin
2 parents f981fe9 + be627e0 commit b85dd7f

3 files changed

Lines changed: 68 additions & 15 deletions

File tree

README.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,23 @@ Free Foreign exchange rates and currency conversion.
1010
Features:
1111
---------
1212
- List all currency rates.
13+
- BitCoin price for all curuncies.
14+
- Converting amount to BitCoins.
1315
- Get historical rates for any day since 1999.
1416
- Conversion rate for one currency(ex; USD to INR).
15-
- Convert amount from one currency to other.('USD 10$' to INR)
16-
- Currency symbols
17-
- Currency names
17+
- Convert amount from one currency to other.('USD 10$' to INR).
18+
- Currency symbols.
19+
- Currency names.
1820

1921
Currency Source:
2022
---------------
2123
Fixer.io is a free API for current and historical foreign exchange rates published by European Central Bank.
2224
The rates are updated daily 3PM CET.
2325

26+
BitCoin Price Source:
27+
---------------------
28+
Bitcoin prices calculated every minute. For more infomation visit [CoinDesk API](http://www.coindesk.com/api/).
29+
2430
Installation:
2531
------------
2632

@@ -34,7 +40,7 @@ Or directly cloning the repo:
3440
$ python setup.py install
3541
```
3642

37-
Examples:
43+
Usage Examples:
3844
------------------
3945

4046
Initialize class
@@ -49,7 +55,7 @@ list all latest currency rates for "USD"
4955
{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}
5056
```
5157

52-
Get Conversion rate from USD to INR
58+
Get conversion rate from USD to INR
5359
```python
5460
>>> c.get_rate('USD', 'INR')
5561
67.473
@@ -61,19 +67,18 @@ Convert amount from USD to INR:
6167
674.73
6268
```
6369

64-
Convert amount from USD to INR based on 2010-03-01 rates
70+
Get latest Bitcoin price.
6571
```python
66-
>>> import datetime
67-
>>> date_obj = datetime.datetime.strptime('2010-05-10', "%Y-%m-%d").date()
68-
>>> c.convert('EUR', 'USD', 10, date_obj)
69-
12.969
72+
>>> from forex_python.bitcoin import BtcConverter
73+
>>> b = BtcConverter()
74+
>>> b.get_latest_price('USD')
75+
533.913
7076
```
7177

72-
RatesNotAvailableError for invalid currency codes and missing currency code from source:
78+
Convert Amount to Bitcoins based on latest exchange price.
7379
```python
74-
>>> c.get_rate('XYZ', 'INR')
75-
Traceback (most recent call last):
76-
RatesNotAvailableError: Currency XYZ => INR rate not available for Date latest.
80+
>>> b.convert_to_btc(400, 'USD')
81+
0.7492699301118473
7782
```
7883

7984
Get currency symbol using currency code

docs/source/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Free Foreign exchange rates and currency conversion.
66
Features:
77
---------
88
- List all currency rates.
9+
- BitCoin price for all curuncies.
10+
- Converting amount to BitCoins.
911
- Get historical rates for any day since 1999.
1012
- Conversion rate for one currency(ex; USD to INR).
1113
- Convert amount from one currency to other.('USD 10$' to INR)

docs/source/usage.rst

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Currency Rates
1717

1818
3. Get conversion rate from USD to INR::
1919
>>> c.get_rate('USD', 'INR')
20-
67.473
20+
67.473 # return type float
2121

2222
4. Get conversion rate from USD to INR on 2014-05-23::
2323
>>> date_obj
@@ -35,6 +35,52 @@ Currency Rates
3535
>>> c.convert('USD', 'INR', 10, date_obj)
3636
585.09
3737

38+
Bitcoin Prices:
39+
---------------
40+
1. Get latest price of one Bitcoin::
41+
>>> from forex_python.bitcoin import BtcConverter
42+
>>> b = BtcConverter()
43+
>>> b.get_latest_price('EUR')
44+
476.5225 # return type float
45+
46+
2. Get price of Bitcoin based on prevois date::
47+
>>> date_obj
48+
datetime.datetime(2016, 5, 18, 19, 39, 36, 815417)
49+
>>> b.get_previous_price('USD', date_obj)
50+
453.378
51+
52+
3. Convert Amout to bitcoins::
53+
>>> b.convert_to_btc(5000, 'USD')
54+
9.36345369116708
55+
56+
4. Convert Amount to bitcoins based on previous date prices::
57+
>>> date_obj
58+
datetime.datetime(2016, 5, 18, 19, 39, 36, 815417)
59+
>>> b.convert_to_btc_on(5000, 'USD', date_obj)
60+
11.028325150316071
61+
62+
5. Convert Bitcoins to valid currency amount based on lates price::
63+
>>> b.convert_btc_to_cur(1.25, 'USD')
64+
668.1012499999999
65+
66+
6. Convert Bitcoins to valid currency amount based on previous date price::
67+
>>> date_obj
68+
datetime.datetime(2016, 5, 18, 19, 39, 36, 815417)
69+
>>> b.convert_btc_to_cur_on(1.25, 'EUR', date_obj)
70+
504.23625000000004
71+
72+
7. Get list of prices list for given date range::
73+
>>> start_date
74+
datetime.datetime(2016, 5, 18, 19, 39, 36, 815417)
75+
>>> end_date
76+
datetime.datetime(2016, 5, 23, 19, 39, 36, 815417)
77+
>>> b.get_previous_price_list('INR', start_date, end_date)
78+
{u'2016-05-19': 29371.7579, u'2016-05-18': 30402.3169, u'2016-05-22': 29586.3631, u'2016-05-23': 29925.3272, u'2016-05-20': 29864.0256, u'2016-05-21': 29884.7449}
79+
80+
8. Get Bitcoin symbol::
81+
>>> print(b.get_symbol())
82+
฿
83+
3884
Currency Symbols & Codes
3985
-------------------------
4086
1. Get Currency symbol Using currency code::

0 commit comments

Comments
 (0)