mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-16 08:01:06 +00:00
wip
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using CryptoExchange.Net.Objects;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for requesting funding info
|
||||
/// </summary>
|
||||
public class GetFundingInfoOptions : PaginatedCapabilityOptions<GetFundingInfoRequest, IGetFundingInfoRest>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve the current funding info for a symbol";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetFundingInfoRequest>.Required(x => x.Symbol, "The symbol", new SharedSymbol(TradingMode.PerpetualLinear, "ETH", "USDT")),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetFundingInfoOptions(string exchange, bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit, bool needsAuthentication)
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetFundingInfoRest.GetFundingInfoAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Request to retrieve the current funding info for a symbol
|
||||
/// </summary>
|
||||
public record GetFundingInfoRequest : SharedSymbolRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
/// <param name="symbol">Symbol to request funding info for</param>
|
||||
/// <param name="exchangeParameters">Exchange specific parameters</param>
|
||||
public GetFundingInfoRequest(
|
||||
SharedSymbol symbol,
|
||||
ExchangeParameters? exchangeParameters = null)
|
||||
: base(symbol, exchangeParameters)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
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 the current funding info for a symbol on an exchange.
|
||||
/// </summary>
|
||||
public interface IGetFundingInfo : ISharedApiCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Funding info request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> 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>
|
||||
GetFundingInfoOptions GetFundingInfoOptions { get; }
|
||||
/// <summary>
|
||||
/// Get current funding info for a symbol, see <see cref="GetFundingInfoOptions"/> for request options and exchange specific required/optional parameters. <br />
|
||||
/// </summary>
|
||||
/// <param name="request">Request info</param>
|
||||
/// <param name="ct">Cancellation token</param>
|
||||
Task<ICallResult<SharedFundingInfo>> GetFundingInfoAsync(GetFundingInfoRequest request, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operation for retrieving the current funding info for a symbol on an exchange via the REST API.
|
||||
/// </summary>
|
||||
public interface IGetFundingInfoRest : IGetFundingInfo, ISharedRest
|
||||
{
|
||||
/// <inheritdoc />
|
||||
new Task<HttpResult<SharedFundingInfo>> GetFundingInfoAsync(GetFundingInfoRequest request, CancellationToken ct = default);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -27,7 +27,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
/// <param name="symbol">Symbol to request klines for</param>
|
||||
/// <param name="symbol">Symbol to request funding rate history for</param>
|
||||
/// <param name="startTime">Filter by start time</param>
|
||||
/// <param name="endTime">Filter by end time</param>
|
||||
/// <param name="limit">Max number of results</param>
|
||||
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
using CryptoExchange.Net.Objects;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for requesting funding rate history
|
||||
/// </summary>
|
||||
public class GetUserFundingHistoryOptions : PaginatedCapabilityOptions<GetUserFundingHistoryRequest, IGetUserFundingHistoryRest>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve funding fee payments for the user";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetUserFundingHistoryRequest>.Optional(x => x.Symbol, "Filter by symbol", new SharedSymbol(TradingMode.PerpetualLinear, "ETH", "USDT")),
|
||||
RequestParameterRule<GetUserFundingHistoryRequest>.Optional(x => x.StartTime, "Filter the result set by start time", DateTime.UtcNow.AddDays(-1)),
|
||||
RequestParameterRule<GetUserFundingHistoryRequest>.Optional(x => x.EndTime, "Filter the result set by end time", DateTime.UtcNow.AddHours(-1)),
|
||||
RequestParameterRule<GetUserFundingHistoryRequest>.Optional(x => x.Limit, "Limit the result set to a maximum number of items", 100),
|
||||
RequestParameterRule<GetUserFundingHistoryRequest>.Optional(x => x.Direction, "The direction in which to retrieve the results", DataDirection.Descending),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetUserFundingHistoryOptions(string exchange, bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit, bool needsAuthentication)
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetUserFundingHistoryRest.GetUserFundingHistoryAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Error? ValidateRequest(GetUserFundingHistoryRequest request, IGetUserFundingHistoryRest client)
|
||||
{
|
||||
if (!SupportsAscending && request.Direction == DataDirection.Ascending)
|
||||
return ArgumentError.Invalid(nameof(GetUserFundingHistoryRequest.Direction), $"Ascending direction is not supported");
|
||||
|
||||
if (!SupportsDescending && request.Direction == DataDirection.Descending)
|
||||
return ArgumentError.Invalid(nameof(GetUserFundingHistoryRequest.Direction), $"Descending direction is not supported");
|
||||
|
||||
if (MaxAge.HasValue && request.StartTime < DateTime.UtcNow.Add(-MaxAge.Value))
|
||||
return ArgumentError.Invalid(nameof(GetUserFundingHistoryRequest.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(GetUserFundingHistoryRequest.StartTime), $"Time filter is not supported");
|
||||
}
|
||||
}
|
||||
|
||||
return base.ValidateRequest(request, client);
|
||||
}
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Request to retrieve user funding fee payment history
|
||||
/// </summary>
|
||||
public record GetUserFundingHistoryRequest : SharedRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Filter be symbol
|
||||
/// </summary>
|
||||
public SharedSymbol? Symbol { get; set; }
|
||||
/// <summary>
|
||||
/// Filter by start time
|
||||
/// </summary>
|
||||
public DateTime? StartTime { get; set; }
|
||||
/// <summary>
|
||||
/// Filter by end time
|
||||
/// </summary>
|
||||
public DateTime? EndTime { get; set; }
|
||||
/// <summary>
|
||||
/// Max number of results
|
||||
/// </summary>
|
||||
public int? Limit { get; set; }
|
||||
/// <summary>
|
||||
/// Data direction
|
||||
/// </summary>
|
||||
public DataDirection? Direction { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
/// <param name="symbol">Symbol to request funding history</param>
|
||||
/// <param name="startTime">Filter by start time</param>
|
||||
/// <param name="endTime">Filter by end time</param>
|
||||
/// <param name="limit">Max number of results</param>
|
||||
/// <param name="direction">Data direction</param>
|
||||
/// <param name="exchangeParameters">Exchange specific parameters</param>
|
||||
public GetUserFundingHistoryRequest(
|
||||
SharedSymbol? symbol = null,
|
||||
DateTime? startTime = null,
|
||||
DateTime? endTime = null,
|
||||
int? limit = null,
|
||||
DataDirection? direction = null,
|
||||
ExchangeParameters? exchangeParameters = null)
|
||||
: base(null, exchangeParameters)
|
||||
{
|
||||
Symbol = symbol;
|
||||
StartTime = startTime;
|
||||
EndTime = endTime;
|
||||
Limit = limit;
|
||||
Direction = direction;
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
@@ -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 history for a user on an exchange.
|
||||
/// </summary>
|
||||
public interface IGetUserFundingHistory : ISharedApiCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Funding history request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> 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>
|
||||
GetUserFundingHistoryOptions GetUserFundingHistoryOptions { get; }
|
||||
/// <summary>
|
||||
/// Get funding history records, see <see cref="GetUserFundingHistoryOptions"/> 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<SharedFundingFee[]>> GetUserFundingHistoryAsync(GetUserFundingHistoryRequest request, PageRequest? nextPageToken = null, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operation for retrieving funding history for a user on an exchange via the REST API.
|
||||
/// </summary>
|
||||
public interface IGetUserFundingHistoryRest : IGetUserFundingHistory, ISharedRest
|
||||
{
|
||||
/// <inheritdoc />
|
||||
new Task<HttpResult<SharedFundingFee[]>> GetUserFundingHistoryAsync(GetUserFundingHistoryRequest request, PageRequest? nextPageToken = null, CancellationToken ct = default);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user