From 809a66323da51e1e5fa36ee98bd97e6d3fe3b743 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 18 Aug 2025 15:25:02 +0000 Subject: [PATCH] fix: Guarantee unique tx id for bybit exe reports Use a version counter instead of 'time.time_ns' (the latter probably would have been fine in practice, but the former is better). --- .../python_interop_plugins/bybit_execution_gateway.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib_python_interop/python_interop_plugins/bybit_execution_gateway.py b/src/lib_python_interop/python_interop_plugins/bybit_execution_gateway.py index 67c6d31d6..1b3037b72 100644 --- a/src/lib_python_interop/python_interop_plugins/bybit_execution_gateway.py +++ b/src/lib_python_interop/python_interop_plugins/bybit_execution_gateway.py @@ -81,6 +81,7 @@ class OrderData: self.status: OrderStatus = OrderStatus.PENDING_NEW # nanos self.timestamp: int = 0 + self.version: int = 0 @property def is_active(self): @@ -114,7 +115,7 @@ class OrderData: } def to_execution_report(self): - transact_time = time.time_ns() + self.version += 1 er = PyExecutionReport() er.set_data( key=self.bts_id, @@ -134,8 +135,8 @@ class OrderData: last_filled_quantity=self.last_filled_quantity, filled_quantity=self.filled_quantity, avg_filled_price=self.avg_filled_price, - # There is no transact_id in Bybit, so we use updatedTime - transact_id=str(transact_time), + # There is no transact_id in Bybit, so we generate one. + transact_id=str(self.version), transact_time=self.timestamp, ) return er