Compare commits

...

3 Commits

5 changed files with 50 additions and 4 deletions
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.14")]
[assembly: AssemblyFileVersion("1.0.14")]
[assembly: AssemblyVersion("1.0.15")]
[assembly: AssemblyFileVersion("1.0.15")]
@@ -259,6 +259,8 @@
<Button Content="HistoryDealGetDouble" Command="{Binding HistoryDealGetDoubleCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="HistoryDealGetInteger" Command="{Binding HistoryDealGetIntegerCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="HistoryDealGetString" Command="{Binding HistoryDealGetStringCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="HistoryOrderGetInteger" Command="{Binding HistoryOrderGetIntegerCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="HistoryDealMethods" Command="{Binding HistoryDealMethodsCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
</StackPanel>
</Grid>
+34
View File
@@ -16,9 +16,11 @@ namespace MtApi5TestClient
public DelegateCommand DisconnectCommand { get; private set; }
public DelegateCommand OrderSendCommand { get; private set; }
public DelegateCommand HistoryOrderGetIntegerCommand { get; private set; }
public DelegateCommand HistoryDealGetDoubleCommand { get; private set; }
public DelegateCommand HistoryDealGetIntegerCommand { get; private set; }
public DelegateCommand HistoryDealGetStringCommand { get; private set; }
public DelegateCommand HistoryDealMethodsCommand { get; private set; }
public DelegateCommand AccountInfoDoubleCommand { get; private set; }
public DelegateCommand AccountInfoIntegerCommand { get; private set; }
@@ -196,9 +198,11 @@ namespace MtApi5TestClient
DisconnectCommand = new DelegateCommand(ExecuteDisconnect, CanExecuteDisconnect);
OrderSendCommand = new DelegateCommand(ExecuteOrderSend);
HistoryOrderGetIntegerCommand = new DelegateCommand(ExecuteHistoryOrderGetInteger);
HistoryDealGetDoubleCommand = new DelegateCommand(ExecuteHistoryDealGetDouble);
HistoryDealGetIntegerCommand = new DelegateCommand(ExecuteHistoryDealGetInteger);
HistoryDealGetStringCommand = new DelegateCommand(ExecuteHistoryDealGetString);
HistoryDealMethodsCommand = new DelegateCommand(ExecuteHistoryDealMethods);
AccountInfoDoubleCommand = new DelegateCommand(ExecuteAccountInfoDouble);
AccountInfoIntegerCommand = new DelegateCommand(ExecuteAccountInfoInteger);
@@ -277,6 +281,16 @@ namespace MtApi5TestClient
AddLog(message);
}
private async void ExecuteHistoryOrderGetInteger(object o)
{
const ulong ticket = 12345;
const ENUM_ORDER_PROPERTY_INTEGER propertyId = ENUM_ORDER_PROPERTY_INTEGER.ORDER_POSITION_ID;
var retVal = await Execute(() => _mtApiClient.HistoryOrderGetInteger(ticket, propertyId));
AddLog($"HistoryOrderGetInteger: {retVal}");
}
private async void ExecuteHistoryDealGetDouble(object o)
{
const ulong ticket = 12345;
@@ -307,6 +321,26 @@ namespace MtApi5TestClient
AddLog($"HistoryDealGetString: {retVal}");
}
private async void ExecuteHistoryDealMethods(object o)
{
try
{
var posId = await Execute(() => _mtApiClient.PositionGetInteger(ENUM_POSITION_PROPERTY_INTEGER.POSITION_IDENTIFIER)); // posId = 7247951
var history = await Execute(() => _mtApiClient.HistorySelectByPosition(posId)); // history = true
var historyDealsTotal = await Execute(() => _mtApiClient.HistoryDealsTotal()); // historyDealsCount = 4
var histDealTicket = await Execute(() => _mtApiClient.HistoryDealGetTicket(0)); // histDealTicket = 6632442
var histDealPrice = await Execute(() => _mtApiClient.HistoryDealGetDouble(histDealTicket, ENUM_DEAL_PROPERTY_DOUBLE.DEAL_PRICE)); // Exception
}
catch (Exception ex)
{
// ex.Messsage = "Service connection failed! Ошибка сериализации параметра http://tempuri.org/:command. Сообщение InnerException было \"Тип \"MtApi5.ENUM_DEAL_PROPERTY_DOUBLE\" с именем контракта данных \"ENUM_DEAL_PROPERTY_DOUBLE:http://schemas.datacontract.org/2004/07/MtApi5\" не ожидается. Попробуйте использовать DataContractResolver, если вы используете DataContractSerializer, или добавьте любые статически неизвестные типы в список известных типов - например, используя атрибут KnownTypeAttribute или путем их добавления в список известных типов, передаваемый в сериализатор.\". Подробнее см. InnerException."
AddLog(ex.Message);
return;
}
AddLog("ExecuteHistoryDealMethods: success.");
}
private async void ExecuteAccountInfoDouble(object o)
{
var result = await Execute(() => _mtApiClient.AccountInfoDouble(AccountInfoDoublePropertyId));
BIN
View File
Binary file not shown.
+12 -2
View File
@@ -1,7 +1,7 @@
#property copyright "Vyacheslav Demidyuk"
#property link ""
#property version "1.3"
#property version "1.4"
#property description "MtApi (MT5) connection expert"
#include <json.mqh>
@@ -39,6 +39,8 @@
bool getBooleanValue(int expertHandle, int paramIndex, bool& res, string& err);
#import
//#define __DEBUG_LOG__
input int Port = 8228;
int ExpertHandle;
@@ -92,7 +94,9 @@ bool IsDemo()
bool IsTesting()
{
bool isTesting = MQLInfoInteger(MQL_TESTER);
#ifdef __DEBUG_LOG__
PrintFormat("IsTesting: %s", isTesting ? "true" : "false");
#endif
return isTesting;
}
@@ -141,7 +145,9 @@ int init()
return (1);
}
#ifdef __DEBUG_LOG__
PrintFormat("Expert Handle = %d", ExpertHandle);
#endif
//--- Backtesting mode
if (IsTesting())
@@ -219,10 +225,12 @@ int executeCommand()
return (0);
}
#ifdef __DEBUG_LOG__
if (commandType > 0)
{
Print("executeCommand: commnad type = ", commandType);
}
#endif
switch (commandType)
{
@@ -681,7 +689,9 @@ void Execute_Request()
string response = "";
if (request != "")
{
#ifdef __DEBUG_LOG__
Print("Execute_Request: incoming request = ", request);
#endif
response = OnRequest(request);
}
@@ -1151,7 +1161,7 @@ void Execute_HistoryOrderGetInteger()
return;
}
if (!sendULongResponse(ExpertHandle, HistoryOrderGetInteger(ticket_number, (ENUM_ORDER_PROPERTY_INTEGER)property_id), _response_error))
if (!sendLongResponse(ExpertHandle, HistoryOrderGetInteger(ticket_number, (ENUM_ORDER_PROPERTY_INTEGER)property_id), _response_error))
{
PrintResponseError("HistoryOrderGetInteger", _response_error);
}