Ejemplo n.º 1
0
        // Given another ZOrderBook, append the Bid and Ask volume to this ZOrderBook
        public void AggregateRows(ZOrderBook appendOrderBook)
        {
            try
            {
                var bestAsks = appendOrderBook.m_asks.Take(Math.Min(LevelCount, appendOrderBook.m_asks.Count)).ToArray();
                var bestBids = appendOrderBook.m_bids.Reverse().Take(Math.Min(LevelCount, appendOrderBook.m_bids.Count)).ToArray();

                foreach (var kv in bestBids)
                {
                    if (m_bids.ContainsKey(kv.Key))
                    {
                        m_bids[kv.Key] += kv.Value;
                    }
                    else
                    {
                        m_bids.Add(kv.Key, kv.Value);
                    }
                }
                foreach (var kv in bestAsks)
                {
                    if (m_asks.ContainsKey(kv.Key))
                    {
                        m_asks[kv.Key] += kv.Value;
                    }
                    else
                    {
                        m_asks.Add(kv.Key, kv.Value);
                    }
                }
            }
            catch (Exception ex)
            {
                dout("EXCEPTION occurred in AggregateRows: {0}", ex.Message);
            }
        }