1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-10-16 16:10:53 +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.Text;
namespace CryptoExchange.Net.SharedApis
{
/// <summary>
/// Options for requesting recent trades
/// </summary>
public class GetRecentTradesOptions : CapabilityOptions<GetRecentTradesRequest, IGetRecentTradesRest>
{
/// <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(IGetRecentTradesRest.GetRecentTradesAsync))
{
MaxLimit = limit;
}
/// <inheritdoc />
public override Error? ValidateRequest(GetRecentTradesRequest request, IGetRecentTradesRest 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();
}
}
}
@@ -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 the most recent trades for a symbol on an exchange.
/// </summary>
public interface IGetRecentTrades : ISharedApiCapability
{
/// <summary>
/// Recent trades 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>
GetRecentTradesOptions GetRecentTradesOptions { get; }
/// <summary>
/// Get the most recent public trades, see <see cref="GetRecentTradesOptions"/> for request options and exchange specific required/optional parameters. <br />
/// </summary>
/// <param name="request">Request info</param>
/// <param name="ct">Cancellation token</param>
/// <returns></returns>
Task<ICallResult<SharedTrade[]>> GetRecentTradesAsync(GetRecentTradesRequest request, CancellationToken ct = default);
}
/// <summary>
/// Operation for retrieving the most recent trades for a symbol on an exchange via the REST API.
/// </summary>
public interface IGetRecentTradesRest : IGetRecentTrades, ISharedRest
{
/// <inheritdoc />
new Task<HttpResult<SharedTrade[]>> GetRecentTradesAsync(GetRecentTradesRequest request, CancellationToken ct = default);
}
}