From 782115d6445e3118fa00d0438880721e5cec38fd Mon Sep 17 00:00:00 2001 From: Vyacheslav Demidyuk Date: Sat, 8 Mar 2025 10:46:44 +0200 Subject: [PATCH] PyMtApi5: implemented function ChartPeriod --- PyMtApi5/client.py | 5 +++++ PyMtApi5/mt5apiclient.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/PyMtApi5/client.py b/PyMtApi5/client.py index 320f6be7..c4bfe1a8 100644 --- a/PyMtApi5/client.py +++ b/PyMtApi5/client.py @@ -69,6 +69,7 @@ class Mt5ApiApp: "ChartNext": self.process_chart_next, "ChartClose": self.process_chart_close, "ChartSymbol": self.process_chart_symbol, + "ChartPeriod": self.process_chart_period, } def on_disconnect(self, error_msg=None): @@ -510,6 +511,10 @@ class Mt5ApiApp: result = mtapi.chart_symbol(int(parameters)) print(f"> ChartSymbol: response = {result}") + def process_chart_period(self, mtapi, parameters): + result = mtapi.chart_period(int(parameters)) + print(f"> ChartPeriod: response = {result}") + def mtapi_command_thread(self, mtapi): while mtapi.is_connected(): filename = "client.cmd" diff --git a/PyMtApi5/mt5apiclient.py b/PyMtApi5/mt5apiclient.py index a1ffe2d9..9c0c75d1 100644 --- a/PyMtApi5/mt5apiclient.py +++ b/PyMtApi5/mt5apiclient.py @@ -504,18 +504,26 @@ class Mt5ApiClient: def chart_first(self): return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartFirst) + # ChartNext def chart_next(self, chart_id): cmd_params = {"ChartId": chart_id} return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartNext, cmd_params) + # ChartClose def chart_close(self, chart_id): cmd_params = {"ChartId": chart_id} return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartClose, cmd_params) + # ChartSymbol def chart_symbol(self, chart_id): cmd_params = {"ChartId": chart_id} return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartSymbol, cmd_params) + # ChartPeriod + def chart_period(self, chart_id): + cmd_params = {"ChartId": chart_id} + return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartPeriod, cmd_params) + # Private methods def __event_thread_func(self):