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:
|
2025.07.21:
|
||||||
. Corrected an error in switch_to_long.
|
. Corrected an error in switch_to_long.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import json
|
import json
|
||||||
import os
|
import time
|
||||||
|
|
||||||
class ConfigHandler:
|
class ConfigHandler:
|
||||||
'''
|
'''
|
||||||
|
|
@ -40,7 +40,8 @@ class ConfigHandler:
|
||||||
|
|
||||||
#Loads from disk the config file (if it exists)
|
#Loads from disk the config file (if it exists)
|
||||||
if self.load_from_file()==1:
|
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()
|
self.save_to_file()
|
||||||
if config_dict is not None:
|
if config_dict is not None:
|
||||||
self.config_dictionary = {**self.config_dictionary, **config_dict}
|
self.config_dictionary = {**self.config_dictionary, **config_dict}
|
||||||
|
|
|
||||||
48
main.py
48
main.py
|
|
@ -16,7 +16,7 @@ import exchange_wrapper
|
||||||
import trader
|
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
|
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)
|
restart_pair_no_json(instance.base,instance.quote)
|
||||||
if instance.quit:
|
if instance.quit:
|
||||||
#Here, check if a duster is needed
|
#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"{broker.get_exchange_name().capitalize()} | Quit flag raised, removing trader.",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: {instance.config.get_pair()}",-1) #Forced message to TG
|
||||||
if f"{instance.base}{instance.quote}" in tickers:
|
if f"{instance.base}{instance.quote}" in tickers:
|
||||||
tickers.remove(f"{instance.base}{instance.quote}")
|
tickers.remove(f"{instance.base}{instance.quote}")
|
||||||
broker.remove_pair_from_config(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
|
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'])
|
@base_api.route("/mod_global_tp_level", methods=['POST'])
|
||||||
def mod_global_tp_level():
|
def mod_global_tp_level():
|
||||||
'''
|
'''
|
||||||
|
|
@ -1764,7 +1786,27 @@ def unwrapped_mod_order_size(base,quote,amount):
|
||||||
except Exception:
|
except Exception:
|
||||||
broker.logger.log_this("Error changing order size. Ignoring...",2,f"{base}/{quote}")
|
broker.logger.log_this("Error changing order size. Ignoring...",2,f"{base}/{quote}")
|
||||||
return jsonify({"Error": "Error changing order size"})
|
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):
|
def unwrapped_mod_global_tp_level(amount):
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
1
todo.txt
1
todo.txt
|
|
@ -11,6 +11,7 @@ Mandatory:
|
||||||
* Status (Mostly done).
|
* Status (Mostly done).
|
||||||
6. API documentation.
|
6. API documentation.
|
||||||
7. Implement api key hashing.
|
7. Implement api key hashing.
|
||||||
|
8. Dockerize.
|
||||||
|
|
||||||
|
|
||||||
Would be nice to have:
|
Would be nice to have:
|
||||||
|
|
|
||||||
|
|
@ -1583,7 +1583,7 @@ class trader:
|
||||||
|
|
||||||
return f"{white}{line1}\n{line3}{white}"
|
return f"{white}{line1}\n{line3}{white}"
|
||||||
|
|
||||||
|
|
||||||
def load_imported_trader(self, forced_tp_order_id = None, forced_safety_order_id = None) -> int:
|
def load_imported_trader(self, forced_tp_order_id = None, forced_safety_order_id = None) -> int:
|
||||||
'''
|
'''
|
||||||
Loads status dictionary, orders and sets up variables
|
Loads status dictionary, orders and sets up variables
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue