removed conditionals in some endpoints

This commit is contained in:
Nicolás Sánchez 2025-09-01 14:19:20 -03:00
parent 23d85de155
commit 694e5a95d1
1 changed files with 17 additions and 24 deletions

41
main.py
View File

@ -1950,16 +1950,15 @@ def unwrapped_last_call(base,quote):
try: try:
symbol = f"{base}/{quote}" symbol = f"{base}/{quote}"
if symbol in broker.get_pairs(): #Why was this? for instance in running_traders:
for instance in running_traders: if symbol==instance.status.get_pair():
if symbol==instance.status.get_pair(): instance.status.set_stop_when_profit(not instance.status.get_stop_when_profit())
instance.status.set_stop_when_profit(not instance.status.get_stop_when_profit()) instance.update_status(True)
if instance.status.get_stop_when_profit():
instance.config.set_autoswitch(False)
instance.update_status(True) instance.update_status(True)
if instance.status.get_stop_when_profit(): return jsonify({"Success": "Trader scheduled to go offline when profit is reached"})
instance.config.set_autoswitch(False) return jsonify({"Success": "Last call cancelled"})
instance.update_status(True)
return jsonify({"Success": "Trader scheduled to go offline when profit is reached"})
return jsonify({"Success": "Last call cancelled"})
return jsonify({"Error": "Trader does not exist"}) return jsonify({"Error": "Trader does not exist"})
except Exception: except Exception:
return jsonify({"Error": "Halp"}) return jsonify({"Error": "Halp"})
@ -2032,14 +2031,11 @@ def unwrapped_global_last_call():
jsonify: A jsonified dictionary detailing the outcome of the operation. jsonify: A jsonified dictionary detailing the outcome of the operation.
''' '''
try: try:
if broker.get_pairs!=[]: for instance in running_traders:
#broker.clear_pairs() instance.status.set_stop_when_profit(True)
for instance in running_traders: instance.config.set_autoswitch(False)
instance.status.set_stop_when_profit(True) broker.logger.log_this("Modified flag",2,f"{instance.base}/{instance.quote}")
instance.config.set_autoswitch(False) return jsonify({"Success": "All traders scheduled to go offline when profit is reached"})
broker.logger.log_this("Modified flag",2,f"{instance.base}/{instance.quote}")
return jsonify({"Success": "All traders scheduled to go offline when profit is reached"})
return jsonify({"Error": "No traders running"})
except Exception: except Exception:
return jsonify({"Error": "Halp"}) return jsonify({"Error": "Halp"})
@ -2052,13 +2048,10 @@ def unwrapped_cancel_global_last_call():
jsonify: A jsonified dictionary detailing the outcome of the operation. jsonify: A jsonified dictionary detailing the outcome of the operation.
''' '''
try: try:
if broker.get_pairs!=[]: for instance in running_traders:
#broker.clear_pairs() instance.status.set_stop_when_profit(False)
for instance in running_traders: broker.logger.log_this("Modified flag",2,f"{instance.base}/{instance.quote}")
instance.status.set_stop_when_profit(False) return jsonify({"Success": "Last call canceled"})
broker.logger.log_this("Modified flag",2,f"{instance.base}/{instance.quote}")
return jsonify({"Success": "Last call canceled"})
return jsonify({"Error": "No traders running"})
except Exception: except Exception:
return jsonify({"Error": "Halp"}) return jsonify({"Error": "Halp"})