From 504f441d2ee1afd86dbca5c4268b35d53c333dac Mon Sep 17 00:00:00 2001 From: John Colvin Date: Sun, 17 Aug 2025 18:25:52 +0000 Subject: [PATCH] fix: Count fills correctly in bybit exe gw plugin * Round fill price and qty to 7 digits in bybit gw plugin * Remove erroneous line of code that reset filled_quantity to 0 on each update (it was causing partial fills to be overcounted) --- .../python_interop_plugins/bybit_execution_gateway.py | 3 ++- 1 file changed, 2 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 65e6c8cd6..ae386033a 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 @@ -132,9 +132,9 @@ class OrderData: status: str, ): self.price = price - self.filled_quantity = 0 self.quantity = quantity lfq = filled_quantity - self.filled_quantity + lfq = round(lfq, 7) if lfq > 0: if self.filled_quantity == 0: self.last_filled_quantity = filled_quantity @@ -143,6 +143,7 @@ class OrderData: price_diff = avg_filled_price - self.avg_filled_price lfq_weight = filled_quantity / (self.filled_quantity + filled_quantity) lfp = self.avg_filled_price + (price_diff / lfq_weight) + lfp = round(lfp, 7) self.last_filled_price = lfp self.last_filled_quantity = lfq self.filled_quantity = filled_quantity