mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-17 00:20:55 +00:00
Time offset management (#266)
Updated time sync / time offset management for REST API's Added time offset tracking for WebSocket API's Added GetAuthenticationQuery virtual method on AuthenticationProvider Updated AuthenticationProvider GetTimestamp methods to include a one second offset by default Added AuthenticationProvider GetTimestamp methods for SocketApiClient instances Added ClientName property on BaseApiClient, resolving to the type name Added ObjectOrArrayConverter JsonConverterFactory implementation for resolving json data which might be returned as object or array Added UpdateServerTime, UpdateLocalTime and DataAge properties to (I)SymbolOrderBook Added OutputToConsoleAsync method to (I)SymbolOrderBook Updated SymbolOrderBook string representation Added DataTimeLocal and DataAge properties to DataEvent object Added SocketConnection parameter to subscription HandleSubQueryResponse and HandleUnsubQueryResponse methods
This commit is contained in:
@@ -18,6 +18,16 @@ namespace CryptoExchange.Net.Objects.Sockets
|
||||
/// </summary>
|
||||
public DateTime? DataTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The timestamp of the data in local time. Note that this is an estimation based on average delay from the server.
|
||||
/// </summary>
|
||||
public DateTime? DataTimeLocal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The age of the data. Note that this is an estimation based on average delay from the server.
|
||||
/// </summary>
|
||||
public TimeSpan? DataAge => DateTime.UtcNow - DataTimeLocal;
|
||||
|
||||
/// <summary>
|
||||
/// The stream producing the update
|
||||
/// </summary>
|
||||
@@ -119,9 +129,16 @@ namespace CryptoExchange.Net.Objects.Sockets
|
||||
/// <summary>
|
||||
/// Specify the data timestamp
|
||||
/// </summary>
|
||||
public DataEvent<T> WithDataTimestamp(DateTime? timestamp)
|
||||
public DataEvent<T> WithDataTimestamp(DateTime? timestamp, TimeSpan? offset)
|
||||
{
|
||||
if (timestamp == null || timestamp == default(DateTime))
|
||||
return this;
|
||||
|
||||
DataTime = timestamp;
|
||||
if (offset == null)
|
||||
return this;
|
||||
|
||||
DataTimeLocal = DataTime + offset;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user