1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-08-12 17:03:10 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
Jkorf bc8faf9822 Updated to version 10.2.5 2026-01-19 10:26:04 +01:00
JKorf 90c1b89ceb Added GetRestOffsets and GetWebsocketOffsets to TimeOffsetManager 2026-01-18 17:46:42 +01:00
JKorf 21206ffb25 Updated SymbolOrderBook.WaitUntilFirstUpdateBufferedAsync 2026-01-18 17:36:18 +01:00
4 changed files with 43 additions and 9 deletions
+3 -3
View File
@@ -6,9 +6,9 @@
<PackageId>CryptoExchange.Net</PackageId>
<Authors>JKorf</Authors>
<Description>CryptoExchange.Net is a base library which is used to implement different cryptocurrency (exchange) API's. It provides a standardized way of implementing different API's, which results in a very similar experience for users of the API implementations.</Description>
<PackageVersion>10.2.4</PackageVersion>
<AssemblyVersion>10.2.4</AssemblyVersion>
<FileVersion>10.2.4</FileVersion>
<PackageVersion>10.2.5</PackageVersion>
<AssemblyVersion>10.2.5</AssemblyVersion>
<FileVersion>10.2.5</FileVersion>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageTags>OKX;OKX.Net;Mexc;Mexc.Net;Kucoin;Kucoin.Net;Kraken;Kraken.Net;Huobi;Huobi.Net;CoinEx;CoinEx.Net;Bybit;Bybit.Net;Bitget;Bitget.Net;Bitfinex;Bitfinex.Net;Binance;Binance.Net;CryptoCurrency;CryptoCurrency Exchange;CryptoExchange.Net</PackageTags>
<RepositoryType>git</RepositoryType>
@@ -643,19 +643,20 @@ namespace CryptoExchange.Net.OrderBook
/// <summary>
/// Wait until an update has been buffered
/// </summary>
/// <param name="timeout">Max wait time</param>
/// <param name="minWait">Min wait time</param>
/// <param name="maxWait">Max wait time</param>
/// <param name="ct">Cancellation token</param>
/// <returns></returns>
protected async Task<CallResult<bool>> WaitUntilFirstUpdateBufferedAsync(TimeSpan timeout, CancellationToken ct)
protected async Task<CallResult> WaitUntilFirstUpdateBufferedAsync(TimeSpan? minWait, TimeSpan maxWait, CancellationToken ct)
{
var startWait = DateTime.UtcNow;
while (_processBuffer.Count == 0)
{
if (ct.IsCancellationRequested)
return new CallResult<bool>(new CancellationRequestedError());
return new CallResult(new CancellationRequestedError());
if (DateTime.UtcNow - startWait > timeout)
return new CallResult<bool>(new ServerError(new ErrorInfo(ErrorType.OrderBookTimeout, "Timeout while waiting for data")));
if (DateTime.UtcNow - startWait > maxWait)
return new CallResult(new ServerError(new ErrorInfo(ErrorType.OrderBookTimeout, "Timeout while waiting for data")));
try
{
@@ -665,7 +666,14 @@ namespace CryptoExchange.Net.OrderBook
{ }
}
return new CallResult<bool>(true);
if (minWait != null)
{
var dif = DateTime.UtcNow - startWait;
if (dif < minWait)
await Task.Delay(minWait.Value - dif).ConfigureAwait(false);
}
return CallResult.SuccessResult;
}
/// <summary>
+22
View File
@@ -1,5 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -139,6 +141,26 @@ namespace CryptoExchange.Net
/// <param name="api">API name</param>
public static TimeSpan? GetSocketOffset(string api) => _lastSocketDelays.TryGetValue(api, out var val) && val.Offset != null ? TimeSpan.FromMilliseconds(val.Offset.Value) : null;
/// <summary>
/// Get a dictionary of API/Client name -> time offset for Rest api's
/// </summary>
public static Dictionary<string, TimeSpan?> GetRestOffsets()
{
return _lastRestDelays.ToDictionary(
x => x.Key,
x => (x.Value.Offset == null ? (TimeSpan?)null : TimeSpan.FromMilliseconds(x.Value.Offset.Value)));
}
/// <summary>
/// Get a dictionary of API/Client name -> time offset for Websocket api's
/// </summary>
public static Dictionary<string, TimeSpan?> GetWebsocketOffsets()
{
return _lastSocketDelays.ToDictionary(
x => x.Key,
x => (x.Value.Offset == null ? (TimeSpan?)null : TimeSpan.FromMilliseconds(x.Value.Offset.Value)));
}
/// <summary>
/// Reset the WebSocket API update timestamp to trigger a new time offset calculation
/// </summary>
+4
View File
@@ -66,6 +66,10 @@ Make a one time donation in a crypto currency of your choice. If you prefer to d
Alternatively, sponsor me on Github using [Github Sponsors](https://github.com/sponsors/JKorf).
## Release notes
* Version 10.2.5 - 19 Jan 2026
* Updated SymbolOrderBook.WaitUntilFirstUpdateBufferedAsync
* Added GetRestOffsets and GetWebsocketOffsets to TimeOffsetManager
* Version 10.2.4 - 17 Jan 2026
* Added WaitUntilFirstUpdateBufferedAsync method on SymbolOrderBook
* Added some util methods