public void Sell(string stock, int quantity) { if (!Shares.ContainsKey(stock)) { return; } Shares[stock] = Shares[stock] - quantity; Orders[stock] = quantity; }
public void Buy(string stock, int quantity) { if (Shares.ContainsKey(stock)) { Shares[stock] = Shares[stock] + quantity; } else { Shares[stock] = quantity; } }
public static string AddShare(FileShare share) { var key = ""; do { key = CryptoHelper.ToSafe64String(Guid.NewGuid().ToByteArray()); } while (Shares.ContainsKey(key)); return(Shares.TryAdd(key, share) ? key : null); }
public Task BuyAsync(string stock, int quantity) { if (Shares.ContainsKey(stock)) { Shares[stock] = Shares[stock] + quantity; } else { Shares[stock] = quantity; } return(Task.CompletedTask); }