diff --git a/CryptoExchange.Net/Authentication/DefaultNonceProvider.cs b/CryptoExchange.Net/Authentication/DefaultNonceProvider.cs new file mode 100644 index 0000000..6cecadf --- /dev/null +++ b/CryptoExchange.Net/Authentication/DefaultNonceProvider.cs @@ -0,0 +1,38 @@ +using CryptoExchange.Net.Interfaces; +using System; + +namespace CryptoExchange.Net.Authentication +{ + /// + /// Default nonce provider + /// + public class DefaultNonceProvider : INonceProvider + { + private static readonly object nonceLock = new object(); + private static long? lastNonce; + + /// + /// Create a new default nonce provider + /// + /// Start with an incremental value from this start nonce. If not provided `DataTime.UtcNow.Ticks` will be used + public DefaultNonceProvider(long? startNonce = null) + { + lastNonce = startNonce; + } + + /// + public long GetNonce() + { + lock (nonceLock) + { + long nonce; + if (lastNonce == null) + nonce = DateTime.UtcNow.Ticks; + else + nonce = lastNonce.Value + 1; + lastNonce = nonce; + return nonce; + } + } + } +} diff --git a/CryptoExchange.Net/CryptoExchange.Net.xml b/CryptoExchange.Net/CryptoExchange.Net.xml index 9dd4dc3..babdda6 100644 --- a/CryptoExchange.Net/CryptoExchange.Net.xml +++ b/CryptoExchange.Net/CryptoExchange.Net.xml @@ -142,6 +142,20 @@ + + + Default nonce provider + + + + + Create a new default nonce provider + + Start with an incremental value from this start nonce. If not provided `DataTime.UtcNow.Ticks` will be used + + + + Private key info @@ -1098,6 +1112,17 @@ + + + A provider for a nonce value used when signing requests + + + + + Get nonce value. Nonce value should be unique and incremental for each call + + Nonce value + Rate limiter interface @@ -1449,6 +1474,12 @@ The type Average fill price + + + String representation of the top x entries + + + Interface for order book entries @@ -3576,11 +3607,6 @@ The topic of the update, what symbol/asset etc.. - - - The event that triggered the update - - The original data that was received, only available when OutputOriginalData is set to true in the client options @@ -3599,14 +3625,13 @@ The new data - + Create a new DataEvent with data in the from of type K based on the current DataEvent. OriginalData and Timestamp will be copied over The type of the new data The new data The new topic - The new event @@ -3951,9 +3976,7 @@ - - -System.Diagnostics.CodeAnalysis.AllowNullAttribute"> + Specifies that is allowed as an input even if the corresponding type disallows it. diff --git a/CryptoExchange.Net/Interfaces/INonceProvider.cs b/CryptoExchange.Net/Interfaces/INonceProvider.cs new file mode 100644 index 0000000..6b57672 --- /dev/null +++ b/CryptoExchange.Net/Interfaces/INonceProvider.cs @@ -0,0 +1,14 @@ +namespace CryptoExchange.Net.Interfaces +{ + /// + /// A provider for a nonce value used when signing requests + /// + public interface INonceProvider + { + /// + /// Get nonce value. Nonce value should be unique and incremental for each call + /// + /// Nonce value + long GetNonce(); + } +} diff --git a/CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs b/CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs index 9a94d9f..f1382be 100644 --- a/CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs +++ b/CryptoExchange.Net/Interfaces/ISymbolOrderBook.cs @@ -100,5 +100,11 @@ namespace CryptoExchange.Net.Interfaces /// The type /// Average fill price CallResult CalculateAverageFillPrice(decimal quantity, OrderBookEntryType type); + + /// + /// String representation of the top x entries + /// + /// + string ToString(int rows); } }