Ejemplo n.º 1
0
        public void PerformSplit(int newShares, decimal newPrice)
        {
            BuyPricePerShare    *= (decimal)Shares / newShares;
            Shares               = newShares;
            CurrentPricePerShare = newPrice;

            EvtUpdate?.Invoke(this, new UpdateEventArgs(this));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 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);
        }