1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-07 16:06:15 +00:00

Split DataEvent.Timestamp in DataEvent.ReceivedTimestamp and

This commit is contained in:
JKorf 2025-02-09 16:40:28 +01:00
parent dec94678ec
commit 4bb5aae40a
2 changed files with 24 additions and 11 deletions

View File

@ -12,7 +12,12 @@ namespace CryptoExchange.Net.Objects.Sockets
/// <summary> /// <summary>
/// The timestamp the data was received /// The timestamp the data was received
/// </summary> /// </summary>
public DateTime Timestamp { get; set; } public DateTime ReceiveTime { get; set; }
/// <summary>
/// The timestamp of the data as specified by the server
/// </summary>
public DateTime? DataTime { get; set; }
/// <summary> /// <summary>
/// The stream producing the update /// The stream producing the update
@ -42,29 +47,29 @@ namespace CryptoExchange.Net.Objects.Sockets
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
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; Data = data;
StreamId = streamId; StreamId = streamId;
Symbol = symbol; Symbol = symbol;
OriginalData = originalData; OriginalData = originalData;
Timestamp = timestamp; ReceiveTime = receiveTimestamp;
UpdateType = updateType; UpdateType = updateType;
} }
/// <summary> /// <summary>
/// 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
/// </summary> /// </summary>
/// <typeparam name="K">The type of the new data</typeparam> /// <typeparam name="K">The type of the new data</typeparam>
/// <param name="data">The new data</param> /// <param name="data">The new data</param>
/// <returns></returns> /// <returns></returns>
public DataEvent<K> As<K>(K data) public DataEvent<K> As<K>(K data)
{ {
return new DataEvent<K>(data, StreamId, Symbol, OriginalData, Timestamp, UpdateType); return new DataEvent<K>(data, StreamId, Symbol, OriginalData, ReceiveTime, UpdateType);
} }
/// <summary> /// <summary>
/// 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
/// </summary> /// </summary>
/// <typeparam name="K">The type of the new data</typeparam> /// <typeparam name="K">The type of the new data</typeparam>
/// <param name="data">The new data</param> /// <param name="data">The new data</param>
@ -72,11 +77,11 @@ namespace CryptoExchange.Net.Objects.Sockets
/// <returns></returns> /// <returns></returns>
public DataEvent<K> As<K>(K data, string? symbol) public DataEvent<K> As<K>(K data, string? symbol)
{ {
return new DataEvent<K>(data, StreamId, symbol, OriginalData, Timestamp, UpdateType); return new DataEvent<K>(data, StreamId, symbol, OriginalData, ReceiveTime, UpdateType);
} }
/// <summary> /// <summary>
/// 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
/// </summary> /// </summary>
/// <typeparam name="K">The type of the new data</typeparam> /// <typeparam name="K">The type of the new data</typeparam>
/// <param name="data">The new data</param> /// <param name="data">The new data</param>
@ -86,7 +91,7 @@ namespace CryptoExchange.Net.Objects.Sockets
/// <returns></returns> /// <returns></returns>
public DataEvent<K> As<K>(K data, string streamId, string? symbol, SocketUpdateType updateType) public DataEvent<K> As<K>(K data, string streamId, string? symbol, SocketUpdateType updateType)
{ {
return new DataEvent<K>(data, streamId, symbol, OriginalData, Timestamp, updateType); return new DataEvent<K>(data, streamId, symbol, OriginalData, ReceiveTime, updateType);
} }
/// <summary> /// <summary>
@ -101,7 +106,6 @@ namespace CryptoExchange.Net.Objects.Sockets
return new ExchangeEvent<K>(exchange, this.As<K>(data)); return new ExchangeEvent<K>(exchange, this.As<K>(data));
} }
/// <summary> /// <summary>
/// Specify the symbol /// Specify the symbol
/// </summary> /// </summary>
@ -135,6 +139,15 @@ namespace CryptoExchange.Net.Objects.Sockets
return this; return this;
} }
/// <summary>
/// Specify the data timestamp
/// </summary>
public DataEvent<T> WithDataTimestamp(DateTime timestamp)
{
DataTime = timestamp;
return this;
}
/// <summary> /// <summary>
/// Create a CallResult from this DataEvent /// Create a CallResult from this DataEvent
/// </summary> /// </summary>

View File

@ -21,7 +21,7 @@ namespace CryptoExchange.Net.SharedApis
evnt.StreamId, evnt.StreamId,
evnt.Symbol, evnt.Symbol,
evnt.OriginalData, evnt.OriginalData,
evnt.Timestamp, evnt.ReceiveTime,
evnt.UpdateType) evnt.UpdateType)
{ {
Exchange = exchange; Exchange = exchange;