mirror of
https://github.com/JKorf/CryptoExchange.Net.git
synced 2026-10-04 02:11:11 +00:00
Added Shared API ISubscribeFundingInfoSocket
This commit is contained in:
@@ -668,6 +668,20 @@ namespace CryptoExchange.Net.SharedApis
|
|||||||
.ParallelEnumerateAsync();
|
.ParallelEnumerateAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Subscribe to funding info updates for all capabilities in parallel and return results as they arrive
|
||||||
|
/// </summary>
|
||||||
|
public static IAsyncEnumerable<WebSocketResult<UpdateSubscription>> SubscribeAllAsync(
|
||||||
|
this IEnumerable<SharedCapabilityResolution<ISubscribeFundingInfoSocket>> capabilities,
|
||||||
|
SubscribeFundingInfoRequest request,
|
||||||
|
Action<DataEvent<SharedFundingInfo>> onData,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
return capabilities
|
||||||
|
.Select(x => x.Capability.SubscribeToFundingInfoUpdatesAsync(request, onData, ct))
|
||||||
|
.ParallelEnumerateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Subscribe to kline updates for all capabilities in parallel and return results as they arrive
|
/// Subscribe to kline updates for all capabilities in parallel and return results as they arrive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
using CryptoExchange.Net.Objects;
|
||||||
|
using CryptoExchange.Net.Objects.Sockets;
|
||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CryptoExchange.Net.SharedApis
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Operation for subscribing to funding info updates
|
||||||
|
/// </summary>
|
||||||
|
public interface ISubscribeFundingInfoSocket : ISharedSubscription
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Funding info subscription options
|
||||||
|
/// </summary>
|
||||||
|
SubscribeFundingInfoOptions SubscribeFundingInfoOptions { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Subscribe to funding info updates
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request">Request info</param>
|
||||||
|
/// <param name="handler">Update handler</param>
|
||||||
|
/// <param name="ct">Cancellation token, can be used to stop the updates</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<WebSocketResult<UpdateSubscription>> SubscribeToFundingInfoUpdatesAsync(SubscribeFundingInfoRequest request, Action<DataEvent<SharedFundingInfo>> handler, CancellationToken ct = default);
|
||||||
|
}
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
using CryptoExchange.Net.Objects;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace CryptoExchange.Net.SharedApis
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Options for subscribing to funding info updates
|
||||||
|
/// </summary>
|
||||||
|
public class SubscribeFundingInfoOptions : CapabilityOptions<SubscribeFundingInfoRequest, ISubscribeFundingInfoSocket>
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override string Description => "Subscribe to funding info updates for a symbol";
|
||||||
|
|
||||||
|
private static readonly RequestParameterDescription[] _defaultParameterRules = new[]
|
||||||
|
{
|
||||||
|
RequestParameterRule<SubscribeFundingInfoRequest>.Optional(x => x.Symbol, "The symbol to subscribe to", new SharedSymbol(TradingMode.PerpetualLinear, "ETH", "USDT")),
|
||||||
|
RequestParameterRule<SubscribeFundingInfoRequest>.Optional(x => x.Symbols, "The symbols to subscribe to", new[] { new SharedSymbol(TradingMode.PerpetualLinear, "ETH", "USDT") }),
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ctor
|
||||||
|
/// </summary>
|
||||||
|
public SubscribeFundingInfoOptions(string exchange, bool needsAuthentication)
|
||||||
|
: base(exchange, needsAuthentication, nameof(ISubscribeFundingInfoSocket.SubscribeToFundingInfoUpdatesAsync), _defaultParameterRules, SharedTradingModeSets.Futures)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace CryptoExchange.Net.SharedApis
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Request to subscribe to funding info updates for a symbol
|
||||||
|
/// </summary>
|
||||||
|
public record SubscribeFundingInfoRequest : SharedSymbolRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ctor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="symbol">The symbol to subscribe to</param>
|
||||||
|
/// <param name="exchangeParameters">Exchange specific parameters</param>
|
||||||
|
public SubscribeFundingInfoRequest(SharedSymbol symbol, ExchangeParameters? exchangeParameters = null)
|
||||||
|
: base(symbol, exchangeParameters)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ctor
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="symbols">The symbols to subscribe to</param>
|
||||||
|
/// <param name="exchangeParameters">Exchange specific parameters</param>
|
||||||
|
public SubscribeFundingInfoRequest(IEnumerable<SharedSymbol> symbols, ExchangeParameters? exchangeParameters = null)
|
||||||
|
: base(symbols, exchangeParameters)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user