public TransactionPNL(TradeGroup <T> tradesGroup) { if (tradesGroup != null) { var trades = tradesGroup.Trades.Select(i => i.SecurityPriceData); if (trades.All(t => t != null)) { this.Trades = trades; this.TradeCount = trades.Count(); this.AverageCost = trades.Average(t => t.Price); this.ExitPrice = trades.FirstOrDefault(t => t.PriceDate == trades.Max(t2 => t2.PriceDate)).Price; this.ProfitLoss = CalculatePNL(); } else { throw new ArgumentNullException("TransactionPNL cannot accept any null reference for any trade in trades collection"); } } else { throw new ArgumentNullException("TransactionPNL cannot accept a null reference for trades collection"); } }
public TransactionPNLCalculator(TradeGroup <T> tradeGroup) : base(tradeGroup) { }