1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-16 19:03:01 +00:00

Added AutoTimestamp option for socket client, fixed socket client timestamp offset bug

This commit is contained in:
JKorf
2026-02-05 21:54:16 +01:00
parent 74e5cf6fc9
commit 40d480e1fc
8 changed files with 31 additions and 15 deletions
@@ -7,6 +7,11 @@ namespace CryptoExchange.Net.Objects.Options
/// </summary>
public class ApiOptions
{
/// <summary>
/// Whether or not to automatically sync the local time with the server time
/// </summary>
public bool? AutoTimestamp { get; set; }
/// <summary>
/// If true, the CallResult and DataEvent objects will also include the originally received string data in the OriginalData property.
/// Note that this comes at a performance cost
@@ -8,6 +8,10 @@ namespace CryptoExchange.Net.Objects.Options
/// </summary>
public class ExchangeOptions
{
/// <summary>
/// Whether or not to automatically sync the local time with the server time
/// </summary>
public bool AutoTimestamp { get; set; }
/// <summary>
/// Proxy settings
/// </summary>
@@ -8,11 +8,6 @@ namespace CryptoExchange.Net.Objects.Options
/// </summary>
public class RestApiOptions : ApiOptions
{
/// <summary>
/// Whether or not to automatically sync the local time with the server time
/// </summary>
public bool? AutoTimestamp { get; set; }
/// <summary>
/// How often the timestamp adjustment between client and server is recalculated. If you need a very small TimeSpan here you're probably better of syncing your server time more often
/// </summary>
@@ -8,11 +8,6 @@ namespace CryptoExchange.Net.Objects.Options
/// </summary>
public class RestExchangeOptions: ExchangeOptions
{
/// <summary>
/// Whether or not to automatically sync the local time with the server time
/// </summary>
public bool AutoTimestamp { get; set; }
/// <summary>
/// How often the timestamp adjustment between client and server is recalculated. If you need a very small TimeSpan here you're probably better of syncing your server time more often
/// </summary>
@@ -27,6 +27,7 @@ namespace CryptoExchange.Net.Objects.Options
item.ApiCredentials = ApiCredentials?.Copy();
item.OutputOriginalData = OutputOriginalData;
item.SocketNoDataTimeout = SocketNoDataTimeout;
item.AutoTimestamp = AutoTimestamp;
item.MaxSocketConnections = MaxSocketConnections;
return item;
}
@@ -75,6 +75,15 @@ namespace CryptoExchange.Net.Objects.Options
/// </remarks>
public int? ReceiveBufferSize { get; set; }
/// <summary>
/// ctor
/// </summary>
public SocketExchangeOptions()
{
// Enable auto timestamping by default for sockets
AutoTimestamp = true;
}
/// <summary>
/// Create a copy of this options
/// </summary>
@@ -83,6 +92,7 @@ namespace CryptoExchange.Net.Objects.Options
public T Set<T>(T item) where T : SocketExchangeOptions, new()
{
item.ApiCredentials = ApiCredentials?.Copy();
item.AutoTimestamp = AutoTimestamp;
item.OutputOriginalData = OutputOriginalData;
item.ReconnectPolicy = ReconnectPolicy;
item.DelayAfterConnect = DelayAfterConnect;