Click or drag to resize

Picker

The SecurityPicker component is designed to find and select instruments. It supports both single and multiple choice. The component allows you to filter the list of instruments by their type. This component can also be used to display financial information (level1 fields), as shown in the SecurityGrid section.

GUI Security Picker 2

SecurityPicker consists of:

  1. A text field, to enter the code (or Id) of the instrument. When you enter, the list is filtered by the entered substring.

  2. The special SecurityTypeComboBox combo box for filtering instruments by their type.

  3. The SecurityGrid table to display the list of instruments.

Main properties

Below is the code snippet with its use, taken from example Samples/InteractiveBrokers/SampleIB.

XAML
<Window x:Class="SampleIB.SecuritiesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:loc="clr-namespace:StockSharp.Localization;assembly=StockSharp.Localization"
    xmlns:xaml="http://schemas.stocksharp.com/xaml"
    Title="{x:Static loc:LocalizedStrings.Securities}" Height="415" Width="1081">
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="*" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>

    <xaml:SecurityPicker x:Name="SecurityPicker" x:FieldModifier="public" SecuritySelected="SecurityPicker_OnSecuritySelected" ShowCommonStatColumns="True" />

    <StackPanel Grid.Row="1" HorizontalAlignment="Right" Orientation="Horizontal">
      <Button x:Name="Find" Width="100" Click="FindClick">
        <TextBlock><Run Text="{x:Static loc:LocalizedStrings.Find}" />...</TextBlock>
      </Button>
            <Button x:Name="Level1" Content="Level1..." Width="100" IsEnabled="False" Click="Level1Click" />
      <Button x:Name="Depth" Width="100" IsEnabled="False" Click="DepthClick">
        <TextBlock><Run Text="{x:Static loc:LocalizedStrings.MarketDepth}" />...</TextBlock>
      </Button>
      <Button x:Name="NewOrder" Width="100" IsEnabled="False" Click="NewOrderClick">
        <TextBlock><Run Text="{x:Static loc:LocalizedStrings.NewOrder}" />...</TextBlock>
      </Button>
      <Button x:Name="NewStopOrder" Width="120" IsEnabled="False" Click="NewStopOrderClick">
        <TextBlock><Run Text="{x:Static loc:LocalizedStrings.NewStopOrder}" />...</TextBlock>
      </Button>
    </StackPanel>
  </Grid>
</Window>
C#
private void ConnectClick(object sender, RoutedEventArgs e)
{
    if (!_isConnected)
    {
       ......................................

            Trader.NewSecurity += security => _securitiesWindow.SecurityPicker.Securities.Add(security);
            Trader.NewMyTrade += trade => _myTradesWindow.TradeGrid.Trades.Add(trade);
            Trader.NewTrade += trade => _tradesWindow.TradeGrid.Trades.Add(trade);
            Trader.NewOrder += order => _ordersWindow.OrderGrid.Orders.Add(order);
            Trader.NewStopOrder += order => _stopOrdersWindow.OrderGrid.Orders.Add(order);
            Trader.OrderRegisterFailed += _ordersWindow.OrderGrid.AddRegistrationFail;
            Trader.OrderCancelFailed += fail => this.GuiAsync(() => MessageBox.Show(this, fail.Error.Message, "OrderCancelFailed"));
            Trader.StopOrderRegisterFailed += _stopOrdersWindow.OrderGrid.AddRegistrationFail;
            Trader.StopOrderCancelFailed += fail => this.GuiAsync(() => MessageBox.Show(this, fail.Error.Message, "StopOrderCancelFailed"));
            Trader.NewPortfolio += portfolio => _portfoliosWindow.PortfolioGrid.Portfolios.Add(portfolio);
            Trader.NewPosition += position => _portfoliosWindow.PortfolioGrid.Positions.Add(position);

       ......................................

            _securitiesWindow.SecurityPicker.MarketDataProvider = Trader;

       ......................................

        Trader.Connect();

        _isConnected = true;
        ConnectBtn.Content = LocalizedStrings.Disconnect;
    }
    else
    {
        Trader.Disconnect();

        _isConnected = false;
        ConnectBtn.Content = LocalizedStrings.Connect;
    }
}

private void SecurityPicker_OnSecuritySelected(Security security)
{
    NewStopOrder.IsEnabled = NewOrder.IsEnabled =
    Level1.IsEnabled = Depth.IsEnabled = security != null;
}