Click or drag to resize

Table

PortfolioGrid is a component that displays the status of portfolios and positions.

GUI Portfolio Grid

Main properties

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

XAML
<Window x:Class="SampleIB.PortfoliosWindow"
        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.Portfolios}" Height="200" Width="470">
  <xaml:PortfolioGrid x:Name="PortfolioGrid" x:FieldModifier="public" />
</Window>
C#
private void ConnectClick(object sender, RoutedEventArgs e)
{
    if (!_isConnected)
    {
        if (Trader == null)
        {
            Trader = new InteractiveBrokersTrader
            {
            };

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

            Trader.NewPortfolio += portfolio => _portfoliosWindow.PortfolioGrid.Portfolios.Add(portfolio);
            Trader.NewPosition += position => _portfoliosWindow.PortfolioGrid.Positions.Add(position);

            _securitiesWindow.SecurityPicker.MarketDataProvider = Trader;

            ShowSecurities.IsEnabled = ShowTrades.IsEnabled =
                ShowMyTrades.IsEnabled = ShowOrders.IsEnabled =
                    ShowPortfolios.IsEnabled = ShowStopOrders.IsEnabled = true;
        }

        Trader.Connect();

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

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