mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 02:57:56 +00:00
PyMtApi5: implemented function SymbolInfoTick
This commit is contained in:
@@ -39,6 +39,7 @@ class Mt5ApiApp:
|
||||
"SymbolInfoDouble": self.process_symbol_info_double,
|
||||
"SymbolInfoInteger": self.process_symbol_info_integer,
|
||||
"SymbolInfoString": self.process_symbol_info_string,
|
||||
"SymbolInfoTick": self.process_symbol_info_tick,
|
||||
}
|
||||
|
||||
def on_disconnect(self, error_msg=None):
|
||||
@@ -215,6 +216,14 @@ class Mt5ApiApp:
|
||||
result = mtapi.symbol_info_string(symbol, prop_id)
|
||||
print(f"> SymbolInfoString: response = {result}")
|
||||
|
||||
def process_symbol_info_tick(self, mtapi, parameters):
|
||||
if len(parameters) == 0:
|
||||
print(f"! Invalid parameters for command SymbolInfoTick: {parameters} - {len(parameters)}")
|
||||
return
|
||||
symbol = parameters
|
||||
result = mtapi.symbol_info_tick(symbol)
|
||||
print(f"> SymbolInfoTick: response = {result}")
|
||||
|
||||
def mtapi_command_thread(self, mtapi):
|
||||
while mtapi.is_connected():
|
||||
filename = "client.cmd"
|
||||
|
||||
@@ -29,6 +29,16 @@ class Mt5Quote:
|
||||
return f"{self.expert_handle}-{self.instrument}: Bid = {self.bid}, Ask = {self.ask}, Volume = {self.volume}"
|
||||
|
||||
|
||||
class Mql5Tick:
|
||||
def __init__(self, tick_json):
|
||||
self.bid = tick_json["Bid"]
|
||||
self.ask = tick_json["Ask"]
|
||||
self.last = tick_json["Last"]
|
||||
self.volume = tick_json["Volume"]
|
||||
|
||||
def __repr__(self):
|
||||
return f"Bid = {self.bid}, Ask = {self.ask}, Last = {self.last}, Volume = {self.volume}"
|
||||
|
||||
class MqlRates:
|
||||
def __init__(self, mql_rates_json):
|
||||
self.time = mql_rates_json["mt_time"]
|
||||
@@ -331,6 +341,14 @@ class Mt5ApiClient:
|
||||
cmd_params = {"Symbol": symbol_name, "PropId": prop_id}
|
||||
return self.__send_command(self.__get_default_expert(), Mt5CommandType.SymbolInfoString, cmd_params)
|
||||
|
||||
# SymbolInoTick
|
||||
def symbol_info_tick(self, symbol_name: str):
|
||||
cmd_params = {"Symbol": symbol_name}
|
||||
res = self.__send_command(self.__get_default_expert(), Mt5CommandType.SymbolInfoTick, cmd_params)
|
||||
if res is not None and res["RetVal"] == True:
|
||||
return Mql5Tick(res["Result"])
|
||||
return None
|
||||
|
||||
# Private methods
|
||||
|
||||
def __event_thread_func(self):
|
||||
|
||||
Reference in New Issue
Block a user