PyMtApi5: implemented function ChartRedraw

This commit is contained in:
Vyacheslav Demidyuk
2025-02-08 12:09:57 +02:00
parent beacad1a10
commit bd59c4052d
2 changed files with 12 additions and 1 deletions
+5
View File
@@ -58,6 +58,7 @@ class Mt5ApiApp:
"CopySpread": self.process_copy_spread,
"CopyTicks": self.process_copy_ticks,
"ChartId": self.process_chart_id,
"ChartRedraw": self.process_chart_redraw,
}
def on_disconnect(self, error_msg=None):
@@ -427,6 +428,10 @@ class Mt5ApiApp:
result = mtapi.chart_id(int(parameters))
print(f"> ChatId: response = {result}")
def process_chart_redraw(self, mtapi, parameters):
mtapi.chart_redraw(int(parameters))
print(f"> ChartRedraw: success")
def mtapi_command_thread(self, mtapi):
while mtapi.is_connected():
filename = "client.cmd"
+7 -1
View File
@@ -458,6 +458,10 @@ class Mt5ApiClient:
else:
return self.__send_command(expert_handle, Mt5CommandType.ChartId)
def chart_redraw(self, chart_id = 0):
cmd_params = {"ChartId": chart_id}
self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartRedraw, cmd_params)
# Private methods
def __event_thread_func(self):
@@ -489,7 +493,9 @@ class Mt5ApiClient:
error_message = response_json["ErrorMessage"]
self.__logger.warning(f"send_command: ErrorCode = {error_code}. {error_message}")
raise Exception(f"Failed to send command: ErrorCode = {error_code}. {error_message} ")
return response_json["Value"]
if "Value" in response_json:
return response_json["Value"]
return None
def __process_tick_event(self, payload):
quote_json = json.loads(payload)