From 7413c57f2cc172012ab5c3cf1f0be4ab62eb0d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Sat, 9 Nov 2024 12:45:15 -0300 Subject: [PATCH] Removed deprecated variables --- changelog.txt | 3 +++ configs/trader_config.json.example | 3 ++- main.py | 2 +- trader.py | 14 +++++++------- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/changelog.txt b/changelog.txt index 661756f..cfc7670 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +2024.11.09: +. Removed multiplier modifier added in 0.12d, since it was not needed anymore. + 2024.11.08: . Added boosted take profit level: If the trader is actively closing deals, the expected profit level is raised by x%. Defaults are: Four deals in one hour, 1% raise. diff --git a/configs/trader_config.json.example b/configs/trader_config.json.example index 3cad8b6..38fe37d 100755 --- a/configs/trader_config.json.example +++ b/configs/trader_config.json.example @@ -8,6 +8,7 @@ "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) @@ -21,5 +22,5 @@ "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": .1 #Amount of percentage to add to the profit target if boosted. + "boosted_amount": .01 #Amount of percentage to add to the profit target if boosted. } diff --git a/main.py b/main.py index fdee2f0..1713837 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.08" +version = "2024.11.09" ''' 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 df32541..9c9ea2c 100755 --- a/trader.py +++ b/trader.py @@ -1270,7 +1270,7 @@ class trader: return 0 - def get_tp_level(self, order_index: int = 0, multiplier: float = 1) -> float: + def get_tp_level(self, order_index: int = 0) -> float: ''' Returns the correct take profit percentage, according to the strategy (config_dict["tp_mode"]): 0. Fixed percentage @@ -1280,7 +1280,7 @@ class trader: ''' tp_level = 1 - boost = 0 + boost_percentage = 0 #BOOST ROUTINE: If the trader closed certain amount of deals within the last t timespan, raise the take profit level by x% #Default values @@ -1302,7 +1302,7 @@ class trader: last_deals_timestamps = self.broker.return_last_n_deals_timestamps(self.pair,boosted_deals_range) if len(last_deals_timestamps)==boosted_deals_range and all(item >= time.time()-boosted_time_range for item in last_deals_timestamps): self.is_boosted = True - boost+=boosted_amount + boost_percentage = boosted_amount if self.is_short or self.config_dict["tp_mode"]==0: #Fixed take profit percentage tp_level = self.config_dict["tp_level"] @@ -1327,7 +1327,7 @@ class trader: tp_level = profit_table[-1] if order_index str: @@ -1346,7 +1346,7 @@ class trader: return None - def send_new_tp_order(self, multiplier: float = 1) -> int: + def send_new_tp_order(self) -> int: ''' Calculates the correct take profit price and sends the order to the exchange ''' @@ -1356,10 +1356,10 @@ class trader: self.broker.logger.log_this("Amount of base equals 0, can't send take profit order",1,self.pair) return 1 if self.is_short: - self.take_profit_price = self.total_amount_of_quote/self.total_amount_of_base*(1-(self.get_tp_level(self.safety_order_index,multiplier)-1)) + self.take_profit_price = self.total_amount_of_quote/self.total_amount_of_base*(1-(self.get_tp_level(self.safety_order_index)-1)) self.tp_order = self.broker.new_limit_order(self.pair,self.total_amount_of_base,"buy",self.take_profit_price) else: - self.take_profit_price = self.total_amount_of_quote/self.total_amount_of_base*self.get_tp_level(self.safety_order_index,multiplier) + self.take_profit_price = self.total_amount_of_quote/self.total_amount_of_base*self.get_tp_level(self.safety_order_index) self.tp_order = self.broker.new_limit_order(self.pair,self.total_amount_of_base,"sell",self.take_profit_price) if self.tp_order==1: #This means that there was a miscalculation of base currency amount, let's correct it. if self.is_short: #If in short mode, we don't recalculate anything.