Click or drag to resize

Table

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

Main properties

Below is the appearance of the component, as well as code snippets with its use. The code example is taken from Samples/OpenECry/SampleOEC.

GUI Portfolio Grid
XAML
<Window x:Class="SampleOEC.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 OpenECryTrader
            {
                Address = Address.SelectedAddress,
                Login = Login.Text,
                Password = Password.Password.To<SecureString>(),
                LogLevel = LogLevels.Debug
            };

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

            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;
    }
}