2025.10.09

This commit is contained in:
Nicolás Sánchez 2025-10-09 17:51:55 -03:00
parent e354ea4d55
commit d06bfd9d10
4 changed files with 11 additions and 9 deletions

View File

@ -1,3 +1,6 @@
2025.10.09:
. Cleanup is done as soon as the trader starts, rather than after sending the take profit and safety orders.
2025.10.07:
. In short traders, if there are too few safety orders (less than 67% of the max amount), safety_order_deviance is increased from 2% to 3%.

View File

@ -19,7 +19,7 @@ class Broker:
#Default values
self.wait_time = self.broker_config.get("wait_time",.5)
self.cooldown_multiplier = self.broker_config.get("cooldown_multiplier",2)
self.wait_after_initial_market_order = self.broker_config.get("wait_after_initial_market_order",2)
self.wait_after_initial_market_order = self.broker_config.get("wait_after_initial_market_order",1)
self.wait_before_new_safety_order = self.broker_config.get("wait_before_new_safety_order",1)
self.retries = self.broker_config.get("retries",5)
self.slippage_default_threshold = self.broker_config.get("slippage_default_threshold",.03)

View File

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

View File

@ -204,7 +204,6 @@ class trader:
self.status.set_pause_reason("start_trader - after slippage")
#Sending initial order
#
# Here, if the amount of the initial order is already available in the account, don't send a market order; just pull the current price and simulate that the order was sent and filled.
@ -278,6 +277,11 @@ class trader:
self.broker.logger.log_this("Error sending take profit order. Aborting.",1,self.status.get_pair())
return 1
# Send cleanup order (if cleanup)
self.status.set_pause_reason("start_trader - doing cleanup (if needed)")
if self.config.get_cleanup() and not self.config.get_is_short(): #Short traders do not need cleanup.
self.do_cleanup()
# Generate the safety prices table
self.status.set_start_price(self.broker.price_to_precision(self.status.get_pair(),self.status.get_quote_spent()/self.status.get_base_bought()))
self.status.set_safety_price_table(self.calculate_safety_prices(self.status.get_start_price(),self.status.get_no_of_safety_orders(),self.config.get_safety_order_deviance()))
@ -295,11 +299,6 @@ class trader:
self.broker.cancel_order(self.status.get_take_profit_order()["id"],self.status.get_pair())
return 1
# Send cleanup order (if cleanup)
self.status.set_pause_reason("start_trader - doing cleanup (if needed)")
if self.config.get_cleanup() and not self.config.get_is_short(): #Short traders do not need cleanup.
self.do_cleanup()
self.status.set_deal_start_time(int(time.time()))
self.update_status(True)
self.set_pause(False)
@ -453,7 +452,7 @@ class trader:
#If the balance is greater than the size of the first safety order, sell the difference.
# Sometimes when an order is filled the balance is not updated immediately, so having a bit of a buffer irons out a couple of issues.
min_size = self.status.get_safety_orders()[0]["amount"]
min_size = self.config.get_order_size()/self.status.get_take_profit_price()
if (balance_in_account-min_size)*self.status.get_start_price()>self.broker.get_min_quote_size(self.status.get_pair()):
self.broker.logger.log_this(f"Balance to clean: {balance_in_account-min_size} {self.base}",2,self.status.get_pair())