private void _smartServer_UpdatePosition(string portfolio, string symbol, double avprice, double amount, double planned)
        {
            Position position = Positions.FirstOrDefault(p => p.Security.Code == symbol && p.Portfolio.Name == portfolio);
            if (position != null)
            {
                position.Update(avprice, amount, planned);

                if (position.Volume == 0)
                {
                    if (this.Positions.Contains(position)) this.Positions.Remove(position);
                    OnPositionChanged(position, eChange.Remove);
                }
                else
                {
                    OnPositionChanged(position, eChange.Change);
                }

            }
            else
            {
                position = new Position() { Portfolio = this.GetPortfolio(portfolio), Security = this.Lookup(symbol, "Symbol") };
                position.Update(avprice, amount, planned);
                this.Positions.Add(position);
                OnPositionChanged(position, eChange.New);
            }
        }
 private void OnPositionChanged(Position position, eChange change)
 {
     if (PositionChanged != null) PositionChanged(position, change);
 }