added pair to status dictionary
This commit is contained in:
parent
10b812d7f0
commit
168c5c823f
|
|
@ -39,7 +39,7 @@ class ConfigHandler:
|
||||||
#Loads from disk the config file (if it exists)
|
#Loads from disk the config file (if it exists)
|
||||||
self.load_from_file()
|
self.load_from_file()
|
||||||
if config_dict is not None:
|
if config_dict is not None:
|
||||||
self.config_dictionary = {**self.default_config_dictionary, **config_dict}
|
self.config_dictionary = {**self.config_dictionary, **config_dict}
|
||||||
self.save_to_file()
|
self.save_to_file()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
1
main.py
1
main.py
|
|
@ -265,7 +265,6 @@ def main_loop():
|
||||||
global last_market_reload
|
global last_market_reload
|
||||||
global reload_interval
|
global reload_interval
|
||||||
global screen_buffer
|
global screen_buffer
|
||||||
#global paused_pairs
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
#Restart traders that have the restart flag raised and remove traders that have the quit flag raised
|
#Restart traders that have the restart flag raised and remove traders that have the quit flag raised
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,10 @@ class StatusHandler:
|
||||||
Handles the status of the trader and the validation of the parameters
|
Handles the status of the trader and the validation of the parameters
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, broker, status_dict = None):
|
def __init__(self, broker, pair, status_dict = None):
|
||||||
self.broker = broker
|
self.broker = broker
|
||||||
self.default_status_dictionary = {
|
self.default_status_dictionary = {
|
||||||
|
"pair": pair,
|
||||||
"tp_order_id": "",
|
"tp_order_id": "",
|
||||||
"take_profit_order": {},
|
"take_profit_order": {},
|
||||||
"take_profit_price": 0.0,
|
"take_profit_price": 0.0,
|
||||||
|
|
@ -42,10 +43,13 @@ class StatusHandler:
|
||||||
"status_string": "",
|
"status_string": "",
|
||||||
"deal_order_history": []
|
"deal_order_history": []
|
||||||
}
|
}
|
||||||
if status_dict is None:
|
self.status_file_path = f"configs/{pair.split('/')[0]}{pair.split('/')[1]}.json"
|
||||||
self.status_dictionary = self.default_status_dictionary.copy()
|
self.status_dictionary = self.default_status_dictionary.copy()
|
||||||
else:
|
|
||||||
self.status_dictionary = {**self.default_status_dictionary, **status_dict}
|
if status_dict is not None:
|
||||||
|
self.status_dictionary = {**self.status_dictionary, **status_dict}
|
||||||
|
self.save_to_file()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_tp_order_id(self):
|
def get_tp_order_id(self):
|
||||||
|
|
@ -283,7 +287,9 @@ class StatusHandler:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
def save_to_file(self, file_path: str):
|
def save_to_file(self, file_path = None):
|
||||||
|
if file_path is None:
|
||||||
|
file_path = self.status_file_path
|
||||||
try:
|
try:
|
||||||
with open(file_path, "w") as f:
|
with open(file_path, "w") as f:
|
||||||
json.dump(self.status_dictionary, f)
|
json.dump(self.status_dictionary, f)
|
||||||
|
|
@ -292,7 +298,9 @@ class StatusHandler:
|
||||||
self.broker.logger.log_this(f"Error saving status to file: {file_path}: {e}",1)
|
self.broker.logger.log_this(f"Error saving status to file: {file_path}: {e}",1)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def load_from_file(self, file_path: str):
|
def load_from_file(self, file_path = None):
|
||||||
|
if file_path is None:
|
||||||
|
file_path = self.status_file_path
|
||||||
try:
|
try:
|
||||||
with open(file_path, "r") as f:
|
with open(file_path, "r") as f:
|
||||||
self.set_status(json.load(f))
|
self.set_status(json.load(f))
|
||||||
|
|
|
||||||
2
todo.txt
2
todo.txt
|
|
@ -42,4 +42,4 @@ Maybe it's a good idea?:
|
||||||
c. Order on screen: BASE/QUOTE | order_id followed | current_price | deal_close_price | total_volume_on_close | pct_to_profit | uptime
|
c. Order on screen: BASE/QUOTE | order_id followed | current_price | deal_close_price | total_volume_on_close | pct_to_profit | uptime
|
||||||
d. In status bar: Total funds to be released.
|
d. In status bar: Total funds to be released.
|
||||||
e. Change main screen: x traders online | y dusters online
|
e. Change main screen: x traders online | y dusters online
|
||||||
f. Since they only need to monitor if one order is filled and the data is already locally available, the extra API load will be negligible.
|
f. Since they only need to monitor if one order is filled and the data is already locally available, there will be no extra API load.
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ class trader:
|
||||||
self.start_price = 0
|
self.start_price = 0
|
||||||
self.safety_order_index = 0
|
self.safety_order_index = 0
|
||||||
self.status_dict = {
|
self.status_dict = {
|
||||||
|
"pair": self.pair,
|
||||||
"quote_spent": 0,
|
"quote_spent": 0,
|
||||||
"base_bought": 0,
|
"base_bought": 0,
|
||||||
"so_amount": 0,
|
"so_amount": 0,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue