diff --git a/PyMtApi5/client.py b/PyMtApi5/client.py index ef7153b7..26347dfd 100644 --- a/PyMtApi5/client.py +++ b/PyMtApi5/client.py @@ -74,6 +74,8 @@ class Mt5ApiApp: self.process_indicator_release(mtapi, pieces[1]) elif pieces[0] == "SymbolsTotal": self.process_symbols_total(mtapi, pieces[1]) + elif pieces[0] == "SymbolName": + self.process_symbol_name(mtapi, pieces[1]) else: print(f"! Unknown command: {pieces[0]}") @@ -157,6 +159,16 @@ class Mt5ApiApp: result = mtpapi.symbols_total(selected) print(f"> SymbolsTotal: response = {result}") + def process_symbol_name(self, mtpapi, parameters): + pieces = parameters.split(' ', 1) + if len(pieces) != 2 or not pieces[0] or not pieces[1] or len(pieces[1]) == 0: + print(f"! Invalid parameters for command SymbolName: {parameters}") + return + pos = int(pieces[0]) + selected = pieces[1][:len(pieces[1]) - 1] == "True" + result = mtpapi.symbol_name(pos, selected) + print(f"> SymbolName: response = {result}") + def mtapi_command_thread(self, mtapi): while mtapi.is_connected(): filename = "client.cmd" diff --git a/PyMtApi5/mt5apiclient.py b/PyMtApi5/mt5apiclient.py index 3e5ac0a4..47dac25a 100644 --- a/PyMtApi5/mt5apiclient.py +++ b/PyMtApi5/mt5apiclient.py @@ -304,6 +304,11 @@ class Mt5ApiClient: return self.__send_command( self.__get_default_expert(), Mt5CommandType.SymbolsTotal, cmd_params) + def symbol_name(self, pos: int, selected: bool): + cmd_params = {"Pos": pos, "Selected" : selected} + return self.__send_command( + self.__get_default_expert(), Mt5CommandType.SymbolName, cmd_params) + # Private methods def __event_thread_func(self):