def getMinMaxExchange(self, symbol): max_exchange = self.exchanges[0] min_exchange = self.exchanges[0] avg_price = 0 min_price = 1000000 prices = 0 avg_count = 0 for e in self.exchanges: price = e.get_last_price(symbol) if price <= 0: continue avg_count += 1 prices += price if price > avg_price: avg_price = price max_exchange = e if price < min_price: min_price = price min_exchange = e if min_price == 1000000: min_price = 0 if avg_count == 0: print('%s没有价格' % symbol) return None # avg_price -= avg_price * 0.003 profit = (avg_price - min_price) * self.rate avg = prices / avg_count rate_price = avg_price / 100 * 0.1 * self.rate # print('%s 最高价格交易所:%s 价格:%f,最低:%s 价格:%f,均价:%f, 差价:%f, 按手续费:%f,两次手续费:%f, 纯利润:%f' % # (symbol, max_exchange.Name, avg_price, min_exchange.Name, min_price, avg, # profit, rate_price, rate_price * 2, profit - rate_price * 2)) # print('\033[1;32m' + 'green' + '\033[0m') if avg_price == min_price: print_blue('%s 只在一个交易所发行, 无差价' % symbol) # print('\033[1;34m %s 只在一个交易所发行, 无差价 \033[0m' % symbol) else: if profit - rate_price * 2 >= 0: print_green( '%s 人民币单价:%f, 纯利润:%f元, 差价:%f元, 按手续费:%f元,两次手续费:%f元' % ( symbol, avg * self.rate, profit - rate_price * 2, profit, rate_price, rate_price * 2, )) else: print_red('%s 人民币单价:%f, 纯利润:%f元, 差价:%f元, 按手续费:%f元,两次手续费:%f元' % ( symbol, avg * self.rate, profit - rate_price * 2, profit, rate_price, rate_price * 2, )) return max_exchange, min_exchange, avg_price, min_price, prices / avg_count
def print_section_header(val): print_green("{:_^55}".format(val))
def print_section_header(val): print_green("{:_^55}".format(val));