mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-15 23:50:54 +00:00
44 lines
1.6 KiB
C#
44 lines
1.6 KiB
C#
using CryptoExchange.Net.Objects;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace CryptoExchange.Net.SharedApis
|
|
{
|
|
/// <summary>
|
|
/// Options for canceling a spot order
|
|
/// </summary>
|
|
public class CancelSpotOrderOptions : CapabilityOptions<CancelOrderRequest, ICancelSpotOrder>
|
|
{
|
|
/// <inheritdoc />
|
|
public override string Description => "Cancel a spot order";
|
|
|
|
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
|
{
|
|
RequestParameterRule<CancelOrderRequest>.Required(x => x.Symbol, "The symbol of the order to cancel", new SharedSymbol(TradingMode.Spot, "ETH", "USDT")),
|
|
RequestParameterRule<CancelOrderRequest>.Required(x => x.OrderId, "The order id of the order to cancel", "123")
|
|
};
|
|
|
|
/// <summary>
|
|
/// ctor
|
|
/// </summary>
|
|
public CancelSpotOrderOptions(string exchange, bool authenticated)
|
|
: base(exchange, authenticated, nameof(ICancelSpotOrder.CancelSpotOrderAsync), _defaultParameterRules, SharedTradingModeSets.Spot)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override Error? ValidateRequest(CancelOrderRequest request, ICancelSpotOrder client)
|
|
{
|
|
var error = base.ValidateRequest(request, client);
|
|
if (error != null)
|
|
return error;
|
|
|
|
if (request.Symbol!.TradingMode != TradingMode.Spot)
|
|
return ArgumentError.Invalid("TradingMode", $"TradingMode.{request.Symbol!.TradingMode} is not supported, should be Spot");
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|