mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-21 06:38:11 +00:00
PyMtApi5: implemented function MarketBookAdd, MarketBookRelease
This commit is contained in:
@@ -42,6 +42,8 @@ class Mt5ApiApp:
|
|||||||
"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,
|
"SymbolInfoSessionTrade": self.process_symbol_info_session_trade,
|
||||||
|
"MarketBookAdd": self.process_market_book_add,
|
||||||
|
"MarketBookRelease": self.process_market_book_release,
|
||||||
}
|
}
|
||||||
|
|
||||||
def on_disconnect(self, error_msg=None):
|
def on_disconnect(self, error_msg=None):
|
||||||
@@ -248,6 +250,22 @@ class Mt5ApiApp:
|
|||||||
result = mtapi.symbol_info_session_trade(symbol, day_of_week, session_index)
|
result = mtapi.symbol_info_session_trade(symbol, day_of_week, session_index)
|
||||||
print(f"> SymbolInfoSessionTrade: response = {result}")
|
print(f"> SymbolInfoSessionTrade: response = {result}")
|
||||||
|
|
||||||
|
def process_market_book_add(self, mtapi, parameters):
|
||||||
|
if len(parameters) == 0:
|
||||||
|
print(f"! Invalid parameters for command MarketBookAdd: {parameters} - {len(parameters)}")
|
||||||
|
return
|
||||||
|
symbol = parameters
|
||||||
|
result = mtapi.market_book_add(symbol)
|
||||||
|
print(f"> MarketBookAdd: response = {result}")
|
||||||
|
|
||||||
|
def process_market_book_release(self, mtapi, parameters):
|
||||||
|
if len(parameters) == 0:
|
||||||
|
print(f"! Invalid parameters for command MarketBookRelease: {parameters} - {len(parameters)}")
|
||||||
|
return
|
||||||
|
symbol = parameters
|
||||||
|
result = mtapi.market_book_release(symbol)
|
||||||
|
print(f"> MarketBookRelease: 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"
|
||||||
|
|||||||
@@ -366,6 +366,16 @@ class Mt5ApiClient:
|
|||||||
return (res["Result"]["From"], res["Result"]["To"])
|
return (res["Result"]["From"], res["Result"]["To"])
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
# MarketBookAdd
|
||||||
|
def market_book_add(self, symbol: str):
|
||||||
|
cmd_params = {"Symbol": symbol}
|
||||||
|
return self.__send_command(self.__get_default_expert(), Mt5CommandType.MarketBookAdd, cmd_params)
|
||||||
|
|
||||||
|
# MarketBookRelease
|
||||||
|
def market_book_release(self, symbol: str):
|
||||||
|
cmd_params = {"Symbol": symbol}
|
||||||
|
return self.__send_command(self.__get_default_expert(), Mt5CommandType.MarketBookRelease, cmd_params)
|
||||||
|
|
||||||
# Private methods
|
# Private methods
|
||||||
|
|
||||||
def __event_thread_func(self):
|
def __event_thread_func(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user