1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-10-14 23:21:48 +00:00
This commit is contained in:
Jkorf
2026-09-04 16:21:13 +02:00
parent a545efbb45
commit 431ef93611
301 changed files with 910 additions and 1 deletions
@@ -0,0 +1,49 @@
using CryptoExchange.Net.Objects;
using System;
using System.Text;
namespace CryptoExchange.Net.SharedApis
{
/// <summary>
/// Options for requesting funding rate history
/// </summary>
public class GetFundingRateHistoryOptions : PaginatedCapabilityOptions<GetFundingRateHistoryRequest, IGetFundingRateHistoryRest>
{
/// <inheritdoc />
public override string Description => "Retrieve historical funding rates for a futures symbol";
/// <summary>
/// ctor
/// </summary>
public GetFundingRateHistoryOptions(string exchange, bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit, bool needsAuthentication)
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetFundingRateHistoryRest.GetFundingRateHistoryAsync))
{
}
/// <inheritdoc />
public override Error? ValidateRequest(GetFundingRateHistoryRequest request, IGetFundingRateHistoryRest client)
{
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 (MaxAge.HasValue && request.StartTime < DateTime.UtcNow.Add(-MaxAge.Value))
return ArgumentError.Invalid(nameof(GetKlinesRequest.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);
}
}
}
@@ -0,0 +1,39 @@
using CryptoExchange.Net.Objects;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace CryptoExchange.Net.SharedApis
{
/// <summary>
/// Operation for retrieving funding rate history for a symbol on an exchange.
/// </summary>
public interface IGetFundingRateHistory : ISharedApiCapability
{
/// <summary>
/// Funding rate request options.<br />
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
/// </summary>
GetFundingRateHistoryOptions GetFundingRateHistoryOptions { get; }
/// <summary>
/// Get funding rate records, see <see cref="GetFundingRateHistoryOptions"/> for request options and exchange specific required/optional parameters. <br />
/// The result is paginated, if there are more results to be retrieved, the <see cref="HttpResult{T}.NextPageRequest"/> property of the result will contain the pagination request to be used for the next request to continue pagination.
/// </summary>
/// <param name="request">Request info</param>
/// <param name="nextPageToken">The pagination request from the previous request result <see cref="HttpResult{T}.NextPageRequest"/> property to continue pagination</param>
/// <param name="ct">Cancellation token</param>
Task<ICallResult<SharedFundingRate[]>> GetFundingRateHistoryAsync(GetFundingRateHistoryRequest request, PageRequest? nextPageToken = null, CancellationToken ct = default);
}
/// <summary>
/// Operation for retrieving funding rate history for a symbol on an exchange via the REST API.
/// </summary>
public interface IGetFundingRateHistoryRest : IGetFundingRateHistory, ISharedRest
{
/// <inheritdoc />
new Task<HttpResult<SharedFundingRate[]>> GetFundingRateHistoryAsync(GetFundingRateHistoryRequest request, PageRequest? nextPageToken = null, CancellationToken ct = default);
}
}