From 912bd77589ce5ffa3514a6876ce948fda5680bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Tue, 12 Aug 2025 11:11:50 -0300 Subject: [PATCH] 2025.08.12 --- changelog.txt | 5 +++++ config_handler.py | 2 +- exchange_wrapper.py | 23 +++++++++++++---------- main.py | 6 +++--- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/changelog.txt b/changelog.txt index 09440d4..2395a21 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +2025.08.12: +. Default "check_slippage" value now True. +. Removed capitalization from exchange name when sending trader quit notification. +. Exception handling when sending Telegram messages. + 2025.08.10: . Added exchange name to the trader quit notification. . New endpoint: mod_default_order_size. It modifies the default order size of a broker. diff --git a/config_handler.py b/config_handler.py index 4bc3a93..e5ed869 100644 --- a/config_handler.py +++ b/config_handler.py @@ -26,7 +26,7 @@ class ConfigHandler: "tp_mode": 3, "tp_level": 1.025, "tp_table": [], - "check_slippage": False, + "check_slippage": True, "programmed_stop": False, "programmed_stop_time": 0, "boosted_deals_range": 4, diff --git a/exchange_wrapper.py b/exchange_wrapper.py index 39d2633..7927975 100755 --- a/exchange_wrapper.py +++ b/exchange_wrapper.py @@ -1110,16 +1110,19 @@ class Logger: ''' Sends a Telegram message ''' - - tg_credentials = credentials.get_credentials("telegram") - send_text = f"https://api.telegram.org/bot{tg_credentials['token']}/sendMessage?chat_id={tg_credentials['chatid']}&parse_mode=Markdown&text={message}" - output = None - if self.broker_config["telegram"] or ignore_config: - output = requests.get(send_text,timeout=5).json() #5 seconds timeout. This could also be a tunable. - if not output["ok"]: - self.log_this(f"Error in send_tg_message: {output}") - return 1 - return 0 + try: + tg_credentials = credentials.get_credentials("telegram") + send_text = f"https://api.telegram.org/bot{tg_credentials['token']}/sendMessage?chat_id={tg_credentials['chatid']}&parse_mode=Markdown&text={message}" + output = None + if self.broker_config["telegram"] or ignore_config: + output = requests.get(send_text,timeout=5).json() #5 seconds timeout. This could also be a tunable. + if not output["ok"]: + self.log_this(f"Error in send_tg_message: {output}") + return 1 + return 0 + except Exception as e: + self.log_this(f"Error in send_tg_message: {e}",1) + return 1 def log_this(self,message,level=2,pair=None): diff --git a/main.py b/main.py index 6675ae6..6884e5d 100644 --- a/main.py +++ b/main.py @@ -16,7 +16,7 @@ import exchange_wrapper import trader -version = "2025.08.10" +version = "2025.08.12" ''' Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors @@ -269,8 +269,8 @@ def main_loop(): restart_pair_no_json(instance.base,instance.quote) if instance.quit: #Here, check if a duster is needed - broker.logger.log_this(f"{broker.get_exchange_name().capitalize()} | Quit flag raised, removing trader.",0,instance.config.get_pair()) - broker.logger.log_this(f"{broker.get_exchange_name().capitalize()} | Quit flag raised, removing trader: {instance.config.get_pair()}",-1) #Forced message to TG + broker.logger.log_this(f"{broker.get_exchange_name()} | Quit flag raised, removing trader.",0,instance.config.get_pair()) + broker.logger.log_this(f"{broker.get_exchange_name()} | Quit flag raised, removing trader: {instance.config.get_pair()}",-1) #Forced message to TG if f"{instance.base}{instance.quote}" in tickers: tickers.remove(f"{instance.base}{instance.quote}") broker.remove_pair_from_config(f"{instance.base}{instance.quote}")