Пример #1
0
        internal void Apply(StockSold sold)
        {
            this.Sells.Add(sold);
            this.LastSale = sold.When;

            this.Transactions.Add(Transaction.CreditTx(
                                      this.Ticker,
                                      $"Sold {sold.NumberOfShares} shares @ ${sold.Price}/share",
                                      sold.Price * sold.NumberOfShares,
                                      sold.When,
                                      false
                                      ));

            this.Transactions.Add(Transaction.PLTx(
                                      this.Ticker,
                                      $"Sold {sold.NumberOfShares} shares @ ${sold.Price}/share",
                                      (sold.Price * sold.NumberOfShares - this.AverageCost * sold.NumberOfShares),
                                      sold.When,
                                      false
                                      ));

            this.Owned -= sold.NumberOfShares;
            if (this.Owned == 0)
            {
                this.AverageCost = 0;
            }

            this.Cost = AverageCost * Owned;
        }
Пример #2
0
        internal void ApplyInternal(StockSold sold)
        {
            BuyOrSell.Add(sold);

            StateUpdateLoop();
        }
Пример #3
0
 private void ApplyInternal(StockSold sold)
 {
     this.State.Apply(sold);
 }