diff --git a/CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs b/CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs index ee24057..7fbb088 100644 --- a/CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs +++ b/CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs @@ -31,11 +31,11 @@ namespace CryptoExchange.Net.Interfaces /// /// Event when order book was updated. Be careful! It can generate a lot of events at high-liquidity markets /// - event Action, IEnumerable> OnOrderBookUpdate; + event Action<(IEnumerable Bids, IEnumerable Asks)> OnOrderBookUpdate; /// /// Event when the BestBid or BestAsk changes ie a Pricing Tick /// - event Action OnBestOffersChanged; + event Action<(ISymbolOrderBookEntry BestBid, ISymbolOrderBookEntry BestAsk)> OnBestOffersChanged; /// /// Timestamp of the last update /// diff --git a/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs b/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs index 8f4e32f..63bd74b 100644 --- a/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs +++ b/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs @@ -96,12 +96,12 @@ namespace CryptoExchange.Net.OrderBook /// /// Event when the BestBid or BestAsk changes ie a Pricing Tick /// - public event Action? OnBestOffersChanged; + public event Action<(ISymbolOrderBookEntry BestBid, ISymbolOrderBookEntry BestAsk)>? 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 + /// 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 /// - public event Action, IEnumerable>? OnOrderBookUpdate; + public event Action<(IEnumerable Bids, IEnumerable Asks)>? OnOrderBookUpdate; /// /// Timestamp of the last update /// @@ -356,8 +356,8 @@ namespace CryptoExchange.Net.OrderBook LastOrderBookUpdate = DateTime.UtcNow; log.Write(LogVerbosity.Debug, $"{Id} order book {Symbol} data set: {BidCount} bids, {AskCount} asks. #{item.EndUpdateId}"); CheckProcessBuffer(); - OnOrderBookUpdate?.Invoke(item.Asks, item.Bids); - OnBestOffersChanged?.Invoke(BestBid, BestAsk); + OnOrderBookUpdate?.Invoke((item.Bids, item.Asks)); + OnBestOffersChanged?.Invoke((BestBid, BestAsk)); } } @@ -392,7 +392,7 @@ namespace CryptoExchange.Net.OrderBook return; } - OnOrderBookUpdate?.Invoke(item.Bids, item.Asks); + OnOrderBookUpdate?.Invoke((item.Bids, item.Asks)); CheckBestOffersChanged(prevBestBid, prevBestAsk); } } @@ -601,7 +601,7 @@ namespace CryptoExchange.Net.OrderBook var (bestBid, bestAsk) = BestOffers; if (bestBid.Price != prevBestBid.Price || bestBid.Quantity != prevBestBid.Quantity || bestAsk.Price != prevBestAsk.Price || bestAsk.Quantity != prevBestAsk.Quantity) - OnBestOffersChanged?.Invoke(bestBid, bestAsk); + OnBestOffersChanged?.Invoke((bestBid, bestAsk)); } ///