def get_current_ask(cls, ccy, btc_amount=0.1): ''' method for testing current ask price ''' url = cls.TICKER_URL.format(ccy) data = get_response(url, ccy) level = cls._pick_level(btc_amount) if btc_amount > 0 else 'small' price = str(data[level]['ask']) return apply_format(price)
def _current_ticker_extractor(cls, ccy, data, btc_amount=0): ''' method for testing current ticker ''' url = cls.TICKER_URL.format(ccy) data = get_response(url, ccy) level = cls._pick_level(btc_amount) if btc_amount > 0 else 'small' ask = apply_format(str(data[level]['ask'])) bid = apply_format(str(data[level]['bid'])) return Ticker(ccy, bid, ask).toJSON()
def get_current_orders(cls, ccy=None, params=None, body=None, max_qty=5): ''' Method for retrieving current orders ''' data = get_response(cls.ORDER_BOOK_URL, ccy, params, body) return cls._current_orders_extractor(data, max_qty)
def get_current_price(cls, ccy): ''' method for testing last price ''' url = cls.TICKER_URL.format(ccy) data = get_response(url, ccy) price = str(data['index']) return apply_format(price)
def get_current_ticker(cls, ccy=None, params=None, body=None): ''' Method for retrieving current ticker ''' data = get_response(cls.TICKER_URL, ccy, params, body) return cls._current_ticker_extractor(data)
def get_current_ask(cls, ccy=None, params=None, body=None): ''' Method for retrieving current ask price ''' data = get_response(cls.TICKER_URL, ccy, params, body) return cls._current_ask_extractor(data)
def get_current_price(cls, ccy=None, params=None, body=None): ''' Method for retrieving last price ''' url = cls.PRICE_URL if hasattr(cls, 'PRICE_URL') and cls.PRICE_URL is not None else cls.TICKER_URL data = get_response(url, ccy, params, body) return cls._current_price_extractor(data)
def _get_historical_data(cls, start, end=None): """ Method for retrieving historical data """ if not end: end = start url = "https://api.coindesk.com/v1/bpi/historical/close.json" "?start={}&end={}".format(start, end) return get_response(url, None)
def get_current_price(cls, ccy=base.CCY_DEFAULT): """ Method for retrieving current price """ url = "https://api.coindesk.com/v1/bpi/currentprice/%s.json" data = get_response(url, ccy) price = data["bpi"][ccy]["rate"] return apply_format(price)