simplifier multiplier calculation - division by zero eliminated

This commit is contained in:
Nicolás Sánchez 2024-12-27 10:39:12 -03:00
parent 0422624c5f
commit 28bbd885af
1 changed files with 3 additions and 5 deletions

View File

@ -1690,11 +1690,9 @@ class trader:
minimum_switch_price = (old_target - self.status_dict["quote_spent"])/base_left
if old_target-self.status_dict["quote_spent"]>0 and base_left>0 and minimum_switch_price<low_price:
low_boundary_color = bright_green
low_boundary = '{:.20f}'.format(minimum_switch_price)[:decimals].center(decimals)
#Logic for multiplier
#When adding a trader, this line always throws an exception since status_dict["price"] is not yet populated
percentage_to_switch = (self.status_dict["old_long"]["tp_price"]-self.status_dict["price"])*100/self.status_dict["price"]
multiplier = int(percentage_to_switch/100)+1
low_boundary = '{:.20f}'.format(minimum_switch_price)[:decimals].center(decimals)
if self.status_dict["price"]!=0:
multiplier = int(self.status_dict["old_long"]["tp_price"]/self.status_dict["price"])
except Exception as e:
print(e)