From cfd8bd93923be042b116c58762a32ec29b9e6094 Mon Sep 17 00:00:00 2001 From: enarjord Date: Sat, 28 Jan 2023 15:16:33 +0100 Subject: [PATCH] improve func determine_pos_side() --- bybit.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bybit.py b/bybit.py index 30f2b5bc1..d33f0bde4 100644 --- a/bybit.py +++ b/bybit.py @@ -23,6 +23,16 @@ def first_capitalized(s: str): def determine_pos_side(o: dict) -> str: if o["side"].lower() == "buy": + if "reduce_only" in o: + if o["reduce_only"]: + return "short" + else: + return "long" + if "closed_size" in o: + if o["closed_size"] != 0.0: + return "short" + else: + return "long" if "entry" in o["order_link_id"]: return "long" elif "close" in o["order_link_id"]: @@ -30,6 +40,16 @@ def determine_pos_side(o: dict) -> str: else: return "both" else: + if "reduce_only" in o: + if o["reduce_only"]: + return "long" + else: + return "short" + if "closed_size" in o: + if o["closed_size"] != 0.0: + return "long" + else: + return "short" if "entry" in o["order_link_id"]: return "short" elif "close" in o["order_link_id"]: