comment cleanup

This commit is contained in:
Nicolás Sánchez 2025-02-27 12:37:45 -03:00
parent cb5f6010b3
commit 0e125a3c19
1 changed files with 3 additions and 23 deletions

View File

@ -252,7 +252,7 @@ class trader:
self.broker.logger.log_this("Restart retries exhausted.",0,self.pair) self.broker.logger.log_this("Restart retries exhausted.",0,self.pair)
self.broker.cancel_order(returned_order["id"],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 #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. #Since it only reaches this point very unfrequently, let we'll the trader get stuck in a pause state.
return 2 return 2
@ -361,13 +361,7 @@ class trader:
if write_to_disk: if write_to_disk:
self.write_status_file() 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 return 0
def write_status_file(self,is_backup:bool=False): 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) self.broker.logger.log_this("Can't switch a long trader to long, there's nothing to do",1,self.pair)
return 1 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) 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: 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) self.broker.logger.log_this("Can't find old long info on status_dict, searching for oldlong file",1,self.pair)
try: try:
@ -736,9 +720,6 @@ class trader:
self.safety_price_table = [0] self.safety_price_table = [0]
self.safety_order_index = 0 self.safety_order_index = 0
#Disabling autoswitch
#self.config.set_autoswitch(False)
#Done. Ready for start_trader #Done. Ready for start_trader
return 0 return 0
@ -771,10 +752,9 @@ class trader:
#calculate profits #calculate profits
if not ignore_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 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 #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.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"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) self.broker.logger.log_this(f"Sell price: {market_tp_order['price']} {self.quote}",0,self.pair)