public void Insert(IEnumerable <InsertDataItem> items, OrderBookSides side) { foreach (var item in items) { if (side == OrderBookSides.Buy) { _bids.TryAdd(item.Id, new OrderBookEntry(item.Id, item.Size, item.Price)); } else if (side == OrderBookSides.Sell) { _asks.TryAdd(item.Id, new OrderBookEntry(item.Id, item.Size, item.Price)); } } }
public void Delete(IEnumerable <DeleteDataItem> items, OrderBookSides side) { foreach (var entry in items) { OrderBookEntry entryToRemove; if (side == OrderBookSides.Buy) { _bids.TryRemove(entry.Id, out entryToRemove); } else if (side == OrderBookSides.Sell) { _asks.TryRemove(entry.Id, out entryToRemove); } } }
public void Update(IEnumerable <UpdateDataItem> items, OrderBookSides side) { foreach (var entry in items) { if (side == OrderBookSides.Buy) { var updatedEntry = new OrderBookEntry(entry.Id, entry.Size, _bids[entry.Id].Price); _bids.TryUpdate(entry.Id, updatedEntry, _bids[entry.Id]); } else if (side == OrderBookSides.Sell) { var updatedEntry = new OrderBookEntry(entry.Id, entry.Size, _asks[entry.Id].Price); _asks.TryUpdate(entry.Id, updatedEntry, _asks[entry.Id]); } } }