1
0
mirror of https://github.com/JKorf/CryptoExchange.Net synced 2025-06-07 07:56:12 +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>
/// The timestamp the data was received
/// </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>
/// The stream producing the update
@ -42,29 +47,29 @@ namespace CryptoExchange.Net.Objects.Sockets
/// <summary>
/// ctor
/// </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;
StreamId = streamId;
Symbol = symbol;
OriginalData = originalData;
Timestamp = timestamp;
ReceiveTime = receiveTimestamp;
UpdateType = updateType;
}
/// <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>
/// <typeparam name="K">The type of the new data</typeparam>
/// <param name="data">The new data</param>
/// <returns></returns>
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>
/// 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>
/// <typeparam name="K">The type of the new data</typeparam>
/// <param name="data">The new data</param>
@ -72,11 +77,11 @@ namespace CryptoExchange.Net.Objects.Sockets
/// <returns></returns>
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>
/// 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>
/// <typeparam name="K">The type of the new data</typeparam>
/// <param name="data">The new data</param>
@ -86,7 +91,7 @@ namespace CryptoExchange.Net.Objects.Sockets
/// <returns></returns>
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>
@ -101,7 +106,6 @@ namespace CryptoExchange.Net.Objects.Sockets
return new ExchangeEvent<K>(exchange, this.As<K>(data));
}
/// <summary>
/// Specify the symbol
/// </summary>
@ -135,6 +139,15 @@ namespace CryptoExchange.Net.Objects.Sockets
return this;
}
/// <summary>
/// Specify the data timestamp
/// </summary>
public DataEvent<T> WithDataTimestamp(DateTime timestamp)
{
DataTime = timestamp;
return this;
}
/// <summary>
/// Create a CallResult from this DataEvent
/// </summary>

View File

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