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).
This commit is contained in:
John Colvin committed 2025-08-18 15:54:22 +00:00
1 parent 5c4ee1a262
commit 809a66323d
1 file changed
+4 -3
@@ -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