From be627e02431cc4f17e7b9d286461a716e51d6f00 Mon Sep 17 00:00:00 2001 From: ravi Date: Thu, 2 Jun 2016 19:57:15 +0530 Subject: [PATCH] Documentation for bit coins --- README.md | 33 ++++++++++++++++------------- docs/source/index.rst | 2 ++ docs/source/usage.rst | 48 ++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 68 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 70886ee..f17cad5 100644 --- a/README.md +++ b/README.md @@ -10,17 +10,23 @@ Free Foreign exchange rates and currency conversion. Features: --------- - List all currency rates. +- BitCoin price for all curuncies. +- 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 +- Convert amount from one currency to other.('USD 10$' to INR). +- Currency symbols. +- Currency names. Currency Source: --------------- Fixer.io 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 infomation visit [CoinDesk API](http://www.coindesk.com/api/). + Installation: ------------ @@ -34,7 +40,7 @@ Or directly cloning the repo: $ python setup.py install ``` -Examples: +Usage Examples: ------------------ Initialize class @@ -49,7 +55,7 @@ list all latest currency rates for "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 +Get conversion rate from USD to INR ```python >>> c.get_rate('USD', 'INR') 67.473 @@ -61,19 +67,18 @@ Convert amount from USD to INR: 674.73 ``` -Convert amount from USD to INR based on 2010-03-01 rates +Get latest Bitcoin price. ```python ->>> import datetime ->>> date_obj = datetime.datetime.strptime('2010-05-10', "%Y-%m-%d").date() ->>> c.convert('EUR', 'USD', 10, date_obj) -12.969 +>>> from forex_python.bitcoin import BtcConverter +>>> b = BtcConverter() +>>> b.get_latest_price('USD') +533.913 ``` -RatesNotAvailableError for invalid currency codes and missing currency code from source: +Convert Amount to Bitcoins based on latest exchange price. ```python ->>> c.get_rate('XYZ', 'INR') -Traceback (most recent call last): -RatesNotAvailableError: Currency XYZ => INR rate not available for Date latest. +>>> b.convert_to_btc(400, 'USD') +0.7492699301118473 ``` Get currency symbol using currency code diff --git a/docs/source/index.rst b/docs/source/index.rst index 661a8b1..2f54b79 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -6,6 +6,8 @@ Free Foreign exchange rates and currency conversion. Features: --------- - List all currency rates. +- BitCoin price for all curuncies. +- 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) diff --git a/docs/source/usage.rst b/docs/source/usage.rst index c9a6a5b..baf507a 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -17,7 +17,7 @@ Currency Rates 3. Get conversion rate from USD to INR:: >>> c.get_rate('USD', 'INR') - 67.473 + 67.473 # return type float 4. Get conversion rate from USD to INR on 2014-05-23:: >>> date_obj @@ -35,6 +35,52 @@ Currency Rates >>> c.convert('USD', 'INR', 10, date_obj) 585.09 +Bitcoin Prices: +--------------- +1. Get latest price of one Bitcoin:: + >>> from forex_python.bitcoin import BtcConverter + >>> b = BtcConverter() + >>> b.get_latest_price('EUR') + 476.5225 # return type float + +2. Get price of Bitcoin based on prevois date:: + >>> date_obj + datetime.datetime(2016, 5, 18, 19, 39, 36, 815417) + >>> b.get_previous_price('USD', date_obj) + 453.378 + +3. Convert Amout to bitcoins:: + >>> b.convert_to_btc(5000, 'USD') + 9.36345369116708 + +4. Convert Amount to bitcoins 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) + 11.028325150316071 + +5. Convert Bitcoins to valid currency amount based on lates price:: + >>> b.convert_btc_to_cur(1.25, 'USD') + 668.1012499999999 + +6. Convert Bitcoins 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) + 504.23625000000004 + +7. Get list of prices list for given date range:: + >>> start_date + datetime.datetime(2016, 5, 18, 19, 39, 36, 815417) + >>> end_date + datetime.datetime(2016, 5, 23, 19, 39, 36, 815417) + >>> b.get_previous_price_list('INR', start_date, end_date) + {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} + +8. Get Bitcoin symbol:: + >>> print(b.get_symbol()) + ฿ + Currency Symbols & Codes ------------------------- 1. Get Currency symbol Using currency code::