diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesOrderByClientOrderIdOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesOrderByClientOrderIdOptions.cs index 8f5448f6..a82a5888 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesOrderByClientOrderIdOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesOrderByClientOrderIdOptions.cs @@ -5,6 +5,9 @@ namespace CryptoExchange.Net.SharedApis /// public class CancelFuturesOrderByClientOrderIdOptions : EndpointOptions { + /// + public override string Description => "Cancel a futures order by its client order id"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesOrderOptions.cs index 3d27bca8..31a06e2e 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesOrderOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class CancelFuturesOrderOptions : EndpointOptions { + /// + public override string Description => "Cancel a futures order"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesTpSlOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesTpSlOptions.cs index 50d93daa..1319e970 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesTpSlOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesTpSlOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class CancelFuturesTpSlOptions : EndpointOptions { + /// + public override string Description => "Cancel a take profit or stop loss order for a futures position"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesTriggerOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesTriggerOrderOptions.cs index d62079b8..b364e5eb 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesTriggerOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelFuturesTriggerOrderOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class CancelFuturesTriggerOrderOptions : EndpointOptions { + /// + public override string Description => "Cancel a futures trigger order"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelSpotOrderByClientOrderIdOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelSpotOrderByClientOrderIdOptions.cs index d0b18aca..619dc4c1 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelSpotOrderByClientOrderIdOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelSpotOrderByClientOrderIdOptions.cs @@ -1,4 +1,5 @@ -using System; +using CryptoExchange.Net.Objects; +using System; using System.Collections.Generic; using System.Text; @@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis /// public class CancelSpotOrderByClientOrderIdOptions : EndpointOptions { + /// + public override string Description => "Cancel a spot order by its client order id"; + /// /// ctor /// public CancelSpotOrderByClientOrderIdOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderClientIdRestClient.CancelSpotOrderByClientOrderIdAsync)) { } + + /// + 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); + } } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelSpotOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelSpotOrderOptions.cs index 757271d7..b27747e6 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelSpotOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelSpotOrderOptions.cs @@ -1,4 +1,5 @@ -using System; +using CryptoExchange.Net.Objects; +using System; using System.Collections.Generic; using System.Text; @@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis /// public class CancelSpotOrderOptions : EndpointOptions { + /// + public override string Description => "Cancel a spot order"; + /// /// ctor /// public CancelSpotOrderOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderRestClient.CancelSpotOrderAsync)) { } + + /// + 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); + } } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelSpotTriggerOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelSpotTriggerOrderOptions.cs index ae940bea..3b994556 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelSpotTriggerOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/CancelSpotTriggerOrderOptions.cs @@ -1,4 +1,5 @@ -using System; +using CryptoExchange.Net.Objects; +using System; using System.Collections.Generic; using System.Text; @@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis /// public class CancelSpotTriggerOrderOptions : EndpointOptions { + /// + public override string Description => "Cancel a spot trigger order"; + /// /// ctor /// public CancelSpotTriggerOrderOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotTriggerOrderRestClient.CancelSpotTriggerOrderAsync)) { } + + /// + 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); + } } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/ClosePositionOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/ClosePositionOptions.cs index 491f41a2..1ccb7739 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/ClosePositionOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/ClosePositionOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class ClosePositionOptions : EndpointOptions { + /// + public override string Description => "Close an open futures position"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/EndpointOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/EndpointOptions.cs index 3fdb2007..5bb9ef65 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/EndpointOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/EndpointOptions.cs @@ -41,6 +41,10 @@ namespace CryptoExchange.Net.SharedApis /// Whether the call is supported. If false the exchange API does not support this operation. /// public bool Supported { get; set; } = true; + /// + /// Description of the endpoint + /// + public abstract string Description { get; } /// /// ctor @@ -87,7 +91,7 @@ namespace CryptoExchange.Net.SharedApis /// /// Type of data #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 #else public abstract class EndpointOptions : EndpointOptions @@ -181,32 +185,40 @@ namespace CryptoExchange.Net.SharedApis /// public override string ToString() { - if (!Supported) - return $"{Exchange} {EndpointName} NOT SUPPORTED"; - var sb = new StringBuilder(); - sb.AppendLine($"{Exchange} {EndpointName}"); - sb.AppendLine($"Needs authentication: {NeedsAuthentication}"); - if (!string.IsNullOrEmpty(RequestNotes)) + sb.AppendLine($"{EndpointName}"); + if (!Supported) + { + sb.AppendLine(" NOT SUPPORTED"); + return sb.ToString(); + } + + sb.AppendLine($"{Description}"); + if (!string.IsNullOrEmpty(RequestNotes)) + { + sb.Append(" Notes: "); sb.AppendLine(RequestNotes); + } if (RequiredOptionalParameters.Any()) { - sb.AppendLine($"Required optional parameters:"); + sb.AppendLine($" Required optional parameters:"); foreach(var param in RequiredOptionalParameters) sb.AppendLine($" {param}"); } if (RequiredExchangeParameters.Any()) { - sb.AppendLine($"Required exchange specific parameters:"); + sb.AppendLine($" Required exchange specific parameters:"); foreach (var param in RequiredExchangeParameters) sb.AppendLine($" {param}"); } if (OptionalExchangeParameters.Any()) { - sb.AppendLine($"Optional exchange specific parameters:"); + sb.AppendLine($" Optional exchange specific parameters:"); foreach (var param in OptionalExchangeParameters) sb.AppendLine($" {param}"); } + sb.Append(" Needs authentication: "); + sb.AppendLine($"{NeedsAuthentication}"); return sb.ToString(); } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetAssetOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetAssetOptions.cs index 1c274ede..47f411f6 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetAssetOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetAssetOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetAssetOptions : EndpointOptions { + /// + public override string Description => "Retrieve basic info for a single asset and networks it supports for withdrawals/deposits"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetAssetsOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetAssetsOptions.cs index 003a7829..c14123c5 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetAssetsOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetAssetsOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetAssetsOptions : EndpointOptions { + /// + public override string Description => "Retrieve basic info for all assets and the networks they support for withdrawals/deposits"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetBalancesOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetBalancesOptions.cs index 0e7c2e92..1d53b379 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetBalancesOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetBalancesOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System.Linq; namespace CryptoExchange.Net.SharedApis @@ -8,6 +8,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetBalancesOptions : EndpointOptions { + /// + public override string Description => "Retrieve account balances"; + /// /// Supported account types /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetBookTickerOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetBookTickerOptions.cs index 221fb7c6..6bec8d04 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetBookTickerOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetBookTickerOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetBookTickerOptions : EndpointOptions { + /// + public override string Description => "Retrieve the best bid and ask price for a symbol"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetDepositAddressesOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetDepositAddressesOptions.cs index 12e2ed9a..d86393c9 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetDepositAddressesOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetDepositAddressesOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetDepositAddressesOptions : EndpointOptions { + /// + public override string Description => "Retrieve deposit addresses for an asset"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetDepositsOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetDepositsOptions.cs index 3cde027e..11d5f20f 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetDepositsOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetDepositsOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetDepositsOptions : PaginatedEndpointOptions { + /// + public override string Description => "Retrieve deposit history"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFeeOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFeeOptions.cs index 4f4d1310..b312b1db 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFeeOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFeeOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetFeeOptions : EndpointOptions { + /// + public override string Description => "Retrieve trading fee information"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFundingRateHistoryOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFundingRateHistoryOptions.cs index f21c54e9..5e8f17f1 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFundingRateHistoryOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFundingRateHistoryOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetFundingRateHistoryOptions : PaginatedEndpointOptions { + /// + public override string Description => "Retrieve historical funding rates for a futures symbol"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesClosedOrdersOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesClosedOrdersOptions.cs index bcba3c84..cd51b2d8 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesClosedOrdersOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesClosedOrdersOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetFuturesClosedOrdersOptions : PaginatedEndpointOptions { + /// + public override string Description => "Retrieve closed futures orders"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesOrderByClientOrderIdOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesOrderByClientOrderIdOptions.cs index f44c0859..b60930ff 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesOrderByClientOrderIdOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesOrderByClientOrderIdOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetFuturesOrderByClientOrderIdOptions : EndpointOptions { + /// + public override string Description => "Retrieve a futures order by its client order id"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesOrderOptions.cs index b1a95fc0..c86e310e 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesOrderOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetFuturesOrderOptions : EndpointOptions { + /// + public override string Description => "Retrieve a futures order"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesOrderTradesOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesOrderTradesOptions.cs index 34b888e8..4d46e302 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesOrderTradesOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesOrderTradesOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetFuturesOrderTradesOptions : EndpointOptions { + /// + public override string Description => "Retrieve trades for a futures order"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesSymbolsOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesSymbolsOptions.cs index ab2b92a3..137bd68c 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesSymbolsOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesSymbolsOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Collections.Generic; using System.Text; @@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetFuturesSymbolsOptions : EndpointOptions { + /// + public override string Description => "Retrieve supported futures symbols and their trading rules"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesTickerOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesTickerOptions.cs index 6a1719d1..4d25a887 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesTickerOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesTickerOptions.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; namespace CryptoExchange.Net.SharedApis { @@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetFuturesTickerOptions : EndpointOptions { + /// + public override string Description => "Retrieve price ticker information for a futures symbol"; + /// /// Type of ticker calculation /// @@ -24,7 +27,7 @@ namespace CryptoExchange.Net.SharedApis public override string ToString() { var sb = new StringBuilder(base.ToString()); - sb.AppendLine($"Ticker data calculation type: {TickerType}"); + sb.AppendLine($" Ticker data calculation type: {TickerType}"); return sb.ToString(); } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesTickersOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesTickersOptions.cs index 40b27e8d..196ee6c6 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesTickersOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesTickersOptions.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; namespace CryptoExchange.Net.SharedApis { @@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetFuturesTickersOptions : EndpointOptions { + /// + public override string Description => "Retrieve price ticker information for all futures symbols"; + /// /// Type of ticker calculation /// @@ -24,7 +27,7 @@ namespace CryptoExchange.Net.SharedApis public override string ToString() { var sb = new StringBuilder(base.ToString()); - sb.AppendLine($"Ticker data calculation type: {TickerType}"); + sb.AppendLine($" Ticker data calculation type: {TickerType}"); return sb.ToString(); } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesTriggerOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesTriggerOrderOptions.cs index 50bf6fa1..a6cd84bd 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesTriggerOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesTriggerOrderOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetFuturesTriggerOrderOptions : EndpointOptions { + /// + public override string Description => "Retrieve a futures trigger order"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesUserTradesOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesUserTradesOptions.cs index cbaf2687..fdc0d93a 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesUserTradesOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetFuturesUserTradesOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetFuturesUserTradesOptions : PaginatedEndpointOptions { + /// + public override string Description => "Retrieve futures user trade history"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetIndexPriceKlinesOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetIndexPriceKlinesOptions.cs index cd63497d..f7df897b 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetIndexPriceKlinesOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetIndexPriceKlinesOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; using System.Text; @@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetIndexPriceKlinesOptions : PaginatedEndpointOptions { + /// + public override string Description => "Retrieve index price candlestick data"; + /// /// The supported kline intervals /// @@ -108,9 +111,9 @@ namespace CryptoExchange.Net.SharedApis public override string 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) - sb.AppendLine($"Max total data points available: {MaxTotalDataPoints}"); + sb.AppendLine($" Max total data points available: {MaxTotalDataPoints}"); return sb.ToString(); } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetKlinesOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetKlinesOptions.cs index fc6f621f..0f17350f 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetKlinesOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetKlinesOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; using System.Text; @@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetKlinesOptions : PaginatedEndpointOptions { + /// + public override string Description => "Retrieve candlestick data for a symbol"; + /// /// The supported kline intervals /// @@ -108,9 +111,9 @@ namespace CryptoExchange.Net.SharedApis public override string 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) - sb.AppendLine($"Max total data points available: {MaxTotalDataPoints}"); + sb.AppendLine($" Max total data points available: {MaxTotalDataPoints}"); return sb.ToString(); } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetLeverageOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetLeverageOptions.cs index f8669438..9cb92072 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetLeverageOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetLeverageOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetLeverageOptions : EndpointOptions { + /// + public override string Description => "Retrieve the current leverage for a futures symbol"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetMarkPriceKlinesOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetMarkPriceKlinesOptions.cs index 1be01efa..148ebc95 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetMarkPriceKlinesOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetMarkPriceKlinesOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; using System.Text; @@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetMarkPriceKlinesOptions : PaginatedEndpointOptions { + /// + public override string Description => "Retrieve mark price candlestick data"; + /// /// The supported kline intervals /// @@ -108,9 +111,9 @@ namespace CryptoExchange.Net.SharedApis public override string 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) - sb.AppendLine($"Max total data points available: {MaxTotalDataPoints}"); + sb.AppendLine($" Max total data points available: {MaxTotalDataPoints}"); return sb.ToString(); } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOpenFuturesOrdersOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOpenFuturesOrdersOptions.cs index 30d09787..fe138b3c 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOpenFuturesOrdersOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOpenFuturesOrdersOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetOpenFuturesOrdersOptions : EndpointOptions { + /// + public override string Description => "Retrieve open futures orders"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOpenInterestOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOpenInterestOptions.cs index 688e0d39..8d83a884 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOpenInterestOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOpenInterestOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetOpenInterestOptions : EndpointOptions { + /// + public override string Description => "Retrieve open interest for a futures symbol"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOpenSpotOrdersOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOpenSpotOrdersOptions.cs index f3fda948..ec026cd8 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOpenSpotOrdersOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOpenSpotOrdersOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetOpenSpotOrdersOptions : EndpointOptions { + /// + public override string Description => "Retrieve open spot orders"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOrderBookOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOrderBookOptions.cs index 4fe0af10..b720a445 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOrderBookOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetOrderBookOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; using System.Text; @@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetOrderBookOptions : EndpointOptions { + /// + public override string Description => "Retrieve the current order book for a symbol"; + /// /// Supported order book depths /// @@ -65,7 +68,7 @@ namespace CryptoExchange.Net.SharedApis public override string ToString() { var sb = new StringBuilder(base.ToString()); - sb.AppendLine($"Supported limit values: [{(SupportedLimits != null ? string.Join(", ", SupportedLimits) : $"{MinLimit}..{MaxLimit}")}]"); + sb.AppendLine($" Supported limit values: [{(SupportedLimits != null ? string.Join(", ", SupportedLimits) : $"{MinLimit}..{MaxLimit}")}]"); return sb.ToString(); } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetPositionHistoryOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetPositionHistoryOptions.cs index 88b2902a..e362b8ee 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetPositionHistoryOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetPositionHistoryOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetPositionHistoryOptions : PaginatedEndpointOptions { + /// + public override string Description => "Retrieve historical futures positions"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetPositionModeOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetPositionModeOptions.cs index 25238991..ae5ae3a8 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetPositionModeOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetPositionModeOptions.cs @@ -1,10 +1,13 @@ -namespace CryptoExchange.Net.SharedApis +namespace CryptoExchange.Net.SharedApis { /// /// Options for requesting current position mode /// public class GetPositionModeOptions : EndpointOptions { + /// + public override string Description => "Retrieve the current futures position mode"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetPositionsOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetPositionsOptions.cs index 6ede6874..3a6a31c7 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetPositionsOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetPositionsOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetPositionsOptions : EndpointOptions { + /// + public override string Description => "Retrieve open futures positions"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetRecentTradesOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetRecentTradesOptions.cs index 91ca1e17..620ba54c 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetRecentTradesOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetRecentTradesOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System.Text; namespace CryptoExchange.Net.SharedApis @@ -8,6 +8,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetRecentTradesOptions : EndpointOptions { + /// + public override string Description => "Retrieve recent public trades for a symbol"; + /// /// The max number of trades that can be requested /// @@ -39,7 +42,7 @@ namespace CryptoExchange.Net.SharedApis public override string ToString() { var sb = new StringBuilder(base.ToString()); - sb.AppendLine($"Max data points: {MaxLimit}"); + sb.AppendLine($" Max data points: {MaxLimit}"); return sb.ToString(); } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotClosedOrdersOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotClosedOrdersOptions.cs index 61d0f6c9..4ab33960 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotClosedOrdersOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotClosedOrdersOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetSpotClosedOrdersOptions : PaginatedEndpointOptions { + /// + public override string Description => "Retrieve closed spot orders"; + /// /// ctor /// @@ -20,6 +23,9 @@ namespace CryptoExchange.Net.SharedApis /// 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) return ArgumentError.Invalid(nameof(GetClosedOrdersRequest.Direction), $"Ascending direction is not supported"); diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotOrderByClientOrderIdOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotOrderByClientOrderIdOptions.cs index a7e21162..771026c5 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotOrderByClientOrderIdOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotOrderByClientOrderIdOptions.cs @@ -1,4 +1,5 @@ -using System; +using CryptoExchange.Net.Objects; +using System; using System.Collections.Generic; using System.Text; @@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis /// public class GetSpotOrderByClientOrderIdOptions : EndpointOptions { + /// + public override string Description => "Retrieve a spot order by its client order id"; + /// /// ctor /// public GetSpotOrderByClientOrderIdOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderClientIdRestClient.GetSpotOrderByClientOrderIdAsync)) { } + + /// + 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); + } } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotOrderOptions.cs index 27f6e466..0c6b0038 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotOrderOptions.cs @@ -1,4 +1,5 @@ -using System; +using CryptoExchange.Net.Objects; +using System; using System.Collections.Generic; using System.Text; @@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis /// public class GetSpotOrderOptions : EndpointOptions { + /// + public override string Description => "Retrieve a spot order"; + /// /// ctor /// public GetSpotOrderOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderRestClient.GetSpotOrderAsync)) { } + + /// + 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); + } } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotOrderTradesOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotOrderTradesOptions.cs index 95dabb33..20cd6a56 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotOrderTradesOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotOrderTradesOptions.cs @@ -1,4 +1,5 @@ -using System; +using CryptoExchange.Net.Objects; +using System; using System.Collections.Generic; using System.Text; @@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis /// public class GetSpotOrderTradesOptions : EndpointOptions { + /// + public override string Description => "Retrieve trades for a spot order"; + /// /// ctor /// public GetSpotOrderTradesOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotOrderRestClient.GetSpotOrderTradesAsync)) { } + + /// + 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); + } } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotSymbolsOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotSymbolsOptions.cs index db7f463b..bf3bf192 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotSymbolsOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotSymbolsOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Collections.Generic; using System.Text; @@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetSpotSymbolsOptions : EndpointOptions { + /// + public override string Description => "Retrieve supported spot symbols and their trading rules"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotTickerOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotTickerOptions.cs index 25f6bf02..cf0554d2 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotTickerOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotTickerOptions.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; namespace CryptoExchange.Net.SharedApis { @@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetSpotTickerOptions : EndpointOptions { + /// + public override string Description => "Retrieve price ticker information for a spot symbol"; + /// /// Type of ticker calculation /// @@ -24,7 +27,7 @@ namespace CryptoExchange.Net.SharedApis public override string ToString() { var sb = new StringBuilder(base.ToString()); - sb.AppendLine($"Ticker data calculation type: {TickerType}"); + sb.AppendLine($" Ticker data calculation type: {TickerType}"); return sb.ToString(); } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotTickersOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotTickersOptions.cs index e6734a9e..2f291696 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotTickersOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotTickersOptions.cs @@ -1,4 +1,4 @@ -using System.Text; +using System.Text; namespace CryptoExchange.Net.SharedApis { @@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetSpotTickersOptions : EndpointOptions { + /// + public override string Description => "Retrieve price ticker information for all spot symbols"; + /// /// Type of ticker calculation /// @@ -24,7 +27,7 @@ namespace CryptoExchange.Net.SharedApis public override string ToString() { var sb = new StringBuilder(base.ToString()); - sb.AppendLine($"Ticker data calculation type: {TickerType}"); + sb.AppendLine($" Ticker data calculation type: {TickerType}"); return sb.ToString(); } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotTriggerOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotTriggerOrderOptions.cs index fcfabcb7..1feb724a 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotTriggerOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotTriggerOrderOptions.cs @@ -1,4 +1,5 @@ -using System; +using CryptoExchange.Net.Objects; +using System; using System.Collections.Generic; using System.Text; @@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis /// public class GetSpotTriggerOrderOptions : EndpointOptions { + /// + public override string Description => "Retrieve a spot trigger order"; + /// /// ctor /// public GetSpotTriggerOrderOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(ISpotTriggerOrderRestClient.GetSpotTriggerOrderAsync)) { } + + /// + 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); + } } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotUserTradesOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotUserTradesOptions.cs index a89d956e..7f06a727 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotUserTradesOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetSpotUserTradesOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetSpotUserTradesOptions : PaginatedEndpointOptions { + /// + public override string Description => "Retrieve spot user trade history"; + /// /// ctor /// @@ -20,6 +23,9 @@ namespace CryptoExchange.Net.SharedApis /// 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) return ArgumentError.Invalid(nameof(GetUserTradesRequest.Direction), $"Ascending direction is not supported"); diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetTradeHistoryOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetTradeHistoryOptions.cs index e64d4cb0..c534c834 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetTradeHistoryOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetTradeHistoryOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetTradeHistoryOptions : PaginatedEndpointOptions { + /// + public override string Description => "Retrieve public trade history for a symbol"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetWithdrawalsOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetWithdrawalsOptions.cs index 85841df7..26693c6f 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetWithdrawalsOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/GetWithdrawalsOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class GetWithdrawalsOptions : PaginatedEndpointOptions { + /// + public override string Description => "Retrieve withdrawal history"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PaginatedEndpointOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PaginatedEndpointOptions.cs index 1927c915..02d955e4 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PaginatedEndpointOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PaginatedEndpointOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics.CodeAnalysis; using System.Text; @@ -8,7 +8,7 @@ namespace CryptoExchange.Net.SharedApis /// Options for paginated endpoints /// #if NET5_0_OR_GREATER - public class PaginatedEndpointOptions<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TRequest, TClient> : EndpointOptions + public abstract class PaginatedEndpointOptions<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] TRequest, TClient> : EndpointOptions where TRequest : SharedRequest where TClient : ISharedClient #else @@ -63,12 +63,12 @@ namespace CryptoExchange.Net.SharedApis public override string ToString() { var sb = new StringBuilder(base.ToString()); - sb.AppendLine($"Ascending retrieval supported: {SupportsAscending}"); - sb.AppendLine($"Descending retrieval supported: {SupportsDescending}"); - sb.AppendLine($"Time period filter supported: {TimePeriodFilterSupport}"); - sb.AppendLine($"Max limit: {MaxLimit}"); + sb.AppendLine($" Ascending retrieval supported: {SupportsAscending}"); + sb.AppendLine($" Descending retrieval supported: {SupportsDescending}"); + sb.AppendLine($" Time period filter supported: {TimePeriodFilterSupport}"); + sb.AppendLine($" Max limit: {MaxLimit}"); if (MaxAge.HasValue) - sb.AppendLine($"Max age: {MaxAge}"); + sb.AppendLine($" Max age: {MaxAge}"); return sb.ToString(); } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceFuturesOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceFuturesOrderOptions.cs index 6cc9c15f..75451572 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceFuturesOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceFuturesOrderOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class PlaceFuturesOrderOptions : EndpointOptions { + /// + public override string Description => "Place a new futures order"; + /// /// Whether or not the API supports setting take profit / stop loss with the order /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceFuturesTriggerOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceFuturesTriggerOrderOptions.cs index 47032789..6f5f8bc2 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceFuturesTriggerOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceFuturesTriggerOrderOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; namespace CryptoExchange.Net.SharedApis { @@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis /// public class PlaceFuturesTriggerOrderOptions : EndpointOptions { + /// + public override string Description => "Place a new futures trigger order"; + /// /// 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. /// @@ -19,19 +22,5 @@ namespace CryptoExchange.Net.SharedApis { HoldsFunds = holdsFunds; } - - /// - /// Validate a request - /// - 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); - } } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceSpotOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceSpotOrderOptions.cs index 8a3ebbbb..e12ce6ea 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceSpotOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceSpotOrderOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class PlaceSpotOrderOptions : EndpointOptions { + /// + public override string Description => "Place a new spot order"; + /// /// ctor @@ -24,6 +27,9 @@ namespace CryptoExchange.Net.SharedApis PlaceSpotOrderRequest request, 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) throw new ArgumentException("OrderType can't be `Other`", nameof(request.OrderType)); diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceSpotTriggerOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceSpotTriggerOrderOptions.cs index bd4c78be..abd48192 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceSpotTriggerOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/PlaceSpotTriggerOrderOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; namespace CryptoExchange.Net.SharedApis { @@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis /// public class PlaceSpotTriggerOrderOptions : EndpointOptions { + /// + public override string Description => "Place a new spot trigger order"; + /// /// 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. /// @@ -27,6 +30,9 @@ namespace CryptoExchange.Net.SharedApis PlaceSpotTriggerOrderRequest request, 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); if (quantityError != null) return quantityError; diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/SetFuturesTpSlOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/SetFuturesTpSlOptions.cs index 6253609f..c6e0eda2 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/SetFuturesTpSlOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/SetFuturesTpSlOptions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class SetFuturesTpSlOptions : EndpointOptions { + /// + public override string Description => "Set take profit or stop loss values for a futures position"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/SetLeverageOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/SetLeverageOptions.cs index de3664d4..dd9d6bc8 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/SetLeverageOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/SetLeverageOptions.cs @@ -1,10 +1,13 @@ -namespace CryptoExchange.Net.SharedApis +namespace CryptoExchange.Net.SharedApis { /// /// Options for setting leverage /// public class SetLeverageOptions : EndpointOptions { + /// + public override string Description => "Set the leverage for a futures symbol"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/SetPositionModeOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/SetPositionModeOptions.cs index 99a7cf89..05a064a3 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/SetPositionModeOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/SetPositionModeOptions.cs @@ -1,10 +1,13 @@ -namespace CryptoExchange.Net.SharedApis +namespace CryptoExchange.Net.SharedApis { /// /// Options for setting position mode /// public class SetPositionModeOptions : EndpointOptions { + /// + public override string Description => "Set the futures position mode"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/TransferOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/TransferOptions.cs index 15021236..bd5f6b07 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/TransferOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/TransferOptions.cs @@ -1,5 +1,6 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System.Linq; +using System.Text; namespace CryptoExchange.Net.SharedApis { @@ -8,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class TransferOptions : EndpointOptions { + /// + public override string Description => "Transfer funds between account types"; + /// /// Supported account types /// @@ -36,5 +40,13 @@ namespace CryptoExchange.Net.SharedApis return base.ValidateRequest(request, client); } + + /// + public override string ToString() + { + var sb = new StringBuilder(base.ToString()); + sb.AppendLine($" Supported accounts: {string.Join(", ", SupportedAccountTypes)}"); + return sb.ToString(); + } } } diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/WithdrawOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/WithdrawOptions.cs index 17df177d..c8a3f403 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/WithdrawOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Endpoints/WithdrawOptions.cs @@ -1,10 +1,13 @@ -namespace CryptoExchange.Net.SharedApis +namespace CryptoExchange.Net.SharedApis { /// /// Options for requesting a withdrawal /// public class WithdrawOptions : EndpointOptions { + /// + public override string Description => "Withdraw an asset"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeBalanceOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeBalanceOptions.cs index a2a9af8b..44685e4b 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeBalanceOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeBalanceOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class SubscribeBalanceOptions : EndpointOptions { + /// + public override string Description => "Subscribe to balance updates"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeBookTickerOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeBookTickerOptions.cs index 0f1f6504..fab66bd8 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeBookTickerOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeBookTickerOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class SubscribeBookTickerOptions : EndpointOptions { + /// + public override string Description => "Subscribe to best bid and ask price updates"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeFuturesOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeFuturesOrderOptions.cs index 8ab785cc..309680a1 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeFuturesOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeFuturesOrderOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class SubscribeFuturesOrderOptions : EndpointOptions { + /// + public override string Description => "Subscribe to futures order updates"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeKlineOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeKlineOptions.cs index ff5bb90a..812b50d9 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeKlineOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeKlineOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class SubscribeKlineOptions : EndpointOptions { + /// + public override string Description => "Subscribe to candlestick updates for a symbol"; + /// /// Kline intervals supported for updates /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeOrderBookOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeOrderBookOptions.cs index 3b979187..af0c9dd0 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeOrderBookOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeOrderBookOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class SubscribeOrderBookOptions : EndpointOptions { + /// + public override string Description => "Subscribe to order book updates for a symbol"; + /// /// Order book depths supported for updates /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribePositionOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribePositionOptions.cs index 95dcf9fc..f313f4d5 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribePositionOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribePositionOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class SubscribePositionOptions : EndpointOptions { + /// + public override string Description => "Subscribe to futures position updates"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeSpotOrderOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeSpotOrderOptions.cs index 11de3855..14326a20 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeSpotOrderOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeSpotOrderOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class SubscribeSpotOrderOptions : EndpointOptions { + /// + public override string Description => "Subscribe to spot order updates"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickerOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickerOptions.cs index 2d0ce0e8..93246dbf 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickerOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickerOptions.cs @@ -1,10 +1,13 @@ -namespace CryptoExchange.Net.SharedApis +namespace CryptoExchange.Net.SharedApis { /// /// Options for subscribing to ticker updates /// public class SubscribeTickerOptions : EndpointOptions { + /// + public override string Description => "Subscribe to price ticker updates for a symbol"; + /// /// Type of ticker calculation /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickersOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickersOptions.cs index ef2bfd2a..1e8c6e5a 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickersOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTickersOptions.cs @@ -1,10 +1,13 @@ -namespace CryptoExchange.Net.SharedApis +namespace CryptoExchange.Net.SharedApis { /// /// Options for subscribing to ticker updates /// public class SubscribeTickersOptions : EndpointOptions { + /// + public override string Description => "Subscribe to price ticker updates for all symbols"; + /// /// Type of ticker calculation /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTradeOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTradeOptions.cs index 0d78a78f..82a8ea39 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTradeOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeTradeOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class SubscribeTradeOptions : EndpointOptions { + /// + public override string Description => "Subscribe to public trade updates for a symbol"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeUserTradeOptions.cs b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeUserTradeOptions.cs index b8c433f2..2a3505bc 100644 --- a/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeUserTradeOptions.cs +++ b/CryptoExchange.Net/SharedApis/Models/Options/Subscriptions/SubscribeUserTradeOptions.cs @@ -1,4 +1,4 @@ -using CryptoExchange.Net.Objects; +using CryptoExchange.Net.Objects; using System; using System.Linq; @@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis /// public class SubscribeUserTradeOptions : EndpointOptions { + /// + public override string Description => "Subscribe to user trade updates"; + /// /// ctor /// diff --git a/CryptoExchange.Net/SharedApis/SharedClientInfo.cs b/CryptoExchange.Net/SharedApis/SharedClientInfo.cs index b5ad4047..a172f345 100644 --- a/CryptoExchange.Net/SharedApis/SharedClientInfo.cs +++ b/CryptoExchange.Net/SharedApis/SharedClientInfo.cs @@ -40,8 +40,13 @@ namespace CryptoExchange.Net.SharedApis /// /// Create a string representation for this client /// - /// public override string ToString() + => ToString(false); + + /// + /// Create a string representation for this client + /// + public string ToString(bool detailed) { var sb = new StringBuilder(); sb.AppendLine($"Exchange: {Exchange}"); @@ -50,9 +55,19 @@ namespace CryptoExchange.Net.SharedApis sb.AppendLine($"Supported trading modes: {string.Join(", ", SupportedTradingModes)}"); sb.AppendLine($"Centralization type: {CentralizationType}"); sb.AppendLine($"Features:"); - foreach (var feature in Features.Where(x => x.Supported)) + foreach (var feature in Features) { - sb.AppendLine($" {feature.EndpointName}"); + 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(); } return sb.ToString(); diff --git a/CryptoExchange.Net/Trackers/UserData/ItemTrackers/PositionTracker.cs b/CryptoExchange.Net/Trackers/UserData/ItemTrackers/PositionTracker.cs index e4dbb7c7..626b59f3 100644 --- a/CryptoExchange.Net/Trackers/UserData/ItemTrackers/PositionTracker.cs +++ b/CryptoExchange.Net/Trackers/UserData/ItemTrackers/PositionTracker.cs @@ -72,9 +72,9 @@ namespace CryptoExchange.Net.Trackers.UserData.ItemTrackers changed = true; } - if (existingItem.PositionSize != updateItem.PositionSize) + if (existingItem.PositionSizes != updateItem.PositionSizes) { - existingItem.PositionSize = updateItem.PositionSize; + existingItem.PositionSizes = updateItem.PositionSizes; changed = true; } @@ -132,7 +132,7 @@ namespace CryptoExchange.Net.Trackers.UserData.ItemTrackers if (toRemove != null) @event = @event.Except(toRemove).ToArray(); - _symbolTracker.UpdateTrackedSymbols(@event.Where(x => x.PositionSize > 0).OfType().Select(x => x.SharedSymbol!)); + _symbolTracker.UpdateTrackedSymbols(@event.Where(x => !x.PositionSizes.IsZero).OfType().Select(x => x.SharedSymbol!)); // Update local store @@ -141,13 +141,13 @@ namespace CryptoExchange.Net.Trackers.UserData.ItemTrackers 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 - 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) { position.Value.UpdateTime = DateTime.UtcNow; position.Value.AverageOpenPrice = null; position.Value.LiquidationPrice = null; - position.Value.PositionSize = 0; + position.Value.PositionSizes = new(); position.Value.StopLossPrice = null; position.Value.TakeProfitPrice = null; position.Value.UnrealizedPnl = null;