From 793c63a40a31e2afd9c5b10d248741049db545d3 Mon Sep 17 00:00:00 2001 From: biohazardxxx Date: Fri, 3 Jul 2026 23:59:38 +0200 Subject: [PATCH 1/5] MtApi5: add SymbolInfoMarginRate command id 380 Co-Authored-By: Claude Fable 5 --- MtApi5/MtProtocol/Mt5CommandType.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MtApi5/MtProtocol/Mt5CommandType.cs b/MtApi5/MtProtocol/Mt5CommandType.cs index 4af91bdb..2e3b0e4b 100755 --- a/MtApi5/MtProtocol/Mt5CommandType.cs +++ b/MtApi5/MtProtocol/Mt5CommandType.cs @@ -260,6 +260,8 @@ internal enum Mt5CommandType OrderCheck = 303, Buy = 304, Sell = 305, - GetSymbols = 306 + GetSymbols = 306, + + SymbolInfoMarginRate = 380 } } From 99e0e2369daa3b21878573a7caef5686116128ee Mon Sep 17 00:00:00 2001 From: biohazardxxx Date: Fri, 3 Jul 2026 23:59:38 +0200 Subject: [PATCH 2/5] MtApi5: add SymbolInfoMarginRate client method Co-Authored-By: Claude Fable 5 --- MtApi5/MtApi5Client.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/MtApi5/MtApi5Client.cs b/MtApi5/MtApi5Client.cs index b75bd2a0..f8b56726 100755 --- a/MtApi5/MtApi5Client.cs +++ b/MtApi5/MtApi5Client.cs @@ -1701,6 +1701,32 @@ public bool SymbolInfoSessionTrade(string name, ENUM_DAY_OF_WEEK dayOfWeek, uint return false; } + /// + ///Returns the margin rates depending on the order type and direction. + /// + ///Symbol name. + ///Order type. + ///A variable, to which the initial margin rate value will be written. + ///A variable, to which the maintenance margin rate value will be written. + public bool SymbolInfoMarginRate(string symbolName, ENUM_ORDER_TYPE orderType, out double initialMarginRate, out double maintenanceMarginRate) + { + Dictionary cmdParams = new() { { "Symbol", symbolName ?? string.Empty }, { "OrderType", orderType } }; + + var response = SendCommand>>(ExecutorHandle, + Mt5CommandType.SymbolInfoMarginRate, cmdParams); + if (response != null && response.Result != null + && response.Result.TryGetValue("Initial", out double initial) + && response.Result.TryGetValue("Maintenance", out double maintenance)) + { + initialMarginRate = initial; + maintenanceMarginRate = maintenance; + return response.RetVal; + } + initialMarginRate = 0; + maintenanceMarginRate = 0; + return false; + } + /// ///Provides opening of Depth of Market for a selected symbol, and subscribes for receiving notifications of the DOM changes. /// From 03bba0e6cb0bf944a36eb54e35c13af4a6c382a2 Mon Sep 17 00:00:00 2001 From: biohazardxxx Date: Fri, 3 Jul 2026 23:59:38 +0200 Subject: [PATCH 3/5] MQL5: add SymbolInfoMarginRate command handler Co-Authored-By: Claude Fable 5 --- mq5/MtApi5.mq5 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/mq5/MtApi5.mq5 b/mq5/MtApi5.mq5 index 18c0b55e..07962b0c 100644 --- a/mq5/MtApi5.mq5 +++ b/mq5/MtApi5.mq5 @@ -381,6 +381,7 @@ int preinit() ADD_EXECUTOR(304, Buy); ADD_EXECUTOR(305, Sell); ADD_EXECUTOR(306, GetSymbols); + ADD_EXECUTOR(380, SymbolInfoMarginRate); return (0); } @@ -1647,6 +1648,26 @@ string Execute_SymbolInfoSessionTrade() return CreateSuccessResponse(result_value_jo); } +string Execute_SymbolInfoMarginRate() +{ + GET_JSON_PAYLOAD(jo); + GET_STRING_JSON_VALUE(jo, "Symbol", symbol); + GET_INT_JSON_VALUE(jo, "OrderType", order_type); + + double initial_margin_rate = 0.0; + double maintenance_margin_rate = 0.0; + bool ok = SymbolInfoMarginRate(symbol, (ENUM_ORDER_TYPE)order_type, initial_margin_rate, maintenance_margin_rate); + + JSONObject* result_value_jo = new JSONObject(); + result_value_jo.put("RetVal", new JSONBool(ok)); + JSONObject* info_jo = new JSONObject(); + info_jo.put("Initial", new JSONNumber(initial_margin_rate)); + info_jo.put("Maintenance", new JSONNumber(maintenance_margin_rate)); + result_value_jo.put("Result", info_jo); + + return CreateSuccessResponse(result_value_jo); +} + string Execute_MarketBookAdd() { GET_JSON_PAYLOAD(jo); From c25d8b6027d1d013a45e56ed5a7e574455d38522 Mon Sep 17 00:00:00 2001 From: biohazardxxx Date: Fri, 3 Jul 2026 23:59:38 +0200 Subject: [PATCH 4/5] MtApi5TestClient: add SymbolInfoMarginRate test action Co-Authored-By: Claude Fable 5 --- TestClients/MtApi5TestClient/MainWindow.xaml | 1 + TestClients/MtApi5TestClient/ViewModel.cs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/TestClients/MtApi5TestClient/MainWindow.xaml b/TestClients/MtApi5TestClient/MainWindow.xaml index c30fe43e..0fdbc630 100755 --- a/TestClients/MtApi5TestClient/MainWindow.xaml +++ b/TestClients/MtApi5TestClient/MainWindow.xaml @@ -499,6 +499,7 @@