From a0c6f8c5845c7d2cc94e75dd3b18dd245572d8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Sat, 30 Nov 2024 13:42:08 -0300 Subject: [PATCH] force_restart_if_retries_exhausted --- changelog.txt | 4 +++ configs/trader_config.json.example | 49 +++++++++++++++--------------- main.py | 2 +- trader.py | 6 +++- 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/changelog.txt b/changelog.txt index d24d311..e7f5b9a 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,7 @@ +2024.11.30: +. Added "forced_restart_if_retries_exhasted" option to the config file of a trader. If set to true, the trader will always restart if the first order of the deal + does not fill. Default behavior is one restart only. + 2024.11.26: . Implemented deals cache to reduce db load until the new database service is implemented. . Added a new API endpoint: /get_deals_cache. diff --git a/configs/trader_config.json.example b/configs/trader_config.json.example index 38fe37d..df5e1cd 100755 --- a/configs/trader_config.json.example +++ b/configs/trader_config.json.example @@ -1,26 +1,27 @@ { - "pair": "BCC/USDT", #Symbol of the market to trade. - "order_size": 15, #Order size of the trader. - "tp_level": 1.02, #Take profit percentage. (check strategy documentation for more details) - "no_of_safety_orders": 23, #Amount of safety orders. (check strategy documentation for more details) - "safety_order_deviance": 2, #Deviance of safety orders. (check strategy documentation for more details) - "safety_order_scale": 0.0105, #Size multiplier of every subsequent safety order. (check strategy documentation for more details) - "write_logs": false, #Write logs to file. - "calculate_fees": true, #Take into account the fees when calculating profits. - "check_slippage": true, #Slippage checks before sending orders. - "slippage_default_threshold": .03 #Default threshold. - "cleanup": true, #Execute the cleanup routine every trader (re)start. - "telegram": true, #Send Telegram notifications. - "tp_mode": 3, #Take profit mode. (check strategy documentation for more details) - "tp_table": [], #Profit percentage table. (check strategy documentation for more details) - "is_short": true, #Signals the trader mode (true if short, false if long) - "autoswitch": true, #If the trader is operating in short mode, switches to long mode if certain conditions are met. (check strategy documentation for more details) - "attempt_restart": true, #Attempts to restart the trader if there is an error. - "check_old_long_price": true, #Compares the current price with the old_long price. (check strategy documentation for more details) - "dynamic_so_deviance": true, #Uses a non-linear safety order deviance algorithm. (check strategy documentation for more details) - "dsd_range": 1, #Range of the dynamic deviance algorithm. (check strategy documentation for more details) - "bias": -0.5, #Bias of the dynamic deviance algorithm. (check strategy documentation for more details) - "boosted_deals_range": 4, #Amount of deals within a timespan to trigger the boost algorithm. - "boosted_time_range": 3600, #Timespan in seconds to count closed trades. - "boosted_amount": .01 #Amount of percentage to add to the profit target if boosted. + "pair": "BCC/USDT", #Symbol of the market to trade. + "order_size": 15, #Order size of the trader. + "tp_level": 1.02, #Take profit percentage. (check strategy documentation for more details) + "no_of_safety_orders": 23, #Amount of safety orders. (check strategy documentation for more details) + "safety_order_deviance": 2, #Deviance of safety orders. (check strategy documentation for more details) + "safety_order_scale": 0.0105, #Size multiplier of every subsequent safety order. (check strategy documentation for more details) + "write_logs": false, #Write logs to file. + "calculate_fees": true, #Take into account the fees when calculating profits. + "check_slippage": true, #Slippage checks before sending orders. + "slippage_default_threshold": .03 #Default threshold. + "cleanup": true, #Execute the cleanup routine every trader (re)start. + "telegram": true, #Send Telegram notifications. + "tp_mode": 3, #Take profit mode. (check strategy documentation for more details) + "tp_table": [], #Profit percentage table. (check strategy documentation for more details) + "is_short": true, #Signals the trader mode (true if short, false if long) + "autoswitch": true, #If the trader is operating in short mode, switches to long mode if certain conditions are met. (check strategy documentation for more details) + "attempt_restart": true, #Attempts to restart the trader if there is an error. + "forced_restart_if_retries_exhasted": false, #Forces restart every time the initial order does not get filled. Default behavior is only one restart. + "check_old_long_price": true, #Compares the current price with the old_long price. (check strategy documentation for more details) + "dynamic_so_deviance": true, #Uses a non-linear safety order deviance algorithm. (check strategy documentation for more details) + "dsd_range": 1, #Range of the dynamic deviance algorithm. (check strategy documentation for more details) + "bias": -0.5, #Bias of the dynamic deviance algorithm. (check strategy documentation for more details) + "boosted_deals_range": 4, #Amount of deals within a timespan to trigger the boost algorithm. + "boosted_time_range": 3600, #Timespan in seconds to count closed trades. + "boosted_amount": .01 #Amount of percentage to add to the profit target if boosted. } diff --git a/main.py b/main.py index 3caac0a..6a283c8 100644 --- a/main.py +++ b/main.py @@ -22,7 +22,7 @@ In case the permissions of the certificate changes, reset them this way: # ll /etc/letsencrypt/ ''' -version = "2024.11.26" +version = "2024.11.30" ''' Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors diff --git a/trader.py b/trader.py index a270afe..0321bee 100755 --- a/trader.py +++ b/trader.py @@ -101,7 +101,11 @@ class trader: elif start_result==1: #If initialization fails self.quit = True elif start_result==2: #Retries exceeded - self.quit = True + if "force_restart_if_retries_exhausted" in self.config_dict and self.config_dict["force_restart_if_retries_exhausted"]: + self.pause = False + self.restart = True + else: + self.quit = True elif start_result==3: #Not enough liquidity self.pause = False self.restart = True