public bool Merge(IOrderbook update)
        {
            if (this.Sequence < update.Sequence)
            {
                this.Sequence  = update.Sequence;
                this.Timestamp = update.Timestamp;

                if (OfficialAsks.Count() != 0 && OfficialBids.Count() != 0)
                {
                    PreviousLowestAsk  = OfficialAsks.Keys.Min();
                    PreviousHighestBid = OfficialBids.Keys.Max();
                }
                else
                {
                    PreviousLowestAsk  = 0;
                    PreviousHighestBid = decimal.MaxValue;
                }


                //Loop through update.asks and update.bids in parallel and either add them to this.asks and this.bids or update the value thats currently there.


                update.OfficialAsks.AsParallel().ForAll(UpdateAskLayer);
                update.OfficialBids.AsParallel().ForAll(UpdateBidLayer);

                var significantChange = SignificantChange(update);
                Exchange.OrderbookUpdateQueue.Enqueue(significantChange);
                return(significantChange.Item1);
            }

            return(false);
        }
Exemple #2
0
        public bool Merge(IOrderbook update)
        {
            if (this.Sequence < update.Sequence)
            {
                this.Sequence  = update.Sequence;
                this.Timestamp = update.Timestamp;

                if (OfficialAsks.Count() != 0 && OfficialBids.Count() != 0)
                {
                    PreviousLowestAsk  = OfficialAsks.Keys.Min();
                    PreviousHighestBid = OfficialBids.Keys.Max();
                }
                else
                {
                    PreviousLowestAsk  = 0;
                    PreviousHighestBid = decimal.MaxValue;
                }

                OfficialAsks = update.OfficialAsks;
                OfficialBids = update.OfficialBids;

                var significantChange = SignificantChange(update);
                Exchange.OrderbookUpdateQueue.Enqueue(significantChange);
                return(significantChange.Item1);
            }

            return(false);
        }