From 4b1baf8b82fd9d7a4d0426b969e5776da3602c8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D0=B5=D0=BC=20=D0=9A=D1=83=D1=80=D1=8C?= =?UTF-8?q?=D1=8F=D0=BD=D0=BE=D0=B2?= Date: Tue, 11 Aug 2020 15:52:26 +0000 Subject: [PATCH] changed some events actions to named tuples for ability more clearly understanding what does exactly happened. fixes typo at OnOrderBookUpdate event invocation --- CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs | 4 ++-- CryptoExchange.Net/OrderBook/SymbolOrderBook.cs | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) 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)); } ///