private async Task TestCandle(IExchangeAPI api, string marketSymbol)
        {
            if (FunctionRegex == null || Regex.IsMatch("candle", FunctionRegex, RegexOptions.IgnoreCase))
            {
                try
                {
                    Console.Write("Test {0} GetCandlesAsync... ", api.Name);
                    var candles = (await api.GetCandlesAsync(marketSymbol, 86400,
                                                             CryptoUtility.UtcNow.Subtract(TimeSpan.FromDays(7.0)), null)).ToArray();
                    Assert(candles.Length != 0 && candles[0].ClosePrice > 0m && candles[0].HighPrice > 0m &&
                           candles[0].LowPrice > 0m && candles[0].OpenPrice > 0m &&
                           candles[0].HighPrice >= candles[0].LowPrice &&
                           candles[0].HighPrice >= candles[0].ClosePrice &&
                           candles[0].HighPrice >= candles[0].OpenPrice &&
                           !string.IsNullOrWhiteSpace(candles[0].Name) && candles[0].ExchangeName == api.Name &&
                           candles[0].PeriodSeconds == 86400 && candles[0].BaseCurrencyVolume > 0.0 &&
                           candles[0].QuoteCurrencyVolume > 0.0 && candles[0].WeightedAverage >= 0m);

                    Console.WriteLine($"OK ({candles.Length})");
                }
                catch (NotImplementedException)
                {
                    Console.WriteLine("Not implemented");
                }
                catch
                {
                    // These API require private access to get candles end points
                    if (!(api is ExchangeKuCoinAPI))
                    {
                        throw;
                    }
                }
            }
        }
Beispiel #2
0
        public void GetDataFromMarketWithSpecialChar()
        {
            IExchangeAPI api          = ExchangeAPI.GetExchangeAPIAsync("Bitfinex").Result;
            string       marketTicker = "DOGE:USD";
            DateTime     start        = new DateTime(2021, 12, 1);
            DateTime     end          = DateTime.Today;

            System.Collections.Generic.IEnumerable <MarketCandle> result = api.GetCandlesAsync(marketTicker, 86400, start, end, 1000).Result;
            result.Should().HaveCountGreaterThan(0, "Returned data");
        }