public async Task Handle(StockPurchased e, CancellationToken cancellationToken)
        {
            var s = await _storage.GetStock(e.Ticker, e.UserId);

            if (s == null)
            {
                return;
            }

            var when   = e.When;
            var notes  = e.Notes;
            var ticker = e.Ticker;

            await CreateNote(e.UserId, when, notes, ticker);
        }
Esempio n. 2
0
        internal void Apply(StockPurchased purchased)
        {
            this.AverageCost =
                (this.AverageCost * this.Owned + purchased.Price * purchased.NumberOfShares)
                / (this.Owned + purchased.NumberOfShares);

            Owned += purchased.NumberOfShares;
            Cost   = AverageCost * Owned;

            LastPurchase = purchased.When;

            this.Buys.Add(purchased);

            this.Transactions.Add(Transaction.DebitTx(
                                      this.Ticker,
                                      $"Purchased {purchased.NumberOfShares} shares @ ${purchased.Price}/share",
                                      purchased.Price * purchased.NumberOfShares,
                                      purchased.When,
                                      false
                                      ));
        }
Esempio n. 3
0
        internal void ApplyInternal(StockPurchased purchased)
        {
            BuyOrSell.Add(purchased);

            StateUpdateLoop();
        }
Esempio n. 4
0
 private void ApplyInternal(StockPurchased purchased)
 {
     this.State.Apply(purchased);
 }