1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-10-28 14:00:48 +00:00
This commit is contained in:
Jkorf
2026-08-25 16:09:15 +02:00
parent 407509e9cd
commit d0ce2563de
155 changed files with 1714 additions and 621 deletions
@@ -0,0 +1,49 @@
using CryptoExchange.Net.Objects;
using System;
using System.Text;
namespace CryptoExchange.Net.SharedApis
{
/// <summary>
/// Options for requesting user trades
/// </summary>
public class GetFuturesUserTradeHistoryOptions : PaginatedEndpointOptions<GetUserTradesRequest, IGetFuturesUserTradeHistoryEndpoint>
{
/// <inheritdoc />
public override string Description => "Retrieve futures user trade history";
/// <summary>
/// ctor
/// </summary>
public GetFuturesUserTradeHistoryOptions(string exchange, bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit)
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, true, nameof(IGetFuturesUserTradeHistoryEndpoint.GetFuturesUserTradesAsync))
{
}
/// <inheritdoc />
public override Error? ValidateRequest(GetUserTradesRequest request, IGetFuturesUserTradeHistoryEndpoint client)
{
if (!SupportsAscending && request.Direction == DataDirection.Ascending)
return ArgumentError.Invalid(nameof(GetUserTradesRequest.Direction), $"Ascending direction is not supported");
if (!SupportsDescending && request.Direction == DataDirection.Descending)
return ArgumentError.Invalid(nameof(GetUserTradesRequest.Direction), $"Descending direction is not supported");
if (MaxAge.HasValue && request.StartTime < DateTime.UtcNow.Add(-MaxAge.Value))
return ArgumentError.Invalid(nameof(GetUserTradesRequest.StartTime), $"Only the most recent {MaxAge} period data is available");
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(request, client);
}
}
}