mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-15 15:40:52 +00:00
56 lines
2.0 KiB
C#
56 lines
2.0 KiB
C#
using CryptoExchange.Net.Objects;
|
|
using System.Text;
|
|
|
|
namespace CryptoExchange.Net.SharedApis
|
|
{
|
|
/// <summary>
|
|
/// Options for requesting recent trades
|
|
/// </summary>
|
|
public class GetRecentTradesOptions : CapabilityOptions<GetRecentTradesRequest, IGetRecentTrades>
|
|
{
|
|
/// <inheritdoc />
|
|
public override string Description => "Retrieve recent public trades for a symbol";
|
|
|
|
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
|
{
|
|
RequestParameterRule<GetRecentTradesRequest>.Required(x => x.Symbol, "The symbol to retrieve recent trades for", new SharedSymbol(TradingMode.Spot, "ETH", "USDT")),
|
|
RequestParameterRule<GetRecentTradesRequest>.Optional(x => x.Limit, "Limit the result set to a maximum number of items", 100),
|
|
};
|
|
|
|
/// <summary>
|
|
/// The max number of trades that can be requested
|
|
/// </summary>
|
|
public int MaxLimit { get; set; }
|
|
|
|
/// <summary>
|
|
/// ctor
|
|
/// </summary>
|
|
public GetRecentTradesOptions(string exchange, int limit, bool authenticated)
|
|
: base(exchange, authenticated, nameof(IGetRecentTrades.GetRecentTradesAsync), _defaultParameterRules)
|
|
{
|
|
MaxLimit = limit;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override Error? ValidateRequest(GetRecentTradesRequest request, IGetRecentTrades client)
|
|
{
|
|
var baseError = base.ValidateRequest(request, client);
|
|
if (baseError != null)
|
|
return baseError;
|
|
|
|
if (request.Limit > MaxLimit)
|
|
return ArgumentError.Invalid(nameof(GetRecentTradesRequest.Limit), $"Only the most recent {MaxLimit} trades are available");
|
|
|
|
return null;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override string ToString()
|
|
{
|
|
var sb = new StringBuilder(base.ToString());
|
|
sb.AppendLine($" Max data points: {MaxLimit}");
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
}
|