mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-13 10:48:08 +00:00
PyMtApi5: implemented function ChartOpen
This commit is contained in:
@@ -64,6 +64,7 @@ class Mt5ApiApp:
|
|||||||
"ChartWindowFind": self.process_chart_window_find,
|
"ChartWindowFind": self.process_chart_window_find,
|
||||||
"ChartTimePriceToXY": self.process_chart_time_price_to_xy,
|
"ChartTimePriceToXY": self.process_chart_time_price_to_xy,
|
||||||
"ChartXYToTimePrice": self.process_chart_xy_to_time_price,
|
"ChartXYToTimePrice": self.process_chart_xy_to_time_price,
|
||||||
|
"ChartOpen": self.process_chart_open,
|
||||||
}
|
}
|
||||||
|
|
||||||
def on_disconnect(self, error_msg=None):
|
def on_disconnect(self, error_msg=None):
|
||||||
@@ -477,6 +478,15 @@ class Mt5ApiApp:
|
|||||||
result = mtapi.chart_xy_to_time_price(int(pieces[0]), int(pieces[1]), int(pieces[2]))
|
result = mtapi.chart_xy_to_time_price(int(pieces[0]), int(pieces[1]), int(pieces[2]))
|
||||||
print(f"> ChartXYToTimePrice: response = {result}")
|
print(f"> ChartXYToTimePrice: response = {result}")
|
||||||
|
|
||||||
|
def process_chart_open(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 ChartOpen: {parameters}")
|
||||||
|
return
|
||||||
|
period = mt5enums.ENUM_TIMEFRAMES(int(pieces[1]))
|
||||||
|
result = mtapi.chart_open(pieces[0], period)
|
||||||
|
print(f"> ChartOpen: 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"
|
||||||
|
|||||||
@@ -495,6 +495,12 @@ class Mt5ApiClient:
|
|||||||
return (res["Result"]["SubWindow"], res["Result"]["Time"], res["Result"]["Price"])
|
return (res["Result"]["SubWindow"], res["Result"]["Time"], res["Result"]["Price"])
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# ChartOpen
|
||||||
|
def chart_open(self, symbol: str, period: ENUM_TIMEFRAMES):
|
||||||
|
cmd_params = {"Symbol": symbol, "Timeframe": period};
|
||||||
|
res = self.__send_command(self.__get_default_expert(), Mt5CommandType.ChartOpen, cmd_params)
|
||||||
|
return res
|
||||||
|
|
||||||
# Private methods
|
# Private methods
|
||||||
|
|
||||||
def __event_thread_func(self):
|
def __event_thread_func(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user