Market Depth giving exactly the same numbers each time

Created at 04 Jun 2025, 16:48
shane.scott.pub's avatar

shane.scott.pub

Joined 22.01.2023

Market Depth giving exactly the same numbers each time
04 Jun 2025, 16:48


private void MarketDepthUpdated()
{
   try
   {
       double bidVolume = 0, askVolume = 0;

       foreach (var entry in _marketDepth.BidEntries)
           bidVolume += entry.VolumeInUnits;

       foreach (var entry in _marketDepth.AskEntries)
           askVolume += entry.VolumeInUnits;

       double imbalance = Math.Abs(bidVolume - askVolume);
       double imbalancePercentage = bidVolume + askVolume > 0 ? (imbalance / (bidVolume + askVolume)) * 100 : 0;

       Print($"Market Depth Updated:");
       Print($"Bid Volume: {bidVolume} units");
       Print($"Ask Volume: {askVolume} units");
       Print($"Order Book Imbalance: {imbalance} units ({imbalancePercentage:F2}%)");
       Print($"Threshold Required: {OrderBookThreshold}");

       if (imbalance < OrderBookThreshold)
           Print("Imbalance below threshold, no trade executed.");
   }
   catch (Exception ex)
   {
       Print($"Error in MarketDepthUpdated: {ex.Message}");
   }
}


@shane.scott.pub