1
0
mirror of https://github.com/JKorf/CryptoExchange.Net.git synced 2026-10-04 10:21:13 +00:00

Added Description property to EndpointOptions classes. Updated client info string representation, added additional validation for Spot endpoints

This commit is contained in:
Jkorf
2026-08-21 09:55:53 +02:00
parent 4987e6be70
commit ac1e9cf2ab
72 changed files with 426 additions and 118 deletions
@@ -5,6 +5,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class CancelFuturesOrderByClientOrderIdOptions : EndpointOptions<CancelOrderRequest, IFuturesOrderClientIdRestClient> public class CancelFuturesOrderByClientOrderIdOptions : EndpointOptions<CancelOrderRequest, IFuturesOrderClientIdRestClient>
{ {
/// <inheritdoc />
public override string Description => "Cancel a futures order by its client order id";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class CancelFuturesOrderOptions : EndpointOptions<CancelOrderRequest, IFuturesOrderRestClient> public class CancelFuturesOrderOptions : EndpointOptions<CancelOrderRequest, IFuturesOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Cancel a futures order";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class CancelFuturesTpSlOptions : EndpointOptions<CancelTpSlRequest, IFuturesTpSlRestClient> public class CancelFuturesTpSlOptions : EndpointOptions<CancelTpSlRequest, IFuturesTpSlRestClient>
{ {
/// <inheritdoc />
public override string Description => "Cancel a take profit or stop loss order for a futures position";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class CancelFuturesTriggerOrderOptions : EndpointOptions<CancelOrderRequest, IFuturesTriggerOrderRestClient> public class CancelFuturesTriggerOrderOptions : EndpointOptions<CancelOrderRequest, IFuturesTriggerOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Cancel a futures trigger order";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,5 @@
using System; using CryptoExchange.Net.Objects;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class CancelSpotOrderByClientOrderIdOptions : EndpointOptions<CancelOrderRequest, ISpotOrderClientIdRestClient> public class CancelSpotOrderByClientOrderIdOptions : EndpointOptions<CancelOrderRequest, ISpotOrderClientIdRestClient>
{ {
/// <inheritdoc />
public override string Description => "Cancel a spot order by its client order id";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public CancelSpotOrderByClientOrderIdOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderClientIdRestClient.CancelSpotOrderByClientOrderIdAsync)) public CancelSpotOrderByClientOrderIdOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderClientIdRestClient.CancelSpotOrderByClientOrderIdAsync))
{ {
} }
/// <inheritdoc />
public override Error? ValidateRequest(CancelOrderRequest request, ISpotOrderClientIdRestClient client)
{
if (request.Symbol!.TradingMode != TradingMode.Spot)
return ArgumentError.Invalid("TradingMode", $"TradingMode.{request.Symbol!.TradingMode} is not supported, should be Spot");
return base.ValidateRequest(request, client);
}
} }
} }
@@ -1,4 +1,5 @@
using System; using CryptoExchange.Net.Objects;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class CancelSpotOrderOptions : EndpointOptions<CancelOrderRequest, ISpotOrderRestClient> public class CancelSpotOrderOptions : EndpointOptions<CancelOrderRequest, ISpotOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Cancel a spot order";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public CancelSpotOrderOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderRestClient.CancelSpotOrderAsync)) public CancelSpotOrderOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderRestClient.CancelSpotOrderAsync))
{ {
} }
/// <inheritdoc />
public override Error? ValidateRequest(CancelOrderRequest request, ISpotOrderRestClient client)
{
if (request.Symbol!.TradingMode != TradingMode.Spot)
return ArgumentError.Invalid("TradingMode", $"TradingMode.{request.Symbol!.TradingMode} is not supported, should be Spot");
return base.ValidateRequest(request, client);
}
} }
} }
@@ -1,4 +1,5 @@
using System; using CryptoExchange.Net.Objects;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class CancelSpotTriggerOrderOptions : EndpointOptions<CancelOrderRequest, ISpotTriggerOrderRestClient> public class CancelSpotTriggerOrderOptions : EndpointOptions<CancelOrderRequest, ISpotTriggerOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Cancel a spot trigger order";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public CancelSpotTriggerOrderOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotTriggerOrderRestClient.CancelSpotTriggerOrderAsync)) public CancelSpotTriggerOrderOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotTriggerOrderRestClient.CancelSpotTriggerOrderAsync))
{ {
} }
/// <inheritdoc />
public override Error? ValidateRequest(CancelOrderRequest request, ISpotTriggerOrderRestClient client)
{
if (request.Symbol!.TradingMode != TradingMode.Spot)
return ArgumentError.Invalid("TradingMode", $"TradingMode.{request.Symbol!.TradingMode} is not supported, should be Spot");
return base.ValidateRequest(request, client);
}
} }
} }
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class ClosePositionOptions : EndpointOptions<ClosePositionRequest, IFuturesOrderRestClient> public class ClosePositionOptions : EndpointOptions<ClosePositionRequest, IFuturesOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Close an open futures position";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -41,6 +41,10 @@ namespace CryptoExchange.Net.SharedApis
/// Whether the call is supported. If false the exchange API does not support this operation. /// Whether the call is supported. If false the exchange API does not support this operation.
/// </summary> /// </summary>
public bool Supported { get; set; } = true; public bool Supported { get; set; } = true;
/// <summary>
/// Description of the endpoint
/// </summary>
public abstract string Description { get; }
/// <summary> /// <summary>
/// ctor /// ctor
@@ -87,7 +91,7 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
/// <typeparam name="TRequest">Type of data</typeparam> /// <typeparam name="TRequest">Type of data</typeparam>
#if NET5_0_OR_GREATER #if NET5_0_OR_GREATER
public class EndpointOptions<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TRequest> : EndpointOptions public abstract class EndpointOptions<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TRequest> : EndpointOptions
where TRequest : SharedRequest where TRequest : SharedRequest
#else #else
public abstract class EndpointOptions<TRequest> : EndpointOptions public abstract class EndpointOptions<TRequest> : EndpointOptions
@@ -181,14 +185,20 @@ namespace CryptoExchange.Net.SharedApis
/// <inheritdoc /> /// <inheritdoc />
public override string ToString() public override string ToString()
{ {
if (!Supported)
return $"{Exchange} {EndpointName} NOT SUPPORTED";
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.AppendLine($"{Exchange} {EndpointName}"); sb.AppendLine($"{EndpointName}");
sb.AppendLine($"Needs authentication: {NeedsAuthentication}"); if (!Supported)
{
sb.AppendLine(" NOT SUPPORTED");
return sb.ToString();
}
sb.AppendLine($"{Description}");
if (!string.IsNullOrEmpty(RequestNotes)) if (!string.IsNullOrEmpty(RequestNotes))
{
sb.Append(" Notes: ");
sb.AppendLine(RequestNotes); sb.AppendLine(RequestNotes);
}
if (RequiredOptionalParameters.Any()) if (RequiredOptionalParameters.Any())
{ {
sb.AppendLine($" Required optional parameters:"); sb.AppendLine($" Required optional parameters:");
@@ -207,6 +217,8 @@ namespace CryptoExchange.Net.SharedApis
foreach (var param in OptionalExchangeParameters) foreach (var param in OptionalExchangeParameters)
sb.AppendLine($" {param}"); sb.AppendLine($" {param}");
} }
sb.Append(" Needs authentication: ");
sb.AppendLine($"{NeedsAuthentication}");
return sb.ToString(); return sb.ToString();
} }
} }
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetAssetOptions : EndpointOptions<GetAssetRequest, IAssetsRestClient> public class GetAssetOptions : EndpointOptions<GetAssetRequest, IAssetsRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve basic info for a single asset and networks it supports for withdrawals/deposits";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetAssetsOptions : EndpointOptions<GetAssetsRequest, IAssetsRestClient> public class GetAssetsOptions : EndpointOptions<GetAssetsRequest, IAssetsRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve basic info for all assets and the networks they support for withdrawals/deposits";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System.Linq; using System.Linq;
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
@@ -8,6 +8,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetBalancesOptions : EndpointOptions<GetBalancesRequest, IBalanceRestClient> public class GetBalancesOptions : EndpointOptions<GetBalancesRequest, IBalanceRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve account balances";
/// <summary> /// <summary>
/// Supported account types /// Supported account types
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetBookTickerOptions : EndpointOptions<GetBookTickerRequest, IBookTickerRestClient> public class GetBookTickerOptions : EndpointOptions<GetBookTickerRequest, IBookTickerRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve the best bid and ask price for a symbol";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetDepositAddressesOptions : EndpointOptions<GetDepositAddressesRequest, IDepositRestClient> public class GetDepositAddressesOptions : EndpointOptions<GetDepositAddressesRequest, IDepositRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve deposit addresses for an asset";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetDepositsOptions : PaginatedEndpointOptions<GetDepositsRequest, IDepositRestClient> public class GetDepositsOptions : PaginatedEndpointOptions<GetDepositsRequest, IDepositRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve deposit history";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetFeeOptions : EndpointOptions<GetFeeRequest, IFeeRestClient> public class GetFeeOptions : EndpointOptions<GetFeeRequest, IFeeRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve trading fee information";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetFundingRateHistoryOptions : PaginatedEndpointOptions<GetFundingRateHistoryRequest, IFundingRateRestClient> public class GetFundingRateHistoryOptions : PaginatedEndpointOptions<GetFundingRateHistoryRequest, IFundingRateRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve historical funding rates for a futures symbol";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetFuturesClosedOrdersOptions : PaginatedEndpointOptions<GetClosedOrdersRequest, IFuturesOrderRestClient> public class GetFuturesClosedOrdersOptions : PaginatedEndpointOptions<GetClosedOrdersRequest, IFuturesOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve closed futures orders";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetFuturesOrderByClientOrderIdOptions : EndpointOptions<GetOrderRequest, IFuturesOrderClientIdRestClient> public class GetFuturesOrderByClientOrderIdOptions : EndpointOptions<GetOrderRequest, IFuturesOrderClientIdRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve a futures order by its client order id";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetFuturesOrderOptions : EndpointOptions<GetOrderRequest, IFuturesOrderRestClient> public class GetFuturesOrderOptions : EndpointOptions<GetOrderRequest, IFuturesOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve a futures order";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetFuturesOrderTradesOptions : EndpointOptions<GetOrderTradesRequest, IFuturesOrderRestClient> public class GetFuturesOrderTradesOptions : EndpointOptions<GetOrderTradesRequest, IFuturesOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve trades for a futures order";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetFuturesSymbolsOptions : EndpointOptions<GetSymbolsRequest, IFuturesSymbolRestClient> public class GetFuturesSymbolsOptions : EndpointOptions<GetSymbolsRequest, IFuturesSymbolRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve supported futures symbols and their trading rules";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System.Text; using System.Text;
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
@@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetFuturesTickerOptions : EndpointOptions<GetTickerRequest, IFuturesTickerRestClient> public class GetFuturesTickerOptions : EndpointOptions<GetTickerRequest, IFuturesTickerRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve price ticker information for a futures symbol";
/// <summary> /// <summary>
/// Type of ticker calculation /// Type of ticker calculation
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System.Text; using System.Text;
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
@@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetFuturesTickersOptions : EndpointOptions<GetTickersRequest, IFuturesTickerRestClient> public class GetFuturesTickersOptions : EndpointOptions<GetTickersRequest, IFuturesTickerRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve price ticker information for all futures symbols";
/// <summary> /// <summary>
/// Type of ticker calculation /// Type of ticker calculation
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetFuturesTriggerOrderOptions : EndpointOptions<GetOrderRequest, IFuturesTriggerOrderRestClient> public class GetFuturesTriggerOrderOptions : EndpointOptions<GetOrderRequest, IFuturesTriggerOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve a futures trigger order";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetFuturesUserTradesOptions : PaginatedEndpointOptions<GetUserTradesRequest, IFuturesOrderRestClient> public class GetFuturesUserTradesOptions : PaginatedEndpointOptions<GetUserTradesRequest, IFuturesOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve futures user trade history";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetIndexPriceKlinesOptions : PaginatedEndpointOptions<GetKlinesRequest, IIndexPriceKlineRestClient> public class GetIndexPriceKlinesOptions : PaginatedEndpointOptions<GetKlinesRequest, IIndexPriceKlineRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve index price candlestick data";
/// <summary> /// <summary>
/// The supported kline intervals /// The supported kline intervals
/// </summary> /// </summary>
@@ -108,7 +111,7 @@ namespace CryptoExchange.Net.SharedApis
public override string ToString() public override string ToString()
{ {
var sb = new StringBuilder(base.ToString()); var sb = new StringBuilder(base.ToString());
sb.AppendLine($"Supported SharedKlineInterval values: {string.Join(", ", SupportIntervals)}"); sb.AppendLine($" Supported intervals: {string.Join(", ", SupportIntervals)}");
if (MaxTotalDataPoints != null) if (MaxTotalDataPoints != null)
sb.AppendLine($" Max total data points available: {MaxTotalDataPoints}"); sb.AppendLine($" Max total data points available: {MaxTotalDataPoints}");
return sb.ToString(); return sb.ToString();
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetKlinesOptions : PaginatedEndpointOptions<GetKlinesRequest, IKlineRestClient> public class GetKlinesOptions : PaginatedEndpointOptions<GetKlinesRequest, IKlineRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve candlestick data for a symbol";
/// <summary> /// <summary>
/// The supported kline intervals /// The supported kline intervals
/// </summary> /// </summary>
@@ -108,7 +111,7 @@ namespace CryptoExchange.Net.SharedApis
public override string ToString() public override string ToString()
{ {
var sb = new StringBuilder(base.ToString()); var sb = new StringBuilder(base.ToString());
sb.AppendLine($"Supported SharedKlineInterval values: {string.Join(", ", SupportIntervals)}"); sb.AppendLine($" Supported intervals: {string.Join(", ", SupportIntervals)}");
if (MaxTotalDataPoints != null) if (MaxTotalDataPoints != null)
sb.AppendLine($" Max total data points available: {MaxTotalDataPoints}"); sb.AppendLine($" Max total data points available: {MaxTotalDataPoints}");
return sb.ToString(); return sb.ToString();
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetLeverageOptions : EndpointOptions<GetLeverageRequest, ILeverageRestClient> public class GetLeverageOptions : EndpointOptions<GetLeverageRequest, ILeverageRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve the current leverage for a futures symbol";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetMarkPriceKlinesOptions : PaginatedEndpointOptions<GetKlinesRequest, IMarkPriceKlineRestClient> public class GetMarkPriceKlinesOptions : PaginatedEndpointOptions<GetKlinesRequest, IMarkPriceKlineRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve mark price candlestick data";
/// <summary> /// <summary>
/// The supported kline intervals /// The supported kline intervals
/// </summary> /// </summary>
@@ -108,7 +111,7 @@ namespace CryptoExchange.Net.SharedApis
public override string ToString() public override string ToString()
{ {
var sb = new StringBuilder(base.ToString()); var sb = new StringBuilder(base.ToString());
sb.AppendLine($"Supported SharedKlineInterval values: {string.Join(", ", SupportIntervals)}"); sb.AppendLine($" Supported intervals: {string.Join(", ", SupportIntervals)}");
if (MaxTotalDataPoints != null) if (MaxTotalDataPoints != null)
sb.AppendLine($" Max total data points available: {MaxTotalDataPoints}"); sb.AppendLine($" Max total data points available: {MaxTotalDataPoints}");
return sb.ToString(); return sb.ToString();
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetOpenFuturesOrdersOptions : EndpointOptions<GetOpenOrdersRequest, IFuturesOrderRestClient> public class GetOpenFuturesOrdersOptions : EndpointOptions<GetOpenOrdersRequest, IFuturesOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve open futures orders";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetOpenInterestOptions : EndpointOptions<GetOpenInterestRequest, IOpenInterestRestClient> public class GetOpenInterestOptions : EndpointOptions<GetOpenInterestRequest, IOpenInterestRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve open interest for a futures symbol";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetOpenSpotOrdersOptions : EndpointOptions<GetOpenOrdersRequest, ISpotOrderRestClient> public class GetOpenSpotOrdersOptions : EndpointOptions<GetOpenOrdersRequest, ISpotOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve open spot orders";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetOrderBookOptions : EndpointOptions<GetOrderBookRequest, IOrderBookRestClient> public class GetOrderBookOptions : EndpointOptions<GetOrderBookRequest, IOrderBookRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve the current order book for a symbol";
/// <summary> /// <summary>
/// Supported order book depths /// Supported order book depths
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetPositionHistoryOptions : PaginatedEndpointOptions<GetPositionHistoryRequest, IPositionHistoryRestClient> public class GetPositionHistoryOptions : PaginatedEndpointOptions<GetPositionHistoryRequest, IPositionHistoryRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve historical futures positions";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,10 +1,13 @@
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
/// <summary> /// <summary>
/// Options for requesting current position mode /// Options for requesting current position mode
/// </summary> /// </summary>
public class GetPositionModeOptions : EndpointOptions<GetPositionModeRequest, IPositionModeRestClient> public class GetPositionModeOptions : EndpointOptions<GetPositionModeRequest, IPositionModeRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve the current futures position mode";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetPositionsOptions : EndpointOptions<GetPositionsRequest, IFuturesOrderRestClient> public class GetPositionsOptions : EndpointOptions<GetPositionsRequest, IFuturesOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve open futures positions";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System.Text; using System.Text;
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
@@ -8,6 +8,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetRecentTradesOptions : EndpointOptions<GetRecentTradesRequest, IRecentTradeRestClient> public class GetRecentTradesOptions : EndpointOptions<GetRecentTradesRequest, IRecentTradeRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve recent public trades for a symbol";
/// <summary> /// <summary>
/// The max number of trades that can be requested /// The max number of trades that can be requested
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetSpotClosedOrdersOptions : PaginatedEndpointOptions<GetClosedOrdersRequest, ISpotOrderRestClient> public class GetSpotClosedOrdersOptions : PaginatedEndpointOptions<GetClosedOrdersRequest, ISpotOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve closed spot orders";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -20,6 +23,9 @@ namespace CryptoExchange.Net.SharedApis
/// <inheritdoc /> /// <inheritdoc />
public override Error? ValidateRequest(GetClosedOrdersRequest request, ISpotOrderRestClient client) public override Error? ValidateRequest(GetClosedOrdersRequest request, ISpotOrderRestClient client)
{ {
if (request.Symbol!.TradingMode != TradingMode.Spot)
return ArgumentError.Invalid("TradingMode", $"TradingMode.{request.Symbol!.TradingMode} is not supported, should be Spot");
if (!SupportsAscending && request.Direction == DataDirection.Ascending) if (!SupportsAscending && request.Direction == DataDirection.Ascending)
return ArgumentError.Invalid(nameof(GetClosedOrdersRequest.Direction), $"Ascending direction is not supported"); return ArgumentError.Invalid(nameof(GetClosedOrdersRequest.Direction), $"Ascending direction is not supported");
@@ -1,4 +1,5 @@
using System; using CryptoExchange.Net.Objects;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetSpotOrderByClientOrderIdOptions : EndpointOptions<GetOrderRequest, ISpotOrderClientIdRestClient> public class GetSpotOrderByClientOrderIdOptions : EndpointOptions<GetOrderRequest, ISpotOrderClientIdRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve a spot order by its client order id";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public GetSpotOrderByClientOrderIdOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderClientIdRestClient.GetSpotOrderByClientOrderIdAsync)) public GetSpotOrderByClientOrderIdOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderClientIdRestClient.GetSpotOrderByClientOrderIdAsync))
{ {
} }
/// <inheritdoc />
public override Error? ValidateRequest(GetOrderRequest request, ISpotOrderClientIdRestClient client)
{
if (request.Symbol!.TradingMode != TradingMode.Spot)
return ArgumentError.Invalid("TradingMode", $"TradingMode.{request.Symbol!.TradingMode} is not supported, should be Spot");
return base.ValidateRequest(request, client);
}
} }
} }
@@ -1,4 +1,5 @@
using System; using CryptoExchange.Net.Objects;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetSpotOrderOptions : EndpointOptions<GetOrderRequest, ISpotOrderRestClient> public class GetSpotOrderOptions : EndpointOptions<GetOrderRequest, ISpotOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve a spot order";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public GetSpotOrderOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderRestClient.GetSpotOrderAsync)) public GetSpotOrderOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderRestClient.GetSpotOrderAsync))
{ {
} }
/// <inheritdoc />
public override Error? ValidateRequest(GetOrderRequest request, ISpotOrderRestClient client)
{
if (request.Symbol!.TradingMode != TradingMode.Spot)
return ArgumentError.Invalid("TradingMode", $"TradingMode.{request.Symbol!.TradingMode} is not supported, should be Spot");
return base.ValidateRequest(request, client);
}
} }
} }
@@ -1,4 +1,5 @@
using System; using CryptoExchange.Net.Objects;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetSpotOrderTradesOptions : EndpointOptions<GetOrderTradesRequest, ISpotOrderRestClient> public class GetSpotOrderTradesOptions : EndpointOptions<GetOrderTradesRequest, ISpotOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve trades for a spot order";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public GetSpotOrderTradesOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderRestClient.GetSpotOrderTradesAsync)) public GetSpotOrderTradesOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderRestClient.GetSpotOrderTradesAsync))
{ {
} }
/// <inheritdoc />
public override Error? ValidateRequest(GetOrderTradesRequest request, ISpotOrderRestClient client)
{
if (request.Symbol!.TradingMode != TradingMode.Spot)
return ArgumentError.Invalid("TradingMode", $"TradingMode.{request.Symbol!.TradingMode} is not supported, should be Spot");
return base.ValidateRequest(request, client);
}
} }
} }
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetSpotSymbolsOptions : EndpointOptions<GetSymbolsRequest, ISpotSymbolRestClient> public class GetSpotSymbolsOptions : EndpointOptions<GetSymbolsRequest, ISpotSymbolRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve supported spot symbols and their trading rules";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System.Text; using System.Text;
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
@@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetSpotTickerOptions : EndpointOptions<GetTickerRequest, ISpotTickerRestClient> public class GetSpotTickerOptions : EndpointOptions<GetTickerRequest, ISpotTickerRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve price ticker information for a spot symbol";
/// <summary> /// <summary>
/// Type of ticker calculation /// Type of ticker calculation
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System.Text; using System.Text;
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
@@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetSpotTickersOptions : EndpointOptions<GetTickersRequest, ISpotTickerRestClient> public class GetSpotTickersOptions : EndpointOptions<GetTickersRequest, ISpotTickerRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve price ticker information for all spot symbols";
/// <summary> /// <summary>
/// Type of ticker calculation /// Type of ticker calculation
/// </summary> /// </summary>
@@ -1,4 +1,5 @@
using System; using CryptoExchange.Net.Objects;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetSpotTriggerOrderOptions : EndpointOptions<GetOrderRequest, ISpotTriggerOrderRestClient> public class GetSpotTriggerOrderOptions : EndpointOptions<GetOrderRequest, ISpotTriggerOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve a spot trigger order";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
public GetSpotTriggerOrderOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotTriggerOrderRestClient.GetSpotTriggerOrderAsync)) public GetSpotTriggerOrderOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotTriggerOrderRestClient.GetSpotTriggerOrderAsync))
{ {
} }
/// <inheritdoc />
public override Error? ValidateRequest(GetOrderRequest request, ISpotTriggerOrderRestClient client)
{
if (request.Symbol!.TradingMode != TradingMode.Spot)
return ArgumentError.Invalid("TradingMode", $"TradingMode.{request.Symbol!.TradingMode} is not supported, should be Spot");
return base.ValidateRequest(request, client);
}
} }
} }
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetSpotUserTradesOptions : PaginatedEndpointOptions<GetUserTradesRequest, ISpotOrderRestClient> public class GetSpotUserTradesOptions : PaginatedEndpointOptions<GetUserTradesRequest, ISpotOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve spot user trade history";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -20,6 +23,9 @@ namespace CryptoExchange.Net.SharedApis
/// <inheritdoc /> /// <inheritdoc />
public override Error? ValidateRequest(GetUserTradesRequest request, ISpotOrderRestClient client) public override Error? ValidateRequest(GetUserTradesRequest request, ISpotOrderRestClient client)
{ {
if (request.Symbol!.TradingMode != TradingMode.Spot)
return ArgumentError.Invalid("TradingMode", $"TradingMode.{request.Symbol!.TradingMode} is not supported, should be Spot");
if (!SupportsAscending && request.Direction == DataDirection.Ascending) if (!SupportsAscending && request.Direction == DataDirection.Ascending)
return ArgumentError.Invalid(nameof(GetUserTradesRequest.Direction), $"Ascending direction is not supported"); return ArgumentError.Invalid(nameof(GetUserTradesRequest.Direction), $"Ascending direction is not supported");
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetTradeHistoryOptions : PaginatedEndpointOptions<GetTradeHistoryRequest, ITradeHistoryRestClient> public class GetTradeHistoryOptions : PaginatedEndpointOptions<GetTradeHistoryRequest, ITradeHistoryRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve public trade history for a symbol";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class GetWithdrawalsOptions : PaginatedEndpointOptions<GetWithdrawalsRequest, IWithdrawalRestClient> public class GetWithdrawalsOptions : PaginatedEndpointOptions<GetWithdrawalsRequest, IWithdrawalRestClient>
{ {
/// <inheritdoc />
public override string Description => "Retrieve withdrawal history";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using System; using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Text; using System.Text;
@@ -8,7 +8,7 @@ namespace CryptoExchange.Net.SharedApis
/// Options for paginated endpoints /// Options for paginated endpoints
/// </summary> /// </summary>
#if NET5_0_OR_GREATER #if NET5_0_OR_GREATER
public class PaginatedEndpointOptions<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TRequest, TClient> : EndpointOptions<TRequest, TClient> public abstract class PaginatedEndpointOptions<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TRequest, TClient> : EndpointOptions<TRequest, TClient>
where TRequest : SharedRequest where TRequest : SharedRequest
where TClient : ISharedClient where TClient : ISharedClient
#else #else
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class PlaceFuturesOrderOptions : EndpointOptions<PlaceFuturesOrderRequest, IFuturesOrderRestClient> public class PlaceFuturesOrderOptions : EndpointOptions<PlaceFuturesOrderRequest, IFuturesOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Place a new futures order";
/// <summary> /// <summary>
/// Whether or not the API supports setting take profit / stop loss with the order /// Whether or not the API supports setting take profit / stop loss with the order
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
@@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class PlaceFuturesTriggerOrderOptions : EndpointOptions<PlaceFuturesTriggerOrderRequest, IFuturesTriggerOrderRestClient> public class PlaceFuturesTriggerOrderOptions : EndpointOptions<PlaceFuturesTriggerOrderRequest, IFuturesTriggerOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Place a new futures trigger order";
/// <summary> /// <summary>
/// When true the API holds the funds until the order is triggered or canceled. When false the funds will only be required when the order is triggered and will fail if the funds are not available at that time. /// When true the API holds the funds until the order is triggered or canceled. When false the funds will only be required when the order is triggered and will fail if the funds are not available at that time.
/// </summary> /// </summary>
@@ -19,19 +22,5 @@ namespace CryptoExchange.Net.SharedApis
{ {
HoldsFunds = holdsFunds; HoldsFunds = holdsFunds;
} }
/// <summary>
/// Validate a request
/// </summary>
public override Error? ValidateRequest(
PlaceFuturesTriggerOrderRequest request,
IFuturesTriggerOrderRestClient client)
{
//var quantityError = client.FuturesSupportedOrderQuantity.Validate(request.OrderDirection, request.OrderPrice == null ? SharedOrderType.Market : SharedOrderType.Limit, request.Quantity);
//if (quantityError != null)
// return quantityError;
return base.ValidateRequest(request, client);
}
} }
} }
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class PlaceSpotOrderOptions : EndpointOptions<PlaceSpotOrderRequest, ISpotOrderRestClient> public class PlaceSpotOrderOptions : EndpointOptions<PlaceSpotOrderRequest, ISpotOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Place a new spot order";
/// <summary> /// <summary>
/// ctor /// ctor
@@ -24,6 +27,9 @@ namespace CryptoExchange.Net.SharedApis
PlaceSpotOrderRequest request, PlaceSpotOrderRequest request,
ISpotOrderRestClient client) ISpotOrderRestClient client)
{ {
if (request.Symbol!.TradingMode != TradingMode.Spot)
return ArgumentError.Invalid("TradingMode", $"TradingMode.{request.Symbol!.TradingMode} is not supported, should be Spot");
if (request.OrderType == SharedOrderType.Other) if (request.OrderType == SharedOrderType.Other)
throw new ArgumentException("OrderType can't be `Other`", nameof(request.OrderType)); throw new ArgumentException("OrderType can't be `Other`", nameof(request.OrderType));
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
@@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class PlaceSpotTriggerOrderOptions : EndpointOptions<PlaceSpotTriggerOrderRequest, ISpotOrderRestClient> public class PlaceSpotTriggerOrderOptions : EndpointOptions<PlaceSpotTriggerOrderRequest, ISpotOrderRestClient>
{ {
/// <inheritdoc />
public override string Description => "Place a new spot trigger order";
/// <summary> /// <summary>
/// When true the API holds the funds until the order is triggered or canceled. When false the funds will only be required when the order is triggered and will fail if the funds are not available at that time. /// When true the API holds the funds until the order is triggered or canceled. When false the funds will only be required when the order is triggered and will fail if the funds are not available at that time.
/// </summary> /// </summary>
@@ -27,6 +30,9 @@ namespace CryptoExchange.Net.SharedApis
PlaceSpotTriggerOrderRequest request, PlaceSpotTriggerOrderRequest request,
ISpotOrderRestClient client) ISpotOrderRestClient client)
{ {
if (request.Symbol!.TradingMode != TradingMode.Spot)
return ArgumentError.Invalid("TradingMode", $"TradingMode.{request.Symbol!.TradingMode} is not supported, should be Spot");
var quantityError = client.SpotSupportedOrderQuantity.Validate(request.OrderSide, request.OrderPrice == null ? SharedOrderType.Market : SharedOrderType.Limit, request.Quantity); var quantityError = client.SpotSupportedOrderQuantity.Validate(request.OrderSide, request.OrderPrice == null ? SharedOrderType.Market : SharedOrderType.Limit, request.Quantity);
if (quantityError != null) if (quantityError != null)
return quantityError; return quantityError;
@@ -1,4 +1,4 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class SetFuturesTpSlOptions : EndpointOptions<SetTpSlRequest, IFuturesTpSlRestClient> public class SetFuturesTpSlOptions : EndpointOptions<SetTpSlRequest, IFuturesTpSlRestClient>
{ {
/// <inheritdoc />
public override string Description => "Set take profit or stop loss values for a futures position";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,10 +1,13 @@
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
/// <summary> /// <summary>
/// Options for setting leverage /// Options for setting leverage
/// </summary> /// </summary>
public class SetLeverageOptions : EndpointOptions<SetLeverageRequest, ILeverageRestClient> public class SetLeverageOptions : EndpointOptions<SetLeverageRequest, ILeverageRestClient>
{ {
/// <inheritdoc />
public override string Description => "Set the leverage for a futures symbol";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,10 +1,13 @@
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
/// <summary> /// <summary>
/// Options for setting position mode /// Options for setting position mode
/// </summary> /// </summary>
public class SetPositionModeOptions : EndpointOptions<SetPositionModeRequest, IPositionModeRestClient> public class SetPositionModeOptions : EndpointOptions<SetPositionModeRequest, IPositionModeRestClient>
{ {
/// <inheritdoc />
public override string Description => "Set the futures position mode";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,5 +1,6 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System.Linq; using System.Linq;
using System.Text;
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
@@ -8,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class TransferOptions : EndpointOptions<TransferRequest, ITransferRestClient> public class TransferOptions : EndpointOptions<TransferRequest, ITransferRestClient>
{ {
/// <inheritdoc />
public override string Description => "Transfer funds between account types";
/// <summary> /// <summary>
/// Supported account types /// Supported account types
/// </summary> /// </summary>
@@ -36,5 +40,13 @@ namespace CryptoExchange.Net.SharedApis
return base.ValidateRequest(request, client); return base.ValidateRequest(request, client);
} }
/// <inheritdoc />
public override string ToString()
{
var sb = new StringBuilder(base.ToString());
sb.AppendLine($" Supported accounts: {string.Join(", ", SupportedAccountTypes)}");
return sb.ToString();
}
} }
} }
@@ -1,10 +1,13 @@
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
/// <summary> /// <summary>
/// Options for requesting a withdrawal /// Options for requesting a withdrawal
/// </summary> /// </summary>
public class WithdrawOptions : EndpointOptions<WithdrawRequest, IWithdrawRestClient> public class WithdrawOptions : EndpointOptions<WithdrawRequest, IWithdrawRestClient>
{ {
/// <inheritdoc />
public override string Description => "Withdraw an asset";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class SubscribeBalanceOptions : EndpointOptions<SubscribeBalancesRequest, IBalanceSocketClient> public class SubscribeBalanceOptions : EndpointOptions<SubscribeBalancesRequest, IBalanceSocketClient>
{ {
/// <inheritdoc />
public override string Description => "Subscribe to balance updates";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class SubscribeBookTickerOptions : EndpointOptions<SubscribeBookTickerRequest, IBookTickerSocketClient> public class SubscribeBookTickerOptions : EndpointOptions<SubscribeBookTickerRequest, IBookTickerSocketClient>
{ {
/// <inheritdoc />
public override string Description => "Subscribe to best bid and ask price updates";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class SubscribeFuturesOrderOptions : EndpointOptions<SubscribeFuturesOrderRequest, IFuturesOrderSocketClient> public class SubscribeFuturesOrderOptions : EndpointOptions<SubscribeFuturesOrderRequest, IFuturesOrderSocketClient>
{ {
/// <inheritdoc />
public override string Description => "Subscribe to futures order updates";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class SubscribeKlineOptions : EndpointOptions<SubscribeKlineRequest, IKlineSocketClient> public class SubscribeKlineOptions : EndpointOptions<SubscribeKlineRequest, IKlineSocketClient>
{ {
/// <inheritdoc />
public override string Description => "Subscribe to candlestick updates for a symbol";
/// <summary> /// <summary>
/// Kline intervals supported for updates /// Kline intervals supported for updates
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class SubscribeOrderBookOptions : EndpointOptions<SubscribeOrderBookRequest, IOrderBookSocketClient> public class SubscribeOrderBookOptions : EndpointOptions<SubscribeOrderBookRequest, IOrderBookSocketClient>
{ {
/// <inheritdoc />
public override string Description => "Subscribe to order book updates for a symbol";
/// <summary> /// <summary>
/// Order book depths supported for updates /// Order book depths supported for updates
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class SubscribePositionOptions : EndpointOptions<SubscribePositionRequest, IPositionSocketClient> public class SubscribePositionOptions : EndpointOptions<SubscribePositionRequest, IPositionSocketClient>
{ {
/// <inheritdoc />
public override string Description => "Subscribe to futures position updates";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class SubscribeSpotOrderOptions : EndpointOptions<SubscribeSpotOrderRequest, ISpotOrderSocketClient> public class SubscribeSpotOrderOptions : EndpointOptions<SubscribeSpotOrderRequest, ISpotOrderSocketClient>
{ {
/// <inheritdoc />
public override string Description => "Subscribe to spot order updates";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,10 +1,13 @@
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
/// <summary> /// <summary>
/// Options for subscribing to ticker updates /// Options for subscribing to ticker updates
/// </summary> /// </summary>
public class SubscribeTickerOptions : EndpointOptions<SubscribeTickerRequest, ITickerSocketClient> public class SubscribeTickerOptions : EndpointOptions<SubscribeTickerRequest, ITickerSocketClient>
{ {
/// <inheritdoc />
public override string Description => "Subscribe to price ticker updates for a symbol";
/// <summary> /// <summary>
/// Type of ticker calculation /// Type of ticker calculation
/// </summary> /// </summary>
@@ -1,10 +1,13 @@
namespace CryptoExchange.Net.SharedApis namespace CryptoExchange.Net.SharedApis
{ {
/// <summary> /// <summary>
/// Options for subscribing to ticker updates /// Options for subscribing to ticker updates
/// </summary> /// </summary>
public class SubscribeTickersOptions : EndpointOptions<SubscribeAllTickersRequest, ITickersSocketClient> public class SubscribeTickersOptions : EndpointOptions<SubscribeAllTickersRequest, ITickersSocketClient>
{ {
/// <inheritdoc />
public override string Description => "Subscribe to price ticker updates for all symbols";
/// <summary> /// <summary>
/// Type of ticker calculation /// Type of ticker calculation
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class SubscribeTradeOptions : EndpointOptions<SubscribeTradeRequest, ITradeSocketClient> public class SubscribeTradeOptions : EndpointOptions<SubscribeTradeRequest, ITradeSocketClient>
{ {
/// <inheritdoc />
public override string Description => "Subscribe to public trade updates for a symbol";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -1,4 +1,4 @@
using CryptoExchange.Net.Objects; using CryptoExchange.Net.Objects;
using System; using System;
using System.Linq; using System.Linq;
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
/// </summary> /// </summary>
public class SubscribeUserTradeOptions : EndpointOptions<SubscribeUserTradeRequest, IUserTradeSocketClient> public class SubscribeUserTradeOptions : EndpointOptions<SubscribeUserTradeRequest, IUserTradeSocketClient>
{ {
/// <inheritdoc />
public override string Description => "Subscribe to user trade updates";
/// <summary> /// <summary>
/// ctor /// ctor
/// </summary> /// </summary>
@@ -40,8 +40,13 @@ namespace CryptoExchange.Net.SharedApis
/// <summary> /// <summary>
/// Create a string representation for this client /// Create a string representation for this client
/// </summary> /// </summary>
/// <returns></returns>
public override string ToString() public override string ToString()
=> ToString(false);
/// <summary>
/// Create a string representation for this client
/// </summary>
public string ToString(bool detailed)
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
sb.AppendLine($"Exchange: {Exchange}"); sb.AppendLine($"Exchange: {Exchange}");
@@ -50,10 +55,20 @@ namespace CryptoExchange.Net.SharedApis
sb.AppendLine($"Supported trading modes: {string.Join(", ", SupportedTradingModes)}"); sb.AppendLine($"Supported trading modes: {string.Join(", ", SupportedTradingModes)}");
sb.AppendLine($"Centralization type: {CentralizationType}"); sb.AppendLine($"Centralization type: {CentralizationType}");
sb.AppendLine($"Features:"); sb.AppendLine($"Features:");
foreach (var feature in Features.Where(x => x.Supported)) foreach (var feature in Features)
{
if (detailed)
{
var stringRep = feature.ToString();
foreach(var line in stringRep!.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries))
sb.AppendLine($" {line}");
}
else
{ {
sb.AppendLine($" {feature.EndpointName}"); sb.AppendLine($" {feature.EndpointName}");
} }
sb.AppendLine();
}
return sb.ToString(); return sb.ToString();
} }
@@ -72,9 +72,9 @@ namespace CryptoExchange.Net.Trackers.UserData.ItemTrackers
changed = true; changed = true;
} }
if (existingItem.PositionSize != updateItem.PositionSize) if (existingItem.PositionSizes != updateItem.PositionSizes)
{ {
existingItem.PositionSize = updateItem.PositionSize; existingItem.PositionSizes = updateItem.PositionSizes;
changed = true; changed = true;
} }
@@ -132,7 +132,7 @@ namespace CryptoExchange.Net.Trackers.UserData.ItemTrackers
if (toRemove != null) if (toRemove != null)
@event = @event.Except(toRemove).ToArray(); @event = @event.Except(toRemove).ToArray();
_symbolTracker.UpdateTrackedSymbols(@event.Where(x => x.PositionSize > 0).OfType<SharedSymbolModel>().Select(x => x.SharedSymbol!)); _symbolTracker.UpdateTrackedSymbols(@event.Where(x => !x.PositionSizes.IsZero).OfType<SharedSymbolModel>().Select(x => x.SharedSymbol!));
// Update local store // Update local store
@@ -141,13 +141,13 @@ namespace CryptoExchange.Net.Trackers.UserData.ItemTrackers
if (WebsocketPositionUpdatesAreFullSnapshots) if (WebsocketPositionUpdatesAreFullSnapshots)
{ {
// Reset any tracking position to zero/null values when it's no longer in the snapshot as it means there is no open position any more // Reset any tracking position to zero/null values when it's no longer in the snapshot as it means there is no open position any more
var notInSnapshot = _store.Where(x => !updatedItems.Contains(x.Key) && x.Value.PositionSize != 0).ToList(); var notInSnapshot = _store.Where(x => !updatedItems.Contains(x.Key) && !x.Value.PositionSizes.IsZero).ToList();
foreach (var position in notInSnapshot) foreach (var position in notInSnapshot)
{ {
position.Value.UpdateTime = DateTime.UtcNow; position.Value.UpdateTime = DateTime.UtcNow;
position.Value.AverageOpenPrice = null; position.Value.AverageOpenPrice = null;
position.Value.LiquidationPrice = null; position.Value.LiquidationPrice = null;
position.Value.PositionSize = 0; position.Value.PositionSizes = new();
position.Value.StopLossPrice = null; position.Value.StopLossPrice = null;
position.Value.TakeProfitPrice = null; position.Value.TakeProfitPrice = null;
position.Value.UnrealizedPnl = null; position.Value.UnrealizedPnl = null;