mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-04 02:11:11 +00:00
50 lines
1.6 KiB
C#
50 lines
1.6 KiB
C#
using CryptoExchange.Net.Objects;
|
|
using System.Text;
|
|
|
|
namespace CryptoExchange.Net.SharedApis
|
|
{
|
|
/// <summary>
|
|
/// Options for requesting recent trades
|
|
/// </summary>
|
|
public class GetRecentTradesOptions : EndpointOptions<GetRecentTradesRequest, IRecentTradeRestClient>
|
|
{
|
|
/// <inheritdoc />
|
|
public override string Description => "Retrieve recent public trades for a symbol";
|
|
|
|
/// <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(IRecentTradeRestClient.GetRecentTradesAsync))
|
|
{
|
|
MaxLimit = limit;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override Error? ValidateRequest(GetRecentTradesRequest request, IRecentTradeRestClient 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();
|
|
}
|
|
}
|
|
}
|