From 217db51cbc1cb54748713a490df1e03c89b9b032 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 21 Aug 2025 13:44:09 +0000 Subject: [PATCH] fix: Propagate error message to ExecutionReport in bybit gw Specifically, the 'rejectReason' field in order update json. --- .../python_interop_plugins/bybit_execution_gateway.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 f4debc098..c748d1680 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 @@ -79,6 +79,7 @@ class OrderData: self.last_filled_price: float = 0 self.exec_type: ExecType = ExecType.PENDING_NEW self.status: OrderStatus = OrderStatus.PENDING_NEW + self.error_msg: Optional[str] = None # nanos self.timestamp: int = 0 self.version: int = 0 @@ -148,9 +149,11 @@ class OrderData: filled_quantity: float, avg_filled_price: float, status: str, + error_msg: Optional[str] = None, ): self.price = price self.quantity = quantity + self.error_msg = error_msg lfq = filled_quantity - self.filled_quantity lfq = round(lfq, 7) if lfq > 0: @@ -197,7 +200,9 @@ class OrderData: status: str = data["orderStatus"] px = parse_float(data["price"]) qty = parse_float(data["qty"]) - self.on_update(px, qty, total_filled_qty, avg_filled_price, status) + reject_rsn = data.get("rejectReason") + error_msg = None if reject_rsn == "EC_NoError" else reject_rsn + self.on_update(px, qty, total_filled_qty, avg_filled_price, status, error_msg) return True def to_exe_report(self, o: dict, security_type: str = "FUTURE"): @@ -224,6 +229,8 @@ class OrderData: transact_id=str(time.time_ns()), transact_time=self.timestamp, ) + if self.error_msg: + er.set_error_msg(self.error_msg) return er