mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-18 13:18:12 +00:00
PyMtApi5: implemented function SymbolInfoSessionTrade
This commit is contained in:
@@ -41,6 +41,7 @@ class Mt5ApiApp:
|
|||||||
"SymbolInfoString": self.process_symbol_info_string,
|
"SymbolInfoString": self.process_symbol_info_string,
|
||||||
"SymbolInfoTick": self.process_symbol_info_tick,
|
"SymbolInfoTick": self.process_symbol_info_tick,
|
||||||
"SymbolInfoSessionQuote": self.process_symbol_info_session_quote,
|
"SymbolInfoSessionQuote": self.process_symbol_info_session_quote,
|
||||||
|
"SymbolInfoSessionTrade": self.process_symbol_info_session_trade,
|
||||||
}
|
}
|
||||||
|
|
||||||
def on_disconnect(self, error_msg=None):
|
def on_disconnect(self, error_msg=None):
|
||||||
@@ -236,6 +237,17 @@ class Mt5ApiApp:
|
|||||||
result = mtapi.symbol_info_session_quote(symbol, day_of_week, session_index)
|
result = mtapi.symbol_info_session_quote(symbol, day_of_week, session_index)
|
||||||
print(f"> SymbolInfoSessionQuote: response = {result}")
|
print(f"> SymbolInfoSessionQuote: response = {result}")
|
||||||
|
|
||||||
|
def process_symbol_info_session_trade(self, mtapi, parameters):
|
||||||
|
pieces = parameters.split(" ", 2)
|
||||||
|
if len(pieces) != 3 or not pieces[0] or not pieces[1] or not pieces[2]:
|
||||||
|
print(f"! Invalid parameters for command SymbolInfoSessionTrade: {parameters}")
|
||||||
|
return
|
||||||
|
symbol = pieces[0]
|
||||||
|
day_of_week = mt5enums.ENUM_DAY_OF_WEEK(int(pieces[1]))
|
||||||
|
session_index = int(pieces[2])
|
||||||
|
result = mtapi.symbol_info_session_trade(symbol, day_of_week, session_index)
|
||||||
|
print(f"> SymbolInfoSessionTrade: 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"
|
||||||
|
|||||||
@@ -358,6 +358,14 @@ class Mt5ApiClient:
|
|||||||
return (res["Result"]["From"], res["Result"]["To"])
|
return (res["Result"]["From"], res["Result"]["To"])
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# SymbolInfoSessionTrade
|
||||||
|
def symbol_info_session_trade(self, name: str, day_of_week: ENUM_DAY_OF_WEEK, session_index: int):
|
||||||
|
cmd_params = {"Symbol": name, "DayOfWeek": day_of_week, "SessionIndex": session_index}
|
||||||
|
res = self.__send_command(self.__get_default_expert(), Mt5CommandType.SymbolInfoSessionTrade, cmd_params)
|
||||||
|
if res is not None and res["RetVal"] == True:
|
||||||
|
return (res["Result"]["From"], res["Result"]["To"])
|
||||||
|
return None
|
||||||
|
|
||||||
# Private methods
|
# Private methods
|
||||||
|
|
||||||
def __event_thread_func(self):
|
def __event_thread_func(self):
|
||||||
@@ -383,7 +391,6 @@ class Mt5ApiClient:
|
|||||||
if response is None:
|
if response is None:
|
||||||
self.__logger.warning("Failed to send commad. Result is None")
|
self.__logger.warning("Failed to send commad. Result is None")
|
||||||
raise Exception("Failed to send commad. Result is None")
|
raise Exception("Failed to send commad. Result is None")
|
||||||
print(f"response = {response}")
|
|
||||||
response_json = json.loads(response)
|
response_json = json.loads(response)
|
||||||
error_code = int(response_json["ErrorCode"])
|
error_code = int(response_json["ErrorCode"])
|
||||||
if error_code != 0:
|
if error_code != 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user