From ccaf1da5c9ed319eb1ca853191b61b4fc0505315 Mon Sep 17 00:00:00 2001 From: JKorf Date: Thu, 23 Jan 2020 14:00:58 +0100 Subject: [PATCH] Renamed OnPriceChanged to OnBestOffersChanged --- CryptoExchange.Net/CryptoExchange.Net.xml | 4 ++-- .../Interfaces/ISymbolOrderBook.cs | 2 +- .../OrderBook/SymbolOrderBook.cs | 21 ++++++++----------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/CryptoExchange.Net/CryptoExchange.Net.xml b/CryptoExchange.Net/CryptoExchange.Net.xml index eb9478e..a29cf01 100644 --- a/CryptoExchange.Net/CryptoExchange.Net.xml +++ b/CryptoExchange.Net/CryptoExchange.Net.xml @@ -797,7 +797,7 @@ Event when order book was updated. Be careful! It can generate a lot of events at high-liquidity markets - + Event when the BestBid or BestAsk changes ie a Pricing Tick @@ -1774,7 +1774,7 @@ Event when the state changes - + Event when the BestBid or BestAsk changes ie a Pricing Tick diff --git a/CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs b/CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs index 1800689..9d0b502 100644 --- a/CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs +++ b/CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs @@ -35,7 +35,7 @@ namespace CryptoExchange.Net.Interfaces /// /// Event when the BestBid or BestAsk changes ie a Pricing Tick /// - event Action OnPriceChanged; + event Action OnBestOffersChanged; /// /// Timestamp of the last update /// diff --git a/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs b/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs index b33512d..36e94b8 100644 --- a/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs +++ b/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs @@ -83,7 +83,7 @@ namespace CryptoExchange.Net.OrderBook /// /// Event when the BestBid or BestAsk changes ie a Pricing Tick /// - public event Action? OnPriceChanged; + public event Action? OnBestOffersChanged; /// /// Event when order book was updated, containing the changed bids and asks. Be careful! It can generate a lot of events at high-liquidity markets @@ -292,14 +292,15 @@ namespace CryptoExchange.Net.OrderBook log.Write(LogVerbosity.Debug, $"{Id} order book {Symbol} data set: {BidCount} bids, {AskCount} asks. #{orderBookSequenceNumber}"); CheckProcessBuffer(); OnOrderBookUpdate?.Invoke(bidList, askList); - OnPriceChanged?.Invoke(BestBid, BestAsk); + OnBestOffersChanged?.Invoke(BestBid, BestAsk); } } - private bool BestPricingUpdated(ISymbolOrderBookEntry prevBestBid, ISymbolOrderBookEntry prevBestAsk) + private void CheckBestOffersChanged(ISymbolOrderBookEntry prevBestBid, ISymbolOrderBookEntry prevBestAsk) { - return BestBid.Price != prevBestBid.Price || BestBid.Quantity != prevBestBid.Quantity || - BestAsk.Price != prevBestAsk.Price || BestAsk.Quantity != prevBestAsk.Quantity; + if (BestBid.Price != prevBestBid.Price || BestBid.Quantity != prevBestBid.Quantity || + BestAsk.Price != prevBestAsk.Price || BestAsk.Quantity != prevBestAsk.Quantity) + OnBestOffersChanged?.Invoke(BestBid, BestAsk); } /// @@ -332,8 +333,7 @@ namespace CryptoExchange.Net.OrderBook var prevBestAsk = BestAsk; ProcessSingleSequenceUpdates(rangeUpdateId, bids, asks); OnOrderBookUpdate?.Invoke(bids, asks); - if (BestPricingUpdated(prevBestBid, prevBestAsk)) - OnPriceChanged?.Invoke(BestBid, BestAsk); + CheckBestOffersChanged(prevBestBid, prevBestAsk); } } } @@ -370,8 +370,7 @@ namespace CryptoExchange.Net.OrderBook var prevBestAsk = BestAsk; ProcessRangeUpdates(firstUpdateId, lastUpdateId, bids, asks); OnOrderBookUpdate?.Invoke(bids, asks); - if (BestPricingUpdated(prevBestBid, prevBestAsk)) - OnPriceChanged?.Invoke(BestBid, BestAsk); + CheckBestOffersChanged(prevBestBid, prevBestAsk); } } } @@ -401,9 +400,7 @@ namespace CryptoExchange.Net.OrderBook var prevBestAsk = BestAsk; ProcessUpdates(bids, asks); OnOrderBookUpdate?.Invoke(bids, asks); - if (BestPricingUpdated(prevBestBid, prevBestAsk)) - OnPriceChanged?.Invoke(BestBid, BestAsk); - + CheckBestOffersChanged(prevBestBid, prevBestAsk); } } }