diff --git a/core/lib/market.py b/core/lib/market.py index 9a923d7..94679f0 100644 --- a/core/lib/market.py +++ b/core/lib/market.py @@ -19,7 +19,15 @@ def crossfilter(account, symbol, direction, func): :param func: Whether we are checking entries or exits :return: dict of action and opposing position, or False """ - position_info = account.client.get_position_info(symbol) + try: + position_info = account.client.get_position_info(symbol) + except GenericAPIError as e: + if "No position exists for the specified instrument" in str(e): + log.debug("No position exists for this symbol") + return False + else: + log.error(f"Error getting position info: {e}") + return None if direction == "buy": opposing_side = "short" elif direction == "sell": @@ -377,6 +385,8 @@ def execute_strategy(callback, strategy, func): # Callback now verified if func == "exit": check_exit = crossfilter(account, symbol, direction, func) + if check_exit is None: + return if not check_exit: log.debug("Exit conditions not met.") return