def hitbtc_token_status(): url = 'https://hitbtc.com/system-monitor' driver.get(url) elems = driver.find_elements_by_xpath( '/html/body/div[3]/div[2]/div/div/table/tbody/tr') for i, elem in enumerate(elems): try: if elem.find_element_by_xpath('td[2]'): # print('/******************') # print(round(number=(i / len(elems) * 100), ndigits=2), '%', sep=' ', end='', flush=True) token = elem.find_element_by_xpath('td[1]').text deposit = elem.find_element_by_xpath('td[2]').text transfers = elem.find_element_by_xpath('td[5]').text trading = elem.find_element_by_xpath('td[6]').text windrawals = elem.find_element_by_xpath('td[7]').text # print('token:', token, 'deposit:', deposit, 'transfers:', transfers, 'trading:', trading, 'windrawals:', # windrawals) if deposit == 'Online' and transfers == 'Online' and trading == 'Online' and windrawals == 'Online': _query( f"""UPDATE module_hitbtc SET is_active = 't' WHERE symbol = '{token}ETH' or symbol = '{token}BTC' or symbol = '{token}USD' or symbol = 'ETH{token}' or symbol = 'BTC{token}' or symbol = 'USD{token}'""" ) else: _query( f"""UPDATE module_hitbtc SET is_active = 'f' WHERE symbol = '{token}ETH' or symbol = '{token}BTC' or symbol = '{token}USD' or symbol = 'ETH{token}' or symbol = 'BTC{token}' or symbol = 'USD{token}'""" ) # print('******************/') except: pass
def hitbtc_token_status(): url = 'https://hitbtc.com/system-monitor' resp = req.get(url) soup = BeautifulSoup(resp.content, 'html.parser') elems = soup.find_all('tr', class_='table__row') for i, elem in enumerate(elems): tds = elem.find_all('td') try: if len(tds) > 1: # print('/******************') # print(round(number=(i / len(elems) * 100), ndigits=2), '%', sep=' ', end='', flush=True) token = tds[0].text.strip() deposit = tds[1].text.strip() transfers = tds[4].text.strip() trading = tds[5].text.strip() windrawals = tds[6].text.strip() # print('token:', token, 'deposit:', deposit, 'transfers:', transfers, 'trading:', trading, 'windrawals:', # windrawals) if deposit == 'Online' and transfers == 'Online' and trading == 'Online' and windrawals == 'Online': _query(f"""UPDATE module_hitbtc SET is_active = 't' WHERE symbol = '{token}ETH' or symbol = '{token}BTC' or symbol = '{token}USD' or symbol = 'ETH{token}' or symbol = 'BTC{token}' or symbol = 'USD{token}'""") else: _query(f"""UPDATE module_hitbtc SET is_active = 'f' WHERE symbol = '{token}ETH' or symbol = '{token}BTC' or symbol = '{token}USD' or symbol = 'ETH{token}' or symbol = 'BTC{token}' or symbol = 'USD{token}'""") # print('******************/') except: pass
def __bilaxy(self): return _query( """SELECT tp.tsymbol, lower(tp.contract), 'bilaxy' as site, bm.market FROM trusted_pairs tp LEFT JOIN bilaxy_markets bm ON lower(bm.tsymbol) = lower(tp.tsymbol) and tp.contract is not null LEFT JOIN settings_modules ON settings_modules.module_name = 'bilaxy' WHERE tp.is_active is true AND bm.is_active is true and settings_modules.is_active is true;""" )
def __hitbtc(self): return _query( """SELECT tp.tsymbol, lower(tp.contract), 'hitbtc' as site, hm.market FROM trusted_pairs tp LEFT JOIN hitbtc_markets hm ON lower(hm.tsymbol) = lower(tp.tsymbol) and tp.contract is not null LEFT JOIN settings_modules ON settings_modules.module_name = 'hitbtc' WHERE tp.is_active is true AND hm.is_active is true and settings_modules.is_active is true;""" )
def __idex(self): return _query( """SELECT tp.tsymbol, lower(tp.contract), 'idex' as site, im.market FROM trusted_pairs tp LEFT JOIN idex_markets im ON lower(im.tsymbol) = lower(tp.tsymbol) and tp.contract is not null LEFT JOIN settings_modules ON settings_modules.module_name = 'idex' WHERE tp.is_active is true AND im.is_active is true and settings_modules.is_active is true;""" )
def __kyber(self): return _query(''' SELECT tp.tsymbol, lower(tp.contract), 'kyber' as site, mk.exch_direction token, mk.highest_bid sell, mk.lowest_ask buy, mk.volume FROM trusted_pairs tp LEFT JOIN module_kyber mk ON lower(mk.tsymbol) = lower(tp.tsymbol) and tp.contract is not null LEFT JOIN settings_modules ON settings_modules.module_name = 'kyber' WHERE mk.exch_direction is not null and tp.is_active is true AND mk.is_active is true and settings_modules.is_active is true and (mk.highest_bid > 0 or mk.lowest_ask > 0);''')
async def get_bilaxy_depth(symbol, cnt): url = f"https://newapi.bilaxy.com/v1/orderbook?pair={symbol}" socks_url = 'socks5://' + proxys[cnt][2] + ':' + proxys[cnt][3] + '@' + proxys[cnt][0] + ':' + proxys[cnt][1] connector = SocksConnector.from_url(socks_url) try: async with aiohttp.ClientSession(connector=connector) as session: async with session.get(url) as response: html = await response.text() jhtml = json.loads(html) if 'timestamp' in html: return jhtml else: print('bilaxy', symbol, jhtml) if 'Not found pair' in html: _query(f"""UPDATE bilaxy_markets SET "is_active" = 'f' WHERE "market" LIKE '%{symbol}%'""") return None except Exception as exc: print(exc, proxys[cnt]) return None
async def get_hotbit_depth(symbol, cnt): url = f"https://api.hotbit.io/api/v1/order.depth?interval=1e-8&&limit=20&market={symbol}" socks_url = 'socks5://' + proxys[cnt][2] + ':' + proxys[cnt][3] + '@' + proxys[cnt][0] + ':' + proxys[cnt][1] connector = SocksConnector.from_url(socks_url) try: async with aiohttp.ClientSession(connector=connector) as session: async with session.get(url) as response: html = await response.text() jhtml = json.loads(html) if jhtml['error'] is None: return jhtml['result'] elif jhtml['error']: print('hotbit', symbol, jhtml['error']) if 'market not exist' in html: _query(f"""UPDATE hotbit_markets SET "is_active" = 'f' WHERE "market" LIKE '%{symbol}%'""") return None else: return None except Exception as exc: print(exc, proxys[cnt]) return None
def get_uni_2(): # print('start get tokens uniswap_v2: ' + str(datetime.datetime.now())) trusted_tokens = _query( f'''SELECT lower(tp.contract) contract, tp.tsymbol, mu.exch_direction token FROM trusted_pairs tp LEFT JOIN module_uniswap mu ON lower(mu.tsymbol) = lower(tp.tsymbol) and tp.contract is not null LEFT JOIN settings_modules ON settings_modules.module_name = 'uniswap' WHERE mu.exch_direction is not null and tp.is_active is true AND mu.is_active is true AND length(tp.contract) > 40;''') ioloop = asyncio.new_event_loop() asyncio.set_event_loop(ioloop) ioloop.set_default_executor(concurrent.futures.ThreadPoolExecutor(max_workers=200)) ioloop = asyncio.get_event_loop() results = ioloop.run_until_complete(asynchronous(trusted_tokens)) ioloop.close() # print('end get tokens uniswap_v2: ' + str(datetime.datetime.now())) return results