Example #1
0
        public void UpdateDelta(BfBoard orders)
        {
            MidPrice = orders.MidPrice;

            foreach (var bid in orders.Bids)
            {
                if (bid.Size == decimal.Zero)
                {
                    _bids.Remove(bid.Price);
                }
                else
                {
                    _bids[bid.Price] = bid.Size;
                }
            }

            if (_bids.Count() == 0)
            {
                _bestBid      = DefaultElement;
                TotalBidDepth = 0;
            }
            else
            {
                _bestBid      = _bids.Last();
                TotalBidDepth = _bids.Values.Sum();
            }

            foreach (var ask in orders.Asks)
            {
                if (ask.Size == decimal.Zero)
                {
                    _asks.Remove(ask.Price);
                }
                else
                {
                    _asks[ask.Price] = ask.Size;
                }
            }

            if (_asks.Count() == 0)
            {
                _bestAsk      = DefaultElement;
                TotalAskDepth = 0;
            }
            else
            {
                _bestAsk      = _asks.First();
                TotalAskDepth = _asks.Values.Sum();
            }
        }
Example #2
0
        public void Reset(BfBoard orders)
        {
            MidPrice = orders.MidPrice;

            TotalBidDepth = 0;
            _bids.Clear(); orders.Bids.ForEach(e =>
            {
                _bids.Add(e.Price, e.Size);
                TotalBidDepth += e.Size;
            });
            _bestBid = _bids.Last();

            TotalAskDepth = 0;
            _asks.Clear(); orders.Asks.ForEach(e =>
            {
                _asks.Add(e.Price, e.Size);
                TotalAskDepth += e.Size;
            });
            _bestAsk = _asks.First();
        }