This commit is contained in:
Nicolás Sánchez 2024-12-03 20:26:30 -03:00
parent 6c058c8114
commit e0d3d4e078
3 changed files with 6 additions and 6 deletions

View File

@ -7,8 +7,9 @@ Mandatory:
3. Consolidate vocabulary (trader, pair and bot; instance & trader)
4. Base add for short traders.
5. Proper handling of order price too high/low in OKX (rare, it happens when under heavy volatility).
6. Optimize database code.
7. Things that should be objects (it's not 1994):
6. Multiple safety orders open at the same time (to catch big volatility spikes more effectively)
7. Optimize database code.
8. Things that should be objects (it's not 1994):
* Orders.
* Sredro.
* A lot more.

View File

@ -699,7 +699,7 @@ class trader:
self.broker.logger.log_this("Can't switch a long trader to long, there's nothing to do",1,self.pair)
return 1
#Check if the orders are OK
#Check if the orders are OK (Is this really necessary?)
if self.tp_order is None:
self.broker.logger.log_this("Take profit order is None, can't switch to short",1,self.pair)
return 1
@ -1194,8 +1194,9 @@ class trader:
self.status_dict["pause_reason"] = "check for autoswitch"
#If it's a short bot that used to be long AND autoswitch is enabled
if self.is_short and "autoswitch" in self.config_dict and self.config_dict["autoswitch"] and "old_long" in self.status_dict:
#If selling the base currency left at the current market price plus the quote already received turns out to be more than the amount of the old_long,
#If selling the base currency left at the current market price plus the quote already received turns out to be more than the old long deal target,
# it means that we already are in profit territory, switch back to long.
#A more conservative approach would be old_target = self.status_dict["old_long"]["quote_spent"], just breaking even.
old_target = self.status_dict["old_long"]["tp_price"]*self.status_dict["old_long"]["tp_amount"]
base_left = self.status_dict["old_long"]["tp_amount"]-self.status_dict["base_bought"]
if (base_left*self.status_dict["price"])+self.status_dict["quote_spent"]>=old_target:

View File

@ -219,8 +219,6 @@ def last_n_lines(file_name,width,amount=4,full_log=False):
return result,len(file_contents)
for line in file_contents[::-1][:amount]:
#trimmed = f"{line[0]}{line[12:21]}{line[23:]}".strip()
#result.append(trimmed[:width])
trimmed = line.strip()
result.append(trimmed[:width])
if len(trimmed)>width: