mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2026-04-12 16:13:12 +00:00
wip
This commit is contained in:
parent
f225f6ffb8
commit
777a0466a0
@ -73,7 +73,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// Spot get closed orders request options
|
||||
/// </summary>
|
||||
PaginatedEndpointOptions<GetClosedOrdersRequest> GetClosedFuturesOrdersOptions { get; }
|
||||
GetClosedOrdersOptions GetClosedFuturesOrdersOptions { get; }
|
||||
/// <summary>
|
||||
/// Get info on closed futures orders
|
||||
/// </summary>
|
||||
@ -96,7 +96,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// Futures user trades request options
|
||||
/// </summary>
|
||||
PaginatedEndpointOptions<GetUserTradesRequest> GetFuturesUserTradesOptions { get; }
|
||||
GetUserTradesOptions GetFuturesUserTradesOptions { get; }
|
||||
/// <summary>
|
||||
/// Get futures user trade records
|
||||
/// </summary>
|
||||
|
||||
@ -72,7 +72,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// Spot get closed orders request options
|
||||
/// </summary>
|
||||
PaginatedEndpointOptions<GetClosedOrdersRequest> GetClosedSpotOrdersOptions { get; }
|
||||
GetClosedOrdersOptions GetClosedSpotOrdersOptions { get; }
|
||||
/// <summary>
|
||||
/// Get info on closed spot orders
|
||||
/// </summary>
|
||||
@ -95,7 +95,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// Spot user trades request options
|
||||
/// </summary>
|
||||
PaginatedEndpointOptions<GetUserTradesRequest> GetSpotUserTradesOptions { get; }
|
||||
GetUserTradesOptions GetSpotUserTradesOptions { get; }
|
||||
/// <summary>
|
||||
/// Get spot user trade records
|
||||
/// </summary>
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
using CryptoExchange.Net.Objects;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for requesting user trades
|
||||
/// </summary>
|
||||
public class GetUserTradesOptions : PaginatedEndpointOptions<GetUserTradesRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetUserTradesOptions(bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit)
|
||||
: base(supportsAscending, supportsDescending, timeFilterSupported, maxLimit, true)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
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);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString(string exchange)
|
||||
{
|
||||
var sb = new StringBuilder(base.ToString(exchange));
|
||||
sb.AppendLine($"Time filter supported: {TimePeriodFilterSupport}");
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user