Merge branch 'dev'

This commit is contained in:
Viacheslav Demydiuk
2025-09-27 17:33:41 +03:00
8 changed files with 1973 additions and 1787 deletions
+6
View File
@@ -502,6 +502,12 @@ namespace MtApi
Dictionary<string, object> cmdParams = new() { { "Pool", (int)pool} };
return SendCommand<List<MtOrder>>(ExecutorHandle, MtCommandType.GetOrders, cmdParams);
}
public List<string>? GetSymbols(bool selected)
{
Dictionary<string, object> cmdParams = new() { { "Selected", selected } };
return SendCommand<List<string>>(ExecutorHandle, MtCommandType.GetSymbols, cmdParams);
}
#endregion
#region Checkup
+2 -1
View File
@@ -287,6 +287,7 @@
SymbolInfoTick = 288,
SymbolInfoDouble = 289,
GetQuote = 290
GetQuote = 290,
GetSymbols = 291
}
}
File diff suppressed because it is too large Load Diff
+19 -37
View File
@@ -8,44 +8,12 @@ using System.Runtime.InteropServices;
namespace TestApiClientUI
{
class MtLogger : IMtLogger
{
public void Debug(object message)
{
Write("DEBUG", message);
}
public void Error(object message)
{
Write("ERROR", message);
}
public void Fatal(object message)
{
Write("FATAL", message);
}
public void Info(object message)
{
Write("INFO", message);
}
public void Warn(object message)
{
Write("WARN", message);
}
private void Write(string level, object message)
{
Console.WriteLine($"[{Environment.CurrentManagedThreadId}] [{level}] {message}");
}
}
public partial class Form1 : Form
{
#region Fields
private readonly List<Action> _groupOrderCommands = [];
private readonly MtApiClient _apiClient = new (new MtLogger());
private readonly MtApiClient _apiClient = new(new MtLogger());
private readonly TimerTradeMonitor _timerTradeMonitor;
private readonly TimeframeTradeMonitor _timeframeTradeMonitor;
@@ -742,7 +710,7 @@ namespace TestApiClientUI
var symbol = textBoxOrderSymbol.Text;
var cmd = (TradeOperation) comboBoxOrderCommand.SelectedIndex;
var cmd = (TradeOperation)comboBoxOrderCommand.SelectedIndex;
double volume;
double.TryParse(textBoxOrderVolume.Text, out volume);
@@ -750,7 +718,7 @@ namespace TestApiClientUI
double price;
double.TryParse(textBoxOrderPrice.Text, out price);
var slippage = (int) numericOrderSlippage.Value;
var slippage = (int)numericOrderSlippage.Value;
double stoploss;
double.TryParse(textBoxOrderStoploss.Text, out stoploss);
@@ -805,8 +773,8 @@ namespace TestApiClientUI
private async void button16_Click(object sender, EventArgs e)
{
var ticket = int.Parse(textBoxIndexTicket.Text);
var selectMode = (OrderSelectMode) comboBox1.SelectedIndex;
var selectSource = (OrderSelectSource) comboBox2.SelectedIndex;
var selectMode = (OrderSelectMode)comboBox1.SelectedIndex;
var selectSource = (OrderSelectSource)comboBox2.SelectedIndex;
var order = await Execute(() => _apiClient.GetOrder(ticket, selectMode, selectSource));
@@ -1544,5 +1512,19 @@ namespace TestApiClientUI
PrintLog($"iBarShift result1 = {result1}, time = {time1}");
PrintLog($"iBarShift result2 = {result2}, time = {time2}");
}
private async void button74_Click(object sender, EventArgs e)
{
listBoxAllSymbols.Items.Clear();
var result = await Execute(() => _apiClient.GetSymbols(checkBox3.Checked));
if (result != null)
{
foreach (string? r in result)
listBoxAllSymbols.Items.Add(r);
}
int count = result != null ? result.Count : 0;
PrintLog($"GetSymbols: {count}");
}
}
}
+25 -25
View File
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
+36
View File
@@ -0,0 +1,36 @@
using MtApi;
namespace TestApiClientUI
{
class MtLogger : IMtLogger
{
public void Debug(object message)
{
Write("DEBUG", message);
}
public void Error(object message)
{
Write("ERROR", message);
}
public void Fatal(object message)
{
Write("FATAL", message);
}
public void Info(object message)
{
Write("INFO", message);
}
public void Warn(object message)
{
Write("WARN", message);
}
private void Write(string level, object message)
{
Console.WriteLine($"[{Environment.CurrentManagedThreadId}] [{level}] {message}");
}
}
}
BIN
View File
Binary file not shown.
+25
View File
@@ -1330,6 +1330,9 @@ int ExecuteCommand()
case 290: //GetQuote
response = Execute_GetQuote();
break;
case 291: //GetSymbols
response = Execute_GetSymbols();
break;
default:
Print("WARNING: Unknown command type = ", command_type);
@@ -4187,3 +4190,25 @@ string Execute_GetQuote()
MtQuote quote(Symbol(), tick);
return CreateSuccessResponse(quote.CreateJson());
}
string Execute_GetSymbols()
{
GET_JSON_PAYLOAD(jo);
GET_BOOL_JSON_VALUE(jo, "Selected", selected);
const int symbolsCount = SymbolsTotal(selected);
JSONArray* jaSymbols = new JSONArray();
int idx = 0;
for(int idxSymbol = 0; idxSymbol < symbolsCount; idxSymbol++)
{
string symbol = SymbolName(idxSymbol, selected);
string firstChar = StringSubstr(symbol, 0, 1);
if(firstChar != "#" && StringLen(symbol) == 6)
{
jaSymbols.put(idx, new JSONString(symbol));
idx++;
}
}
return CreateSuccessResponse(jaSymbols);
}