From 9771f76dd4c117389d492221078a7c01632c7277 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Wed, 13 Nov 2024 09:24:09 -0300 Subject: [PATCH] timestamps fix --- changelog.txt | 2 ++ exchange_wrapper.py | 2 +- main.py | 2 +- trader.py | 3 +-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 61b5e43..c59f6b2 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,5 @@ +2024.11.13: Fixed bug handling timestamps. + 2024.11.11: . Refactored boost check to optimize CPU usage. diff --git a/exchange_wrapper.py b/exchange_wrapper.py index ca28bc9..fd469fb 100755 --- a/exchange_wrapper.py +++ b/exchange_wrapper.py @@ -75,7 +75,7 @@ class broker: try: database_connection = sqlite3.connect("profits/profits_database.db") database_cursor = database_connection.cursor() - database_cursor.execute(f"SELECT * FROM profits_table WHERE timestamp >= {time.time()-timespan} ORDER BY timestamp DESC") + database_cursor.execute(f"SELECT * FROM profits_table WHERE timestamp >= {time.time()-timespan} ORDER BY timestamp") rows = database_cursor.fetchall() return [item[0] for item in rows if item[1]==pair] except Exception as e: diff --git a/main.py b/main.py index 0085691..d8a1bb0 100644 --- a/main.py +++ b/main.py @@ -22,7 +22,7 @@ In case the permissions of the certificate changes, reset them this way: # ll /etc/letsencrypt/ ''' -version = "2024.11.11" +version = "2024.11.13" ''' Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors diff --git a/trader.py b/trader.py index 22cb30e..8c5fd78 100755 --- a/trader.py +++ b/trader.py @@ -1227,10 +1227,9 @@ class trader: The last n deals must be within the last t seconds ''' - return len(self.deals_timestamps)>=self.boosted_deals_range and self.deals_timestamps[-1]-self.boosted_time_range<=self.deals_timestamps[-4] + return len(self.deals_timestamps)>=self.boosted_deals_range and time.time()-self.boosted_time_range<=self.deals_timestamps[-self.boosted_deals_range] - def get_tp_level(self, order_index: int = 0) -> float: ''' Returns the correct take profit percentage, according to the strategy (config_dict["tp_mode"]):