public SellOrder CreateSellOrder(string name, ulong quantity, ulong pricePerItem) { Security security; if (!Securities.TryGetValue(name, out security)) { return(null); } var split = security.Split(quantity); if (split == null) { return(null); } var order = new SellOrder(split, pricePerItem); order.AddCancelAction(CancelSellOrder); order.AddExecuteAction(ExecuteSellOrder); lock (SellOrders) { SellOrders.Add(order); } Updated?.Invoke(this, this); return(order); }
public void Sell(SellOrder order) { lock (_sellOrders) { if (_sellOrders.ContainsKey(order.ForSale.Name)) { _sellOrders[order.ForSale.Name].Add(order); } else { _sellOrders.Add(order.ForSale.Name, new List <SellOrder> { order }); } order.AddCancelAction(RemoveSell); order.AddExecuteAction(RemoveSell); } }