17 using System.Collections.Generic;
29 private decimal _bestBidPrice;
30 private decimal _bestBidSize;
31 private decimal _bestAskPrice;
32 private decimal _bestAskSize;
33 private readonly
object _locker =
new object();
38 protected SortedDictionary<decimal, decimal>
Bids {
get; init; } =
new SortedDictionary<decimal, decimal>();
43 protected SortedDictionary<decimal, decimal>
Asks {
get; init; } =
new SortedDictionary<decimal, decimal>();
148 if (_bestBidPrice == 0 || price >= _bestBidPrice)
150 _bestBidPrice = price;
169 if (_bestAskPrice == 0 || price <= _bestAskPrice)
171 _bestAskPrice = price;
189 if (price == _bestBidPrice)
191 var priceLevel =
Bids.LastOrDefault();
192 _bestBidPrice = priceLevel.Key;
193 _bestBidSize = priceLevel.Value;
210 if (price == _bestAskPrice)
212 var priceLevel =
Asks.FirstOrDefault();
213 _bestAskPrice = priceLevel.Key;
214 _bestAskSize = priceLevel.Value;
229 if (
Asks.ContainsKey(priceLevel))
233 else if (
Bids.ContainsKey(priceLevel))