vocabulary consolidation
This commit is contained in:
parent
0b1cc99558
commit
1998b428f2
2
main.py
2
main.py
|
|
@ -1805,7 +1805,7 @@ def unwrapped_add_quote(base,quote,amount):
|
|||
for x in running_instances:
|
||||
if f"{base}/{quote}"==x.config.get_pair():
|
||||
if x.config.get_is_short():
|
||||
return jsonify({"Error": "Quote can't be added to short bots"})
|
||||
return jsonify({"Error": "Quote can't be added to short traders"})
|
||||
x.pause = True
|
||||
new_average_price = (x.status.get_quote_spent()+float(amount))/(x.status.get_base_bought()+(float(amount)/x.get_status_dict()["price"]))
|
||||
broker.logger.log_this(f"Your new average buy price will be {new_average_price} {x.quote}",2,f"{base}/{quote}")
|
||||
|
|
|
|||
38
trader.py
38
trader.py
|
|
@ -237,7 +237,7 @@ class trader:
|
|||
self.status.set_base_bought(self.status.get_base_bought()-self.status.get_fees_paid_in_base())
|
||||
self.status.set_quote_spent(returned_order["cost"])
|
||||
else:
|
||||
self.broker.logger.log_this("Error starting bot. Aborting.",1,self.config.get_pair())
|
||||
self.broker.logger.log_this("Error starting trader. Aborting.",1,self.config.get_pair())
|
||||
return 1
|
||||
|
||||
# Send the take profit order
|
||||
|
|
@ -324,7 +324,7 @@ class trader:
|
|||
|
||||
def return_optimal_order_size(self, amount: float, min_size: float, amount_of_safety_orders: int, scalar: float) -> float:
|
||||
'''
|
||||
Calculates the optimal order size for a short bot, according to the amount passed as a parameter.
|
||||
Calculates the optimal order size for a short trader, according to the amount passed as a parameter.
|
||||
Due to performance issues, the step size that is used is 1/10th of the minimum order size.
|
||||
|
||||
:param amount: float
|
||||
|
|
@ -405,10 +405,10 @@ class trader:
|
|||
A more elegant solution would be to take note of the amount and the price at the moment of the deal closing that lead to
|
||||
that small amount of change to appear, to make possible to calculate an optimal sell price of the remaining assets
|
||||
instead of brute forcing it this way.
|
||||
For smaller bots that might be overengineering it a bit anyway
|
||||
For smaller traders that might be overengineering it a bit anyway
|
||||
'''
|
||||
|
||||
if self.config.get_is_short(): #Short bots do not need cleanup
|
||||
if self.config.get_is_short(): #Short traders do not need cleanup
|
||||
return 0
|
||||
balance_to_clean = self.fetch_free_base()
|
||||
if balance_to_clean is None:
|
||||
|
|
@ -475,12 +475,12 @@ class trader:
|
|||
|
||||
def switch_to_short(self) -> int:
|
||||
'''
|
||||
This method modifies the config file of a pair to convert it to short.
|
||||
This method modifies the config file of a trader to convert it to short.
|
||||
It automagically sets the order size according to the funds available.
|
||||
If not enough funds, it returns 1
|
||||
'''
|
||||
|
||||
if self.config.get_is_short(): #Check if bot is already a short bot
|
||||
if self.config.get_is_short(): #Check if the trader is already in short mode
|
||||
return 1
|
||||
|
||||
#Let's do some type checking first
|
||||
|
|
@ -491,7 +491,7 @@ class trader:
|
|||
self.broker.logger.log_this("Safety order is None, can't switch to short",1,self.config.get_pair())
|
||||
return 1
|
||||
|
||||
#Pauses bot
|
||||
#Pauses trader
|
||||
self.pause = True
|
||||
self.status.set_pause_reason("switch_to_short")
|
||||
|
||||
|
|
@ -562,20 +562,20 @@ class trader:
|
|||
return 1
|
||||
self.status.set_stop_when_profit(False)
|
||||
#self.config.set_is_short(True)
|
||||
self.broker.logger.log_this("Done configuring. Starting bot...",2,self.config.get_pair())
|
||||
self.broker.logger.log_this("Done configuring. Starting trader...",2,self.config.get_pair())
|
||||
return 0
|
||||
|
||||
|
||||
def switch_to_long(self, ignore_old_long: bool = False, already_received_quote: float = 0) -> int:
|
||||
'''
|
||||
Takes a short bot and changes the mode to long.
|
||||
Only does it if the current bot was previously a long one.
|
||||
Takes a short trader and changes the mode to long.
|
||||
Only does it if the current trader was previously a long one.
|
||||
'''
|
||||
|
||||
if not self.config.get_is_short():
|
||||
self.broker.logger.log_this("Trader already in long mode, nothing to do",1,self.config.get_pair())
|
||||
return 1
|
||||
self.broker.logger.log_this("Attempting to switch to long bot",0,self.config.get_pair())
|
||||
self.broker.logger.log_this("Attempting to switch to long trader",0,self.config.get_pair())
|
||||
|
||||
#Check old_long data
|
||||
if not ignore_old_long and self.status.get_old_long()=={}:
|
||||
|
|
@ -682,7 +682,7 @@ class trader:
|
|||
the reporting and the restart of the trader.
|
||||
'''
|
||||
|
||||
self.pause = True #To stop the main thread to iterate through this bot's orders (just in case)
|
||||
self.pause = True #To stop the main thread to iterate through this trader's orders (just in case)
|
||||
self.status.set_pause_reason("take_profit_routine - order handling") #start_trader will set this flag to False again once it starts
|
||||
|
||||
#Add the timestamp to the deals cache
|
||||
|
|
@ -691,7 +691,7 @@ class trader:
|
|||
#Let's do some type checking first
|
||||
if self.status.get_take_profit_order() is None:
|
||||
self.status.set_pause_reason(time.strftime(f"[%Y/%m/%d %H:%M:%S] | {self.config.get_pair()} | TP order is None"))
|
||||
self.broker.logger.log_this("Error. Take profit order is None, pair will be restarted",0,self.config.get_pair())
|
||||
self.broker.logger.log_this("Error. Take profit order is None, trader will be restarted",0,self.config.get_pair())
|
||||
self.status.save_to_file(is_backup=True)
|
||||
self.restart = True
|
||||
return 1
|
||||
|
|
@ -977,7 +977,7 @@ class trader:
|
|||
self.status.set_safety_order(self.broker.get_empty_order())
|
||||
#return 1
|
||||
if self.status.get_take_profit_order()["id"]=="":
|
||||
self.broker.logger.log_this(f"Take profit order missing. Stopping bot. No order ID was provided.",1,self.config.get_pair())
|
||||
self.broker.logger.log_this(f"Take profit order missing. Stopping trader. No order ID was provided.",1,self.config.get_pair())
|
||||
self.broker.cancel_order(self.status.get_safety_order()["id"],self.config.get_pair())
|
||||
if self.config.get_attempt_restart():
|
||||
self.status.save_to_file(is_backup=True)
|
||||
|
|
@ -993,8 +993,8 @@ class trader:
|
|||
if tp_status["status"]=="closed":
|
||||
if tp_status["filled"]>0:
|
||||
return self.take_profit_routine(tp_status)
|
||||
self.broker.logger.log_this(f"Take profit order closed but not filled, 0 filled. Stopping bot. Order ID: {self.status.get_take_profit_order()['id']}",1,self.config.get_pair())
|
||||
#Cancelling safety order and stopping bot
|
||||
self.broker.logger.log_this(f"Take profit order closed but not filled, 0 filled. Stopping trader. Order ID: {self.status.get_take_profit_order()['id']}",1,self.config.get_pair())
|
||||
#Cancelling safety order and stopping trader
|
||||
self.broker.cancel_order(self.status.get_safety_order()["id"],self.config.get_pair())
|
||||
if self.config.get_attempt_restart():
|
||||
self.status.save_to_file(is_backup=True)
|
||||
|
|
@ -1006,7 +1006,7 @@ class trader:
|
|||
elif tp_status["status"]=="canceled":
|
||||
#TODO: Here, if the safety order is still open, we could resend the tp order.
|
||||
if self.config.get_attempt_restart():
|
||||
self.broker.logger.log_this("Take profit order canceled. Restarting the bot.",1,self.config.get_pair())
|
||||
self.broker.logger.log_this("Take profit order canceled. Restarting the trader.",1,self.config.get_pair())
|
||||
self.status.save_to_file(is_backup=True)
|
||||
self.restart = True
|
||||
else:
|
||||
|
|
@ -1061,7 +1061,7 @@ class trader:
|
|||
self.check_old_long_price()
|
||||
|
||||
self.status.set_pause_reason("check for autoswitch")
|
||||
#If it's a short bot that used to be long AND autoswitch is enabled
|
||||
#If it's a short trader that used to be long AND autoswitch is enabled
|
||||
if self.config.get_is_short() and self.config.get_autoswitch() and self.status.get_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.
|
||||
|
|
@ -1377,7 +1377,7 @@ class trader:
|
|||
|
||||
def quote_currency_switch_configs(self, new_quote: str) -> int:
|
||||
'''
|
||||
Updates the broker config file, changes all the variables and writes the new pair config file
|
||||
Updates the broker config file, changes all the variables and writes the new trader config file
|
||||
'''
|
||||
#Change broker config file
|
||||
self.broker.remove_pair_from_config(f"{self.base}{self.quote}")
|
||||
|
|
|
|||
Loading…
Reference in New Issue