print(timestamp + res) process_message(res) except Exception as e: timestamp = get_timestamp() print(timestamp + "连接断开,正在重连……") print(e) continue if __name__ == '__main__': if len(sys.argv) > 2: coin_name = sys.argv[1] # 默认币种handle_deque coin = Coin(coin_name, "usdt") instrument_id = coin.get_instrument_id() future_instrument_id = coin.get_future_instrument_id() file_transaction, file_deal = coin.gen_file_name() config_file = sys.argv[2] if config_file == 'config_mother': from config_mother import spotAPI, okFuture, futureAPI # elif config_file == 'config_son1': # from config_son1 import spotAPI, okFuture, futureAPI # elif config_file == 'config_son3': # from config_son3 import spotAPI, okFuture, futureAPI else: print( '输入config_file有误,请输入config_mother or config_son1 or config_son3' ) sys.exit() run_websocket(coin_name)
break else: return False return True except Exception as e: info = traceback.format_exc() log_trade_v3("In future sell_more func, error: %s\r\n traceback: %s" % (repr(e), info)) return False def get_latest_future_price(future_api, future_instrument_id): try: ticker = future_api.get_specific_ticker(future_instrument_id) latest_future_price = float(ticker['last']) return latest_future_price except Exception as e: info = traceback.format_exc() log_trade_v3( "In get_latest_future_price func, error: %s \r\n traceback: %s" % (repr(e), info)) return False if __name__ == '__main__': from config_mother import futureAPI coin_name = "eos" coin = Coin(coin_name, "usdt") print(coin.get_future_instrument_id()) print(get_latest_future_price(futureAPI, coin.get_future_instrument_id()))