mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-04 02:11:11 +00:00
Added Description property to EndpointOptions classes. Updated client info string representation, added additional validation for Spot endpoints
This commit is contained in:
+3
@@ -5,6 +5,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class CancelFuturesOrderByClientOrderIdOptions : EndpointOptions<CancelOrderRequest, IFuturesOrderClientIdRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Cancel a futures order by its client order id";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class CancelFuturesOrderOptions : EndpointOptions<CancelOrderRequest, IFuturesOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Cancel a futures order";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class CancelFuturesTpSlOptions : EndpointOptions<CancelTpSlRequest, IFuturesTpSlRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Cancel a take profit or stop loss order for a futures position";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class CancelFuturesTriggerOrderOptions : EndpointOptions<CancelOrderRequest, IFuturesTriggerOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Cancel a futures trigger order";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+14
-1
@@ -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
|
||||
/// </summary>
|
||||
public class CancelSpotOrderByClientOrderIdOptions : EndpointOptions<CancelOrderRequest, ISpotOrderClientIdRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Cancel a spot order by its client order id";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
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.Text;
|
||||
|
||||
@@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class CancelSpotOrderOptions : EndpointOptions<CancelOrderRequest, ISpotOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Cancel a spot order";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-1
@@ -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
|
||||
/// </summary>
|
||||
public class CancelSpotTriggerOrderOptions : EndpointOptions<CancelOrderRequest, ISpotTriggerOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Cancel a spot trigger order";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
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.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class ClosePositionOptions : EndpointOptions<ClosePositionRequest, IFuturesOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Close an open futures position";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -41,6 +41,10 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// Whether the call is supported. If false the exchange API does not support this operation.
|
||||
/// </summary>
|
||||
public bool Supported { get; set; } = true;
|
||||
/// <summary>
|
||||
/// Description of the endpoint
|
||||
/// </summary>
|
||||
public abstract string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
@@ -87,7 +91,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
/// <typeparam name="TRequest">Type of data</typeparam>
|
||||
#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<TRequest> : EndpointOptions
|
||||
@@ -181,32 +185,40 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
if (!Supported)
|
||||
return $"{Exchange} {EndpointName} NOT SUPPORTED";
|
||||
|
||||
var sb = new StringBuilder();
|
||||
sb.AppendLine($"{Exchange} {EndpointName}");
|
||||
sb.AppendLine($"Needs authentication: {NeedsAuthentication}");
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
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>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
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>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class GetBalancesOptions : EndpointOptions<GetBalancesRequest, IBalanceRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve account balances";
|
||||
|
||||
/// <summary>
|
||||
/// Supported account types
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetBookTickerOptions : EndpointOptions<GetBookTickerRequest, IBookTickerRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve the best bid and ask price for a symbol";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetDepositAddressesOptions : EndpointOptions<GetDepositAddressesRequest, IDepositRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve deposit addresses for an asset";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class GetDepositsOptions : PaginatedEndpointOptions<GetDepositsRequest, IDepositRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve deposit history";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetFeeOptions : EndpointOptions<GetFeeRequest, IFeeRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve trading fee information";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -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
|
||||
/// </summary>
|
||||
public class GetFundingRateHistoryOptions : PaginatedEndpointOptions<GetFundingRateHistoryRequest, IFundingRateRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve historical funding rates for a futures symbol";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -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
|
||||
/// </summary>
|
||||
public class GetFuturesClosedOrdersOptions : PaginatedEndpointOptions<GetClosedOrdersRequest, IFuturesOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve closed futures orders";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetFuturesOrderByClientOrderIdOptions : EndpointOptions<GetOrderRequest, IFuturesOrderClientIdRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve a futures order by its client order id";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetFuturesOrderOptions : EndpointOptions<GetOrderRequest, IFuturesOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve a futures order";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetFuturesOrderTradesOptions : EndpointOptions<GetOrderTradesRequest, IFuturesOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve trades for a futures order";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class GetFuturesSymbolsOptions : EndpointOptions<GetSymbolsRequest, IFuturesSymbolRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve supported futures symbols and their trading rules";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
@@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetFuturesTickerOptions : EndpointOptions<GetTickerRequest, IFuturesTickerRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve price ticker information for a futures symbol";
|
||||
|
||||
/// <summary>
|
||||
/// Type of ticker calculation
|
||||
/// </summary>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
@@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetFuturesTickersOptions : EndpointOptions<GetTickersRequest, IFuturesTickerRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve price ticker information for all futures symbols";
|
||||
|
||||
/// <summary>
|
||||
/// Type of ticker calculation
|
||||
/// </summary>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetFuturesTriggerOrderOptions : EndpointOptions<GetOrderRequest, IFuturesTriggerOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve a futures trigger order";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -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
|
||||
/// </summary>
|
||||
public class GetFuturesUserTradesOptions : PaginatedEndpointOptions<GetUserTradesRequest, IFuturesOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve futures user trade history";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+6
-3
@@ -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
|
||||
/// </summary>
|
||||
public class GetIndexPriceKlinesOptions : PaginatedEndpointOptions<GetKlinesRequest, IIndexPriceKlineRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve index price candlestick data";
|
||||
|
||||
/// <summary>
|
||||
/// The supported kline intervals
|
||||
/// </summary>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class GetKlinesOptions : PaginatedEndpointOptions<GetKlinesRequest, IKlineRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve candlestick data for a symbol";
|
||||
|
||||
/// <summary>
|
||||
/// The supported kline intervals
|
||||
/// </summary>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetLeverageOptions : EndpointOptions<GetLeverageRequest, ILeverageRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve the current leverage for a futures symbol";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class GetMarkPriceKlinesOptions : PaginatedEndpointOptions<GetKlinesRequest, IMarkPriceKlineRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve mark price candlestick data";
|
||||
|
||||
/// <summary>
|
||||
/// The supported kline intervals
|
||||
/// </summary>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetOpenFuturesOrdersOptions : EndpointOptions<GetOpenOrdersRequest, IFuturesOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve open futures orders";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetOpenInterestOptions : EndpointOptions<GetOpenInterestRequest, IOpenInterestRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve open interest for a futures symbol";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetOpenSpotOrdersOptions : EndpointOptions<GetOpenOrdersRequest, ISpotOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve open spot orders";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class GetOrderBookOptions : EndpointOptions<GetOrderBookRequest, IOrderBookRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve the current order book for a symbol";
|
||||
|
||||
/// <summary>
|
||||
/// Supported order book depths
|
||||
/// </summary>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class GetPositionHistoryOptions : PaginatedEndpointOptions<GetPositionHistoryRequest, IPositionHistoryRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve historical futures positions";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for requesting current position mode
|
||||
/// </summary>
|
||||
public class GetPositionModeOptions : EndpointOptions<GetPositionModeRequest, IPositionModeRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve the current futures position mode";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetPositionsOptions : EndpointOptions<GetPositionsRequest, IFuturesOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve open futures positions";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class GetRecentTradesOptions : EndpointOptions<GetRecentTradesRequest, IRecentTradeRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve recent public trades for a symbol";
|
||||
|
||||
/// <summary>
|
||||
/// The max number of trades that can be requested
|
||||
/// </summary>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -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
|
||||
/// </summary>
|
||||
public class GetSpotClosedOrdersOptions : PaginatedEndpointOptions<GetClosedOrdersRequest, ISpotOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve closed spot orders";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
@@ -20,6 +23,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
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");
|
||||
|
||||
|
||||
+14
-1
@@ -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
|
||||
/// </summary>
|
||||
public class GetSpotOrderByClientOrderIdOptions : EndpointOptions<GetOrderRequest, ISpotOrderClientIdRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve a spot order by its client order id";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
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.Text;
|
||||
|
||||
@@ -9,11 +10,23 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetSpotOrderOptions : EndpointOptions<GetOrderRequest, ISpotOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve a spot order";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-1
@@ -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
|
||||
/// </summary>
|
||||
public class GetSpotOrderTradesOptions : EndpointOptions<GetOrderTradesRequest, ISpotOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve trades for a spot order";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
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.Collections.Generic;
|
||||
using System.Text;
|
||||
@@ -10,6 +10,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetSpotSymbolsOptions : EndpointOptions<GetSymbolsRequest, ISpotSymbolRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve supported spot symbols and their trading rules";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
@@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetSpotTickerOptions : EndpointOptions<GetTickerRequest, ISpotTickerRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve price ticker information for a spot symbol";
|
||||
|
||||
/// <summary>
|
||||
/// Type of ticker calculation
|
||||
/// </summary>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Text;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
@@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetSpotTickersOptions : EndpointOptions<GetTickersRequest, ISpotTickerRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve price ticker information for all spot symbols";
|
||||
|
||||
/// <summary>
|
||||
/// Type of ticker calculation
|
||||
/// </summary>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
+14
-1
@@ -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
|
||||
/// </summary>
|
||||
public class GetSpotTriggerOrderOptions : EndpointOptions<GetOrderRequest, ISpotTriggerOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve a spot trigger order";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
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.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class GetSpotUserTradesOptions : PaginatedEndpointOptions<GetUserTradesRequest, ISpotOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve spot user trade history";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
@@ -20,6 +23,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
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");
|
||||
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class GetTradeHistoryOptions : PaginatedEndpointOptions<GetTradeHistoryRequest, ITradeHistoryRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve public trade history for a symbol";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class GetWithdrawalsOptions : PaginatedEndpointOptions<GetWithdrawalsRequest, IWithdrawalRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve withdrawal history";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
#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 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class PlaceFuturesOrderOptions : EndpointOptions<PlaceFuturesOrderRequest, IFuturesOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Place a new futures order";
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the API supports setting take profit / stop loss with the order
|
||||
/// </summary>
|
||||
|
||||
+4
-15
@@ -1,4 +1,4 @@
|
||||
using CryptoExchange.Net.Objects;
|
||||
using CryptoExchange.Net.Objects;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
@@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class PlaceFuturesTriggerOrderOptions : EndpointOptions<PlaceFuturesTriggerOrderRequest, IFuturesTriggerOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Place a new futures trigger order";
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
@@ -19,19 +22,5 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
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.Linq;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class PlaceSpotOrderOptions : EndpointOptions<PlaceSpotOrderRequest, ISpotOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Place a new spot order";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 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));
|
||||
|
||||
|
||||
+7
-1
@@ -1,4 +1,4 @@
|
||||
using CryptoExchange.Net.Objects;
|
||||
using CryptoExchange.Net.Objects;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
@@ -7,6 +7,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class PlaceSpotTriggerOrderOptions : EndpointOptions<PlaceSpotTriggerOrderRequest, ISpotOrderRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Place a new spot trigger order";
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
@@ -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;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public class SetFuturesTpSlOptions : EndpointOptions<SetTpSlRequest, IFuturesTpSlRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Set take profit or stop loss values for a futures position";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for setting leverage
|
||||
/// </summary>
|
||||
public class SetLeverageOptions : EndpointOptions<SetLeverageRequest, ILeverageRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Set the leverage for a futures symbol";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for setting position mode
|
||||
/// </summary>
|
||||
public class SetPositionModeOptions : EndpointOptions<SetPositionModeRequest, IPositionModeRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Set the futures position mode";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class TransferOptions : EndpointOptions<TransferRequest, ITransferRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Transfer funds between account types";
|
||||
|
||||
/// <summary>
|
||||
/// Supported account types
|
||||
/// </summary>
|
||||
@@ -36,5 +40,13 @@ namespace CryptoExchange.Net.SharedApis
|
||||
|
||||
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>
|
||||
/// Options for requesting a withdrawal
|
||||
/// </summary>
|
||||
public class WithdrawOptions : EndpointOptions<WithdrawRequest, IWithdrawRestClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Withdraw an asset";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -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
|
||||
/// </summary>
|
||||
public class SubscribeBalanceOptions : EndpointOptions<SubscribeBalancesRequest, IBalanceSocketClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to balance updates";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -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
|
||||
/// </summary>
|
||||
public class SubscribeBookTickerOptions : EndpointOptions<SubscribeBookTickerRequest, IBookTickerSocketClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to best bid and ask price updates";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -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
|
||||
/// </summary>
|
||||
public class SubscribeFuturesOrderOptions : EndpointOptions<SubscribeFuturesOrderRequest, IFuturesOrderSocketClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to futures order updates";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class SubscribeKlineOptions : EndpointOptions<SubscribeKlineRequest, IKlineSocketClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to candlestick updates for a symbol";
|
||||
|
||||
/// <summary>
|
||||
/// Kline intervals supported for updates
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -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
|
||||
/// </summary>
|
||||
public class SubscribeOrderBookOptions : EndpointOptions<SubscribeOrderBookRequest, IOrderBookSocketClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to order book updates for a symbol";
|
||||
|
||||
/// <summary>
|
||||
/// Order book depths supported for updates
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -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
|
||||
/// </summary>
|
||||
public class SubscribePositionOptions : EndpointOptions<SubscribePositionRequest, IPositionSocketClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to futures position updates";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -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
|
||||
/// </summary>
|
||||
public class SubscribeSpotOrderOptions : EndpointOptions<SubscribeSpotOrderRequest, ISpotOrderSocketClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to spot order updates";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -1,10 +1,13 @@
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for subscribing to ticker updates
|
||||
/// </summary>
|
||||
public class SubscribeTickerOptions : EndpointOptions<SubscribeTickerRequest, ITickerSocketClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to price ticker updates for a symbol";
|
||||
|
||||
/// <summary>
|
||||
/// Type of ticker calculation
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -1,10 +1,13 @@
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for subscribing to ticker updates
|
||||
/// </summary>
|
||||
public class SubscribeTickersOptions : EndpointOptions<SubscribeAllTickersRequest, ITickersSocketClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to price ticker updates for all symbols";
|
||||
|
||||
/// <summary>
|
||||
/// Type of ticker calculation
|
||||
/// </summary>
|
||||
|
||||
@@ -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
|
||||
/// </summary>
|
||||
public class SubscribeTradeOptions : EndpointOptions<SubscribeTradeRequest, ITradeSocketClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to public trade updates for a symbol";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
+4
-1
@@ -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
|
||||
/// </summary>
|
||||
public class SubscribeUserTradeOptions : EndpointOptions<SubscribeUserTradeRequest, IUserTradeSocketClient>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to user trade updates";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
|
||||
@@ -40,8 +40,13 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// Create a string representation for this client
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
=> ToString(false);
|
||||
|
||||
/// <summary>
|
||||
/// Create a string representation for this client
|
||||
/// </summary>
|
||||
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();
|
||||
|
||||
@@ -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<SharedSymbolModel>().Select(x => x.SharedSymbol!));
|
||||
_symbolTracker.UpdateTrackedSymbols(@event.Where(x => !x.PositionSizes.IsZero).OfType<SharedSymbolModel>().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;
|
||||
|
||||
Reference in New Issue
Block a user