2025.09.01

This commit is contained in:
Nicolás Sánchez 2025-09-01 13:42:22 -03:00
parent 433813115f
commit 23d85de155
2 changed files with 7 additions and 5 deletions

View File

@ -18,7 +18,7 @@ import exchange_wrapper
import trader import trader
version = "2025.08.31" version = "2025.09.01"
''' '''
Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

View File

@ -53,6 +53,9 @@ class trader:
if is_import: if is_import:
self.load_imported_trader() self.load_imported_trader()
return None return None
else:
#Only reloads the value from config file if the trader wasn't running previously.
self.status.set_no_of_safety_orders(self.config.get_no_of_safety_orders())
# An alternative would be to set up a variable like self.is_initalized to false and finish the initialization here. # An alternative would be to set up a variable like self.is_initalized to false and finish the initialization here.
# Then, in the main loop, check if self.is_initalized is false. If it is, run start_trader. # Then, in the main loop, check if self.is_initalized is false. If it is, run start_trader.
@ -111,7 +114,7 @@ class trader:
''' '''
#Perhaps we should search for open buy orders from a crashed trader and cancel them? #Perhaps we should search for open buy orders from a crashed trader and cancel them?
#Reset some variables #Resets some variables
self.status.set_so_amount(0) self.status.set_so_amount(0)
self.status.clear_deal_order_history() self.status.clear_deal_order_history()
self.status.set_take_profit_order(self.broker.get_empty_order()) self.status.set_take_profit_order(self.broker.get_empty_order())
@ -1238,7 +1241,7 @@ class trader:
tp_level = self.config.get_tp_table()[-1] tp_level = self.config.get_tp_table()[-1]
tp_level = self.config.get_tp_level() tp_level = self.config.get_tp_level()
elif self.config.get_tp_mode()==3: #Linear percentage table elif self.config.get_tp_mode()==3: #Linear percentage table
profit_table = self.linear_space(self.config.get_tp_level()+0.005,self.config.get_tp_level()-0.005,self.config.get_no_of_safety_orders()) profit_table = self.linear_space(self.config.get_tp_level()+0.005,self.config.get_tp_level()-0.005,self.status.get_no_of_safety_orders())
tp_level = profit_table[-1] tp_level = profit_table[-1]
if order_index<len(profit_table): #If more safety orders were added, instead of recalculating the whole table if order_index<len(profit_table): #If more safety orders were added, instead of recalculating the whole table
tp_level = profit_table[order_index] #it just returns the last value. Otherwise, the percentage gets very small. tp_level = profit_table[order_index] #it just returns the last value. Otherwise, the percentage gets very small.
@ -1646,7 +1649,6 @@ class trader:
return 1 return 1
self.status.set_pause_reason("Importing trader") self.status.set_pause_reason("Importing trader")
#self.config.set_no_of_safety_orders(self.status.get_no_of_safety_orders()) #If this is not loaded from status_dict, it will ignore if safety orders were added at runtime
#Refresh take profit order #Refresh take profit order
order_id = self.status.get_take_profit_order()["id"] order_id = self.status.get_take_profit_order()["id"]