PyMtApi5: Implemented function SymbolName

This commit is contained in:
Vyacheslav Demidyuk
2025-01-16 14:01:57 +02:00
parent ee149feef1
commit 7c1d2e53d4
2 changed files with 17 additions and 0 deletions
+12
View File
@@ -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"
+5
View File
@@ -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):