diff --git a/config_handler.py b/config_handler.py index ab26ba3..bb897a3 100644 --- a/config_handler.py +++ b/config_handler.py @@ -39,7 +39,7 @@ class ConfigHandler: #Loads from disk the config file (if it exists) self.load_from_file() 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() diff --git a/main.py b/main.py index 8c26a82..4535850 100644 --- a/main.py +++ b/main.py @@ -265,7 +265,6 @@ def main_loop(): global last_market_reload global reload_interval global screen_buffer - #global paused_pairs while True: #Restart traders that have the restart flag raised and remove traders that have the quit flag raised diff --git a/status_handler.py b/status_handler.py index b17ef5c..4cce8cd 100644 --- a/status_handler.py +++ b/status_handler.py @@ -5,9 +5,10 @@ class StatusHandler: 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.default_status_dictionary = { + "pair": pair, "tp_order_id": "", "take_profit_order": {}, "take_profit_price": 0.0, @@ -42,10 +43,13 @@ class StatusHandler: "status_string": "", "deal_order_history": [] } - if status_dict is None: - self.status_dictionary = self.default_status_dictionary.copy() - else: - self.status_dictionary = {**self.default_status_dictionary, **status_dict} + self.status_file_path = f"configs/{pair.split('/')[0]}{pair.split('/')[1]}.json" + self.status_dictionary = self.default_status_dictionary.copy() + + if status_dict is not None: + self.status_dictionary = {**self.status_dictionary, **status_dict} + self.save_to_file() + def get_tp_order_id(self): @@ -283,7 +287,9 @@ class StatusHandler: 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: with open(file_path, "w") as 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) 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: with open(file_path, "r") as f: self.set_status(json.load(f)) diff --git a/todo.txt b/todo.txt index 44519ad..60b80ad 100755 --- a/todo.txt +++ b/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 d. In status bar: Total funds to be released. 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. diff --git a/trader.py b/trader.py index 93e21f3..7b5765e 100755 --- a/trader.py +++ b/trader.py @@ -37,6 +37,7 @@ class trader: self.start_price = 0 self.safety_order_index = 0 self.status_dict = { + "pair": self.pair, "quote_spent": 0, "base_bought": 0, "so_amount": 0,