Exemple #1
0
        public void Sell(string stock, int quantity)
        {
            if (!Shares.ContainsKey(stock))
            {
                return;
            }

            Shares[stock] = Shares[stock] - quantity;
            Orders[stock] = quantity;
        }
Exemple #2
0
 public void Buy(string stock, int quantity)
 {
     if (Shares.ContainsKey(stock))
     {
         Shares[stock] = Shares[stock] + quantity;
     }
     else
     {
         Shares[stock] = quantity;
     }
 }
Exemple #3
0
        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);
        }
Exemple #4
0
        public Task BuyAsync(string stock, int quantity)
        {
            if (Shares.ContainsKey(stock))
            {
                Shares[stock] = Shares[stock] + quantity;
            }
            else
            {
                Shares[stock] = quantity;
            }

            return(Task.CompletedTask);
        }