public void PerformSplit(int newShares, decimal newPrice) { BuyPricePerShare *= (decimal)Shares / newShares; Shares = newShares; CurrentPricePerShare = newPrice; EvtUpdate?.Invoke(this, new UpdateEventArgs(this)); }
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)); }
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)); }
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); }