mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-19 13:48:11 +00:00
PyMtApi5: implemented function ChartSaveTemplate"
This commit is contained in:
@@ -60,6 +60,7 @@ class Mt5ApiApp:
|
|||||||
"ChartId": self.process_chart_id,
|
"ChartId": self.process_chart_id,
|
||||||
"ChartRedraw": self.process_chart_redraw,
|
"ChartRedraw": self.process_chart_redraw,
|
||||||
"ChartApplyTemplate": self.process_chart_apply_template,
|
"ChartApplyTemplate": self.process_chart_apply_template,
|
||||||
|
"ChartSaveTemplate": self.process_chart_save_template,
|
||||||
}
|
}
|
||||||
|
|
||||||
def on_disconnect(self, error_msg=None):
|
def on_disconnect(self, error_msg=None):
|
||||||
@@ -441,6 +442,14 @@ class Mt5ApiApp:
|
|||||||
result = mtapi.chart_apply_template(int(pieces[0]), pieces[1])
|
result = mtapi.chart_apply_template(int(pieces[0]), pieces[1])
|
||||||
print(f"> ChartApplyTemplate: response = {result}")
|
print(f"> ChartApplyTemplate: response = {result}")
|
||||||
|
|
||||||
|
def process_chart_save_template(self, mtapi, parameters):
|
||||||
|
pieces = parameters.split(" ", 1)
|
||||||
|
if len(pieces) != 2 or not pieces[0] or not pieces[1]:
|
||||||
|
print(f"! Invalid parameters for command ChartSaveTemplate: {parameters}")
|
||||||
|
return
|
||||||
|
result = mtapi.chart_save_template(int(pieces[0]), pieces[1])
|
||||||
|
print(f"> ChartSaveTemplate: 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"
|
||||||
|
|||||||
@@ -453,22 +453,27 @@ class Mt5ApiClient:
|
|||||||
return self.__send_command(self.__get_default_expert(), Mt5CommandType.MarketBookGet, cmd_params)
|
return self.__send_command(self.__get_default_expert(), Mt5CommandType.MarketBookGet, cmd_params)
|
||||||
|
|
||||||
# ChartId
|
# ChartId
|
||||||
def chart_id(self, expert_handle = 0):
|
def chart_id(self, expert_handle=0):
|
||||||
if expert_handle == 0:
|
if expert_handle == 0:
|
||||||
return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartId)
|
return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartId)
|
||||||
else:
|
else:
|
||||||
return self.__send_command(expert_handle, Mt5CommandType.ChartId)
|
return self.__send_command(expert_handle, Mt5CommandType.ChartId)
|
||||||
|
|
||||||
# ChartRedraw
|
# ChartRedraw
|
||||||
def chart_redraw(self, chart_id = 0):
|
def chart_redraw(self, chart_id=0):
|
||||||
cmd_params = {"ChartId": chart_id}
|
cmd_params = {"ChartId": chart_id}
|
||||||
self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartRedraw, cmd_params)
|
self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartRedraw, cmd_params)
|
||||||
|
|
||||||
# ChartApplyTemplate
|
# ChartApplyTemplate
|
||||||
def chart_apply_template(self, chart_id, filename: str):
|
def chart_apply_template(self, chart_id, filename: str):
|
||||||
cmd_params = { "ChartId": chart_id, "TemplateFileName": filename};
|
cmd_params = {"ChartId": chart_id, "TemplateFileName": filename}
|
||||||
return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartApplyTemplate, cmd_params)
|
return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartApplyTemplate, cmd_params)
|
||||||
|
|
||||||
|
# ChartSaveTemplate
|
||||||
|
def chart_save_template(self, chart_id, filename: str):
|
||||||
|
cmd_params = {"ChartId": chart_id, "TemplateFileName": filename}
|
||||||
|
return self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartSaveTemplate, cmd_params)
|
||||||
|
|
||||||
# Private methods
|
# Private methods
|
||||||
|
|
||||||
def __event_thread_func(self):
|
def __event_thread_func(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user