/// <summary>
        /// 
        /// </summary>
        public bool RemovePosition(Position position)
        {
            lock (this)
            {
                if (_positions.Remove(position.Symbol))
                {
                    position.UpdateEvent -= new UpdateDelegate(position_UpdateEvent);
                    return true;
                }
            }

            return false;
        }
        void SetItemAsPosition(ListViewItem item, Position position)
        {
            if (item.SubItems[0].Text != position.Symbol.Name)
            {
                // Symbol
                item.SubItems[0].Text = position.Symbol.Name;
            }

            string volume = position.Volume.ToString("### ### ##0.");
            if (item.SubItems[1].Text != volume)
            {
                // Volume
                item.SubItems[1].Text = volume;
            }

            string marketValue = GeneralHelper.ToString(position.Info.MarketValue, "### ### ##0.");
            if (item.SubItems[2].Text != marketValue)
            {
                // Mkt Value
                item.SubItems[2].Text = marketValue;
            }

            string pending  = GeneralHelper.ToString(position.Info.PendingBuyVolume);
            if (item.SubItems[2].Text != pending)
            {
                // Pending
                item.SubItems[3].Text = pending;
            }

            string basePrice = GeneralHelper.ToString(position.BasePrice);
            if (item.SubItems[4].Text != basePrice)
            {
                // Base Price
                item.SubItems[4].Text = basePrice;
            }

            if (item.SubItems[5].Text != GeneralHelper.ToString(position.Result))
            {
                // Open Result
                item.SubItems[5].Text = GeneralHelper.ToString(position.Result);
            }

            if (item.SubItems[6].Text != GeneralHelper.ToString(position.Info.ClosedResult))
            {
                // Closed Result
                item.SubItems[6].Text = GeneralHelper.ToString(position.Info.ClosedResult);
            }

            if (item.SubItems[7].Text != GeneralHelper.ToString(position.Price))
            {
                // Current Price
                item.SubItems[7].Text = GeneralHelper.ToString(position.Price);
            }

            if (item.Tag != position)
            {
                item.Tag = position;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public bool AddPosition(Position position)
        {
            if (position.Symbol.IsEmpty || string.IsNullOrEmpty(position.Symbol.Name))
            {
                SystemMonitor.Warning("Added a position with empty symbol.");
                return false;
            }

            lock (this)
            {
                if (_positions.ContainsKey(position.Symbol))
                {
                    SystemMonitor.Warning("Added a position, but symbol already has a position.");
                    return false;
                }

                _positions.Add(position.Symbol, position);
            }

            position.UpdateEvent += new UpdateDelegate(position_UpdateEvent);

            if (PositionsAddedEvent != null)
            {
                if (_provider == null || _provider.DefaultAccount == null)
                {
                    SystemMonitor.Error("Provider or account not yet assigned, position add event not launched.");
                }
                else
                {
                    PositionsAddedEvent(this, _provider.DefaultAccount.Info, new Position[] { position });
                }
            }

            return true;
        }
        void _subItem_OperationalStatusChangedEvent(IOperational subItem, OperationalStateEnum previousState)
        {
            if (_sessionDataProvider != null && _sessionDataProvider.OperationalState == OperationalStateEnum.Operational
                && (_orderExecutionProvider == null || _orderExecutionProvider.OperationalState == OperationalStateEnum.Operational))
            {
                if (_orderExecutionProvider != null && _orderExecutionProvider.TradeEntities != null)
                {
                    // Create the default position for this session.
                    _position = _orderExecutionProvider.TradeEntities.ObtainPositionBySymbol(_sessionInfo.Symbol);
                }

                ChangeOperationalState(OperationalStateEnum.Operational);
            }
            else
            {
                ChangeOperationalState(OperationalStateEnum.NotOperational);
            }
        }