コード例 #1
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;
                }


                //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);
        }
コード例 #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);
        }
コード例 #3
0
 public void UpdateAskLayer(KeyValuePair <decimal, decimal> layer)
 {
     if (layer.Value > 0)
     {
         OfficialAsks.AddOrUpdate(layer.Key, layer.Value, (key, oldValue) => oldValue = layer.Value);
     }
     else
     {
         OfficialAsks.TryRemove(layer.Key, out var _);
     }
 }