mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-18 21:28:10 +00:00
PyMtApi5: Implemented function SymbolName
This commit is contained in:
@@ -74,6 +74,8 @@ class Mt5ApiApp:
|
|||||||
self.process_indicator_release(mtapi, pieces[1])
|
self.process_indicator_release(mtapi, pieces[1])
|
||||||
elif pieces[0] == "SymbolsTotal":
|
elif pieces[0] == "SymbolsTotal":
|
||||||
self.process_symbols_total(mtapi, pieces[1])
|
self.process_symbols_total(mtapi, pieces[1])
|
||||||
|
elif pieces[0] == "SymbolName":
|
||||||
|
self.process_symbol_name(mtapi, pieces[1])
|
||||||
else:
|
else:
|
||||||
print(f"! Unknown command: {pieces[0]}")
|
print(f"! Unknown command: {pieces[0]}")
|
||||||
|
|
||||||
@@ -157,6 +159,16 @@ class Mt5ApiApp:
|
|||||||
result = mtpapi.symbols_total(selected)
|
result = mtpapi.symbols_total(selected)
|
||||||
print(f"> SymbolsTotal: response = {result}")
|
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):
|
def mtapi_command_thread(self, mtapi):
|
||||||
while mtapi.is_connected():
|
while mtapi.is_connected():
|
||||||
filename = "client.cmd"
|
filename = "client.cmd"
|
||||||
|
|||||||
@@ -304,6 +304,11 @@ class Mt5ApiClient:
|
|||||||
return self.__send_command(
|
return self.__send_command(
|
||||||
self.__get_default_expert(), Mt5CommandType.SymbolsTotal, cmd_params)
|
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
|
# Private methods
|
||||||
|
|
||||||
def __event_thread_func(self):
|
def __event_thread_func(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user