From 4bb5aae40aaaa39e37463d44d4b53f603ba9346d Mon Sep 17 00:00:00 2001 From: JKorf Date: Sun, 9 Feb 2025 16:40:28 +0100 Subject: [PATCH] Split DataEvent.Timestamp in DataEvent.ReceivedTimestamp and --- .../Objects/Sockets/DataEvent.cs | 33 +++++++++++++------ .../SharedApis/Models/ExchangeEvent.cs | 2 +- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/CryptoExchange.Net/Objects/Sockets/DataEvent.cs b/CryptoExchange.Net/Objects/Sockets/DataEvent.cs index e486f37..5b1ecf2 100644 --- a/CryptoExchange.Net/Objects/Sockets/DataEvent.cs +++ b/CryptoExchange.Net/Objects/Sockets/DataEvent.cs @@ -12,7 +12,12 @@ namespace CryptoExchange.Net.Objects.Sockets /// /// The timestamp the data was received /// - public DateTime Timestamp { get; set; } + public DateTime ReceiveTime { get; set; } + + /// + /// The timestamp of the data as specified by the server + /// + public DateTime? DataTime { get; set; } /// /// The stream producing the update @@ -42,29 +47,29 @@ namespace CryptoExchange.Net.Objects.Sockets /// /// ctor /// - public DataEvent(T data, string? streamId, string? symbol, string? originalData, DateTime timestamp, SocketUpdateType? updateType) + public DataEvent(T data, string? streamId, string? symbol, string? originalData, DateTime receiveTimestamp, SocketUpdateType? updateType) { Data = data; StreamId = streamId; Symbol = symbol; OriginalData = originalData; - Timestamp = timestamp; + ReceiveTime = receiveTimestamp; UpdateType = updateType; } /// - /// Create a new DataEvent with data in the from of type K based on the current DataEvent. Topic, OriginalData and Timestamp will be copied over + /// Create a new DataEvent with data in the from of type K based on the current DataEvent. Topic, OriginalData and ReceivedTimestamp will be copied over /// /// The type of the new data /// The new data /// public DataEvent As(K data) { - return new DataEvent(data, StreamId, Symbol, OriginalData, Timestamp, UpdateType); + return new DataEvent(data, StreamId, Symbol, OriginalData, ReceiveTime, UpdateType); } /// - /// Create a new DataEvent with data in the from of type K based on the current DataEvent. OriginalData and Timestamp will be copied over + /// Create a new DataEvent with data in the from of type K based on the current DataEvent. OriginalData and ReceivedTimestamp will be copied over /// /// The type of the new data /// The new data @@ -72,11 +77,11 @@ namespace CryptoExchange.Net.Objects.Sockets /// public DataEvent As(K data, string? symbol) { - return new DataEvent(data, StreamId, symbol, OriginalData, Timestamp, UpdateType); + return new DataEvent(data, StreamId, symbol, OriginalData, ReceiveTime, UpdateType); } /// - /// Create a new DataEvent with data in the from of type K based on the current DataEvent. OriginalData and Timestamp will be copied over + /// Create a new DataEvent with data in the from of type K based on the current DataEvent. OriginalData and ReceivedTimestamp will be copied over /// /// The type of the new data /// The new data @@ -86,7 +91,7 @@ namespace CryptoExchange.Net.Objects.Sockets /// public DataEvent As(K data, string streamId, string? symbol, SocketUpdateType updateType) { - return new DataEvent(data, streamId, symbol, OriginalData, Timestamp, updateType); + return new DataEvent(data, streamId, symbol, OriginalData, ReceiveTime, updateType); } /// @@ -101,7 +106,6 @@ namespace CryptoExchange.Net.Objects.Sockets return new ExchangeEvent(exchange, this.As(data)); } - /// /// Specify the symbol /// @@ -135,6 +139,15 @@ namespace CryptoExchange.Net.Objects.Sockets return this; } + /// + /// Specify the data timestamp + /// + public DataEvent WithDataTimestamp(DateTime timestamp) + { + DataTime = timestamp; + return this; + } + /// /// Create a CallResult from this DataEvent /// diff --git a/CryptoExchange.Net/SharedApis/Models/ExchangeEvent.cs b/CryptoExchange.Net/SharedApis/Models/ExchangeEvent.cs index cb5d834..6587617 100644 --- a/CryptoExchange.Net/SharedApis/Models/ExchangeEvent.cs +++ b/CryptoExchange.Net/SharedApis/Models/ExchangeEvent.cs @@ -21,7 +21,7 @@ namespace CryptoExchange.Net.SharedApis evnt.StreamId, evnt.Symbol, evnt.OriginalData, - evnt.Timestamp, + evnt.ReceiveTime, evnt.UpdateType) { Exchange = exchange;