public unsafe void ReBuild(ref MarketSnapshotLevel3 marketSnapshot) { lock (_syncRoot) { _bids.Clear(); _asks.Clear(); for (int i = 0; i < MarketSnapshotLevel3.MaxDepth; i++) { var bidPrice = marketSnapshot.BidPrices[i]; var bidVolume = marketSnapshot.BidVolumes[i]; if (bidPrice > 0 && bidVolume > 0) { _bids.Add(new PriceVolumePair(bidPrice, bidVolume)); } var askPrice = marketSnapshot.AskPrices[i]; var askVolume = marketSnapshot.AskVolumes[i]; if (askPrice > 0 && askVolume > 0) { _asks.Add(new PriceVolumePair(askPrice, askVolume)); } } } }
private unsafe void OnMarketSnapshotHandler(MarketDepthSocket socket, ref MarketSnapshotLevel3 marketSnapshot) { _marketSnapshotBuilder.ReBuild(ref marketSnapshot); if (AddMessageToFileLog != null) { StringBuilder log = new StringBuilder($"----- IN MS - {DateTime.Now.ToString("hh:mm:ss.fff")}{Environment.NewLine}"); for (int i = 0; i < MarketSnapshotLevel3.MaxDepth; i++) { log.AppendLine($" BP={marketSnapshot.BidPrices[i].ToString("F11")} BV={marketSnapshot.BidVolumes[i].ToString("F11")}"); log.AppendLine($" SP={marketSnapshot.AskPrices[i].ToString("F11")} SV={marketSnapshot.AskVolumes[i].ToString("F11")}{Environment.NewLine}"); } log.AppendLine($"----- OUT MS"); AddMessageToFileLog?.Invoke(log.ToString()); } }