Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="symbol"></param>
        /// <param name="limit"></param>
        /// <param name="callback"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static Task StreamAsync(this IAggregateTradeCache cache, string symbol, int limit, Action <AggregateTradeCacheEventArgs> callback, CancellationToken token)
        {
            Throw.IfNull(cache, nameof(cache));

            cache.Subscribe(symbol, limit, callback);

            return(cache.Client.WebSocket.StreamAsync(token));
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="symbol"></param>
 /// <param name="callback"></param>
 /// <returns></returns>
 public static void Subscribe(this IAggregateTradeCache cache, string symbol, Action <AggregateTradeCacheEventArgs> callback)
 => cache.Subscribe(symbol, default, callback);
 /// <summary>
 ///
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="symbol"></param>
 /// <param name="limit"></param>
 /// <returns></returns>
 public static void Subscribe(this IAggregateTradeCache cache, string symbol, int limit)
 => cache.Subscribe(symbol, limit, null);
 /// <summary>
 ///
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="symbol"></param>
 /// <returns></returns>
 public static void Subscribe(this IAggregateTradeCache cache, string symbol)
 => cache.Subscribe(symbol, default, null);
Beispiel #5
0
        internal static async Task DisableLiveTask()
        {
            LiveTokenSource?.Cancel();

            // Wait for live task to complete.
            if (LiveTask != null && !LiveTask.IsCompleted)
            {
                await LiveTask;
            }

            LiveTokenSource?.Dispose();

            if (TradeCache != null)
            {
                lock (ConsoleSync)
                {
                    Console.WriteLine();
                    Console.WriteLine("  ...live trades feed disabled.");
                }
            }
            TradeCache = null;

            if (OrderBookCache != null)
            {
                lock (ConsoleSync)
                {
                    Console.WriteLine();
                    Console.WriteLine("  ...live order book feed disabled.");
                }
            }
            OrderBookCache = null;

            if (CandlestickCache != null)
            {
                lock (ConsoleSync)
                {
                    Console.WriteLine();
                    Console.WriteLine("  ...live candlestick feed disabled.");
                }
            }
            CandlestickCache = null;

            if (AggregateTradeCache != null)
            {
                lock (ConsoleSync)
                {
                    Console.WriteLine();
                    Console.WriteLine("  ...live aggregate trades feed disabled.");
                }
            }
            AggregateTradeCache = null;

            if (UserDataClient != null)
            {
                lock (ConsoleSync)
                {
                    Console.WriteLine();
                    Console.WriteLine("  ...live account feed disabled.");
                }
            }
            UserDataClient = null;

            LiveTokenSource = null;
            LiveTask        = null;
        }
Beispiel #6
0
 /// <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 IAggregateTradeCache cache, string symbol, Action <AggregateTradeCacheEventArgs> callback, CancellationToken token)
 => cache.SubscribeAsync(symbol, default, callback, token);
Beispiel #7
0
 /// <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 IAggregateTradeCache cache, string symbol, int limit, CancellationToken token)
 => cache.SubscribeAsync(symbol, limit, null, token);
Beispiel #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="symbol"></param>
 /// <param name="limit"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 public static Task StreamAsync(this IAggregateTradeCache cache, string symbol, int limit, CancellationToken token)
 => StreamAsync(cache, symbol, limit, null, token);
Beispiel #9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="cache"></param>
 /// <param name="symbol"></param>
 /// <param name="token"></param>
 /// <returns></returns>
 public static Task SubscribeAndStreamAsync(this IAggregateTradeCache cache, string symbol, CancellationToken token)
 => SubscribeAndStreamAsync(cache, symbol, default, null, token);
Beispiel #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static Task StreamAsync(this IAggregateTradeCache cache, CancellationToken token)
        {
            Throw.IfNull(cache, nameof(cache));

            return(cache.Client.WebSocket.StreamAsync(token));
        }