mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-13 22:51:39 +00:00
wip
This commit is contained in:
@@ -4,9 +4,18 @@ using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// The type of transport used for the shared API
|
||||
/// </summary>
|
||||
public record SharedTransport(string Name)
|
||||
{
|
||||
/// <summary>
|
||||
/// REST transport
|
||||
/// </summary>
|
||||
public static SharedTransport Rest { get; } = new("REST");
|
||||
/// <summary>
|
||||
/// WebSocket transport
|
||||
/// </summary>
|
||||
public static SharedTransport Socket { get; } = new("WebSocket");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameter description
|
||||
/// </summary>
|
||||
public class ParameterDescription
|
||||
{
|
||||
/// <summary>
|
||||
/// Possible names for the parameter. One of these names can be used to provide the parameter in the ExchangeParameters of the request.
|
||||
/// </summary>
|
||||
public string[] Names { get; set; }
|
||||
/// <summary>
|
||||
/// Type of the value
|
||||
/// </summary>
|
||||
public Type ValueType { get; set; }
|
||||
/// <summary>
|
||||
/// Parameter description
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
/// <summary>
|
||||
/// Example value
|
||||
/// </summary>
|
||||
public object ExampleValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public ParameterDescription(string parameterName, Type valueType, string description, object exampleValue)
|
||||
{
|
||||
Names = [parameterName];
|
||||
ValueType = valueType;
|
||||
Description = description;
|
||||
ExampleValue = exampleValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public ParameterDescription(string[] parameterNames, Type valueType, string description, object exampleValue)
|
||||
{
|
||||
Names = parameterNames;
|
||||
ValueType = valueType;
|
||||
Description = description;
|
||||
ExampleValue = exampleValue;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[{ValueType.Name}] {string.Join(" / ", Names.Select(x => $"\"{x}\""))}: {Description}";
|
||||
}
|
||||
}
|
||||
}
|
||||
+117
-44
@@ -13,26 +13,44 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// </summary>
|
||||
public abstract class CapabilityOptions
|
||||
{
|
||||
private List<ParameterDescription> _requiredRequestParameters = new();
|
||||
/// <summary>
|
||||
/// Request parameter rules for the capability. The rules differ per exchange API and can be used to
|
||||
/// dynamically discover and adjust the request parameters for a capability.
|
||||
/// </summary>
|
||||
public RequestParameterDescription[] RequestParameterRules { get; private set; } = [];
|
||||
/// <summary>
|
||||
/// Exchange parameter rules for the capability. These are parameters specific to the exchange API and
|
||||
/// must be provided in the request via the ExchangeParameters property of the request object.
|
||||
/// </summary>
|
||||
public ExchangeParameterDescription[] ExchangeParameterRules { get; set; } = [];
|
||||
|
||||
private readonly RequestParameterDescription[] _defaultParameterRules;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Request properties that are optional in the shared contract,
|
||||
/// but required by this exchange implementation.
|
||||
/// Deprectaed, use RequestParameterRules instead.
|
||||
/// </summary>
|
||||
public List<ParameterDescription> RequiredRequestParameters
|
||||
public List<ParameterDescription> RequiredOptionalParameters
|
||||
{
|
||||
get => _requiredRequestParameters;
|
||||
set => _requiredRequestParameters = value;
|
||||
get => RequestParameterRules.Where(x => x.DefaultSupport == RequestParameterSupport.Optional
|
||||
&& x.Support == RequestParameterSupport.Required)
|
||||
.Cast<ParameterDescription>()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use RequiredRequestParameters instead.
|
||||
/// Deprectaed, use ExchangeParameterRules instead.
|
||||
/// </summary>
|
||||
[Obsolete("Use RequiredRequestParameters instead")]
|
||||
public List<ParameterDescription> RequiredOptionalParameters
|
||||
public List<ParameterDescription> RequiredExchangeParameters
|
||||
{
|
||||
get => _requiredRequestParameters;
|
||||
set => _requiredRequestParameters = value;
|
||||
get => ExchangeParameterRules.Where(x => x.Requirement == ExchangeParameterRequirement.Required).Cast<ParameterDescription>().ToList();
|
||||
}
|
||||
/// <summary>
|
||||
/// Deprectaed, use ExchangeParameterRules instead.
|
||||
/// </summary>
|
||||
public List<ParameterDescription> OptionalExchangeParameters
|
||||
{
|
||||
get => ExchangeParameterRules.Where(x => x.Requirement == ExchangeParameterRequirement.Optional).Cast<ParameterDescription>().ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -43,15 +61,6 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// The max number of symbols which can be passed in a call (Only applicable to request requiring symbol parameters)
|
||||
/// </summary>
|
||||
public int? MaxSymbolCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Required exchange-specific parameters. These can be provided via the `exchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
public List<ParameterDescription> RequiredExchangeParameters { get; set; } = new List<ParameterDescription>();
|
||||
/// <summary>
|
||||
/// Optional exchange-specific parameters. These can be provided via the `exchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
public List<ParameterDescription> OptionalExchangeParameters { get; set; } = new List<ParameterDescription>();
|
||||
/// <summary>
|
||||
/// Exchange
|
||||
/// </summary>
|
||||
@@ -84,11 +93,59 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public CapabilityOptions(string exchange, string operationName, bool needAuthentication)
|
||||
public CapabilityOptions(
|
||||
string exchange,
|
||||
string operationName,
|
||||
bool needAuthentication,
|
||||
IEnumerable<RequestParameterDescription> defaultParameterRules)
|
||||
{
|
||||
Exchange = exchange;
|
||||
OperationName = operationName;
|
||||
NeedsAuthentication = needAuthentication;
|
||||
|
||||
_defaultParameterRules = defaultParameterRules
|
||||
.Select(x => x.WithSupport(x.DefaultSupport))
|
||||
.ToArray();
|
||||
|
||||
RequestParameterRules = CombineParameters(
|
||||
_defaultParameterRules,
|
||||
Array.Empty<RequestParameterRuleOverride>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set request parameter overrides for this instance
|
||||
/// </summary>
|
||||
/// <param name="overrides">The parameter overrides</param>
|
||||
protected void SetRequestParameters(IEnumerable<RequestParameterRuleOverride> overrides)
|
||||
{
|
||||
RequestParameterRules = CombineParameters(_defaultParameterRules, overrides);
|
||||
}
|
||||
|
||||
private RequestParameterDescription[] CombineParameters(
|
||||
RequestParameterDescription[] defaultParameters,
|
||||
IEnumerable<RequestParameterRuleOverride> overrideParameters
|
||||
)
|
||||
{
|
||||
var result = defaultParameters
|
||||
.Select(x => x.WithSupport(x.DefaultSupport))
|
||||
.ToList();
|
||||
|
||||
foreach (var item in overrideParameters)
|
||||
{
|
||||
var index = result.FindIndex(
|
||||
x => x.Name == item.ParameterName);
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
throw new ArgumentException(
|
||||
$"No default request parameter rule exists for " +
|
||||
$"`{item.ParameterName}`");
|
||||
}
|
||||
|
||||
result[index] = result[index].WithOverride(item);
|
||||
}
|
||||
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -108,12 +165,13 @@ namespace CryptoExchange.Net.SharedApis
|
||||
|
||||
foreach (var param in RequiredExchangeParameters)
|
||||
{
|
||||
if (param.Names!.All(x => ExchangeParameters.HasValue(exchangeParameters, Exchange, x, param.ValueType) != true))
|
||||
if (ExchangeParameters.HasValue(exchangeParameters, Exchange, param.Name, param.ValueType) != true
|
||||
&& param.Aliases.Any(x => ExchangeParameters.HasValue(exchangeParameters, Exchange, x, param.ValueType) != true))
|
||||
{
|
||||
if (param.Names.Length == 1)
|
||||
return ArgumentError.Invalid(string.Join("/", param.Names!), $"Exchange parameter `{param.Names[0]}` for exchange `{Exchange}` should be provided. Example: {param.ExampleValue}");
|
||||
if (param.Aliases.Length == 0)
|
||||
return ArgumentError.Invalid(param.Name, $"Exchange parameter `{param.Name}` for exchange `{Exchange}` should be provided. Example: {param.ExampleValue}");
|
||||
else
|
||||
return ArgumentError.Invalid(string.Join("/", param.Names!), $"One of exchange parameters `{string.Join(", ", param.Names!)}` for exchange `{Exchange}` should be provided. Example: {param.ExampleValue}");
|
||||
return ArgumentError.Invalid(string.Join("/", [param.Name, .. param.Aliases]), $"One of exchange parameters `{string.Join(", ", [param.Name, .. param.Aliases])}` for exchange `{Exchange}` should be provided. Example: {param.ExampleValue}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,22 +195,16 @@ namespace CryptoExchange.Net.SharedApis
|
||||
sb.Append(" Notes: ");
|
||||
sb.AppendLine(RequestNotes);
|
||||
}
|
||||
if (RequiredRequestParameters.Any())
|
||||
if (RequestParameterRules.Any())
|
||||
{
|
||||
sb.AppendLine($" Required request parameters:");
|
||||
foreach (var param in RequiredRequestParameters)
|
||||
sb.AppendLine($" Request parameters:");
|
||||
foreach (var param in RequestParameterRules)
|
||||
sb.AppendLine($" {param}");
|
||||
}
|
||||
if (RequiredExchangeParameters.Any())
|
||||
if (ExchangeParameterRules.Any())
|
||||
{
|
||||
sb.AppendLine($" Required exchange specific parameters:");
|
||||
foreach (var param in RequiredExchangeParameters)
|
||||
sb.AppendLine($" {param}");
|
||||
}
|
||||
if (OptionalExchangeParameters.Any())
|
||||
{
|
||||
sb.AppendLine($" Optional exchange specific parameters:");
|
||||
foreach (var param in OptionalExchangeParameters)
|
||||
sb.AppendLine($" Exchange specific parameters:");
|
||||
foreach (var param in ExchangeParameterRules)
|
||||
sb.AppendLine($" {param}");
|
||||
}
|
||||
sb.Append(" Needs authentication: ");
|
||||
@@ -179,10 +231,17 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override Type CapabilityType => typeof(TCapability);
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual RequestParameterRuleOverride[] ParameterRuleOverwrites
|
||||
{
|
||||
set => SetRequestParameters(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public CapabilityOptions(string exchange, bool needsAuthentication, string requestName) : base(exchange, requestName, needsAuthentication)
|
||||
public CapabilityOptions(string exchange, bool needsAuthentication, string requestName, IEnumerable<RequestParameterDescription> defaultParameterRules)
|
||||
: base(exchange, requestName, needsAuthentication, defaultParameterRules)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -197,14 +256,28 @@ namespace CryptoExchange.Net.SharedApis
|
||||
if (NeedsAuthentication && !client.Authenticated)
|
||||
return new NoApiCredentialsError();
|
||||
|
||||
foreach (var param in RequiredRequestParameters)
|
||||
foreach (var param in RequestParameterRules)
|
||||
{
|
||||
if (param.Names!.All(x => _requestProperties.Single(p => p.Name == x).GetValue(request, null) == null))
|
||||
var property = _requestProperties.Single(x => x.Name == param.Name);
|
||||
var value = property.GetValue(request);
|
||||
|
||||
if (param.Support == RequestParameterSupport.Required)
|
||||
{
|
||||
if (param.Names.Length == 1)
|
||||
return ArgumentError.Invalid(string.Join("/", param.Names!), $"Optional parameter `{param.Names[0]}` for exchange `{Exchange}` should be provided. Example: {param.ExampleValue}");
|
||||
else
|
||||
return ArgumentError.Invalid(string.Join("/", param.Names!), $"One of optional parameters `{string.Join(", ", param.Names!)}` for exchange `{Exchange}` should be provided. Example: {param.ExampleValue}");
|
||||
if (value == null)
|
||||
{
|
||||
return ArgumentError.Invalid(
|
||||
param.Name,
|
||||
$"Request parameter `{param.Name}` for exchange `{Exchange}` is required and should be provided. Example: {param.ExampleValue}");
|
||||
}
|
||||
}
|
||||
else if (param.Support == RequestParameterSupport.NotSupported)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
return ArgumentError.Invalid(
|
||||
param.Name,
|
||||
$"Request parameter `{param.Name}` is not supported by exchange `{Exchange}`");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -30,8 +30,9 @@ namespace CryptoExchange.Net.SharedApis
|
||||
protected EndpointOptions(
|
||||
string exchange,
|
||||
string operationName,
|
||||
bool needsAuthentication)
|
||||
: base(exchange, operationName, needsAuthentication)
|
||||
bool needsAuthentication,
|
||||
IEnumerable<RequestParameterDescription> defaultParameterRules)
|
||||
: base(exchange, operationName, needsAuthentication, defaultParameterRules)
|
||||
{
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Text;
|
||||
|
||||
@@ -49,7 +51,8 @@ namespace CryptoExchange.Net.SharedApis
|
||||
bool timePeriodSupport,
|
||||
int maxLimit,
|
||||
bool needsAuthentication,
|
||||
string requestName) : base(exchange, needsAuthentication, requestName)
|
||||
string requestName,
|
||||
IEnumerable<RequestParameterDescription> defaultParameterRules) : base(exchange, needsAuthentication, requestName, defaultParameterRules)
|
||||
{
|
||||
SupportsAscending = supportsAscending;
|
||||
SupportsDescending = supportsDescending;
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Exchange parameter requirements
|
||||
/// </summary>
|
||||
public enum ExchangeParameterRequirement
|
||||
{
|
||||
/// <summary>
|
||||
/// Required parameter
|
||||
/// </summary>
|
||||
Required,
|
||||
/// <summary>
|
||||
/// Optional parameter
|
||||
/// </summary>
|
||||
Optional
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameter description
|
||||
/// </summary>
|
||||
public class ParameterDescription
|
||||
{
|
||||
/// <summary>
|
||||
/// Name of the parameter
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// Alternative names for the parameter.
|
||||
/// </summary>
|
||||
public string[] Aliases { get; set; } = [];
|
||||
/// <summary>
|
||||
/// Type of the value
|
||||
/// </summary>
|
||||
public Type ValueType { get; set; }
|
||||
/// <summary>
|
||||
/// Parameter description
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
/// <summary>
|
||||
/// Example value
|
||||
/// </summary>
|
||||
public object ExampleValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Names of the parameter
|
||||
/// </summary>
|
||||
[Obsolete("Use Name and Aliases instead")]
|
||||
public string[] Names
|
||||
{
|
||||
get => [Name, .. Aliases];
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public ParameterDescription(string parameterName, Type valueType, string description, object exampleValue)
|
||||
{
|
||||
Name = parameterName;
|
||||
ValueType = valueType;
|
||||
Description = description;
|
||||
ExampleValue = exampleValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public ParameterDescription(string parameterName, string[] aliases, Type valueType, string description, object exampleValue)
|
||||
{
|
||||
Name = parameterName;
|
||||
Aliases = aliases;
|
||||
ValueType = valueType;
|
||||
Description = description;
|
||||
ExampleValue = exampleValue;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[{ValueType.Name}] \"{Name}\" {string.Join(" / ", Aliases.Select(x => $"\"{x}\""))}: {Description}";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request parameter description
|
||||
/// </summary>
|
||||
public class RequestParameterDescription : ParameterDescription
|
||||
{
|
||||
/// <summary>
|
||||
/// Status defined by the shared request contract.
|
||||
/// </summary>
|
||||
public RequestParameterSupport DefaultSupport { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Status after applying exchange overrides.
|
||||
/// </summary>
|
||||
public RequestParameterSupport Support { get; }
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public RequestParameterDescription(
|
||||
RequestParameterSupport support,
|
||||
string parameterName,
|
||||
Type valueType,
|
||||
string description,
|
||||
object exampleValue)
|
||||
: base(parameterName, valueType, description, exampleValue)
|
||||
{
|
||||
Support = support;
|
||||
DefaultSupport = support;
|
||||
}
|
||||
|
||||
private RequestParameterDescription(
|
||||
RequestParameterSupport defaultSupport,
|
||||
RequestParameterSupport support,
|
||||
string parameterName,
|
||||
Type valueType,
|
||||
string description,
|
||||
object exampleValue)
|
||||
: base(parameterName, valueType, description, exampleValue)
|
||||
{
|
||||
DefaultSupport = defaultSupport;
|
||||
Support = support;
|
||||
}
|
||||
|
||||
internal RequestParameterDescription WithSupport(
|
||||
RequestParameterSupport support)
|
||||
=> new(
|
||||
DefaultSupport,
|
||||
support,
|
||||
Name,
|
||||
ValueType,
|
||||
Description,
|
||||
ExampleValue);
|
||||
|
||||
internal RequestParameterDescription WithOverride(
|
||||
RequestParameterRuleOverride parameterOverride)
|
||||
=> new(
|
||||
DefaultSupport,
|
||||
parameterOverride.Support,
|
||||
Name,
|
||||
ValueType,
|
||||
parameterOverride.Description ?? Description,
|
||||
ExampleValue);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[{Support}] [{ValueType.Name}] \"{Name}\" {string.Join(" / ", Aliases.Select(x => $"\"{x}\""))}: {Description}";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Exchange-specific parameter description
|
||||
/// </summary>
|
||||
public class ExchangeParameterDescription : ParameterDescription
|
||||
{
|
||||
/// <summary>
|
||||
/// Requirement for the parameter
|
||||
/// </summary>
|
||||
public ExchangeParameterRequirement Requirement { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public ExchangeParameterDescription(
|
||||
ExchangeParameterRequirement requirement,
|
||||
string parameterName,
|
||||
string[] aliases,
|
||||
Type valueType,
|
||||
string description,
|
||||
object exampleValue)
|
||||
: base(parameterName, aliases, valueType, description, exampleValue)
|
||||
{
|
||||
Requirement = requirement;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[{Requirement}] [{ValueType.Name}] \"{Name}\" {string.Join(" / ", Aliases.Select(x => $"\"{x}\""))}: {Description}";
|
||||
}
|
||||
}
|
||||
}
|
||||
+51
-16
@@ -9,13 +9,13 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// Creates descriptions for properties on a shared request.
|
||||
/// </summary>
|
||||
public static class RequestParameter<TRequest>
|
||||
public static class RequestParameterRule<TRequest>
|
||||
where TRequest : SharedRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Describe a request property which is required by an implementation.
|
||||
/// </summary>
|
||||
public static ParameterDescription Required<TValue>(
|
||||
public static RequestParameterDescription Required<TValue>(
|
||||
Expression<Func<TRequest, TValue>> selector,
|
||||
string description,
|
||||
TValue exampleValue)
|
||||
@@ -37,51 +37,86 @@ namespace CryptoExchange.Net.SharedApis
|
||||
nameof(selector));
|
||||
}
|
||||
|
||||
return new ParameterDescription(
|
||||
return new RequestParameterDescription(
|
||||
RequestParameterSupport.Required,
|
||||
property.Name,
|
||||
property.PropertyType,
|
||||
description,
|
||||
exampleValue!);
|
||||
exampleValue!
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describe a request property which is optional by an implementation.
|
||||
/// </summary>
|
||||
public static RequestParameterDescription Optional<TValue>(
|
||||
Expression<Func<TRequest, TValue>> selector,
|
||||
string description,
|
||||
TValue exampleValue)
|
||||
{
|
||||
Expression body = selector.Body;
|
||||
|
||||
if (body is UnaryExpression unary
|
||||
&& unary.NodeType == ExpressionType.Convert)
|
||||
{
|
||||
body = unary.Operand;
|
||||
}
|
||||
|
||||
if (body is not MemberExpression member
|
||||
|| member.Member is not PropertyInfo property
|
||||
|| member.Expression != selector.Parameters[0])
|
||||
{
|
||||
throw new ArgumentException(
|
||||
"Selector must select a direct request property",
|
||||
nameof(selector));
|
||||
}
|
||||
|
||||
return new RequestParameterDescription(
|
||||
RequestParameterSupport.Optional,
|
||||
property.Name,
|
||||
property.PropertyType,
|
||||
description,
|
||||
exampleValue!
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates descriptions for exchange-specific parameters.
|
||||
/// </summary>
|
||||
public static class ExchangeParameterDescription
|
||||
public static class ExchangeParameterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// Describe a required exchange-specific parameter.
|
||||
/// </summary>
|
||||
public static ParameterDescription Required<TValue>(
|
||||
public static ExchangeParameterDescription Required<TValue>(
|
||||
string name,
|
||||
string description,
|
||||
TValue exampleValue,
|
||||
params string[] aliases)
|
||||
=> Create(name, description, exampleValue, aliases);
|
||||
=> Create(ExchangeParameterRequirement.Required, name, description, exampleValue, aliases);
|
||||
|
||||
/// <summary>
|
||||
/// Describe an optional exchange-specific parameter.
|
||||
/// </summary>
|
||||
public static ParameterDescription Optional<TValue>(
|
||||
public static ExchangeParameterDescription Optional<TValue>(
|
||||
string name,
|
||||
string description,
|
||||
TValue exampleValue,
|
||||
params string[] aliases)
|
||||
=> Create(name, description, exampleValue, aliases);
|
||||
=> Create(ExchangeParameterRequirement.Optional, name, description, exampleValue, aliases);
|
||||
|
||||
private static ParameterDescription Create<TValue>(
|
||||
private static ExchangeParameterDescription Create<TValue>(
|
||||
ExchangeParameterRequirement requirement,
|
||||
string name,
|
||||
string description,
|
||||
TValue exampleValue,
|
||||
string[] aliases)
|
||||
{
|
||||
var names = new string[aliases.Length + 1];
|
||||
names[0] = name;
|
||||
Array.Copy(aliases, 0, names, 1, aliases.Length);
|
||||
|
||||
return new ParameterDescription(
|
||||
names,
|
||||
return new ExchangeParameterDescription(
|
||||
requirement,
|
||||
name,
|
||||
aliases,
|
||||
typeof(TValue),
|
||||
description,
|
||||
exampleValue!);
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Request parameter rule override
|
||||
/// </summary>
|
||||
/// <param name="ParameterName">The name of the parameter</param>
|
||||
/// <param name="Support">The support level of the parameter</param>
|
||||
/// <param name="Description">A description of the parameter</param>
|
||||
public record RequestParameterRuleOverride(
|
||||
string ParameterName,
|
||||
RequestParameterSupport Support,
|
||||
string? Description = null);
|
||||
|
||||
/// <summary>
|
||||
/// Request parameter rule override factory
|
||||
/// </summary>
|
||||
/// <typeparam name="TRequest">The type of the request</typeparam>
|
||||
public static class RequestParameterRuleOverride<TRequest>
|
||||
where TRequest : SharedRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// Required parameter rule override
|
||||
/// </summary>
|
||||
public static RequestParameterRuleOverride Required<TValue>(
|
||||
Expression<Func<TRequest, TValue>> selector,
|
||||
string? description = null)
|
||||
=> Create(selector, RequestParameterSupport.Required, description);
|
||||
|
||||
/// <summary>
|
||||
/// Optional parameter rule override
|
||||
/// </summary>
|
||||
public static RequestParameterRuleOverride Optional<TValue>(
|
||||
Expression<Func<TRequest, TValue>> selector,
|
||||
string? description = null)
|
||||
=> Create(selector, RequestParameterSupport.Optional, description);
|
||||
|
||||
/// <summary>
|
||||
/// Not supported parameter rule override
|
||||
/// </summary>
|
||||
public static RequestParameterRuleOverride NotSupported<TValue>(
|
||||
Expression<Func<TRequest, TValue>> selector,
|
||||
string? description = null)
|
||||
=> Create(selector, RequestParameterSupport.NotSupported, description);
|
||||
|
||||
private static RequestParameterRuleOverride Create<TValue>(
|
||||
Expression<Func<TRequest, TValue>> selector,
|
||||
RequestParameterSupport support,
|
||||
string? description)
|
||||
{
|
||||
var body = selector.Body is UnaryExpression unary
|
||||
&& unary.NodeType == ExpressionType.Convert
|
||||
? unary.Operand
|
||||
: selector.Body;
|
||||
|
||||
if (body is not MemberExpression member
|
||||
|| member.Member is not PropertyInfo property
|
||||
|| member.Expression != selector.Parameters[0])
|
||||
{
|
||||
throw new ArgumentException(
|
||||
"Selector must select a direct request property",
|
||||
nameof(selector));
|
||||
}
|
||||
|
||||
return new RequestParameterRuleOverride(
|
||||
property.Name,
|
||||
support,
|
||||
description);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Request parameter support
|
||||
/// </summary>
|
||||
public enum RequestParameterSupport
|
||||
{
|
||||
/// <summary>
|
||||
/// Required parameter
|
||||
/// </summary>
|
||||
Required,
|
||||
/// <summary>
|
||||
/// Optional parameter
|
||||
/// </summary>
|
||||
Optional,
|
||||
/// <summary>
|
||||
/// Not supported parameter
|
||||
/// </summary>
|
||||
NotSupported
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,12 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve basic info for all assets and the networks they support for withdrawals/deposits";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = [];
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetAllAssetsOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetAllAssetsRest.GetAllAssetsAsync))
|
||||
public GetAllAssetsOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetAllAssetsRest.GetAllAssetsAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Assets request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetAllAssetsOptions GetAllAssetsOptions { get; }
|
||||
|
||||
@@ -12,10 +12,15 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve basic info for a single asset and networks it supports for withdrawals/deposits";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetAssetRequest>.Required(x => x.Asset, "The asset to retrieve information for", "ETH"),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetAssetOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetAssetRest.GetAssetAsync))
|
||||
public GetAssetOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetAssetRest.GetAssetAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Asset request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetAssetOptions GetAssetOptions { get; }
|
||||
|
||||
@@ -11,6 +11,12 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve account balances";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetBalancesRequest>.Optional(x => x.TradingMode, "Filter the balances by trading mode", TradingMode.Spot),
|
||||
RequestParameterRule<GetBalancesRequest>.Optional(x => x.AccountType, "The account type to retrieve balances for", SharedAccountType.Spot),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Supported account types
|
||||
/// </summary>
|
||||
@@ -19,7 +25,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetBalancesOptions(string exchange, params AccountTypeFilter[] accountTypes) : base(exchange, true, nameof(IGetBalancesRest.GetBalancesAsync))
|
||||
public GetBalancesOptions(string exchange, params AccountTypeFilter[] accountTypes) : base(exchange, true, nameof(IGetBalancesRest.GetBalancesAsync), _defaultParameterRules)
|
||||
{
|
||||
SupportedAccountTypes = accountTypes;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Balances request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetBalancesOptions GetBalancesOptions { get; }
|
||||
|
||||
+6
-1
@@ -12,10 +12,15 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to balance updates";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<SubscribeBalancesRequest>.Optional(x => x.TradingMode, "Filter balance updates by trading mode", TradingMode.Spot),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public SubscribeBalanceOptions(string exchange, bool needsAuthentication) : base(exchange, needsAuthentication, nameof(ISubscribeBalancesSocket.SubscribeToBalanceUpdatesAsync))
|
||||
public SubscribeBalanceOptions(string exchange, bool needsAuthentication) : base(exchange, needsAuthentication, nameof(ISubscribeBalancesSocket.SubscribeToBalanceUpdatesAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -12,10 +12,16 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve deposit addresses for an asset";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetDepositAddressesRequest>.Required(x => x.Asset, "The asset to retrieve deposit addresses for", "ETH"),
|
||||
RequestParameterRule<GetDepositAddressesRequest>.Optional(x => x.Network, "The network to retrieve a deposit address for", "ERC20"),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetDepositAddressesOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetDepositAddressesRest.GetDepositAddressesAsync))
|
||||
public GetDepositAddressesOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetDepositAddressesRest.GetDepositAddressesAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Deposit addresses request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetDepositAddressesOptions GetDepositAddressesOptions { get; }
|
||||
|
||||
+10
-1
@@ -12,11 +12,20 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve deposit history";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetDepositsRequest>.Optional(x => x.Asset, "Filter the result set by asset", "ETH"),
|
||||
RequestParameterRule<GetDepositsRequest>.Optional(x => x.StartTime, "Filter the result set by start time", DateTime.UtcNow.AddDays(-1)),
|
||||
RequestParameterRule<GetDepositsRequest>.Optional(x => x.EndTime, "Filter the result set by end time", DateTime.UtcNow.AddHours(-1)),
|
||||
RequestParameterRule<GetDepositsRequest>.Optional(x => x.Limit, "Limit the result set to a maximum number of items", 100),
|
||||
RequestParameterRule<GetDepositsRequest>.Optional(x => x.Direction, "The direction in which to retrieve the results", DataDirection.Descending),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetDepositHistoryOptions(string exchange, bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit)
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, true, nameof(IGetDepositHistoryRest.GetDepositHistoryAsync))
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, true, nameof(IGetDepositHistoryRest.GetDepositHistoryAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Deposits request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetDepositHistoryOptions GetDepositHistoryOptions { get; }
|
||||
|
||||
@@ -12,10 +12,15 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve trading fee information";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetFeeRequest>.Required(x => x.Symbol, "The symbol to retrieve trading fees for", new SharedSymbol(TradingMode.Spot, "ETH", "USDT")),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetFeeOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetFeesRest.GetFeesAsync))
|
||||
public GetFeeOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetFeesRest.GetFeesAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Fee request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetFeeOptions GetFeeOptions { get; }
|
||||
|
||||
+10
-1
@@ -12,11 +12,20 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve historical funding rates for a futures symbol";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetFundingRateHistoryRequest>.Required(x => x.Symbol, "The symbol to retrieve funding rate history for", new SharedSymbol(TradingMode.PerpetualLinear, "ETH", "USDT")),
|
||||
RequestParameterRule<GetFundingRateHistoryRequest>.Optional(x => x.StartTime, "Filter the result set by start time", DateTime.UtcNow.AddDays(-1)),
|
||||
RequestParameterRule<GetFundingRateHistoryRequest>.Optional(x => x.EndTime, "Filter the result set by end time", DateTime.UtcNow.AddHours(-1)),
|
||||
RequestParameterRule<GetFundingRateHistoryRequest>.Optional(x => x.Limit, "Limit the result set to a maximum number of items", 100),
|
||||
RequestParameterRule<GetFundingRateHistoryRequest>.Optional(x => x.Direction, "The direction in which to retrieve the results", DataDirection.Descending),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetFundingRateHistoryOptions(string exchange, bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit, bool needsAuthentication)
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetFundingRateHistoryRest.GetFundingRateHistoryAsync))
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetFundingRateHistoryRest.GetFundingRateHistoryAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Funding rate request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetFundingRateHistoryOptions GetFundingRateHistoryOptions { get; }
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for requesting the index price
|
||||
/// </summary>
|
||||
public class GetAllIndexPricesOptions : CapabilityOptions<GetAllIndexPricesRequest, IGetAllIndexPricesRest>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve the index prices for all futures symbols";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetAllIndexPricesRequest>.Optional(x => x.TradingMode, "Filter the index prices by trading mode", TradingMode.PerpetualLinear),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetAllIndexPricesOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetAllIndexPricesRest.GetAllIndexPricesAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -3,14 +3,14 @@
|
||||
/// <summary>
|
||||
/// Request to retrieve the current index prices for all symbols
|
||||
/// </summary>
|
||||
public record GetIndexPricesRequest : SharedRequest
|
||||
public record GetAllIndexPricesRequest : SharedRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
/// <param name="tradingMode">Trading mode</param>
|
||||
/// <param name="exchangeParameters">Exchange specific parameters</param>
|
||||
public GetIndexPricesRequest(TradingMode? tradingMode = null, ExchangeParameters? exchangeParameters = null) : base(tradingMode, exchangeParameters)
|
||||
public GetAllIndexPricesRequest(TradingMode? tradingMode = null, ExchangeParameters? exchangeParameters = null) : base(tradingMode, exchangeParameters)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using CryptoExchange.Net.Objects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Operation for retrieving the index price for all symbols from an exchange.
|
||||
/// </summary>
|
||||
public interface IGetAllIndexPrices : ISharedApiCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Index price request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetAllIndexPricesOptions GetAllIndexPricesOptions { get; }
|
||||
/// <summary>
|
||||
/// Get the index price for a symbol, see <see cref="GetAllIndexPricesOptions"/> for request options and exchange specific required/optional parameters. <br />
|
||||
/// </summary>
|
||||
/// <param name="request">Request info</param>
|
||||
/// <param name="ct">Cancellation token</param>
|
||||
Task<ICallResult<SharedIndexPrice[]>> GetAllIndexPricesAsync(GetAllIndexPricesRequest request, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operation for retrieving the index price for all symbols from an exchange via the REST API.
|
||||
/// </summary>
|
||||
public interface IGetAllIndexPricesRest : IGetAllIndexPrices, ISharedRest
|
||||
{
|
||||
/// <inheritdoc />
|
||||
new Task<HttpResult<SharedIndexPrice[]>> GetAllIndexPricesAsync(GetAllIndexPricesRequest request, CancellationToken ct = default);
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,15 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve the index price for a futures symbol";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetIndexPriceRequest>.Required(x => x.Symbol, "The symbol to retrieve the index price for", new SharedSymbol(TradingMode.PerpetualLinear, "ETH", "USDT")),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetIndexPriceOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetIndexPriceRest.GetIndexPriceAsync))
|
||||
public GetIndexPriceOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetIndexPriceRest.GetIndexPriceAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Index price request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetIndexPriceOptions GetIndexPriceOptions { get; }
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for requesting the index price
|
||||
/// </summary>
|
||||
public class GetIndexPricesOptions : CapabilityOptions<GetIndexPricesRequest, IGetIndexPricesRest>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve the index prices for all futures symbols";
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetIndexPricesOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetIndexPricesRest.GetIndexPricesAsync))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
using CryptoExchange.Net.Objects;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Operation for retrieving the index price for a symbol from an exchange.
|
||||
/// </summary>
|
||||
public interface IGetIndexPrices : ISharedApiCapability
|
||||
{
|
||||
/// <summary>
|
||||
/// Index price request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetIndexPricesOptions GetIndexPricesOptions { get; }
|
||||
/// <summary>
|
||||
/// Get the index price for a symbol, see <see cref="GetIndexPricesOptions"/> for request options and exchange specific required/optional parameters. <br />
|
||||
/// </summary>
|
||||
/// <param name="request">Request info</param>
|
||||
/// <param name="ct">Cancellation token</param>
|
||||
Task<ICallResult<SharedIndexPrice[]>> GetIndexPricesAsync(GetIndexPricesRequest request, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Operation for retrieving the index price for a symbol from an exchange via the REST API.
|
||||
/// </summary>
|
||||
public interface IGetIndexPricesRest : IGetIndexPrices, ISharedRest
|
||||
{
|
||||
/// <inheritdoc />
|
||||
new Task<HttpResult<SharedIndexPrice[]>> GetIndexPricesAsync(GetIndexPricesRequest request, CancellationToken ct = default);
|
||||
}
|
||||
}
|
||||
+12
-2
@@ -13,6 +13,16 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve index price candlestick data";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetKlinesRequest>.Required(x => x.Symbol, "The symbol to retrieve klines for", new SharedSymbol(TradingMode.PerpetualLinear, "ETH", "USDT")),
|
||||
RequestParameterRule<GetKlinesRequest>.Required(x => x.Interval, "The kline interval", SharedKlineInterval.OneMinute),
|
||||
RequestParameterRule<GetKlinesRequest>.Optional(x => x.StartTime, "Filter the result set by start time", DateTime.UtcNow.AddDays(-1)),
|
||||
RequestParameterRule<GetKlinesRequest>.Optional(x => x.EndTime, "Filter the result set by end time", DateTime.UtcNow.AddHours(-1)),
|
||||
RequestParameterRule<GetKlinesRequest>.Optional(x => x.Limit, "Limit the result set to a maximum number of items", 100),
|
||||
RequestParameterRule<GetKlinesRequest>.Optional(x => x.Direction, "The direction in which to retrieve the results", DataDirection.Descending),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The supported kline intervals
|
||||
/// </summary>
|
||||
@@ -26,7 +36,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetIndexPriceKlinesOptions(string exchange, bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit, bool needsAuthentication)
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetIndexPriceKlinesRest.GetIndexPriceKlinesAsync))
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetIndexPriceKlinesRest.GetIndexPriceKlinesAsync), _defaultParameterRules)
|
||||
{
|
||||
SupportIntervals = new[]
|
||||
{
|
||||
@@ -51,7 +61,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetIndexPriceKlinesOptions(string exchange, bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit, bool needsAuthentication, params SharedKlineInterval[] intervals)
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IIndexPriceKlineRestClient.GetIndexPriceKlinesAsync))
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IIndexPriceKlineRestClient.GetIndexPriceKlinesAsync), _defaultParameterRules)
|
||||
{
|
||||
SupportIntervals = intervals;
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Index price klines request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetIndexPriceKlinesOptions GetIndexPriceKlinesOptions { get; }
|
||||
|
||||
+12
-2
@@ -13,6 +13,16 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve mark price candlestick data";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetKlinesRequest>.Required(x => x.Symbol, "The symbol to retrieve klines for", new SharedSymbol(TradingMode.PerpetualLinear, "ETH", "USDT")),
|
||||
RequestParameterRule<GetKlinesRequest>.Required(x => x.Interval, "The kline interval", SharedKlineInterval.OneMinute),
|
||||
RequestParameterRule<GetKlinesRequest>.Optional(x => x.StartTime, "Filter the result set by start time", DateTime.UtcNow.AddDays(-1)),
|
||||
RequestParameterRule<GetKlinesRequest>.Optional(x => x.EndTime, "Filter the result set by end time", DateTime.UtcNow.AddHours(-1)),
|
||||
RequestParameterRule<GetKlinesRequest>.Optional(x => x.Limit, "Limit the result set to a maximum number of items", 100),
|
||||
RequestParameterRule<GetKlinesRequest>.Optional(x => x.Direction, "The direction in which to retrieve the results", DataDirection.Descending),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The supported kline intervals
|
||||
/// </summary>
|
||||
@@ -26,7 +36,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetMarkPriceKlinesOptions(string exchange, bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit, bool needsAuthentication)
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetMarkPriceKlinesRest.GetMarkPriceKlinesAsync))
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetMarkPriceKlinesRest.GetMarkPriceKlinesAsync), _defaultParameterRules)
|
||||
{
|
||||
SupportIntervals = new[]
|
||||
{
|
||||
@@ -51,7 +61,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetMarkPriceKlinesOptions(string exchange, bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit, bool needsAuthentication, params SharedKlineInterval[] intervals)
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetMarkPriceKlinesRest.GetMarkPriceKlinesAsync))
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetMarkPriceKlinesRest.GetMarkPriceKlinesAsync), _defaultParameterRules)
|
||||
{
|
||||
SupportIntervals = intervals;
|
||||
}
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Mark price klines request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetMarkPriceKlinesOptions GetMarkPriceKlinesOptions { get; }
|
||||
|
||||
@@ -13,6 +13,16 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve candlestick data for a symbol";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetKlinesRequest>.Required(x => x.Symbol, "The symbol to retrieve klines for", new SharedSymbol(TradingMode.Spot, "ETH", "USDT")),
|
||||
RequestParameterRule<GetKlinesRequest>.Required(x => x.Interval, "The kline interval", SharedKlineInterval.OneMinute),
|
||||
RequestParameterRule<GetKlinesRequest>.Optional(x => x.StartTime, "Filter the result set by start time", DateTime.UtcNow.AddDays(-1)),
|
||||
RequestParameterRule<GetKlinesRequest>.Optional(x => x.EndTime, "Filter the result set by end time", DateTime.UtcNow.AddHours(-1)),
|
||||
RequestParameterRule<GetKlinesRequest>.Optional(x => x.Limit, "Limit the result set to a maximum number of items", 100),
|
||||
RequestParameterRule<GetKlinesRequest>.Optional(x => x.Direction, "The direction in which to retrieve the results", DataDirection.Descending),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The supported kline intervals
|
||||
/// </summary>
|
||||
@@ -26,7 +36,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetKlinesOptions(string exchange, bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit, bool needsAuthentication)
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetKlinesRest.GetKlinesAsync))
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetKlinesRest.GetKlinesAsync), _defaultParameterRules)
|
||||
{
|
||||
SupportIntervals = new[]
|
||||
{
|
||||
@@ -51,7 +61,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetKlinesOptions(string exchange, bool supportsAscending, bool supportsDescending, bool timeFilterSupported, int maxLimit, bool needsAuthentication, params SharedKlineInterval[] intervals)
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetKlinesRest.GetKlinesAsync))
|
||||
: base(exchange, supportsAscending, supportsDescending, timeFilterSupported, maxLimit, needsAuthentication, nameof(IGetKlinesRest.GetKlinesAsync), _defaultParameterRules)
|
||||
{
|
||||
SupportIntervals = intervals;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Kline request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetKlinesOptions GetKlinesOptions { get; }
|
||||
|
||||
@@ -12,6 +12,13 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Subscribe to candlestick updates for a symbol";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<SubscribeKlineRequest>.Optional(x => x.Symbol, "The symbol to subscribe to", new SharedSymbol(TradingMode.Spot, "ETH", "USDT")),
|
||||
RequestParameterRule<SubscribeKlineRequest>.Optional(x => x.Symbols, "The symbols to subscribe to", new[] { new SharedSymbol(TradingMode.Spot, "ETH", "USDT") }),
|
||||
RequestParameterRule<SubscribeKlineRequest>.Required(x => x.Interval, "The kline interval", SharedKlineInterval.OneMinute),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Kline intervals supported for updates
|
||||
/// </summary>
|
||||
@@ -20,7 +27,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public SubscribeKlineOptions(string exchange, bool needsAuthentication) : base(exchange, needsAuthentication, nameof(ISubscribeKlinesSocket.SubscribeToKlineUpdatesAsync))
|
||||
public SubscribeKlineOptions(string exchange, bool needsAuthentication) : base(exchange, needsAuthentication, nameof(ISubscribeKlinesSocket.SubscribeToKlineUpdatesAsync), _defaultParameterRules)
|
||||
{
|
||||
SupportIntervals = new[]
|
||||
{
|
||||
@@ -45,7 +52,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public SubscribeKlineOptions(string exchange, bool needsAuthentication, params SharedKlineInterval[] intervals)
|
||||
: base(exchange, needsAuthentication, nameof(ISubscribeKlinesSocket.SubscribeToKlineUpdatesAsync))
|
||||
: base(exchange, needsAuthentication, nameof(ISubscribeKlinesSocket.SubscribeToKlineUpdatesAsync), _defaultParameterRules)
|
||||
{
|
||||
SupportIntervals = intervals;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,17 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve the current leverage for a futures symbol";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetLeverageRequest>.Required(x => x.Symbol, "The symbol to retrieve leverage for", new SharedSymbol(TradingMode.PerpetualLinear, "ETH", "USDT")),
|
||||
RequestParameterRule<GetLeverageRequest>.Optional(x => x.PositionSide, "The position side to retrieve leverage for", SharedPositionSide.Long),
|
||||
RequestParameterRule<GetLeverageRequest>.Optional(x => x.MarginMode, "The margin mode to retrieve leverage for", SharedMarginMode.Cross),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetLeverageOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetLeverageRest.GetLeverageAsync))
|
||||
public GetLeverageOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetLeverageRest.GetLeverageAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Leverage request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
GetLeverageOptions GetLeverageOptions { get; }
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace CryptoExchange.Net.SharedApis
|
||||
|
||||
/// <summary>
|
||||
/// Leverage set request options.<br />
|
||||
/// Use <see cref="CapabilityOptions.RequiredRequestParameters"/>, <see cref="CapabilityOptions.RequiredExchangeParameters"/> and <see cref="CapabilityOptions.OptionalExchangeParameters"/> to check for required and optional parameters for the request. <br />
|
||||
/// Use <see cref="CapabilityOptions.RequestParameterRules"/> and <see cref="CapabilityOptions.ExchangeParameterRules"/> to check for required and optional parameters for the request. <br />
|
||||
/// Exchange specific parameters can be added to the request via the `ExchangeParameters` property of the request object.
|
||||
/// </summary>
|
||||
SetLeverageOptions SetLeverageOptions { get; }
|
||||
|
||||
@@ -8,10 +8,18 @@ namespace CryptoExchange.Net.SharedApis
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Set the leverage for a futures symbol";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<SetLeverageRequest>.Required(x => x.Symbol, "The symbol to set leverage for", new SharedSymbol(TradingMode.PerpetualLinear, "ETH", "USDT")),
|
||||
RequestParameterRule<SetLeverageRequest>.Required(x => x.Leverage, "The leverage to set", 10m),
|
||||
RequestParameterRule<SetLeverageRequest>.Optional(x => x.Side, "The position side to set leverage for", SharedPositionSide.Long),
|
||||
RequestParameterRule<SetLeverageRequest>.Optional(x => x.MarginMode, "The margin mode to set leverage for", SharedMarginMode.Cross),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public SetLeverageOptions(string exchange) : base(exchange, true, nameof(ISetLeverageRest.SetLeverageAsync))
|
||||
public SetLeverageOptions(string exchange) : base(exchange, true, nameof(ISetLeverageRest.SetLeverageAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CryptoExchange.Net.SharedApis
|
||||
{
|
||||
/// <summary>
|
||||
/// Options for requesting the mark price
|
||||
/// </summary>
|
||||
public class GetAllMarkPricesOptions : CapabilityOptions<GetAllMarkPricesRequest, IGetAllMarkPricesRest>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string Description => "Retrieve the mark prices for all futures symbols";
|
||||
|
||||
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||
{
|
||||
RequestParameterRule<GetAllMarkPricesRequest>.Optional(x => x.TradingMode, "Filter the mark prices by trading mode", TradingMode.PerpetualLinear),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
public GetAllMarkPricesOptions(string exchange, bool authenticated) : base(exchange, authenticated, nameof(IGetAllMarkPricesRest.GetAllMarkPricesAsync), _defaultParameterRules)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user