private void processAggregateCollection() { if (!TradeAggregates.Any()) { return; } TransactionAggregate latest = TradeAggregates.MaxBy(t => t.LastTransactionDate); Stock = latest.Stock; InventoryValue = latest.InventoryValue; TransactionAggregate first = TradeAggregates.MinBy(t => t.FirstTransactionDate); if (first != null) { OpeningBuyPrice = first.OpeningBuyPrice; OpeningSellPrice = first.OpeningSellPrice; } TransactionAggregate last = TradeAggregates.MaxBy(t => t.FirstTransactionDate); if (last != null) { ClosingBuyPrice = last.ClosingBuyPrice; ClosingSellPrice = last.ClosingSellPrice; PerpetualAverageCost = last.PerpetualAverageCost; } }
public TransactionAggregate(IEnumerable <IGrouping <InvType, Transaction> > grouping) : this() { foreach (var group in grouping) { var entry = new TransactionAggregate(group.Key, group); processAggregate(entry); TradeAggregates.Add(entry); } processAggregateCollection(); calculateTotals(); }
public TransactionAggregate(IEnumerable <IGrouping <DateTime, Transaction> > grouping, InvType invType, Order order) : this() { InvType = invType; Order = order; foreach (var group in grouping) { var entry = new TransactionAggregate(group); processAggregate(entry); TradeAggregates.Add(entry); } processAggregateCollection(); calculateTotals(); }