Issue #284: MtApi5/MQL5 - added function GetSymbols

This commit is contained in:
Viacheslav Demydiuk
2025-09-30 16:14:13 +03:00
parent 92322e866e
commit c536585cd2
6 changed files with 94 additions and 18 deletions
+28 -16
View File
@@ -473,22 +473,34 @@
</TabItem>
<TabItem Header="Market Info">
<WrapPanel VerticalAlignment="Top" Margin="5">
<Button Command="{Binding SymbolsTotalCommand}" Content="SymbolsTotal" Margin="2"/>
<Button Command="{Binding SymbolNameCommand}" Content="SymbolName" Margin="2"/>
<Button Command="{Binding SymbolSelectCommand}" Content="SymbolSelect" Margin="2"/>
<Button Command="{Binding SymbolIsSynchronizedCommand}" Content="SymbolIsSynchronized" Margin="2"/>
<Button Command="{Binding SymbolInfoDoubleCommand}" Content="SymbolInfoDouble" Margin="2"/>
<Button Command="{Binding SymbolInfoIntegerCommand}" Content="SymbolInfoInteger" Margin="2"/>
<Button Command="{Binding SymbolInfoStringCommand}" Content="SymbolInfoString" Margin="2"/>
<Button Command="{Binding SymbolInfoString2Command}" Content="SymbolInfoString-2" Margin="2"/>
<Button Command="{Binding SymbolInfoTickCommand}" Content="SymbolInfoTick" Margin="2"/>
<Button Command="{Binding SymbolInfoSessionQuoteCommand}" Content="SymbolInfoSessionQuote" Margin="2"/>
<Button Command="{Binding SymbolInfoSessionTradeCommand}" Content="SymbolInfoSessionTrade" Margin="2"/>
<Button Command="{Binding MarketBookAddCommand}" Content="MarketBookAdd" Margin="2"/>
<Button Command="{Binding MarketBookReleaseCommand}" Content="MarketBookRelease" Margin="2"/>
<Button Command="{Binding MarketBookGetCommand}" Content="MarketBookGet" Margin="2"/>
</WrapPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<WrapPanel Grid.Row="0" VerticalAlignment="Top" Margin="5">
<Button Command="{Binding SymbolsTotalCommand}" Content="SymbolsTotal" Margin="2"/>
<Button Command="{Binding SymbolNameCommand}" Content="SymbolName" Margin="2"/>
<Button Command="{Binding SymbolSelectCommand}" Content="SymbolSelect" Margin="2"/>
<Button Command="{Binding SymbolIsSynchronizedCommand}" Content="SymbolIsSynchronized" Margin="2"/>
<Button Command="{Binding SymbolInfoDoubleCommand}" Content="SymbolInfoDouble" Margin="2"/>
<Button Command="{Binding SymbolInfoIntegerCommand}" Content="SymbolInfoInteger" Margin="2"/>
<Button Command="{Binding SymbolInfoStringCommand}" Content="SymbolInfoString" Margin="2"/>
<Button Command="{Binding SymbolInfoString2Command}" Content="SymbolInfoString-2" Margin="2"/>
<Button Command="{Binding SymbolInfoTickCommand}" Content="SymbolInfoTick" Margin="2"/>
<Button Command="{Binding SymbolInfoSessionQuoteCommand}" Content="SymbolInfoSessionQuote" Margin="2"/>
<Button Command="{Binding SymbolInfoSessionTradeCommand}" Content="SymbolInfoSessionTrade" Margin="2"/>
<Button Command="{Binding MarketBookAddCommand}" Content="MarketBookAdd" Margin="2"/>
<Button Command="{Binding MarketBookReleaseCommand}" Content="MarketBookRelease" Margin="2"/>
<Button Command="{Binding MarketBookGetCommand}" Content="MarketBookGet" Margin="2"/>
</WrapPanel>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<Button Content="GetSymbols" Command="{Binding GetSymbolsCommand}" Width="100" Margin="2"/>
<CheckBox Content="Selected" IsChecked="{Binding GetSymbolsSelected}" Margin="5" />
</StackPanel>
<ListBox Grid.Row="2" ItemsSource="{Binding Symbols}" Height="Auto" Width="200" HorizontalAlignment="Left"/>
</Grid>
</TabItem>
<TabItem Header="CTrade (Positions)">
+30
View File
@@ -160,6 +160,8 @@ namespace MtApi5TestClient
public DelegateCommand GlobalVariablesTotalCommand { get; private set; }
public DelegateCommand UnlockTicksCommand { get; private set; }
public DelegateCommand GetSymbolsCommand { get; private set; }
#endregion
#region Properties
@@ -314,6 +316,19 @@ namespace MtApi5TestClient
OnPropertyChanged("PositionTicketValue");
}
}
public bool GetSymbolsSelected { get; set; } = false;
private List<string> _symbols;
public List<string> Symbols
{
get { return _symbols; }
set
{
_symbols = value;
OnPropertyChanged("Symbols");
}
}
#endregion
#region Public Methods
@@ -475,6 +490,8 @@ namespace MtApi5TestClient
GlobalVariablesTotalCommand = new DelegateCommand(ExecuteGlobalVariablesTotal);
UnlockTicksCommand = new DelegateCommand(ExecuteUnlockTicks);
GetSymbolsCommand = new DelegateCommand(ExecuteGetSymbols);
}
private bool CanExecuteConnect(object o)
@@ -1726,6 +1743,19 @@ namespace MtApi5TestClient
_mtApiClient.UnlockTicks();
}
private async void ExecuteGetSymbols(object o)
{
var result = await Execute(() => _mtApiClient.GetSymbols(GetSymbolsSelected));
if (result == null)
return;
AddLog($"ChartScreenShot: {result.Count} count of symbols");
RunOnUiThread(() =>
{
Symbols = result;
});
}
private static void RunOnUiThread(Action action)
{
Application.Current?.Dispatcher.Invoke(action);