public void Update(PortfolioValueMessage message, string accountName) { this.Contract = Contract.FromPortfolioValueMessage(message); this.AveragePrice = message.AverageCost; this.MarketPrice = message.MarketPrice; this.MarketValue = message.MarketValue; this.Quantity = message.Position; this.RealizedPL = message.RealizedPNL; this.OpenPL = message.UnrealizedPNL; this.AccountName = accountName; this.PositionChanged(this, new PositionChangedEventArgs{Position = this}); }
private void OnPositionUpdate(PortfolioValueMessage message) { var positionContract = Contract.FromPortfolioValueMessage(message); Position position; if (this.positions.TryGetValue(positionContract, out position)) { position.Update(message, this.accountName); return; } position = this.objectsFactory.CreatePosition(); position.Update(message, this.accountName); this.positions[positionContract] = position; this.PositionAdded(this, new PositionAddedEventArgs{Position = position}); }