From 6a3df9f7e79327113a2b3a48203443e6a3e9fcdd Mon Sep 17 00:00:00 2001 From: msg_kurt Date: Wed, 4 Sep 2019 17:23:30 +0300 Subject: [PATCH] removed event triggering timeout --- CryptoExchange.Net/CryptoExchange.Net.xml | 10 ++++++++++ CryptoExchange.Net/Objects/Options.cs | 12 +++--------- CryptoExchange.Net/OrderBook/SymbolOrderBook.cs | 17 +++-------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/CryptoExchange.Net/CryptoExchange.Net.xml b/CryptoExchange.Net/CryptoExchange.Net.xml index fd9367b..63ed486 100644 --- a/CryptoExchange.Net/CryptoExchange.Net.xml +++ b/CryptoExchange.Net/CryptoExchange.Net.xml @@ -1553,6 +1553,16 @@ Event when the state changes + + + Event when orderbook was updated. Be careful! It can generate a lot of events at high-liquidity markets + + + + + Should be useful for low-liquidity order-books to monitor market activity + + The number of asks in the book diff --git a/CryptoExchange.Net/Objects/Options.cs b/CryptoExchange.Net/Objects/Options.cs index 156364f..22c3729 100644 --- a/CryptoExchange.Net/Objects/Options.cs +++ b/CryptoExchange.Net/Objects/Options.cs @@ -27,11 +27,7 @@ namespace CryptoExchange.Net.Objects /// Base for order book options /// public class OrderBookOptions : BaseOptions - { - /// - /// Update event raising timeout in milliseconds (to limit it at high-liquidity order books) - /// - public int UpdateEventTimeout { get; } + { /// /// The name of the order book implementation /// @@ -46,10 +42,8 @@ namespace CryptoExchange.Net.Objects /// /// The name of the order book implementation /// Whether each update should have a consecutive id number. Used to identify and reconnect when numbers are skipped. - /// Update event raising timeout in milliseconds (to limit it at high-liquidity order books) - public OrderBookOptions(string name, bool sequencesAreConsecutive, int? updateInterval) - { - UpdateEventTimeout = updateInterval ?? 1000; + public OrderBookOptions(string name, bool sequencesAreConsecutive) + { OrderBookName = name; SequenceNumbersAreConsecutive = sequencesAreConsecutive; } diff --git a/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs b/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs index 2e5f2dc..d942ed9 100644 --- a/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs +++ b/CryptoExchange.Net/OrderBook/SymbolOrderBook.cs @@ -72,16 +72,14 @@ namespace CryptoExchange.Net.OrderBook /// public event Action OnStatusChange; /// - /// Event when orderbook was updated, but not more often then timeout setted in orderbook options (1000ms by default). Be careful! with small timeout it can generate a lot of events at high-liquidity order books + /// Event when orderbook was updated. Be careful! It can generate a lot of events at high-liquidity markets /// public event Action OnOrderBookUpdate; /// /// Should be useful for low-liquidity order-books to monitor market activity /// public DateTime LastOrderBookUpdate; - private DateTime LastOrderBookUpdateEventTrigger; - private readonly int updateEventInterval; /// /// The number of asks in the book /// @@ -149,7 +147,6 @@ namespace CryptoExchange.Net.OrderBook id = options.OrderBookName; processBuffer = new List(); sequencesAreConsecutive = options.SequenceNumbersAreConsecutive; - updateEventInterval = options.UpdateEventTimeout; Symbol = symbol; Status = OrderBookStatus.Disconnected; @@ -272,11 +269,7 @@ namespace CryptoExchange.Net.OrderBook CheckProcessBuffer(); bookSet = true; LastOrderBookUpdate = DateTime.UtcNow; - if ((LastOrderBookUpdate - LastOrderBookUpdateEventTrigger).TotalMilliseconds >= updateEventInterval) - { - OnOrderBookUpdate?.Invoke(); - LastOrderBookUpdateEventTrigger = DateTime.UtcNow; - } + OnOrderBookUpdate?.Invoke(); log.Write(LogVerbosity.Debug, $"{id} order book {Symbol} data set: {BidCount} bids, {AskCount} asks"); } } @@ -318,11 +311,7 @@ namespace CryptoExchange.Net.OrderBook LastSequenceNumber = lastSequenceNumber; CheckProcessBuffer(); LastOrderBookUpdate = DateTime.UtcNow; - if ((LastOrderBookUpdate - LastOrderBookUpdateEventTrigger).TotalMilliseconds >= updateEventInterval) - { - OnOrderBookUpdate?.Invoke(); - LastOrderBookUpdateEventTrigger = DateTime.UtcNow; - } + OnOrderBookUpdate?.Invoke(); log.Write(LogVerbosity.Debug, $"{id} order book {Symbol} update: {entries.Count} entries processed"); } }