2025.10.10

This commit is contained in:
Nicolás Sánchez 2025-10-11 09:58:58 -03:00
parent d06bfd9d10
commit ca43b3dad5
4 changed files with 55 additions and 4 deletions

View File

@ -1,3 +1,7 @@
2025.10.10:
. New endpoint: /refresh_log_cache.
. Fixed an error in /add_so endpoint that incremented the config setting but not the status setting.
2025.10.09:
. Cleanup is done as soon as the trader starts, rather than after sending the take profit and safety orders.

View File

@ -1067,6 +1067,16 @@ class Logger:
return 1
def refresh_logs(self):
try:
self.log_list.clear()
self.preload_logs()
return 0
except Exception as e:
print(e)
return 1
def set_log_list_max_length(self, amount):
self.log_list_max_length = amount
return self.log_list_max_length

36
main.py
View File

@ -18,7 +18,7 @@ import exchange_wrapper
import trader
version = "2025.10.09"
version = "2025.10.10"
'''
Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
@ -1308,6 +1308,21 @@ def get_log_list():
return unwrapped_get_log_list()
@base_api.route("/refresh_log_cache", methods=['POST'])
def refresh_log_cache():
'''
POST request
'''
if not "X-API-KEY" in request.headers or not request.headers.get("X-API-KEY") in valid_keys:
return jsonify({'Error': 'API key invalid'}), 401
try:
return unwrapped_refresh_log_cache()
except Exception as e:
print(e)
return jsonify({'Error': 'Halp'})
@base_api.route("/get_balance", methods=['GET'])
def get_balance():
'''
@ -1795,8 +1810,7 @@ def unwrapped_add_safety_orders(base,quote,amount):
for instance in running_traders:
if symbol==instance.status.get_pair():
instance.set_pause(True, "Adding safety orders")
#x.no_of_safety_orders += int(amount)
instance.config.set_no_of_safety_orders(instance.config.get_no_of_safety_orders()+int(amount))
instance.status.set_no_of_safety_orders(instance.status.get_no_of_safety_orders()+int(amount))
broker.logger.log_this("Recalculating safety price table...",1,symbol)
instance.status.set_safety_price_table(instance.calculate_safety_prices(instance.status.get_start_price(),instance.config.get_no_of_safety_orders(),instance.config.get_safety_order_deviance()))
broker.logger.log_this(f"Done. Added {amount} safety orders",1,symbol)
@ -2459,6 +2473,22 @@ def unwrapped_get_log_list():
return jsonify({"Logs": broker.logger.get_log_list()})
def unwrapped_refresh_log_cache():
'''
Reloads the log file cache.
Parameters:
None
Returns:
jsonify: A jsonified dictionary containing the last n entries from the log file.
'''
if broker.logger.refresh_logs()==0:
return jsonify({"Success": "Logs refreshed"})
else:
return jsonify({"Error": "Error while refreshing logs"})
def unwrapped_get_deals_cache():
'''
Retrieves the last n entries from the broker's logger.

View File

@ -44,6 +44,7 @@ INSTANCE
13) paused_traders 14) fetch_log 15) edit_cooldown_multiplier
16) get_balance 17) cancel_global_last_call
18) mod_default_order_size 19) toggle_log_orders
20) refresh_log_cache
EARN
31) toggle_pause 32) get_step_size 33) set_step_size
@ -347,7 +348,13 @@ if __name__=="__main__":
url = f"{base_url}{port}/toggle_log_orders"
print(json.loads(requests.post(url, headers=headers).content))
input("Press ENTER to continue ")
elif command==20:
print("refresh_log_cache refreshes the log cache")
if input("Proceed? (Y/n) ") in ["Y","y",""]:
url = f"{base_url}{port}/refresh_log_cache"
print(json.loads(requests.post(url, headers=headers).content))
input("Press ENTER to continue ")
######################
######## EARN ########