diff --git a/hummingbot/connector/exchange/bitmax/bitmax_exchange.py b/hummingbot/connector/exchange/bitmax/bitmax_exchange.py index 4606157dd3..bef04d3a52 100644 --- a/hummingbot/connector/exchange/bitmax/bitmax_exchange.py +++ b/hummingbot/connector/exchange/bitmax/bitmax_exchange.py @@ -493,7 +493,7 @@ async def _create_order(self, raise ValueError(f"Notional amount {notional} is not withing the range of {bitmax_trading_rule.minNotional}-{bitmax_trading_rule.maxNotional}.") # TODO: check balance - [exchange_order_id, timestamp] = bitmax_utils.gen_exchange_order_id(self._account_uid) + [exchange_order_id, timestamp] = bitmax_utils.gen_exchange_order_id(self._account_uid, order_id) api_params = { "id": exchange_order_id, diff --git a/hummingbot/connector/exchange/bitmax/bitmax_utils.py b/hummingbot/connector/exchange/bitmax/bitmax_utils.py index 45f943688d..93d33eb9d1 100644 --- a/hummingbot/connector/exchange/bitmax/bitmax_utils.py +++ b/hummingbot/connector/exchange/bitmax/bitmax_utils.py @@ -15,7 +15,7 @@ DEFAULT_FEES = [0.1, 0.1] -HBOT_BROKER_ID = "hbot-" +HBOT_BROKER_ID = "HMBot" def convert_from_exchange_trading_pair(exchange_trading_pair: str) -> str: @@ -35,29 +35,29 @@ def uuid32(): return ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(32)) -def derive_order_id(user_uid: str, cl_order_id: str, ts: int, order_src='a') -> str: +def derive_order_id(user_uid: str, cl_order_id: str, ts: int) -> str: """ Server order generator based on user info and input. :param user_uid: user uid :param cl_order_id: user random digital and number id :param ts: order timestamp in milliseconds - :param order_src: 'a' for rest api order, 's' for websocket order. :return: order id of length 32 """ - return (order_src + format(ts, 'x')[-11:] + user_uid[-11:] + cl_order_id[-9:])[:32] + return (HBOT_BROKER_ID + format(ts, 'x')[-11:] + user_uid[-11:] + cl_order_id[-5:])[:32] -def gen_exchange_order_id(userUid: str) -> Tuple[str, int]: +def gen_exchange_order_id(userUid: str, client_order_id: str) -> Tuple[str, int]: """ - Generate an order id - :param user_uid: user uid + Generates the exchange order id based on user uid and client order id. + :param user_uid: user uid, + :param client_order_id: client order id used for local order tracking :return: order id of length 32 """ time = get_ms_timestamp() return [ derive_order_id( userUid, - uuid32(), + client_order_id, time ), time @@ -66,7 +66,7 @@ def gen_exchange_order_id(userUid: str) -> Tuple[str, int]: def gen_client_order_id(is_buy: bool, trading_pair: str) -> str: side = "B" if is_buy else "S" - return f"{HBOT_BROKER_ID}{side}-{trading_pair}-{get_tracking_nonce()}" + return f"{HBOT_BROKER_ID}-{side}-{trading_pair}-{get_tracking_nonce()}" KEYS = {