public void Sell(string stock, int qty) { if (qty <= 0) { //We can't sell 0 or less... _log.Warn("Cannot sell " + qty + " " + stock + " for " + this.id + " use an integer greater than 0"); return; } if (!PortfolioFeedSimulator.CheckStock(stock)) { //this stock does not exist _log.Warn("Not valid stock to sell: " + stock); return; } _log.Debug("Selling " + qty + " " + stock + " for " + this.id); //Change the quantity sign and pass it to the changeQty method this.ChangeQty(stock, -qty); }
public void Buy(string stock, int qty) { if (qty <= 0) { //We can't buy 0 or less... _log.Warn("Cannot buy " + qty + " " + stock + " for " + this.id + " use an integer greater than 0"); return; } if (!PortfolioFeedSimulator.CheckStock(stock)) { //this stock does not exist _log.Warn("Not valid stock to buy: " + stock); return; } _log.Debug("Buying " + qty + " " + stock + " for " + this.id); //Pass the quantity to add to the ChangeQty method this.ChangeQty(stock, qty); }