public void Process(BuySellOperation buySellOperation) { if (buySellOperation.Price <= 0 || buySellOperation.Quantity < 0) { return; } if (buySellOperation.OperationType == OperationType.Buy) { // Put the current buy / sell operation on the queue. BuyOperations.Add(buySellOperation); // Add buyOperation to historical price to quantity map. if (buySellOperation.OrderType != OrderType.Ioc && BuyPriceToQuantityMap.TryGetValue(buySellOperation.Price, out var quantity)) { BuyPriceToQuantityMap[buySellOperation.Price] = quantity + buySellOperation.Quantity; } else if (buySellOperation.OrderType != OrderType.Ioc) { BuyPriceToQuantityMap.Add(buySellOperation.Price, buySellOperation.Quantity); } } else { // Put the current buy / sell operation on the queue. SellOperations.Add(buySellOperation); // Add buyOperation to historical price to quantity map. if (buySellOperation.OrderType != OrderType.Ioc && SellPriceToQuantityMap.TryGetValue(buySellOperation.Price, out var quantity)) { SellPriceToQuantityMap[buySellOperation.Price] = quantity + buySellOperation.Quantity; } else if (buySellOperation.OrderType != OrderType.Ioc) { SellPriceToQuantityMap.Add(buySellOperation.Price, buySellOperation.Quantity); } } }