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