mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-25 16:48:10 +00:00
PyMtApi5: Implemented function SymbolSelect
This commit is contained in:
+12
-2
@@ -76,6 +76,8 @@ class Mt5ApiApp:
|
|||||||
self.process_symbols_total(mtapi, pieces[1])
|
self.process_symbols_total(mtapi, pieces[1])
|
||||||
elif pieces[0] == "SymbolName":
|
elif pieces[0] == "SymbolName":
|
||||||
self.process_symbol_name(mtapi, pieces[1])
|
self.process_symbol_name(mtapi, pieces[1])
|
||||||
|
elif pieces[0] == "SymbolSelect":
|
||||||
|
self.process_symbol_select(mtapi, pieces[1])
|
||||||
else:
|
else:
|
||||||
print(f"! Unknown command: {pieces[0]}")
|
print(f"! Unknown command: {pieces[0]}")
|
||||||
|
|
||||||
@@ -154,8 +156,7 @@ class Mt5ApiApp:
|
|||||||
if not parameters or len(parameters) == 0:
|
if not parameters or len(parameters) == 0:
|
||||||
print(f"! Invalid parameters for command SymbolsTotal: {parameters}")
|
print(f"! Invalid parameters for command SymbolsTotal: {parameters}")
|
||||||
return
|
return
|
||||||
parameters = parameters[:len(parameters) - 1]
|
selected = parameters[:len(parameters) - 1] == "True"
|
||||||
selected = parameters == "True"
|
|
||||||
result = mtpapi.symbols_total(selected)
|
result = mtpapi.symbols_total(selected)
|
||||||
print(f"> SymbolsTotal: response = {result}")
|
print(f"> SymbolsTotal: response = {result}")
|
||||||
|
|
||||||
@@ -169,6 +170,15 @@ class Mt5ApiApp:
|
|||||||
result = mtpapi.symbol_name(pos, selected)
|
result = mtpapi.symbol_name(pos, selected)
|
||||||
print(f"> SymbolName: response = {result}")
|
print(f"> SymbolName: response = {result}")
|
||||||
|
|
||||||
|
def process_symbol_select(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 SymbolSelect: {parameters}")
|
||||||
|
return
|
||||||
|
selected = pieces[1][:len(pieces[1]) - 1] == "True"
|
||||||
|
result = mtpapi.symbol_select(pieces[0], selected)
|
||||||
|
print(f"> SymbolSelect: 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,11 +304,18 @@ 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)
|
||||||
|
|
||||||
|
# SymbolName
|
||||||
def symbol_name(self, pos: int, selected: bool):
|
def symbol_name(self, pos: int, selected: bool):
|
||||||
cmd_params = {"Pos": pos, "Selected" : selected}
|
cmd_params = {"Pos": pos, "Selected" : selected}
|
||||||
return self.__send_command(
|
return self.__send_command(
|
||||||
self.__get_default_expert(), Mt5CommandType.SymbolName, cmd_params)
|
self.__get_default_expert(), Mt5CommandType.SymbolName, cmd_params)
|
||||||
|
|
||||||
|
# SymbolSelect
|
||||||
|
def symbol_select(self, symbol_name: str, selected: bool):
|
||||||
|
cmd_params = {"Symbol": symbol_name, "Selected": selected}
|
||||||
|
return self.__send_command(
|
||||||
|
self.__get_default_expert(), Mt5CommandType.SymbolSelect, cmd_params)
|
||||||
|
|
||||||
# Private methods
|
# Private methods
|
||||||
|
|
||||||
def __event_thread_func(self):
|
def __event_thread_func(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user