Example #1
0
 def get_current_price(cls, currency='USD'):
     url = 'https://api.coindesk.com/v1/bpi/currentprice/{}.json'.format(
         currency
     )
     data = get_response(url)
     price = data['bpi'][currency]['rate']
     return Decimal(price)
Example #2
0
 def get_current_price(cls, currency='USD'):
     url = 'https://api.coindesk.com/v1/bpi/currentprice/{}.json'.format(
         currency
     )
     data = get_response(url)
     price = data['bpi'][currency]['rate_float']
     return Decimal(price)
Example #3
0
 def _get_historical_data(cls, start, end=None):
     if not end:
         end = start
     url = (
         'https://api.coindesk.com/v1/bpi/historical/close.json'
         '?start={}&end={}'.format(
             start, end
         )
     )
     return get_response(url)
Example #4
0
 def _get_historical_data(cls, start, end=None):
     if not end:
         end = start
     url = (
         'https://api.coindesk.com/v1/bpi/historical/close.json'
         '?start={}&end={}'.format(
             start, end
         )
     )
     return get_response(url)
Example #5
0
 def refresh(self, callback=None, client_data=None):
     self.data = get_response(self.ticker_url)
     if callback is not None:
         callback(self, client_data)
Example #6
0
 def get_current_ask(cls, currency='USD', btc_amount=0.1):
     url = cls.TICKER_URL.format(currency)
     data = get_response(url)
     level = cls._pick_level(btc_amount) if btc_amount > 0 else 'small'
     price = str(data[level]['ask'])
     return Decimal(price)
Example #7
0
 def get_current_price(cls, currency='USD'):
     url = cls.TICKER_URL.format(currency)
     data = get_response(url)
     price = str(data['index'])
     return Decimal(price)
Example #8
0
 def _get_current_price(cls, currency='USD', price_type='spot'):
     url = cls.TICKER_URL.format(currency, price_type)
     data = get_response(url)
     price = data.get('data').get('amount')
     return Decimal(price)
Example #9
0
 def get_current_ask(cls, pair=''):
     data = get_response(cls.DEPTH_URL % cls.PAIR)
     price = data['result'][cls.PAIR]['asks'][0][0]
     return Decimal(str(price))
Example #10
0
 def get_current_ask(cls, pair='XXBTZUSD'):
     data = get_response(cls.DEPTH_URL % pair)
     price = data['result'][pair]['asks'][0][0]
     return Decimal(str(price))
Example #11
0
 def get_current_price(cls, pair='XXBTZUSD'):
     data = get_response(cls.TICKER_URL %  pair)
     price = data['result'][pair][-1][0]
     return Decimal(str(price))
 def get_current_ask(cls, pair='XXBTZUSD'):
     data = get_response(cls.DEPTH_URL % pair)
     price = data['result'][pair]['asks'][0][0]
     return Decimal(str(price))
 def get_current_price(cls, pair='XXBTZUSD'):
     data = get_response(cls.TICKER_URL % pair)
     price = data['result'][pair][-1][0]
     return Decimal(str(price))
Example #14
0
 def get_current_price(cls, currency='USD'):
     url = cls.TICKER_URL.format(currency)
     data = get_response(url)
     price = str(data['index'])
     return Decimal(price)
 def refresh(self, callback=None, client_data=None):
     self.data = get_response(self.ticker_url)
     if callback is not None:
         callback(self, client_data)
Example #16
0
 def get_current_ask(cls, currency='USD', btc_amount=0.1):
     url = cls.TICKER_URL.format(currency)
     data = get_response(url)
     level = cls._pick_level(btc_amount) if btc_amount > 0 else 'small'
     price = str(data[level]['ask'])
     return Decimal(price)
Example #17
0
 def get_current_price(cls, pair=''):
     data = get_response(cls.TICKER_URL % cls.PAIR)
     price = data['result'][cls.PAIR][-1][0]
     return Decimal(str(price))