From 56de8fed252d8f5c69e0b3602672732d84082305 Mon Sep 17 00:00:00 2001 From: Giorgos Kontopoulos Date: Sun, 23 Feb 2025 08:32:21 +0200 Subject: [PATCH] Discard outdated position.json data --- soltrade/trading.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/soltrade/trading.py b/soltrade/trading.py index 47e4bb7..affa370 100644 --- a/soltrade/trading.py +++ b/soltrade/trading.py @@ -79,6 +79,13 @@ def perform_analysis(): return else: input_amount = find_balance(config().secondary_mint) + + # sometimes position.json might contain wrong or outdated data + if input_amount == 0.0: + stoploss = takeprofit = market().sl = market().tp = 0 + market().update_position(False, stoploss, takeprofit) + log_transaction.info("Soltrade has detected outdated data in position.json. Reseting position.") + return if price <= stoploss or price >= takeprofit: log_transaction.info("Soltrade has detected a sell signal. Stoploss or takeprofit has been reached.")