diff --git a/CryptoExchange.Net/SharedApis/Interfaces/Rest/Futures/IFuturesOrderRestClient.cs b/CryptoExchange.Net/SharedApis/Interfaces/Rest/Futures/IFuturesOrderRestClient.cs
index 30f9030..bc766b5 100644
--- a/CryptoExchange.Net/SharedApis/Interfaces/Rest/Futures/IFuturesOrderRestClient.cs
+++ b/CryptoExchange.Net/SharedApis/Interfaces/Rest/Futures/IFuturesOrderRestClient.cs
@@ -73,7 +73,7 @@ namespace CryptoExchange.Net.SharedApis
///
/// Spot get closed orders request options
///
- PaginatedEndpointOptions GetClosedFuturesOrdersOptions { get; }
+ GetClosedOrdersOptions GetClosedFuturesOrdersOptions { get; }
///
/// Get info on closed futures orders
///
@@ -96,7 +96,7 @@ namespace CryptoExchange.Net.SharedApis
///
/// Futures user trades request options
///
- PaginatedEndpointOptions GetFuturesUserTradesOptions { get; }
+ GetUserTradesOptions GetFuturesUserTradesOptions { get; }
///
/// Get futures user trade records
///
diff --git a/CryptoExchange.Net/SharedApis/Interfaces/Rest/Spot/ISpotOrderRestClient.cs b/CryptoExchange.Net/SharedApis/Interfaces/Rest/Spot/ISpotOrderRestClient.cs
index 4ad5c22..963cc75 100644
--- a/CryptoExchange.Net/SharedApis/Interfaces/Rest/Spot/ISpotOrderRestClient.cs
+++ b/CryptoExchange.Net/SharedApis/Interfaces/Rest/Spot/ISpotOrderRestClient.cs
@@ -72,7 +72,7 @@ namespace CryptoExchange.Net.SharedApis
///
/// Spot get closed orders request options
///
- PaginatedEndpointOptions GetClosedSpotOrdersOptions { get; }
+ GetClosedOrdersOptions GetClosedSpotOrdersOptions { get; }
///
/// Get info on closed spot orders
///
@@ -95,7 +95,7 @@ namespace CryptoExchange.Net.SharedApis
///
/// Spot user trades request options
///
- PaginatedEndpointOptions GetSpotUserTradesOptions { get; }
+ GetUserTradesOptions GetSpotUserTradesOptions { get; }
///
/// Get spot user trade records
///
diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetUserTradesOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetUserTradesOptions.cs
new file mode 100644
index 0000000..3caf0dd
--- /dev/null
+++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetUserTradesOptions.cs
@@ -0,0 +1,51 @@
+using CryptoExchange.Net.Objects;
+using System;
+using System.Text;
+
+namespace CryptoExchange.Net.SharedApis
+{
+ ///
+ /// Options for requesting user trades
+ ///
+ public class GetUserTradesOptions : PaginatedEndpointOptions
+ {
+ ///
+ /// ctor
+ ///
+ public GetUserTradesOptions(bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit)
+ : base(supportsAscending, supportsDescending, timeFilterSupported, maxLimit, true)
+ {
+ }
+
+ ///
+ public override Error? ValidateRequest(string exchange, GetUserTradesRequest request, TradingMode? tradingMode, TradingMode[] supportedApiTypes)
+ {
+ if (!SupportsAscending && request.Direction == DataDirection.Ascending)
+ return ArgumentError.Invalid(nameof(GetWithdrawalsRequest.Direction), $"Ascending direction is not supported");
+
+ if (!SupportsDescending && request.Direction == DataDirection.Descending)
+ return ArgumentError.Invalid(nameof(GetWithdrawalsRequest.Direction), $"Descending direction is not supported");
+
+ if (!TimePeriodFilterSupport)
+ {
+ // When going descending we can still allow startTime filter to limit the results
+ var now = DateTime.UtcNow;
+ if ((request.Direction != DataDirection.Descending && request.StartTime != null)
+ || (request.EndTime != null && now - request.EndTime > TimeSpan.FromSeconds(5)))
+ {
+ return ArgumentError.Invalid(nameof(GetDepositsRequest.StartTime), $"Time filter is not supported");
+ }
+ }
+
+ return base.ValidateRequest(exchange, request, tradingMode, supportedApiTypes);
+ }
+
+ ///
+ public override string ToString(string exchange)
+ {
+ var sb = new StringBuilder(base.ToString(exchange));
+ sb.AppendLine($"Time filter supported: {TimePeriodFilterSupport}");
+ return sb.ToString();
+ }
+ }
+}
diff --git a/CryptoExchange.Net/SharedApis/Models/Pagination.cs b/CryptoExchange.Net/SharedApis/Models/Pagination.cs
index 6f7a2f4..8778219 100644
--- a/CryptoExchange.Net/SharedApis/Models/Pagination.cs
+++ b/CryptoExchange.Net/SharedApis/Models/Pagination.cs
@@ -60,9 +60,15 @@ namespace CryptoExchange.Net.SharedApis
if (direction == DataDirection.Ascending)
{
if (startTime == null)
+ {
startTime = endTime.Add(-maxPeriod.Value);
+ }
else
+ {
endTime = startTime.Value.Add(maxPeriod.Value);
+ if (endTime > DateTime.UtcNow)
+ endTime = DateTime.UtcNow;
+ }
}
else
{
@@ -196,10 +202,11 @@ namespace CryptoExchange.Net.SharedApis
}
else
{
+ var lastPageStartTime = lastPaginationParameters.StartTime ?? lastPaginationParameters.EndTime!.Value.Add(-period);
if (requestStartTime != null)
- return (lastPaginationParameters.StartTime!.Value - requestStartTime.Value).TotalSeconds > 1;
+ return (lastPageStartTime - requestStartTime.Value).TotalSeconds > 1;
else
- return (lastPaginationParameters.StartTime!.Value - (lastPaginationParameters.EndTime!.Value - period)).TotalSeconds > 1;
+ return (lastPageStartTime - (lastPaginationParameters.EndTime!.Value - period)).TotalSeconds > 1;
}
}