URI: 
       tSorted exchange_rate.py - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 4847fe5f41894a9d3c67ed196831dc218ea8afdd
   DIR parent 1c02ced131c2f0cad9aeb5e49f72c2d128912734
  HTML Author: Alexx Saver <lzsaver@users.noreply.github.com>
       Date:   Mon,  5 Jun 2017 13:05:47 +0400
       
       Sorted exchange_rate.py
       
       Notice: no real changes
       
       Diffstat:
         M lib/exchange_rate.py                |     135 ++++++++++++++++++++-----------
       
       1 file changed, 87 insertions(+), 48 deletions(-)
       ---
   DIR diff --git a/lib/exchange_rate.py b/lib/exchange_rate.py
       t@@ -88,6 +88,7 @@ class ExchangeBase(PrintError):
        
        
        class BitcoinAverage(ExchangeBase):
       +
            def get_rates(self, ccy):
                json = self.get_json('apiv2.bitcoinaverage.com', '/indices/global/ticker/short')
                return dict([(r.replace("BTC", ""), Decimal(json[r]['last']))
       t@@ -104,6 +105,17 @@ class BitcoinAverage(ExchangeBase):
                return dict([(h['DateTime'][:10], h['Average'])
                             for h in history])
        
       +
       +class Bitcointoyou(ExchangeBase):
       +
       +    def get_rates(self, ccy):
       +        json = self.get_json('bitcointoyou.com', "/API/ticker.aspx")
       +        return {'BRL': Decimal(json['ticker']['last'])}
       +
       +    def history_ccys(self):
       +        return ['BRL']
       +
       +
        class BitcoinVenezuela(ExchangeBase):
        
            def get_rates(self, ccy):
       t@@ -119,45 +131,58 @@ class BitcoinVenezuela(ExchangeBase):
                return self.get_json('api.bitcoinvenezuela.com',
                                     "/historical/index.php?coin=BTC")[ccy +'_BTC']
        
       -class BTCParalelo(ExchangeBase):
       -
       -    def get_rates(self, ccy):
       -        json = self.get_json('btcparalelo.com', '/api/price')
       -        return {'VEF': Decimal(json['price'])}
       -
       -
       -class Bitso(ExchangeBase):
       -    def get_rates(self, ccy):
       -        json = self.get_json('api.bitso.com', '/v2/ticker')
       -        return {'MXN': Decimal(json['last'])}
       -
        
        class Bitmarket(ExchangeBase):
       +
            def get_rates(self, ccy):
                json = self.get_json('www.bitmarket.pl', '/json/BTCPLN/ticker.json')
                return {'PLN': Decimal(json['last'])}
        
       +
        class BitPay(ExchangeBase):
       +
            def get_rates(self, ccy):
                json = self.get_json('bitpay.com', '/api/rates')
                return dict([(r['code'], Decimal(r['rate'])) for r in json])
        
       +
       +class Bitso(ExchangeBase):
       +
       +    def get_rates(self, ccy):
       +        json = self.get_json('api.bitso.com', '/v2/ticker')
       +        return {'MXN': Decimal(json['last'])}
       +
       +
        class BitStamp(ExchangeBase):
       +
            def get_rates(self, ccy):
                json = self.get_json('www.bitstamp.net', '/api/ticker/')
                return {'USD': Decimal(json['last'])}
        
       +
       +class Bitvalor(ExchangeBase):
       +
       +    def get_rates(self,ccy):
       +        json = self.get_json('api.bitvalor.com', '/v1/ticker.json')
       +        return {'BRL': Decimal(json['ticker_1h']['total']['last'])}
       +
       +
        class BlockchainInfo(ExchangeBase):
       +
            def get_rates(self, ccy):
                json = self.get_json('blockchain.info', '/ticker')
                return dict([(r, Decimal(json[r]['15m'])) for r in json])
        
       +
        class BTCChina(ExchangeBase):
       +
            def get_rates(self, ccy):
                json = self.get_json('data.btcchina.com', '/data/ticker')
                return {'CNY': Decimal(json['ticker']['last'])}
        
       +
        class BTCe(ExchangeBase):
       +
            def get_rates(self, ccy):
                json_eur = self.get_json('btc-e.nz', '/api/3/ticker/btc_eur')
                json_rub = self.get_json('btc-e.nz', '/api/3/ticker/btc_rur')
       t@@ -166,14 +191,25 @@ class BTCe(ExchangeBase):
                        'RUB': Decimal(json_rub['btc_rur']['last']),
                        'USD': Decimal(json_usd['btc_usd']['last'])}
        
       +
       +class BTCParalelo(ExchangeBase):
       +
       +    def get_rates(self, ccy):
       +        json = self.get_json('btcparalelo.com', '/api/price')
       +        return {'VEF': Decimal(json['price'])}
       +
       +
        class Coinbase(ExchangeBase):
       +
            def get_rates(self, ccy):
                json = self.get_json('coinbase.com',
                                     '/api/v1/currencies/exchange_rates')
                return dict([(r[7:].upper(), Decimal(json[r]))
                             for r in json if r.startswith('btc_to_')])
        
       +
        class CoinDesk(ExchangeBase):
       +
            def get_rates(self, ccy):
                dicts = self.get_json('api.coindesk.com',
                                      '/v1/bpi/supported-currencies.json')
       t@@ -199,17 +235,23 @@ class CoinDesk(ExchangeBase):
                json = self.get_json('api.coindesk.com', query)
                return json['bpi']
        
       +
        class Coinsecure(ExchangeBase):
       +
            def get_rates(self, ccy):
                json = self.get_json('api.coinsecure.in', '/v0/noauth/newticker')
                return {'INR': Decimal(json['lastprice'] / 100.0 )}
        
       -class Unocoin(ExchangeBase):
       -    def get_rates(self, ccy):
       -        json = self.get_json('www.unocoin.com', 'trade?buy')
       -        return {'INR': Decimal(json)}
       +
       +class Foxbit(ExchangeBase):
       +
       +    def get_rates(self,ccy):
       +        json = self.get_json('api.bitvalor.com', '/v1/ticker.json')
       +        return {'BRL': Decimal(json['ticker_1h']['exchanges']['FOX']['last'])}
       +
        
        class itBit(ExchangeBase):
       +
            def get_rates(self, ccy):
                ccys = ['USD', 'EUR', 'SGD']
                json = self.get_json('api.itbit.com', '/v1/markets/XBT%s/ticker' % ccy)
       t@@ -218,7 +260,9 @@ class itBit(ExchangeBase):
                    result[ccy] = Decimal(json['lastPrice'])
                return result
        
       +
        class Kraken(ExchangeBase):
       +
            def get_rates(self, ccy):
                ccys = ['EUR', 'USD', 'CAD', 'GBP', 'JPY']
                pairs = ['XBT%s' % c for c in ccys]
       t@@ -227,58 +271,54 @@ class Kraken(ExchangeBase):
                return dict((k[-3:], Decimal(float(v['c'][0])))
                             for k, v in json['result'].items())
        
       +
        class LocalBitcoins(ExchangeBase):
       +
            def get_rates(self, ccy):
                json = self.get_json('localbitcoins.com',
                                     '/bitcoinaverage/ticker-all-currencies/')
                return dict([(r, Decimal(json[r]['rates']['last'])) for r in json])
        
       -class Winkdex(ExchangeBase):
       -    def get_rates(self, ccy):
       -        json = self.get_json('winkdex.com', '/api/v0/price')
       -        return {'USD': Decimal(json['price'] / 100.0)}
       -
       -    def history_ccys(self):
       -        return ['USD']
       -
       -    def historical_rates(self, ccy):
       -        json = self.get_json('winkdex.com',
       -                             "/api/v0/series?start_time=1342915200")
       -        history = json['series'][0]['results']
       -        return dict([(h['timestamp'][:10], h['price'] / 100.0)
       -                     for h in history])
        
        class MercadoBitcoin(ExchangeBase):
       +
            def get_rates(self, ccy):
                json = self.get_json('api.bitvalor.com', '/v1/ticker.json')
                return {'BRL': Decimal(json['ticker_1h']['exchanges']['MBT']['last'])}
        
       -class Bitcointoyou(ExchangeBase):
       -    def get_rates(self, ccy):
       -        json = self.get_json('bitcointoyou.com', "/API/ticker.aspx")
       -        return {'BRL': Decimal(json['ticker']['last'])}
        
       -    def history_ccys(self):
       -        return ['BRL']
       +class NegocieCoins(ExchangeBase):
        
       -class Bitvalor(ExchangeBase):
            def get_rates(self,ccy):
                json = self.get_json('api.bitvalor.com', '/v1/ticker.json')
       -        return {'BRL': Decimal(json['ticker_1h']['total']['last'])}
       +        return {'BRL': Decimal(json['ticker_1h']['exchanges']['NEG']['last'])}
        
       +    def history_ccys(self):
       +        return ['BRL']
        
       -class Foxbit(ExchangeBase):
       -    def get_rates(self,ccy):
       -        json = self.get_json('api.bitvalor.com', '/v1/ticker.json')
       -        return {'BRL': Decimal(json['ticker_1h']['exchanges']['FOX']['last'])}
        
       -class NegocieCoins(ExchangeBase):
       -    def get_rates(self,ccy):
       -        json = self.get_json('api.bitvalor.com', '/v1/ticker.json')
       -        return {'BRL': Decimal(json['ticker_1h']['exchanges']['NEG']['last'])}
       +class Unocoin(ExchangeBase):
       +
       +    def get_rates(self, ccy):
       +        json = self.get_json('www.unocoin.com', 'trade?buy')
       +        return {'INR': Decimal(json)}
       +
       +
       +class Winkdex(ExchangeBase):
       +
       +    def get_rates(self, ccy):
       +        json = self.get_json('winkdex.com', '/api/v0/price')
       +        return {'USD': Decimal(json['price'] / 100.0)}
        
            def history_ccys(self):
       -        return ['BRL']
       +        return ['USD']
       +
       +    def historical_rates(self, ccy):
       +        json = self.get_json('winkdex.com',
       +                             "/api/v0/series?start_time=1342915200")
       +        history = json['series'][0]['results']
       +        return dict([(h['timestamp'][:10], h['price'] / 100.0)
       +                     for h in history])
        
        
        def dictinvert(d):
       t@@ -327,7 +367,6 @@ def get_exchanges_by_ccy(history=True):
            return dictinvert(d)
        
        
       -
        class FxThread(ThreadJob):
        
            def __init__(self, config, network):