From 0e125a3c192d3077fb4cc1ff4774da43543dbe92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Thu, 27 Feb 2025 12:37:45 -0300 Subject: [PATCH] comment cleanup --- trader.py | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/trader.py b/trader.py index b7bb026..93e21f3 100755 --- a/trader.py +++ b/trader.py @@ -252,7 +252,7 @@ class trader: self.broker.logger.log_this("Restart retries exhausted.",0,self.pair) self.broker.cancel_order(returned_order["id"],self.pair) #self.restart = True #This restart is tricky, it can end up in an endless loop of retries - #By this point, both the take_profit_routine initialization AND the subsequent restart attempt failed. + #At this point, both the take_profit_routine initialization AND the subsequent restart attempt failed. #Since it only reaches this point very unfrequently, let we'll the trader get stuck in a pause state. return 2 @@ -361,13 +361,7 @@ class trader: if write_to_disk: self.write_status_file() - #try: - # if write_to_disk: - # json_object = json.dumps(self.status_dict, indent=4) - # with open(f"status/{self.base}{self.quote}.status", "w") as c: - # c.write(json_object) - #except Exception as e: - # self.broker.logger.log_this(f"Can't write status file to disk. Exception: {e}",1,self.pair) + return 0 def write_status_file(self,is_backup:bool=False): @@ -670,17 +664,7 @@ class trader: self.broker.logger.log_this("Can't switch a long trader to long, there's nothing to do",1,self.pair) return 1 - #Check if the orders are OK (Is this really necessary?) - # if self.tp_order is None: - # self.broker.logger.log_this("Take profit order is None, can't switch to short",1,self.pair) - # return 1 - # if self.so is None: - # self.broker.logger.log_this("Safety order is None, can't switch to short",1,self.pair) - # return 1 - - #Send Telegram message self.broker.logger.log_this("Attempting to switch to long bot",0,self.pair) - if not ignore_old_long and "old_long" not in self.status_dict: self.broker.logger.log_this("Can't find old long info on status_dict, searching for oldlong file",1,self.pair) try: @@ -736,9 +720,6 @@ class trader: self.safety_price_table = [0] self.safety_order_index = 0 - #Disabling autoswitch - #self.config.set_autoswitch(False) - #Done. Ready for start_trader return 0 @@ -771,10 +752,9 @@ class trader: #calculate profits if not ignore_profits: profit = already_received_quote + market_tp_order["cost"] - self.status_dict["old_long"]["quote_spent"] - self.status_dict["old_long"]["fees_paid_in_quote"] - fees_paid - #self.status_dict["acc_profit"] += profit #Add profits to file and send telegram notifying profits - self.profit_to_file(profit,market_tp_order["id"]) #This is not used anymore, but it's still here since it does not take almost any disk space and/or CPU time. + self.profit_to_file(profit,market_tp_order["id"]) self.profit_to_db(profit,market_tp_order["id"],self.broker.get_write_order_history()) self.broker.logger.log_this(f"Switch successful. Profit: {round(profit,2)} {self.quote}",0,self.pair) self.broker.logger.log_this(f"Sell price: {market_tp_order['price']} {self.quote}",0,self.pair)