mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-08-12 17:03:10 +00:00
50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using CryptoExchange.Net.Objects;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace CryptoExchange.Net.SharedApis
|
|
{
|
|
/// <summary>
|
|
/// Options for placing a new spot order
|
|
/// </summary>
|
|
public class PlaceSpotOrderOptions : EndpointOptions<PlaceSpotOrderRequest>
|
|
{
|
|
|
|
/// <summary>
|
|
/// ctor
|
|
/// </summary>
|
|
public PlaceSpotOrderOptions() : base(true)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Validate a request
|
|
/// </summary>
|
|
public Error? ValidateRequest(
|
|
string exchange,
|
|
PlaceSpotOrderRequest request,
|
|
TradingMode? tradingMode,
|
|
TradingMode[] supportedApiTypes,
|
|
SharedOrderType[] supportedOrderTypes,
|
|
SharedTimeInForce[] supportedTimeInForce,
|
|
SharedQuantitySupport quantitySupport)
|
|
{
|
|
if (request.OrderType == SharedOrderType.Other)
|
|
throw new ArgumentException("OrderType can't be `Other`", nameof(request.OrderType));
|
|
|
|
if (!supportedOrderTypes.Contains(request.OrderType))
|
|
return ArgumentError.Invalid(nameof(PlaceSpotOrderRequest.OrderType), "Order type not supported");
|
|
|
|
if (request.TimeInForce != null && !supportedTimeInForce.Contains(request.TimeInForce.Value))
|
|
return ArgumentError.Invalid(nameof(PlaceSpotOrderRequest.TimeInForce), "Order time in force not supported");
|
|
|
|
var quantityError = quantitySupport.Validate(request.Side, request.OrderType, request.Quantity);
|
|
if (quantityError != null)
|
|
return quantityError;
|
|
|
|
return base.ValidateRequest(exchange, request, tradingMode, supportedApiTypes);
|
|
}
|
|
}
|
|
}
|