mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 02:57:56 +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])
|
||||
elif pieces[0] == "SymbolName":
|
||||
self.process_symbol_name(mtapi, pieces[1])
|
||||
elif pieces[0] == "SymbolSelect":
|
||||
self.process_symbol_select(mtapi, pieces[1])
|
||||
else:
|
||||
print(f"! Unknown command: {pieces[0]}")
|
||||
|
||||
@@ -154,8 +156,7 @@ class Mt5ApiApp:
|
||||
if not parameters or len(parameters) == 0:
|
||||
print(f"! Invalid parameters for command SymbolsTotal: {parameters}")
|
||||
return
|
||||
parameters = parameters[:len(parameters) - 1]
|
||||
selected = parameters == "True"
|
||||
selected = parameters[:len(parameters) - 1] == "True"
|
||||
result = mtpapi.symbols_total(selected)
|
||||
print(f"> SymbolsTotal: response = {result}")
|
||||
|
||||
@@ -169,6 +170,15 @@ class Mt5ApiApp:
|
||||
result = mtpapi.symbol_name(pos, selected)
|
||||
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):
|
||||
while mtapi.is_connected():
|
||||
filename = "client.cmd"
|
||||
|
||||
@@ -304,11 +304,18 @@ class Mt5ApiClient:
|
||||
return self.__send_command(
|
||||
self.__get_default_expert(), Mt5CommandType.SymbolsTotal, cmd_params)
|
||||
|
||||
# SymbolName
|
||||
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)
|
||||
|
||||
# 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
|
||||
|
||||
def __event_thread_func(self):
|
||||
|
||||
Reference in New Issue
Block a user