Earn support for commander

This commit is contained in:
Nicolás Sánchez 2025-01-08 10:22:25 -03:00
parent b8f1193143
commit 1303ee7c51
1 changed files with 140 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import json
import credentials
try:
earn_api_key = credentials.get_credentials("earn_api_key")["key"]
if sys.argv[1]=="--testnet":
is_testnet = True
string_to_add = "TESTNET "
@ -24,6 +25,8 @@ except Exception as e:
sys.exit()
headers = {'X-API-KEY': api_key}
earn_headers = {'X-API-KEY': earn_api_key}
command_list = f'''{string_to_add}COMMANDS:
@ -35,6 +38,14 @@ INSTANCE
13) paused_traders 14) fetch_log 15) edit_cooldown_multiplier
16) backtests 17) get_balance
EARN
31) toggle_pause 32) get_step_size 33) set_step_size
34) get_percentage 35) set_percentage 36) get_time_between_subscriptions
37) set_time_between_subscriptions 38) get_time_between_redemptions
39) set_time_between_redemptions 40) get_minimum_amount_in_trading_account
41) set_minimum_amount_in_trading_account 42) get_last_subscription
43) get_last_redemption 44) get_total_balance
TRADERS
51) worker_status 52) get_all_worker_status
53) add_pair 54) remove_pair 55) restart_pair
@ -99,6 +110,10 @@ if __name__=="__main__":
#print("Invalid input")
#sys.exit()
port = exchanges[selection]
earn_broker = port[1:]
if earn_broker=="okex":
earn_broker="okx"
print("DCAv2 COMMANDER")
@ -132,6 +147,9 @@ if __name__=="__main__":
# break
selection = select_exchange(exchanges)
port = exchanges[selection]
earn_broker = port[1:]
if earn_broker=="okex":
earn_broker="okx"
print(f"New exchange selected: {selection}")
@ -308,6 +326,128 @@ if __name__=="__main__":
print(json.loads(requests.get(url,headers=headers).content))
input("Press ENTER to continue ")
######################
######## EARN ########
######################
elif command==31:
print("toggle_pause interrupts or resume the subcription and redemption of funds")
if input(f"This will toggle the subscription and redemption of funds on {port}. Are you sure? (Y/n) ") in ["Y","y",""]:
url = f"{base_url}/earn/toggle_pause"
parameters = {"broker": earn_broker}
print(json.loads(requests.post(url,headers=earn_headers, json=parameters).content))
input("Press ENTER to continue ")
elif command==32:
print("get_step_size returns the step size")
url = f"{base_url}/earn/get_step_size?broker={earn_broker}"
print(json.loads(requests.get(url,headers=earn_headers).content))
input("Press ENTER to continue ")
elif command==33:
print("set_step_size sets the step size")
new_step_size = input("New step size? ")
if not validate_float_or_int(new_step_size):
print("Invalid step size")
break
if input(f"This will set the step size to {new_step_size}. Are you sure? (Y/n) ") in ["Y","y",""]:
url = f"{base_url}/earn/set_step_size"
parameters = {"broker": earn_broker, "new_step_size": new_step_size}
print(json.loads(requests.post(url,headers=earn_headers, json=parameters).content))
input("Press ENTER to continue ")
elif command==34:
print("get_percentage displays the percentage of funds to be allocated to earn")
url = f"{base_url}/earn/get_percentage?broker={earn_broker}"
print(json.loads(requests.get(url,headers=earn_headers).content))
input("Press ENTER to continue ")
elif command==35:
print("set_percentage sets the percentage of funds to be allocated to earn")
new_percentage = input("New percentage? ")
if not validate_float_or_int(new_percentage):
print("Invalid percentage")
break
if input(f"This will set the percentage to {new_percentage}. Are you sure? (Y/n) ") in ["Y","y",""]:
url = f"{base_url}/earn/set_percentage"
parameters = {"broker": earn_broker, "new_percentage": new_percentage}
print(json.loads(requests.post(url,headers=earn_headers, json=parameters).content))
input("Press ENTER to continue ")
elif command==36:
print("get_time_between_subscriptions displays the time to wait between subscriptions")
url = f"{base_url}/earn/get_time_between_subscriptions?broker={earn_broker}"
print(json.loads(requests.get(url,headers=earn_headers).content))
input("Press ENTER to continue ")
elif command==37:
print("set_time_between_subscriptions sets the time to wait between subscriptions")
new_time_between_subscriptions = input("New time between subscriptions? ")
if not validate_int(new_time_between_subscriptions):
print("Invalid time")
break
if input(f"This will set the time to wait between subscriptions to {new_time_between_subscriptions}. Are you sure? (Y/n) ") in ["Y","y",""]:
url = f"{base_url}/earn/set_time_between_subscriptions"
parameters = {"broker": earn_broker, "new_time_between_subscriptions": new_time_between_subscriptions}
print(json.loads(requests.post(url,headers=earn_headers, json=parameters).content))
input("Press ENTER to continue ")
elif command==38:
print("get_time_between_redemptions displays the time to wait between redemptions")
url = f"{base_url}/earn/get_time_between_redemptions?broker={earn_broker}"
print(json.loads(requests.get(url,headers=earn_headers).content))
input("Press ENTER to continue ")
elif command==39:
print("set_time_between_redemptions sets the time to wait between redemptions")
new_time_between_redemptions = input("New time between redemptions? ")
if not validate_int(new_time_between_redemptions):
print("Invalid time")
break
if input(f"This will set the time to wait between redemptions to {new_time_between_redemptions}. Are you sure? (Y/n) ") in ["Y","y",""]:
url = f"{base_url}/earn/set_time_between_redemptions"
parameters = {"broker": earn_broker, "new_time_between_redemptions": new_time_between_redemptions}
print(json.loads(requests.post(url,headers=earn_headers, json=parameters).content))
input("Press ENTER to continue ")
elif command==40:
print("get_minimum_amount_in_trading_account displays the minimum amount of funds that always have to exist in the trading account")
url = f"{base_url}/earn/get_minimum_amount_in_trading_account?broker={earn_broker}"
print(json.loads(requests.get(url,headers=earn_headers).content))
input("Press ENTER to continue ")
elif command==41:
print("set_minimum_amount_in_trading_account sets the minimum amount of funds that always have to exist in the trading account")
new_minimum_amount_in_trading_account = input("New minimum amount in trading account? ")
if not validate_int(new_minimum_amount_in_trading_account):
print("Invalid amount")
break
if input(f"This will set the minimum amount of funds that always have to exist in the trading account to {new_minimum_amount_in_trading_account}. Are you sure? (Y/n) ") in ["Y","y",""]:
url = f"{base_url}/earn/set_minimum_amount_in_trading_account"
parameters = {"broker": earn_broker, "new_minimum_amount_in_trading_account": new_minimum_amount_in_trading_account}
print(json.loads(requests.post(url,headers=earn_headers, json=parameters).content))
input("Press ENTER to continue ")
elif command==42:
print("get_last_subscription display the last subscription")
url = f"{base_url}/earn/get_last_subscription?broker={earn_broker}"
print(json.loads(requests.get(url,headers=earn_headers).content))
input("Press ENTER to continue ")
elif command==43:
print("get_last_redemptions displays the last redemption")
url = f"{base_url}/earn/get_last_redemption?broker={earn_broker}"
print(json.loads(requests.get(url,headers=earn_headers).content))
input("Press ENTER to continue ")
elif command==44:
print("get_total_balance displays the trading account balance and the earning account balance")
url = f"{base_url}/earn/get_total_balance?broker={earn_broker}"
print(json.loads(requests.get(url,headers=earn_headers).content))
input("Press ENTER to continue ")
######################
####### TRADER #######
######################