def __init__(self): self._base_cur = ['USDT'] self._sec_base_cur = [ 'USDT', 'BTC', 'ETH', 'BNB', 'LTC', 'NEO', 'XMR', 'USD' ] self._session = requests.Session() self._base_url = "https://api.binance.com" self._marketcap = Pmarket.Pymarketcap() self._exchange = self._marketcap.exchange('binance') self._currencies_symbol = [] self._Error_stat = {}
def get_need_volumes(volume_threshold_usd): coinmarketcap = pymarketcap.Pymarketcap() volume_coin_threshold = {} tickers = retry_call(coinmarketcap.ticker, tries=10, delay=0.5) for ticker in tickers: coin = ticker['symbol'] value = ticker['price_usd'] price_usd = float(1e-9 if not value else float(value)) need_volume = volume_threshold_usd / price_usd volume_coin_threshold[coin] = need_volume return volume_coin_threshold
def get_conversion(BASE_CURRENCIES, FIAT): conversion = {} coinmarketcap = pymarketcap.Pymarketcap() for base in BASE_CURRENCIES: if base in FIAT: continue ticker = retry_call(coinmarketcap.ticker, fargs=[base], tries=10, delay=0.5) price_usd = ticker['price_usd'] conversion[base + '_' + 'USD'] = float(price_usd) conversion.update({'USD_USD': 1}) conversion.update({'CNY_USD': 0.15}) return conversion
def __init__(self, api_key=None, api_secret=None): self._api_key = api_key self._api_secret = api_secret self._base_cur = ['USDT'] self._sec_base_cur = [ 'USD', 'USDT', 'BTC', 'ETH', 'BNB', 'LTC', 'NEO', 'XMR' ] self._base_url = "https://bittrex.com/api/v1.1/" self._session = requests.Session() self._pymarket = Pmarket.Pymarketcap().exchange('bittrex') self._currencies = self._session.get(self._base_url + "public/getcurrencies").json() self._currencies_symbol = [] self._currencies_markets = [] if self._currencies['success'] == True: for index in self._currencies['result']: self._currencies_symbol.append(index['Currency'])
def __init__(self, api_key=None, api_secret=None): self._api_key = api_key self._api_secret = api_secret self._base_cur = ['USDT'] self._sec_base_cur = [ 'USD', 'USDT', 'BTC', 'ETH', 'BNB', 'LTC', 'NEO', 'XMR' ] self._base_url = "https://api.hitbtc.com/api/2" self._session = requests.Session() self._pymarket = Pmarket.Pymarketcap().exchange('hitbtc') self._currencies = self._session.get(self._base_url + "/public/currency").json() self._currencies_symbol = [] self._currencies_markets = [] self._Error_stat = {} for index in self._currencies: self._currencies_symbol.append(index['id'])
def get_markets(coin, volume_threshold): cm = pymarketcap.Pymarketcap() print('Processing %s' % coin) try: cm_markets = cm.markets(coin) except: print('Failed to process') return [] result = [] for market in cm_markets: value = market['24h_volume_usd'] volume = float(0 if value is None else value) if volume > volume_threshold: result.append({ 'pair': market['pair'], 'exchange': market['source'].lower() }) return result
def find_arb(coin, min_exchange_percentage_volume=1, filter_exchanges=[], notify_percentage=5, logger=logging.getLogger(__name__)): ''' For each coin, look for coinmarketcap /#markets page to see if there is arb opportunity Parameters: coin: Name of coin in short: i.e. BTC min_exchange_percentage_volume: only look for exchange pairs with this much volume filter_exchanges: List of exchanges that you can access. notify_percentage: log percentage diff > x ''' cmc = pymarketcap.Pymarketcap() df = pd.DataFrame(cmc.markets(coin)) if len(filter_exchanges) > 0: df = df[df['exchange'].isin(filter_exchanges)] df = df[df['updated'] == True] df = df[df['percent_volume'] > min_exchange_percentage_volume] # if diff more than 3%, notify max_difference = float(df['price_usd'].max() - df['price_usd'].min()) / float( df['price_usd'].median()) * 100 if max_difference > notify_percentage: print(f"{round(max_difference, 2)}% diff in {coin}") logger.info(f"{round(max_difference, 2)}% diff in {coin}") df = df.reset_index(drop=True) res = pd.DataFrame([ df.iloc[df['price_usd'].idxmax()], df.iloc[df['price_usd'].idxmin()] ]) print(f"\n{res.to_string()}") logger.info(f"\n{res.to_string()}")
def __init__(self): self._All_exchanges = [ "Binance", "Bitfinex", "Hitbtc", "Poloniex", "Bittrex", "Cryptopia" ] self._Market_system = pymarketcap.Pymarketcap() self._exchanges_data = []