Skip to content

Commit

Permalink
Merge branch 'development' into digifinex
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisocana authored Mar 29, 2021
2 parents fefa57e + af94355 commit f84c61e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion hummingbot/connector/exchange/bitmax/bitmax_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions hummingbot/connector/exchange/bitmax/bitmax_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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 = {
Expand Down

0 comments on commit f84c61e

Please sign in to comment.