mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 02:57:56 +00:00
PyMtApi5: implemented function CopyTime
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user