/// <summary> /// The DI constructor. /// </summary> /// <param name="aggregateTradeClient"></param> /// <param name="candlestickClient"></param> /// <param name="depthClient"></param> /// <param name="statisticsClient"></param> /// <param name="tradeClient"></param> /// <param name="logger"></param> protected BinanceJsonClientManager( IAggregateTradeWebSocketClient aggregateTradeClient, ICandlestickWebSocketClient candlestickClient, IDepthWebSocketClient depthClient, ISymbolStatisticsWebSocketClient statisticsClient, ITradeWebSocketClient tradeClient, ILogger<BinanceJsonClientManager<TStream>> logger = null) { Throw.IfNull(aggregateTradeClient, nameof(aggregateTradeClient)); Throw.IfNull(candlestickClient, nameof(candlestickClient)); Throw.IfNull(depthClient, nameof(depthClient)); Throw.IfNull(statisticsClient, nameof(statisticsClient)); Throw.IfNull(tradeClient, nameof(tradeClient)); AggregateTradeClient = aggregateTradeClient; CandlestickClient = candlestickClient; DepthClient = depthClient; StatisticsClient = statisticsClient; TradeClient = tradeClient; _logger = logger; // Forward controller error events. aggregateTradeClient.Error += HandleError; candlestickClient.Error += HandleError; depthClient.Error += HandleError; statisticsClient.Error += HandleError; tradeClient.Error += HandleError; }
/// <summary> /// /// </summary> /// <param name="client"></param> /// <param name="symbol"></param> /// <param name="limit"></param> /// <param name="callback"></param> /// <param name="token"></param> /// <returns></returns> public static Task StreamAsync(this IDepthWebSocketClient client, string symbol, int limit, Action <DepthUpdateEventArgs> callback, CancellationToken token) { Throw.IfNull(client, nameof(client)); client.Subscribe(symbol, limit, callback); return(client.WebSocket.StreamAsync(token)); }
/// <summary> /// The DI constructor. /// </summary> /// <param name="aggregateTradeWebSocketClient"></param> /// <param name="candlestickWebSocketClient"></param> /// <param name="depthWebSocketClient"></param> /// <param name="symbolStatisticsWebSocketClient"></param> /// <param name="tradeWebSocketClient"></param> /// <param name="logger"></param> public BinanceWebSocketClientManager( IAggregateTradeWebSocketClient aggregateTradeWebSocketClient, ICandlestickWebSocketClient candlestickWebSocketClient, IDepthWebSocketClient depthWebSocketClient, ISymbolStatisticsWebSocketClient symbolStatisticsWebSocketClient, ITradeWebSocketClient tradeWebSocketClient, ILogger <BinanceWebSocketClientManager> logger = null) : base(aggregateTradeWebSocketClient, candlestickWebSocketClient, depthWebSocketClient, symbolStatisticsWebSocketClient, tradeWebSocketClient, logger) { }
/// <summary> /// /// </summary> /// <param name="client"></param> /// <param name="symbol"></param> /// <param name="callback"></param> /// <param name="token"></param> /// <returns></returns> public static Task StreamAsync(this IDepthWebSocketClient client, string symbol, Action <DepthUpdateEventArgs> callback, CancellationToken token) => StreamAsync(client, symbol, default, callback, token);
/// <summary> /// /// </summary> /// <param name="client"></param> /// <param name="symbol"></param> /// <param name="limit"></param> /// <param name="token"></param> /// <returns></returns> public static Task StreamAsync(this IDepthWebSocketClient client, string symbol, int limit, CancellationToken token) => client.StreamAsync(symbol, limit, null, token);
/// <summary> /// /// </summary> /// <param name="client"></param> /// <param name="symbol"></param> /// <param name="callback"></param> /// <returns></returns> public static void Subscribe(this IDepthWebSocketClient client, string symbol, Action <DepthUpdateEventArgs> callback) => client.Subscribe(symbol, default, callback);
/// <summary> /// /// </summary> /// <param name="client"></param> /// <param name="symbol"></param> /// <param name="limit"></param> /// <returns></returns> public static void Subscribe(this IDepthWebSocketClient client, string symbol, int limit) => client.Subscribe(symbol, limit, null);
/// <summary> /// /// </summary> /// <param name="client"></param> /// <param name="symbol"></param> /// <returns></returns> public static void Subscribe(this IDepthWebSocketClient client, string symbol) => client.Subscribe(symbol, default, null);
/// <summary> /// /// </summary> /// <param name="client"></param> /// <param name="token"></param> /// <returns></returns> public static Task StreamAsync(this IDepthWebSocketClient client, CancellationToken token) { Throw.IfNull(client, nameof(client)); return(client.WebSocket.StreamAsync(token)); }
public KucoinWebSocketManager( IAggregateTradeWebSocketClient aggregateTradeClient, ICandlestickWebSocketClient candlestickClient, IDepthWebSocketClient depthClient, ISymbolStatisticsWebSocketClient statisticsClient, ITradeWebSocketClient tradeClient, ILogger <IKucoinWebSocketManager> logger = null) { Throw.IfNull(aggregateTradeClient, nameof(aggregateTradeClient)); Throw.IfNull(candlestickClient, nameof(candlestickClient)); Throw.IfNull(depthClient, nameof(depthClient)); Throw.IfNull(statisticsClient, nameof(statisticsClient)); Throw.IfNull(tradeClient, nameof(tradeClient)); _logger = logger; _aggregateTradeClientAdapter = new AggregateTradeWebSocketClientAdapter( this, aggregateTradeClient, _logger, err => RaiseErrorEvent(_aggregateTradeClientAdapter, err, $"{nameof(IAggregateTradeWebSocketClient)}: Adapter failed.")); _candlestickClientAdapter = new CandlestickWebSocketClientAdapter( this, candlestickClient, _logger, err => RaiseErrorEvent(_candlestickClientAdapter, err, $"{nameof(ICandlestickWebSocketClient)}: Adapter failed.")); _depthClientAdapter = new DepthWebSocketClientAdapter( this, depthClient, _logger, err => RaiseErrorEvent(_depthClientAdapter, err, $"{nameof(IDepthWebSocketClient)}: Adapter failed.")); _statisticsClientAdapter = new SymbolStatisticsWebSocketClientAdapter( this, statisticsClient, _logger, err => RaiseErrorEvent(_statisticsClientAdapter, err, $"{nameof(ISymbolStatisticsWebSocketClient)}: Adapter failed.")); _tradeClientAdapter = new TradeWebSocketClientAdapter( this, tradeClient, _logger, err => RaiseErrorEvent(_tradeClientAdapter, err, $"{nameof(ITradeWebSocketClient)}: Adapter failed.")); _controllers[aggregateTradeClient.WebSocket] = new WebSocketStreamController( aggregateTradeClient.WebSocket, err => RaiseErrorEvent(_aggregateTradeClientAdapter, err, $"{nameof(IAggregateTradeWebSocketClient)}: Controller failed.")); _controllers[candlestickClient.WebSocket] = new WebSocketStreamController( candlestickClient.WebSocket, err => RaiseErrorEvent(_candlestickClientAdapter, err, $"{nameof(ICandlestickWebSocketClient)}: Controller failed.")); _controllers[depthClient.WebSocket] = new WebSocketStreamController( depthClient.WebSocket, err => RaiseErrorEvent(_depthClientAdapter, err, $"{nameof(IDepthWebSocketClient)}: Controller failed.")); _controllers[statisticsClient.WebSocket] = new WebSocketStreamController( statisticsClient.WebSocket, err => RaiseErrorEvent(_statisticsClientAdapter, err, $"{nameof(ISymbolStatisticsWebSocketClient)}: Controller failed.")); _controllers[tradeClient.WebSocket] = new WebSocketStreamController( tradeClient.WebSocket, err => RaiseErrorEvent(_tradeClientAdapter, err, $"{nameof(ITradeWebSocketClient)}: Controller failed.")); }
/// <summary> /// /// </summary> /// <param name="cache"></param> /// <param name="symbol"></param> /// <param name="callback"></param> /// <param name="token"></param> /// <returns></returns> public static Task SubscribeAsync(this IDepthWebSocketClient cache, string symbol, int limit, Action <DepthUpdateEventArgs> callback, CancellationToken token) => cache.SubscribeAsync(symbol, limit, callback, token);
/// <summary> /// /// </summary> /// <param name="cache"></param> /// <param name="symbol"></param> /// <param name="limit"></param> /// <param name="token"></param> /// <returns></returns> public static Task SubscribeAsync(this IDepthWebSocketClient cache, string symbol, int limit, CancellationToken token) => cache.SubscribeAsync(symbol, limit, null, token);
/// <summary> /// /// </summary> /// <param name="client"></param> /// <param name="symbol"></param> /// <param name="token"></param> /// <returns></returns> public static Task SubscribeAsync(this IDepthWebSocketClient client, string symbol, CancellationToken token) => client.SubscribeAsync(symbol, default, null, token);