2025.08.10
This commit is contained in:
parent
e49945ddbc
commit
3feb5f3a77
|
|
@ -1,3 +1,8 @@
|
|||
2025.08.10:
|
||||
. Added exchange name to the trader quit notification.
|
||||
. New endpoint: mod_default_order_size. It modified the default order size of a broker.
|
||||
. Added "generated_at" field to any new generated trader config file.
|
||||
|
||||
2025.07.21:
|
||||
. Corrected an error in switch_to_long.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import json
|
||||
import os
|
||||
import time
|
||||
|
||||
class ConfigHandler:
|
||||
'''
|
||||
|
|
@ -40,7 +40,8 @@ class ConfigHandler:
|
|||
|
||||
#Loads from disk the config file (if it exists)
|
||||
if self.load_from_file()==1:
|
||||
#If the config file does not exist, write a new one with the default values
|
||||
#If the config file does not exist, write a new one with the default values and sign it with timestamp.
|
||||
self.config_dictionary["generated_at"] = int(time.time())
|
||||
self.save_to_file()
|
||||
if config_dict is not None:
|
||||
self.config_dictionary = {**self.config_dictionary, **config_dict}
|
||||
|
|
|
|||
48
main.py
48
main.py
|
|
@ -16,7 +16,7 @@ import exchange_wrapper
|
|||
import trader
|
||||
|
||||
|
||||
version = "2025.07.21"
|
||||
version = "2025.08.10"
|
||||
|
||||
'''
|
||||
Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
|
||||
|
|
@ -269,8 +269,8 @@ def main_loop():
|
|||
restart_pair_no_json(instance.base,instance.quote)
|
||||
if instance.quit:
|
||||
#Here, check if a duster is needed
|
||||
broker.logger.log_this(f"Quit flag raised, removing pair.",0,instance.config.get_pair())
|
||||
broker.logger.log_this(f"Quit flag raised, removing pair: {instance.config.get_pair()}",-1) #Forced message to TG
|
||||
broker.logger.log_this(f"{broker.get_exchange_name().capitalize()} | Quit flag raised, removing trader.",0,instance.config.get_pair())
|
||||
broker.logger.log_this(f"{broker.get_exchange_name().capitalize()} | Quit flag raised, removing trader: {instance.config.get_pair()}",-1) #Forced message to TG
|
||||
if f"{instance.base}{instance.quote}" in tickers:
|
||||
tickers.remove(f"{instance.base}{instance.quote}")
|
||||
broker.remove_pair_from_config(f"{instance.base}{instance.quote}")
|
||||
|
|
@ -827,6 +827,28 @@ def mod_order_size():
|
|||
return jsonify({'Error': 'API key invalid'}), 401
|
||||
|
||||
|
||||
@base_api.route("/mod_default_order_size", methods=['POST'])
|
||||
def mod_default_order_size():
|
||||
'''
|
||||
POST request
|
||||
|
||||
Parameters:
|
||||
amount: float
|
||||
'''
|
||||
|
||||
if "X-API-KEY" in request.headers and request.headers.get("X-API-KEY") in valid_keys:
|
||||
try:
|
||||
if request.json is None:
|
||||
return jsonify({'Error': 'request.json is None'})
|
||||
data = request.json
|
||||
amount = data["amount"]
|
||||
return unwrapped_mod_default_order_size(amount)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return jsonify({'Error': 'Halp'})
|
||||
return jsonify({'Error': 'API key invalid'}), 401
|
||||
|
||||
|
||||
@base_api.route("/mod_global_tp_level", methods=['POST'])
|
||||
def mod_global_tp_level():
|
||||
'''
|
||||
|
|
@ -1766,6 +1788,26 @@ def unwrapped_mod_order_size(base,quote,amount):
|
|||
return jsonify({"Error": "Error changing order size"})
|
||||
|
||||
|
||||
def unwrapped_mod_default_order_size(amount):
|
||||
'''
|
||||
Modifies the default order size of a broker.
|
||||
|
||||
Parameters:
|
||||
amount (str): The new order size.
|
||||
|
||||
Returns:
|
||||
jsonify: A jsonified dictionary detailing the outcome of the operation
|
||||
'''
|
||||
|
||||
try:
|
||||
broker.set_default_order_size(float(amount))
|
||||
broker.logger.log_this(f"Done. Default order size modified to {float(amount)}",2)
|
||||
return jsonify({"Success": f"Success. Default order size modified to {float(amount)}"})
|
||||
except Exception:
|
||||
broker.logger.log_this("Error modifying default order size",2)
|
||||
return jsonify({"Error": "Error modifying default order size"})
|
||||
|
||||
|
||||
def unwrapped_mod_global_tp_level(amount):
|
||||
'''
|
||||
Modifies the take profit percentage of all pairs. It applies the new percentage only after a new TP order is sent.
|
||||
|
|
|
|||
Loading…
Reference in New Issue