PyMtApi5: implemented function CopyTime

This commit is contained in:
Vyacheslav Demidyuk
2025-01-26 00:09:24 +02:00
parent 05aa533e3b
commit c61c773fb9
2 changed files with 21 additions and 3 deletions
+13
View File
@@ -47,6 +47,7 @@ class Mt5ApiApp:
"MarketBookGet": self.process_market_book_get,
"CopyBuffer": self.process_copy_buffer,
"CopyRates": self.process_copy_rates,
"CopyTime": self.process_copy_time,
}
def on_disconnect(self, error_msg=None):
@@ -304,6 +305,18 @@ class Mt5ApiApp:
result = mtapi.copy_rates(symbol_name, timeframe, start_pos, count)
print(f"> CopyRates: response = {result}")
def process_copy_time(self, mtapi, parameters):
pieces = parameters.split(" ", 3)
if len(pieces) != 4 or not pieces[0] or not pieces[1] or not pieces[2] or not pieces[3]:
print(f"! Invalid parameters for command CopyTime: {parameters}")
return
symbol_name = pieces[0]
timeframe = mt5enums.ENUM_TIMEFRAMES(int(pieces[1]))
start_pos = int(pieces[2])
count = int(pieces[3])
result = mtapi.copy_time(symbol_name, timeframe, start_pos, count)
print(f"> CopyTime: response = {result}")
def mtapi_command_thread(self, mtapi):
while mtapi.is_connected():
filename = "client.cmd"
+8 -3
View File
@@ -285,9 +285,14 @@ class Mt5ApiClient:
return rates
# CopyTime
def copy_time(self):
# TODO
pass
def copy_time(self, symbol_name: str, timeframe: ENUM_TIMEFRAMES, start_pos: int, count: int):
cmdParams = {
"Symbol": symbol_name,
"Timeframe": timeframe,
"StartPos": start_pos,
"Count": count,
}
return self.__send_command(self.__get_default_expert(), Mt5CommandType.CopyTime, cmdParams)
# Copy Open
def copy_open(self):