605 lines
28 KiB
Python
605 lines
28 KiB
Python
import requests
|
|
import sys
|
|
import json
|
|
import credentials
|
|
|
|
try:
|
|
if sys.argv[1]=="--testnet":
|
|
is_testnet = True
|
|
string_to_add = "TESTNET "
|
|
api_key = credentials.get_credentials("testnet_api_key")["key"]
|
|
base_url = credentials.get_url("testnet") #type: ignore
|
|
exchanges = {"Binance":"/binance"}
|
|
elif sys.argv[1]=="--mainnet":
|
|
is_testnet = False
|
|
string_to_add = "MAINNET "
|
|
api_key = credentials.get_credentials("mainnet_api_key")["key"]
|
|
base_url = credentials.get_url("mainnet") #type: ignore
|
|
exchanges = {"binance":"/binance", "gate.io":"/gateio", "kucoin":"/kucoin", "okx":"/okex"}
|
|
else:
|
|
print(f"Unrecognized parameter {sys.argv[1]}")
|
|
sys.exit()
|
|
except Exception as e:
|
|
print(e)
|
|
sys.exit()
|
|
|
|
headers = {'X-API-KEY': api_key}
|
|
|
|
command_list = f'''{string_to_add}COMMANDS:
|
|
|
|
INSTANCE
|
|
1) global_status 2) missing_pairs 3) server_time
|
|
4) trader_time 5) toggle_restart 6) toggle_telegram
|
|
7) mod_global_tp_level 8) global_last_call 9) edit_loop_wait_time
|
|
10) edit_call_wait_time 11) reload_markets 12) fetch_full_log
|
|
13) paused_traders 14) fetch_log 15) edit_cooldown_multiplier
|
|
|
|
TRADERS
|
|
51) worker_status 52) get_all_worker_status
|
|
53) add_pair 54) remove_pair 55) restart_pair
|
|
56) import_pair 57) switch_to_short 58) switch_to_long
|
|
59) load_old_long 60) add_so 61) add_quote
|
|
62) mod_tp_level 63) last_call 64) deferred_last_call
|
|
65) toggle_pause 66) toggle_cleanup 67) toggle_autoswitch
|
|
68) toggle_check_old_long_price 69) switch_quote_currency
|
|
70) reload_safety_order 71) view_old_long
|
|
|
|
98) Change broker 99) Exit
|
|
'''
|
|
|
|
def validate_pair(trading_pair):
|
|
return "/" in trading_pair and len(trading_pair)>3
|
|
|
|
def validate_float_or_int(number):
|
|
'''
|
|
Validates if the number can be interpreted as a float or an int
|
|
'''
|
|
try:
|
|
number = str(float(number))
|
|
return True
|
|
except Exception:
|
|
return False
|
|
|
|
def validate_int(number):
|
|
'''
|
|
Validates if the number can be interpreted as an integer
|
|
'''
|
|
try:
|
|
new_number = int(number)
|
|
if str(new_number) == str(number):
|
|
return True
|
|
return False
|
|
except Exception:
|
|
return False
|
|
|
|
def select_exchange(exchanges):
|
|
'''
|
|
Selects the exchange to use
|
|
'''
|
|
|
|
selection = input("Enter exchange: (Binance, Gate.io, KuCoin, OKX) ").lower()
|
|
for item in exchanges:
|
|
if selection in item.lower():
|
|
return item
|
|
print("Invalid input")
|
|
sys.exit()
|
|
|
|
if __name__=="__main__":
|
|
|
|
if len(exchanges)==1:
|
|
selection = list(exchanges.keys())[0]
|
|
else:
|
|
selection = select_exchange(exchanges)
|
|
#selection = input("Enter exchange: (Binance, Gate.io, KuCoin, OKX) ").lower()
|
|
#for item in exchanges:
|
|
# if selection in item.lower():
|
|
# selection = item
|
|
# break
|
|
#print("Invalid input")
|
|
#sys.exit()
|
|
port = exchanges[selection]
|
|
|
|
|
|
print("DCAv2 COMMANDER")
|
|
if not is_testnet:
|
|
print("WARNING: RUNNING ON MAINNET")
|
|
|
|
while True:
|
|
print("="*80)
|
|
print(f"Exchange: {selection}")
|
|
print(command_list)
|
|
|
|
|
|
#When entering the command, it shows a brief description and requests for parameters.
|
|
command = input("Your input: ")
|
|
|
|
try:
|
|
command = int(command)
|
|
except Exception as e:
|
|
print(e)
|
|
|
|
if command==99:
|
|
print("Goodbye")
|
|
sys.exit()
|
|
|
|
elif command==98:
|
|
#while True:
|
|
# selection = input("Enter exchange: (Binance, Gate.io, KuCoin, OKX) ").lower()
|
|
# if selection not in exchanges:
|
|
# print("Invalid input")
|
|
# port = exchanges[selection]
|
|
# break
|
|
selection = select_exchange(exchanges)
|
|
port = exchanges[selection]
|
|
print(f"New exchange selected: {selection}")
|
|
|
|
|
|
######################
|
|
###### INSTANCE ######
|
|
######################
|
|
|
|
elif command==1:
|
|
print("global_status returns a dictionary of the global status of the instance")
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/global_status"
|
|
print(json.loads(requests.get(url,headers=headers).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==2:
|
|
print("missing_pairs returns a list of pairs that are in the config file of the instance")
|
|
print("but are not running.")
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/missing_pairs"
|
|
print(json.loads(requests.get(url,headers=headers).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==3:
|
|
print("server_time returns the linux time of the server")
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/server_time"
|
|
print(json.loads(requests.get(url,headers=headers).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==4:
|
|
print("trader_time return the last time of the traders was active")
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/trader_time"
|
|
print(json.loads(requests.get(url,headers=headers).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==5:
|
|
print("toggle_restart controls if the instance will attempt to restart failed traders or not")
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/toggle_restart"
|
|
print(json.loads(requests.post(url, headers=headers).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==6:
|
|
print("toggle_telegram turns on or off the Telegram notifications")
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/toggle_telegram"
|
|
print(json.loads(requests.post(url, headers=headers).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==7:
|
|
print("mod_global_tp_level modifies the percentage of profit of all the traders")
|
|
print("Example: 1.02 is equal to 2% profit")
|
|
new_profit_level = input("Desired profit level: ")
|
|
if not validate_float_or_int(new_profit_level):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/mod_global_tp_level"
|
|
parameters = {"amount": new_profit_level}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==8:
|
|
print("global_last_call signals all traders to cease operation when profit is reached")
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/global_last_call"
|
|
print(json.loads(requests.post(url, headers=headers).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==9:
|
|
print("edit_loop_wait_time modifies the pause the instance takes after processing the open orders")
|
|
print("instance fetch the orders -> instance sends the orders to the traders ->")
|
|
print("instance waits for the traders to complete their tasks -> instance waits <loop_wait_time> seconds")
|
|
print("The input value can be an integer or a float")
|
|
new_wait_time = input("Desired wait time: ")
|
|
if not validate_float_or_int(new_wait_time):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/edit_loop_wait_time"
|
|
parameters = {"wait_time": new_wait_time}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==10:
|
|
print("edit_call_wait_time modifies the pause that the traders take between some API calls")
|
|
print("This aims to reduce the load on the API endpoints of the broker.")
|
|
print("The input value can be an integer or a float")
|
|
new_wait_time = input("Desired call wait time: ")
|
|
if not validate_float_or_int(new_wait_time):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/edit_call_wait_time"
|
|
parameters = {"wait_time": new_wait_time}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==11:
|
|
print("reload_markets forces CCXT to renew all the market information")
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/reload_markets"
|
|
print(json.loads(requests.post(url, headers=headers).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==12:
|
|
print("fetch_full_log displays the log of an instance.")
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}/statistics_server/fetch_full_log?exchange_name={port[1:]}&width={100}"
|
|
for item in json.loads(requests.get(url, headers=headers).content)["line"]:
|
|
print(item)
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==13:
|
|
print("paused_traders returns a list of paused traders.")
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/paused_traders"
|
|
print(json.loads(requests.get(url,headers=headers).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==14:
|
|
print("fetch_log displays the last n log entries of an instance.")
|
|
amount = input("Amount of lines? ")
|
|
if not validate_float_or_int(amount):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}/statistics_server/fetch_log?exchange_name={port[1:]}&width={100}&amount={amount}"
|
|
for item in json.loads(requests.get(url, headers=headers).content)["line"]:
|
|
print(item)
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==15:
|
|
print("edit_cooldown_multiplier modifies the pause's multiplier after it hits profit.")
|
|
print("This aims to reduce the volatility when there are big orderbook movements.")
|
|
print("The input value can be an integer or a float")
|
|
new_multiplier = input("Desired multiplier: ")
|
|
if not validate_float_or_int(new_multiplier):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/edit_cooldown_multiplier"
|
|
parameters = {"cooldown_multiplier": new_multiplier}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
######################
|
|
####### TRADER #######
|
|
######################
|
|
|
|
elif command==51:
|
|
print("worker_status return the status dictionary of the trader")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
base,quote = trading_pair.split("/")
|
|
url = f"{base_url}{port}/worker_status?base={base}"e={quote}"
|
|
print(json.loads(requests.get(url,headers=headers).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==52:
|
|
print("get_all_worker_status returns a dictionary of all the status dictionaries of all active trader")
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/get_all_worker_status"
|
|
print(json.loads(requests.get(url,headers=headers).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==53:
|
|
print("add_pair add a trader to the instance.")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/add_pair"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==54:
|
|
print("remove_pair terminates a running trader from the instance.")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/remove_pair"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==55:
|
|
print("restart_pair terminates and restarts a trader from the instance.")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/restart_pair"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==56:
|
|
print("import_pair imports a trader to the instance.")
|
|
print("In order for the importing to be successful, a status file must exist in the status directory ")
|
|
print("and the take profit order must be open.")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/import_pair"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==57:
|
|
print("switch_to_short changes the mode of operation of a trader from long mode (the default one) to short mode.")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/switch_to_short"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==58:
|
|
print("switch_to_long changes the mode of operation of a trader from short mode to the default long mode")
|
|
print("It takes an extra parameter flag: 0 to ignore the profit calculation from the switch and 1 to do that calculation")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
calculation = input("Profit calculation? 0: ignore, 1: calculate ")
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if int(calculation) not in [0,1]:
|
|
print("The input for the calculation flag is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/switch_to_long"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote,
|
|
"calculate_profits": calculation}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==59:
|
|
print("load_old_long load to the status dictionary the contents of an old_long file")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/load_old_long"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==60:
|
|
print("add_so extends the safety order limit of a trader")
|
|
print("You can also use negative numbers to substract to that limit")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
amount = input("Amount of safety orders to add/remove: ")
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if not validate_int(amount):
|
|
print("The amount entered is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/add_so"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote,
|
|
"amount": amount}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==61:
|
|
print("add_quote adds a lump sum of quote currency to the deal.")
|
|
print("This is not possible to do on a short trader")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
amount = input("Amount of quote to add: ")
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if not validate_float_or_int(amount):
|
|
print("The amount entered is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/add_quote"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote,
|
|
"amount": amount}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==62:
|
|
print("mod_tp_level modifies the profit percentage of a trader")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
new_profit_level = input("Desired profit level: ")
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if not validate_float_or_int(new_profit_level):
|
|
print("The amount entered is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/mod_tp_level"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote,
|
|
"amount": new_profit_level}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==63:
|
|
print("last_call signals a trader to cease operation when profit is reached")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/last_call"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==64:
|
|
print("deferred_last_call signals a trader to cease operation when profit is reached after certain date")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
yyyymmdd = input("Input date (YYYYMMDD) ")
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if len(yyyymmdd)!=8:
|
|
print("Date format is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/deferred_last_call"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote,
|
|
"yyyymmdd": yyyymmdd}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==65:
|
|
print("toggle_pause pauses or unpauses a trader")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/toggle_pause"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==66:
|
|
print("toggle_cleanup enables or disables the cleanup routine of a trader")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/toggle_cleanup"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==67:
|
|
print("toggle_autoswitch enables or disables the automatic switch to long of a short trader once certain conditions are met.")
|
|
print("This is only valid in a short trader, of course.")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/toggle_autoswitch"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==68:
|
|
print("toggle_check_old_long_price enables or disables the verification of the current price exceeding the old long price.")
|
|
print("This is only valid in a short trader, of course.")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/toggle_check_old_long_price"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==69:
|
|
print("switch_quote_currency changes the quote currency of a running trader.")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
new_quote = input("Input new quote currency: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if len(new_quote)==0:
|
|
print("The quote currency is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/switch_quote_currency"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote,
|
|
"new_quote": new_quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==70:
|
|
print("reload_safety_order reloads the safety order to the reader using the order id present in the status dictionary")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
url = f"{base_url}{port}/reload_safety_order"
|
|
base,quote = trading_pair.split("/")
|
|
parameters = {"base": base,
|
|
"quote": quote}
|
|
print(json.loads(requests.post(url, headers=headers, json=parameters).content))
|
|
input("Press ENTER to continue ")
|
|
|
|
elif command==71:
|
|
print("Views the old_long information")
|
|
trading_pair = input("Input trader in the format BASE/QUOTE: ").upper()
|
|
if not validate_pair(trading_pair):
|
|
print("The input is invalid")
|
|
break
|
|
from_file = 0 if input("From file? (y/N) ") in ["N","n",""] else 1
|
|
if input("Proceed? (Y/n) ") in ["Y","y",""]:
|
|
base,quote = trading_pair.split("/")
|
|
url = f"{base_url}{port}/view_old_long?base={base}"e={quote}&from_file={from_file}"
|
|
print(json.loads(requests.get(url,headers=headers).content))
|
|
input("Press ENTER to continue ")
|