From c08a893ecf629a1e0024bb41f6a44277048d293b Mon Sep 17 00:00:00 2001 From: John Colvin Date: Thu, 21 Aug 2025 13:31:32 +0000 Subject: [PATCH] change: Hardcode PostOnly flag for Limit/GTC orders in bybit gw 'PostOnly' is a TimeInForce flag that we don't have in our system. It makes it so Limit orders that would be filled on entry are rejected. Ali's SprayAndSkew algo needs this to avoid taker fees. --- .../python_interop_plugins/bybit_execution_gateway.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 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 115541391..f4debc098 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 @@ -722,13 +722,20 @@ class BybitExecutionGateway(ExecutionGateway): ) self.buffered_requests[req.key()] = req return + order_type = req.order_type().title() + time_in_force = req.time_in_force().upper() + if order_type == "Limit" and time_in_force == "GTC": + # 'PostOnly' makes it so the order gets rejected if it would be filled on entry. + # We're hardcoding this flag for Limit/GTC orders to avoid taker fees in Ali's + # algo (SprayAndSkew), since our TimeInForce enum doesn't have 'PostOnly'. + time_in_force = "PostOnly" params = { "orderLinkId": exch_ord_id, "category": "linear", "symbol": exch_sec_id, "side": "Buy" if req.is_buy() else "Sell", - "orderType": req.order_type().title(), - "timeInForce": req.time_in_force().upper(), + "orderType": order_type, + "timeInForce": time_in_force, "price": format_price(sec, px), "qty": format_quantity(sec, qty), }