Exemple #1
0
        /// <summary>
        /// Get Candlesticks
        /// </summary>
        /// <param name="symbol">Trading Symbol</param>
        /// <param name="interval">Candlestick Interval</param>
        /// <param name="range">Number of sticks to return</param>
        /// <returns>BotStick Array</returns>
        public BotStick[] GetCandlesticks(string symbol, Interval interval, int range)
        {
            int i = 0;

            if (_thisExchange == Exchange.BINANCE)
            {
                Candlestick[] sticks = null;

                while (sticks == null && i < 3)
                {
                    i++;
                    sticks = _bianceRepo.GetCandlestick(symbol, interval, range).Result;
                }

                return(BinanceStickToBotStick(sticks));
            }
            else if (_thisExchange == Exchange.GDAX)
            {
                var trades = _gdaxRepo.GetTrades(symbol).Result;

                while (trades == null)
                {
                    trades = _gdaxRepo.GetTrades(symbol).Result;
                }

                return(GetSticksFromGdaxTrades(trades, range));
            }
            else if (_thisExchange == Exchange.KUCOIN)
            {
                range = 10;
                var values = _kuRepo.GetCandlesticks(symbol, interval, range).Result;
                while ((values == null || values.close.Length == 0) && i < 3)
                {
                    i++;
                    values = _kuRepo.GetCandlesticks(symbol, interval, range).Result;
                }
                return(values.close.Length == 0 ? new BotStick[0] : KuCoinChartValueArrayToBotStickArray(values));
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        public void GetCandlesticksTest()
        {
            var interval = Interval.FifteenM;
            var symbol   = "ETH-BTC";

            var sticks = _repo.GetCandlesticks(symbol, interval, 10).Result;

            Assert.True(sticks != null);
            Assert.True(sticks.close.Length > 0);
            Assert.True(sticks.open.Length > 0);
        }