예제 #1
0
파일: Stock.cs 프로젝트: armwal/StockView
        public void PerformSplit(int newShares, decimal newPrice)
        {
            BuyPricePerShare    *= (decimal)Shares / newShares;
            Shares               = newShares;
            CurrentPricePerShare = newPrice;

            EvtUpdate?.Invoke(this, new UpdateEventArgs(this));
        }
예제 #2
0
파일: Stock.cs 프로젝트: armwal/StockView
        public void Buy(int shares, decimal totalCost, DateTime date)
        {
            BuyPricePerShare = (BuyPricePerShare * Shares + totalCost) / (Shares + shares);
            Shares          += shares;

            Transactions.Add(Transaction.CreateBuyTransaction(shares, totalCost, date));

            EvtUpdate?.Invoke(this, new UpdateEventArgs(this));
        }
예제 #3
0
파일: Stock.cs 프로젝트: armwal/StockView
        public void Sell(int shares, decimal totalPrice, DateTime date)
        {
            if (shares > Shares)
            {
                throw new ArgumentException("Can't sell more than you have!");
            }

            Shares -= shares;

            RealizedRevenue += totalPrice - (shares * BuyPricePerShare);

            Transactions.Add(Transaction.CreateSellTransaction(shares, totalPrice, date));

            EvtUpdate?.Invoke(this, new UpdateEventArgs(this));
        }
예제 #4
0
        private void OnStockUpdate(object sender, EventArgs e)
        {
            RaisePropertyChanged(nameof(Shares));
            RaisePropertyChanged(nameof(BuyPricePerShare));
            RaisePropertyChanged(nameof(CurrentPricePerShare));
            RaisePropertyChanged(nameof(BuyPriceTotal));
            RaisePropertyChanged(nameof(SellPriceTotal));
            RaisePropertyChanged(nameof(PossibleRevenueTotal));
            RaisePropertyChanged(nameof(RevenueBrush));
            RaisePropertyChanged(nameof(RealizedRevenueBrush));
            RaisePropertyChanged(nameof(PossibleRevenuePercentage));
            RaisePropertyChanged(nameof(BuyDate));

            EvtUpdate?.Invoke(this, EventArgs.Empty);
        }