mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-16 16:10:53 +00:00
wip
This commit is contained in:
@@ -97,7 +97,7 @@ public record CallResult<T> : CallResult, ICallResult<T>
|
|||||||
/// Call result for an exchange
|
/// Call result for an exchange
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="T">Data type</typeparam>
|
/// <typeparam name="T">Data type</typeparam>
|
||||||
public record ExchangeCallResult<T> : CallResult<T>
|
public record ExchangeCallResult<T> : CallResult<T>, IExchangeCallResult<T>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Exchange name
|
/// Exchange name
|
||||||
|
|||||||
@@ -10,12 +10,8 @@ namespace CryptoExchange.Net.Objects
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// HTTP call result
|
/// HTTP call result
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IHttpResult : ICallResult
|
public interface IHttpResult : ICallResult, IExchangeCallResult
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Exchange name
|
|
||||||
/// </summary>
|
|
||||||
string Exchange { get; init; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The original data returned by the call, only available when `OutputOriginalData` is set to `true` in the client options
|
/// The original data returned by the call, only available when `OutputOriginalData` is set to `true` in the client options
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -10,13 +10,8 @@ namespace CryptoExchange.Net.Objects
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// WebSocket call result
|
/// WebSocket call result
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IWebSocketResult : ICallResult
|
public interface IWebSocketResult : ICallResult, IExchangeCallResult
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Exchange name
|
|
||||||
/// </summary>
|
|
||||||
string Exchange { get; init; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The request id
|
/// The request id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ namespace CryptoExchange.Net.RateLimiting.Guards
|
|||||||
/// <param name="decayPerTimeSpan">The decay per timespan if windowType is DecayWindowTracker</param>
|
/// <param name="decayPerTimeSpan">The decay per timespan if windowType is DecayWindowTracker</param>
|
||||||
/// <param name="connectionWeight">The weight of a new connection</param>
|
/// <param name="connectionWeight">The weight of a new connection</param>
|
||||||
/// <param name="shared">Whether this guard is shared between multiple gates</param>
|
/// <param name="shared">Whether this guard is shared between multiple gates</param>
|
||||||
public RateLimitGuard(Func<RequestDefinition, string?, string> keySelector, IGuardFilter filter, int limit, TimeSpan timeSpan, RateLimitWindowType windowType, TimeSpan? safetyMargin = null, double? decayPerTimeSpan = null, int? connectionWeight = null, bool shared = false)
|
public RateLimitGuard(Func<RequestDefinition, string?, string> keySelector, IGuardFilter filter, int limit, TimeSpan timeSpan, RateLimitWindowType windowType, double? decayPerTimeSpan = null, int? connectionWeight = null, bool shared = false, TimeSpan? safetyMargin = null)
|
||||||
: this(keySelector, new[] { filter }, limit, timeSpan, windowType, safetyMargin, decayPerTimeSpan, connectionWeight, shared)
|
: this(keySelector, new[] { filter }, limit, timeSpan, windowType, decayPerTimeSpan, connectionWeight, shared, safetyMargin)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ namespace CryptoExchange.Net.RateLimiting.Guards
|
|||||||
/// <param name="decayPerTimeSpan">The decay per timespan if windowType is DecayWindowTracker</param>
|
/// <param name="decayPerTimeSpan">The decay per timespan if windowType is DecayWindowTracker</param>
|
||||||
/// <param name="connectionWeight">The weight of a new connection</param>
|
/// <param name="connectionWeight">The weight of a new connection</param>
|
||||||
/// <param name="shared">Whether this guard is shared between multiple gates</param>
|
/// <param name="shared">Whether this guard is shared between multiple gates</param>
|
||||||
public RateLimitGuard(Func<RequestDefinition, string?, string> keySelector, IEnumerable<IGuardFilter> filters, int limit, TimeSpan timeSpan, RateLimitWindowType windowType, TimeSpan? safetyMargin = null, double? decayPerTimeSpan = null, int? connectionWeight = null, bool shared = false)
|
public RateLimitGuard(Func<RequestDefinition, string?, string> keySelector, IEnumerable<IGuardFilter> filters, int limit, TimeSpan timeSpan, RateLimitWindowType windowType, double? decayPerTimeSpan = null, int? connectionWeight = null, bool shared = false, TimeSpan? safetyMargin = null)
|
||||||
{
|
{
|
||||||
_filters = filters;
|
_filters = filters;
|
||||||
_trackers = new Dictionary<string, IWindowTracker>();
|
_trackers = new Dictionary<string, IWindowTracker>();
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ namespace CryptoExchange.Net.RateLimiting.Guards
|
|||||||
TimeSpan period,
|
TimeSpan period,
|
||||||
RateLimitWindowType windowType,
|
RateLimitWindowType windowType,
|
||||||
TimeSpan? safetyMargin = null,
|
TimeSpan? safetyMargin = null,
|
||||||
double? decayRate = null,
|
Func<RequestDefinition, string?, string>? keySelector = null,
|
||||||
Func<RequestDefinition, string?, string>? keySelector = null)
|
double? decayRate = null)
|
||||||
{
|
{
|
||||||
_limit = limit;
|
_limit = limit;
|
||||||
_period = period;
|
_period = period;
|
||||||
|
|||||||
@@ -78,6 +78,474 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetAssetAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedAsset>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetAsset>> capabilities,
|
||||||
|
GetAssetRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetAssetAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetAssetAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedAsset>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetAssetRest>> capabilities,
|
||||||
|
GetAssetRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetAssetAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetAllAssetsAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedAsset[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetAllAssets>> capabilities,
|
||||||
|
GetAssetsRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetAllAssetsAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetAllAssetsAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedAsset[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetAllAssetsRest>> capabilities,
|
||||||
|
GetAssetsRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetAllAssetsAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetBalancesAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedBalance[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetBalancesRest>> capabilities,
|
||||||
|
GetBalancesRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetBalancesAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetBalancesAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedBalance[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetBalances>> capabilities,
|
||||||
|
GetBalancesRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetBalancesAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetFeesAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedFee>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetFeesRest>> capabilities,
|
||||||
|
GetFeeRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetFeesAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetFeesAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedFee>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetFees>> capabilities,
|
||||||
|
GetFeeRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetFeesAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetFundingInfoAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedFundingInfo>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetFundingInfoRest>> capabilities,
|
||||||
|
GetFundingInfoRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetFundingInfoAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetFundingInfoAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedFundingInfo>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetFundingInfo>> capabilities,
|
||||||
|
GetFundingInfoRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetFundingInfoAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetIndexPriceAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedIndexPrice>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetIndexPriceRest>> capabilities,
|
||||||
|
GetIndexPriceRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetIndexPriceAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetIndexPriceAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedIndexPrice>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetIndexPrice>> capabilities,
|
||||||
|
GetIndexPriceRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetIndexPriceAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetMarkPriceAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedMarkPrice>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetMarkPriceRest>> capabilities,
|
||||||
|
GetMarkPriceRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetMarkPriceAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetMarkPriceAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedMarkPrice>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetMarkPrice>> capabilities,
|
||||||
|
GetMarkPriceRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetMarkPriceAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetAllMarkPricesAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedMarkPrice[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetAllMarkPricesRest>> capabilities,
|
||||||
|
GetAllMarkPricesRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetAllMarkPricesAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetAllMarkPricesAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedMarkPrice[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetAllMarkPrices>> capabilities,
|
||||||
|
GetAllMarkPricesRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetAllMarkPricesAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetAllIndexPricesAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedIndexPrice[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetAllIndexPricesRest>> capabilities,
|
||||||
|
GetAllIndexPricesRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetAllIndexPricesAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetAllIndexPricesAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedIndexPrice[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetAllIndexPrices>> capabilities,
|
||||||
|
GetAllIndexPricesRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetAllIndexPricesAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetLeverageAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedLeverage>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetLeverageRest>> capabilities,
|
||||||
|
GetLeverageRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetLeverageAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetLeverageAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedLeverage>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetLeverage>> capabilities,
|
||||||
|
GetLeverageRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetLeverageAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetLeverageTiersAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedLeverageTier[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetLeverageTiersRest>> capabilities,
|
||||||
|
GetLeverageTiersRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetLeverageTiersAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetLeverageTiersAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedLeverageTier[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetLeverageTiers>> capabilities,
|
||||||
|
GetLeverageTiersRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetLeverageTiersAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetOpenInterestAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedOpenInterest>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetOpenInterestRest>> capabilities,
|
||||||
|
GetOpenInterestRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetOpenInterestAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetOpenInterestAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedOpenInterest>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetOpenInterest>> capabilities,
|
||||||
|
GetOpenInterestRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetOpenInterestAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetBookTickerAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedBookTicker>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetBookTickerRest>> capabilities,
|
||||||
|
GetBookTickerRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetBookTickerAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetBookTickerAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedBookTicker>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetBookTicker>> capabilities,
|
||||||
|
GetBookTickerRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetBookTickerAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetOrderBookAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedOrderBook>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetOrderBookRest>> capabilities,
|
||||||
|
GetOrderBookRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetOrderBookAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetOrderBookAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedOrderBook>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetOrderBook>> capabilities,
|
||||||
|
GetOrderBookRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetOrderBookAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetPositionModeAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedPositionModeResult>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetPositionModeRest>> capabilities,
|
||||||
|
GetPositionModeRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetPositionModeAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetPositionModeAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedPositionModeResult>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetPositionMode>> capabilities,
|
||||||
|
GetPositionModeRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetPositionModeAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetPositionsAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedPosition[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetPositionsRest>> capabilities,
|
||||||
|
GetPositionsRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetPositionsAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetPositionsAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedPosition[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetPositions>> capabilities,
|
||||||
|
GetPositionsRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetPositionsAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetSpotSymbolsAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedSpotSymbol[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetSpotSymbolsRest>> capabilities,
|
||||||
|
GetSymbolsRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetSpotSymbolsAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetSpotSymbolsAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedSpotSymbol[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetSpotSymbols>> capabilities,
|
||||||
|
GetSymbolsRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetSpotSymbolsAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetFuturesSymbolsAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<HttpResult<SharedFuturesSymbol[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetFuturesSymbolsRest>> capabilities,
|
||||||
|
GetSymbolsRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetFuturesSymbolsAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetFuturesSymbolsAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedFuturesSymbol[]>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetFuturesSymbols>> capabilities,
|
||||||
|
GetSymbolsRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetFuturesSymbolsAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute GetTickerAsync for all capabilities in parallel and return results as they arrive
|
/// Execute GetTickerAsync for all capabilities in parallel and return results as they arrive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -91,6 +559,19 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
.ParallelEnumerateAsync();
|
.ParallelEnumerateAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Execute GetTickerAsync for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<IExchangeCallResult<SharedTicker>> ExecuteAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<IGetTicker>> capabilities,
|
||||||
|
GetTickerRequest request,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.GetTickerAsync(request, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute GetAllTickersAsync for all capabilities in parallel and return results as they arrive
|
/// Execute GetAllTickersAsync for all capabilities in parallel and return results as they arrive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -105,55 +586,43 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute GetAssetAsync for all capabilities in parallel and return results as they arrive
|
/// Execute GetAllTickersAsync for all capabilities in parallel and return results as they arrive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IAsyncEnumerable<HttpResult<SharedAsset>> ExecuteAllAsync(
|
public static IAsyncEnumerable<IExchangeCallResult<SharedTicker[]>> ExecuteAllAsync(
|
||||||
this IEnumerable<SharedCapabilityResolution<IGetAssetRest>> capabilities,
|
this IEnumerable<SharedCapabilityResolution<IGetAllTickers>> capabilities,
|
||||||
GetAssetRequest request,
|
GetTickersRequest request,
|
||||||
CancellationToken ct = default)
|
CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
return capabilities
|
return capabilities
|
||||||
.Select(x => x.Capability.GetAssetAsync(request, ct))
|
.Select(x => x.Capability.GetAllTickersAsync(request, ct))
|
||||||
.ParallelEnumerateAsync();
|
.ParallelEnumerateAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute GetAllAssetsAsync for all capabilities in parallel and return results as they arrive
|
/// Execute GetRecentTradesAsync for all capabilities in parallel and return results as they arrive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IAsyncEnumerable<HttpResult<SharedAsset[]>> ExecuteAllAsync(
|
public static IAsyncEnumerable<HttpResult<SharedTrade[]>> ExecuteAllAsync(
|
||||||
this IEnumerable<SharedCapabilityResolution<IGetAllAssetsRest>> capabilities,
|
this IEnumerable<SharedCapabilityResolution<IGetRecentTradesRest>> capabilities,
|
||||||
GetAssetsRequest request,
|
GetRecentTradesRequest request,
|
||||||
CancellationToken ct = default)
|
CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
return capabilities
|
return capabilities
|
||||||
.Select(x => x.Capability.GetAllAssetsAsync(request, ct))
|
.Select(x => x.Capability.GetRecentTradesAsync(request, ct))
|
||||||
.ParallelEnumerateAsync();
|
.ParallelEnumerateAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute GetAllBalancesAsync for all capabilities in parallel and return results as they arrive
|
/// Execute GetRecentTradesAsync for all capabilities in parallel and return results as they arrive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IAsyncEnumerable<HttpResult<SharedBalance[]>> ExecuteAllAsync(
|
public static IAsyncEnumerable<IExchangeCallResult<SharedTrade[]>> ExecuteAllAsync(
|
||||||
this IEnumerable<SharedCapabilityResolution<IGetBalancesRest>> capabilities,
|
this IEnumerable<SharedCapabilityResolution<IGetRecentTrades>> capabilities,
|
||||||
GetBalancesRequest request,
|
GetRecentTradesRequest request,
|
||||||
CancellationToken ct = default)
|
CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
return capabilities
|
return capabilities
|
||||||
.Select(x => x.Capability.GetBalancesAsync(request, ct))
|
.Select(x => x.Capability.GetRecentTradesAsync(request, ct))
|
||||||
.ParallelEnumerateAsync();
|
.ParallelEnumerateAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Execute GetAllBalancesAsync for all capabilities in parallel and return results as they arrive
|
|
||||||
/// </summary>
|
|
||||||
public static IAsyncEnumerable<ICallResult<SharedBalance[]>> ExecuteAllAsync(
|
|
||||||
this IEnumerable<SharedCapabilityResolution<IGetBalances>> capabilities,
|
|
||||||
GetBalancesRequest request,
|
|
||||||
CancellationToken ct = default)
|
|
||||||
{
|
|
||||||
return capabilities
|
|
||||||
.Select(x => x.Capability.GetBalancesAsync(request, ct))
|
|
||||||
.ParallelEnumerateAsync();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request">Request info</param>
|
/// <param name="request">Request info</param>
|
||||||
/// <param name="ct">Cancellation token</param>
|
/// <param name="ct">Cancellation token</param>
|
||||||
Task<ICallResult<SharedFuturesSymbol[]>> GetFuturesSymbolsAsync(GetSymbolsRequest request, CancellationToken ct = default);
|
Task<IExchangeCallResult<SharedFuturesSymbol[]>> GetFuturesSymbolsAsync(GetSymbolsRequest request, CancellationToken ct = default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="request">Request info</param>
|
/// <param name="request">Request info</param>
|
||||||
/// <param name="ct">Cancellation token</param>
|
/// <param name="ct">Cancellation token</param>
|
||||||
Task<ICallResult<SharedSpotSymbol[]>> GetSpotSymbolsAsync(GetSymbolsRequest request, CancellationToken ct = default);
|
Task<IExchangeCallResult<SharedSpotSymbol[]>> GetSpotSymbolsAsync(GetSymbolsRequest request, CancellationToken ct = default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user