From 878188354c55d32b8843df136de1f2402196f3e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Wed, 30 Oct 2024 18:57:24 -0300 Subject: [PATCH] Bug hunting --- changelog.txt | 1 + trader.py | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 150a773..0c53534 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ 2024.10.30: . Changes trying to catch the wrong base amount bug. . Simplified new_market_order code. +. Changed the amount to cleanup after the trader starts to get around the wrong base bug. It seems that Gate.io is not "freeing the funds" quick enough after some order fills. 2024.10.29: . New functions to get top ask and top bid prices. diff --git a/trader.py b/trader.py index cd209c2..e5c711e 100755 --- a/trader.py +++ b/trader.py @@ -490,12 +490,13 @@ class trader: if balance_to_clean is None: self.broker.logger.log_this("Can't fetch free base",1,self.pair) return 1 - balance_to_clean /= 2 #Maybe it's a good idea, sort of DCAing the dust. + #balance_to_clean /= 2 #Maybe it's a good idea, sort of DCAing the dust. min_base_size = self.broker.get_min_base_size(self.pair) - if min_base_size is not None and balance_to_clean >= min_base_size: - self.broker.logger.log_this(f"Balance to clean: {balance_to_clean} {self.base}",2,self.pair) + minimum_cleanup_size = self.so["amount"]*2 # type: ignore + if balance_to_clean-minimum_cleanup_size >= min_base_size: + self.broker.logger.log_this(f"Balance to clean: {balance_to_clean-minimum_cleanup_size} {self.base}",2,self.pair) self.broker.logger.log_this("Sending cleanup order...",2,self.pair) - cleanup_order = self.broker.new_limit_order(self.pair,balance_to_clean,"sell",self.take_profit_price) + cleanup_order = self.broker.new_limit_order(self.pair,balance_to_clean-minimum_cleanup_size,"sell",self.take_profit_price) if cleanup_order not in [None,self.broker.get_empty_order()]: self.broker.logger.log_this("Cleanup successful",2,self.pair) return 0