Ejemplo n.º 1
0
 def filter_symbols(self):
     raw_pair = self._pair
     self._pair = [
         filter_bit_symbol(j)
         for j in [filter_prefix_symbol(i) for i in raw_pair]
     ]
     debug(self._pair)
Ejemplo n.º 2
0
def get_gecko_price(**kwargs):
    price = None
    for key, value in list(kwargs.items()):
        debug("The value of {} is {}".format(key, value))  # debug
        if key == "pair_":
            price = get_gecko_price_by_pair(value)
        elif key == "symbol_":
            pair = split_pair(value)  # pair=[quote, base]
            price = get_gecko_price_by_pair(pair)
    return price
Ejemplo n.º 3
0
def _get_market_price(base, quote):
    try:
        coin_list = asyncio.get_event_loop().run_until_complete(get_json(GECKO_COINS_URL + 'list'))
        quote_name = check_gecko_symbol_exists(coin_list, quote.lower())
        lookup_pair = "?vs_currency=" + base.lower() + "&ids=" + quote_name
        market_url = GECKO_COINS_URL + 'markets' + lookup_pair
        debug(market_url)
        ticker = asyncio.get_event_loop().run_until_complete(get_json(market_url))
        current_price = None
        for entry in ticker:
            current_price = entry['current_price']
            high_24h = entry['high_24h']
            low_24h = entry['low_24h']
            total_volume = entry['total_volume']
        return current_price
    except TypeError:
        return None
Ejemplo n.º 4
0
def get_gecko_price_by_pair(pair):
    current_price = None
    try:
        quote = pair[0]
        base = pair[1]
        current_price = _get_market_price(base, quote)
        if current_price is None:  # Try inverted version
            debug("Trying pair inversion...")
            current_price = _get_market_price(quote, base)
            debug(base + '/' + quote, str(current_price))
            if current_price is not None:  # Re-invert price
                actual_price = 1 / current_price
                debug(quote + '/' + base, str(actual_price))
                current_price = actual_price
        else:
            debug(pair, current_price)
    except Exception as e:
        print(type(e).__name__, e.args, str(e))
    return current_price
Ejemplo n.º 5
0
 def _get_center_price(self):
     symbol = self._symbol
     price = None
     if self._exchange not in self._alt_exchanges:
         price = get_ccxt_price(symbol, self._exchange)
         debug('Use ccxt exchange {} symbol {} price: {}'.format(self.exchange, symbol, price))
     elif self._exchange == 'gecko':
         price = get_gecko_price(symbol_=symbol)
         debug('Use ccxt exchange {} symbol {} price: {}'.format(self.exchange, symbol, price))
     elif self._exchange == 'waves':
         price = get_waves_price(symbol_=symbol)
         debug('Use waves exchange {} symbol {} price: {}'.format(self.exchange, symbol, price))
     return price
Ejemplo n.º 6
0
 def _get_center_price(self):
     symbol = self._symbol
     price = None
     if self._exchange not in self._alt_exchanges:
         price = get_ccxt_price(symbol, self._exchange)
         debug("use ccxt exchange ", self._exchange, ' symbol ', symbol,
               ' price:', price)
     elif self._exchange == 'gecko':
         price = get_gecko_price(symbol_=symbol)
         debug("gecko exchange - ", self._exchange, ' symbol ', symbol,
               ' price:', price)
     elif self._exchange == 'waves':
         price = get_waves_price(symbol_=symbol)
         debug("use waves -", self._exchange, ' symbol ', symbol, ' price:',
               price)
     return price