Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
 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();
 }
Exemplo n.º 3
0
 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();
 }