def scout(client: Client, transaction_fee=0.001, multiplier=5): ''' Scout for potential jumps from the current coin to another coin ''' all_tickers = get_all_market_tickers(client) current_coin = get_current_coin() current_coin_price = get_market_ticker_price_from_list(all_tickers, current_coin + BRIDGE) if current_coin_price is None: logger.info("Skipping scouting... current coin {0} not found".format(current_coin + BRIDGE)) return for pair in get_pairs_from(current_coin): if not pair.to_coin.enabled: continue optional_coin_price = get_market_ticker_price_from_list(all_tickers, pair.to_coin + BRIDGE) if optional_coin_price is None: logger.info("Skipping scouting... optional coin {0} not found".format(pair.to_coin + BRIDGE)) continue # Obtain (current coin)/(optional coin) coin_opt_coin_ratio = current_coin_price / optional_coin_price if (coin_opt_coin_ratio - transaction_fee * multiplier * coin_opt_coin_ratio) > pair.ratio: logger.info('Will be jumping from {0} to {1}'.format( current_coin, pair.to_coin)) transaction_through_tether( client, current_coin, pair.to_coin) break
def scout(client: BinanceAPIManager, transaction_fee=0.001, multiplier=5): ''' Scout for potential jumps from the current coin to another coin ''' all_tickers = client.get_all_market_tickers() current_coin = get_current_coin() #Display on the console, the current coin+Bridge, so users can see *some* activity and not thinkg the bot has stopped. Not logging though to reduce log size. print( str(datetime.datetime.now()) + " - CONSOLE - INFO - I am scouting the best trades. Current coin: {0} " .format(current_coin + BRIDGE), end='\r') current_coin_price = get_market_ticker_price_from_list( all_tickers, current_coin + BRIDGE) if current_coin_price is None: logger.info("Skipping scouting... current coin {0} not found".format( current_coin + BRIDGE)) return ratio_dict: Dict[Pair, float] = {} for pair in get_pairs_from(current_coin): if not pair.to_coin.enabled: continue optional_coin_price = get_market_ticker_price_from_list( all_tickers, pair.to_coin + BRIDGE) if optional_coin_price is None: logger.info( "Skipping scouting... optional coin {0} not found".format( pair.to_coin + BRIDGE)) continue log_scout(pair, pair.ratio, current_coin_price, optional_coin_price) # Obtain (current coin)/(optional coin) coin_opt_coin_ratio = current_coin_price / optional_coin_price # save ratio so we can pick the best option, not necessarily the first ratio_dict[pair] = (coin_opt_coin_ratio - transaction_fee * multiplier * coin_opt_coin_ratio) - pair.ratio # keep only ratios bigger than zero ratio_dict = {k: v for k, v in ratio_dict.items() if v > 0} # if we have any viable options, pick the one with the biggest ratio if ratio_dict: best_pair = max(ratio_dict, key=ratio_dict.get) logger.info('Will be jumping from {0} to {1}'.format( current_coin, best_pair.to_coin_id)) transaction_through_tether(client, best_pair, all_tickers)
def scout(client: BinanceAPIManager, transaction_fee=0.001, multiplier=5): ''' Scout for potential jumps from the current coin to another coin ''' all_tickers = client.get_all_market_tickers() current_coin = get_current_coin() current_coin_price = get_market_ticker_price_from_list( all_tickers, current_coin + BRIDGE) if current_coin_price is None: logger.info("Skipping scouting... current coin {0} not found".format( current_coin + BRIDGE)) return ratio_dict: Dict[Pair, float] = {} for pair in get_pairs_from(current_coin): if not pair.to_coin.enabled: continue optional_coin_price = get_market_ticker_price_from_list( all_tickers, pair.to_coin + BRIDGE) if optional_coin_price is None: logger.info( "Skipping scouting... optional coin {0} not found".format( pair.to_coin + BRIDGE)) continue log_scout(pair, pair.ratio, current_coin_price, optional_coin_price) # Obtain (current coin)/(optional coin) coin_opt_coin_ratio = current_coin_price / optional_coin_price # save ratio so we can pick the best option, not necessarily the first ratio_dict[pair] = (coin_opt_coin_ratio - transaction_fee * multiplier * coin_opt_coin_ratio) - pair.ratio # keep only ratios bigger than zero ratio_dict = {k: v for k, v in ratio_dict.items() if v > 0} # if we have any viable options, pick the one with the biggest ratio if ratio_dict: best_pair = max(ratio_dict, key=ratio_dict.get) logger.info('Will be jumping from {0} to {1}'.format( current_coin, best_pair.to_coin_id)) transaction_through_tether(client, best_pair, all_tickers)
def scout(client: Client, transaction_fee=0.001, multiplier=5): ''' Scout for potential jumps from the current coin to another coin ''' all_tickers = get_all_market_tickers(client) current_coin = get_current_coin() current_coin_price = get_market_ticker_price_from_list(all_tickers, current_coin + BRIDGE) if current_coin_price is None: logger.info("Skipping scouting... current coin {0} not found".format(current_coin + BRIDGE)) return ratio_dict = {} for pair in get_pairs_from(current_coin): if not pair.to_coin.enabled: continue optional_coin_price = get_market_ticker_price_from_list(all_tickers, pair.to_coin + BRIDGE) if optional_coin_price is None: logger.info("Skipping scouting... optional coin {0} not found".format(pair.to_coin + BRIDGE)) continue # Obtain (current coin)/(optional coin) coin_opt_coin_ratio = current_coin_price / optional_coin_price # save ratio so we can pick the best option, not necessarily the first ratio_dict[pair.to_coin] = (coin_opt_coin_ratio - transaction_fee * multiplier * coin_opt_coin_ratio) - pair.ratio # keep only ratios bigger than zero ratio_dict = dict(filter(lambda x: x[1] > 0, ratio_dict.items())) # if we have any viable options, pick the one with the biggest ratio if ratio_dict: max_optional_coin = max(ratio_dict, key=ratio_dict.get) logger.info('Will be jumping from {0} to {1}'.format( current_coin, max_optional_coin)) transaction_through_tether( client, current_coin, max_optional_coin)