fix: Propagate error message to ExecutionReport in bybit gw
Specifically, the 'rejectReason' field in order update json.
This commit is contained in:
1 parent
c08a893ecf
commit
217db51cbc
1 file changed
+8
-1
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user