public void GetCurrency_Using300_Return300Entries()
        {
            ICoinmarketcapClient m_Sut = new CoinmarketcapClient(API_KEY);
            var retValue = m_Sut.GetCurrencies(300);

            retValue.Count().Should().Be(300);
        }
        public void GetCurrencyBySlug_WrongCurrency_ThrowsException()
        {
            ICoinmarketcapClient m_Sut = new CoinmarketcapClient(API_KEY);
            Action act = () => m_Sut.GetCurrencyBySlug("AnyWrongCurrency");

            act.Should().Throw <HttpRequestException>();
        }
        public void GetCurrency_Nothing_Return100()
        {
            ICoinmarketcapClient m_Sut = new CoinmarketcapClient(API_KEY);
            var retValue = m_Sut.GetCurrencies();

            retValue.Count().Should().Be(100);
        }
        public void GetCurrency_Nothing_ReturnAll()
        {
            ICoinmarketcapClient m_Sut = new CoinmarketcapClient();
            var retValue = m_Sut.GetCurrencies();

            retValue.Count().Should().BeGreaterThan(900);
        }
Exemple #5
0
        private async void AnalyzeCurrencies()
        {
            ICoinmarketcapClient client      = new CoinmarketcapClient("ed57fadd-e7a7-4eb8-8fd5-ab510d358856");
            IMailService         mailService = new MailService();

            while (true)
            {
                DateTime currentTime = DateTime.Now;

                IEnumerable <Currency> currencies = client.GetCurrencies(1500, "USD");

                // Algorithm for identifying potential data
                List <Currency> currenciesToNotify = FindPotentialCoinsInBullishTrend(currencies);

                if (currenciesToNotify.Count > 0)
                {
                    // Verify if any found coin has already been notified in the last 24h
                    currenciesToNotify = await RemoveCoinsWithExistingNotification(currenciesToNotify);

                    // If there are still coins to be notified
                    if (currenciesToNotify.Count > 0)
                    {
                        string mailMessage = AssembleMailNotification(currenciesToNotify);
                        mailService.Send("Irmãos ao Crypto - NEW Bullish coins", mailMessage);

                        // Update database with this notification
                        await UpdateNotificationsAtDB(currenciesToNotify);
                    }
                }

                Thread.Sleep(4000000);
            }
        }
        public static IList <Currency> GetCurrencyList()
        {
            if (ConfigHelper.DisplayUnitUSDValue ||
                ConfigHelper.DisplayPercentage1h ||
                ConfigHelper.DisplayPercentage24h ||
                ConfigHelper.DisplayPercentage7d ||
                ConfigHelper.DisplayRank ||
                ConfigHelper.DisplayMarketCap
                )
            {
                try
                {
                    ICoinmarketcapClient client = new CoinmarketcapClient();
                    return(client.GetCurrencies(ConfigHelper.CoinMarketCapFetchCount).ToList());
                }
                catch
                {
                    ApiProblemDetected = true;
                    ConfigHelper.DisplayUnitUSDValue  = false;
                    ConfigHelper.DisplayPercentage1h  = false;
                    ConfigHelper.DisplayPercentage24h = false;
                    ConfigHelper.DisplayPercentage7d  = false;
                    ConfigHelper.DisplayRank          = false;
                    ConfigHelper.DisplayMarketCap     = false;
                }
            }

            return(null);
        }
        public void GetCurrencyById_WrongCurrency_ThrowsException()
        {
            ICoinmarketcapClient m_Sut = new CoinmarketcapClient();
            Action act = () => m_Sut.GetCurrencyById("AnyWrongCurrency");

            act.ShouldThrow <AggregateException>().Where(e => e.InnerExceptions[0].Message.Contains("404"));
        }
        public void GetCoinCapListingsNoobsMucTest()
        {
            ICoinmarketcapClient      client     = new CoinmarketcapClient(Global.CoinmarketcapApiKey);
            IEnumerable <CmcCurrency> currencies = client.GetCurrencies(5000);

            Output.WriteLine(
                string.Join(",\n", currencies.Select(c => String.Concat(c.Id, ":", c.Name, ":", c.Symbol)).ToArray())
                );
        }
        public void GetCurrencyBySlug_Bitcoin_ReturnBitcoinDetail()
        {
            ICoinmarketcapClient m_Sut    = new CoinmarketcapClient(API_KEY);
            Currency             currency = m_Sut.GetCurrencyBySlug("bitcoin");

            currency.Name.Should().Be("Bitcoin");
            currency.Symbol.Should().Be("BTC");
            currency.Price.Should().NotBe(null);
            currency.MarketCapConvert.Should().NotBe(null);
        }
        public void GetCurrencyBySlug_PivxInEur_ReturnPivxDetail()
        {
            ICoinmarketcapClient m_Sut    = new CoinmarketcapClient(API_KEY);
            Currency             currency = m_Sut.GetCurrencyBySlug("pivx", "EUR");

            currency.Name.Should().Be("PIVX");
            currency.Symbol.Should().Be("PIVX");
            currency.Price.Should().NotBe(null);
            currency.MarketCapConvert.Should().NotBe(null);
            currency.ConvertCurrency.Should().Be("EUR");
        }
        public void GetCurrencyById_Bitcoin_ReturnBitcoinDetail()
        {
            ICoinmarketcapClient m_Sut    = new CoinmarketcapClient();
            Currency             currency = m_Sut.GetCurrencyById("bitcoin");

            currency.Id.Should().Be("bitcoin");
            currency.Symbol.Should().Be("BTC");
            currency.PriceConvert.Should().BeNull();
            currency.MarketCapConvert.Should().BeNull();
            currency.Volume24Convert.Should().BeNull();
        }
        public void GetCurrencyById_PivxInEur_ReturnPivxDetail()
        {
            ICoinmarketcapClient m_Sut    = new CoinmarketcapClient();
            Currency             currency = m_Sut.GetCurrencyById("pivx", "EUR");

            currency.Id.Should().Be("pivx");
            currency.Symbol.Should().Be("PIVX");
            currency.PriceConvert.Should().NotBeNullOrEmpty();
            currency.MarketCapConvert.Should().NotBeNullOrEmpty();
            currency.Volume24Convert.Should().NotBeNullOrEmpty();
            currency.ConvertCurrency.Should().Be("EUR");
        }
        public void GetCurrency_UsingJPYAnd200_Return200Entries()
        {
            ICoinmarketcapClient   m_Sut    = new CoinmarketcapClient(API_KEY);
            IEnumerable <Currency> retValue = m_Sut.GetCurrencies(200, "JPY");

            retValue.Count().Should().Be(200);
            retValue.First().Price.Should().NotBe(null);
            retValue.First().MarketCapConvert.Should().NotBe(null);
            retValue.First().ConvertCurrency.Should().Be("JPY");

            retValue.Last().Price.Should().NotBe(null);
            retValue.Last().MarketCapConvert.Should().NotBe(null);
            retValue.Last().ConvertCurrency.Should().Be("JPY");
        }
        public void GetCurrency_UsingGBP_ReturnCurrencyWithConverted()
        {
            ICoinmarketcapClient m_Sut = new CoinmarketcapClient(API_KEY);
            var retValue = m_Sut.GetCurrencies("GBP");

            retValue.Count().Should().Be(100);
            retValue.First().Price.Should().NotBe(null);;
            retValue.First().MarketCapConvert.Should().NotBe(null);
            retValue.First().ConvertCurrency.Should().Be("GBP");

            retValue.Take(155).Last().Price.Should().NotBe(null);
            retValue.Take(155).Last().MarketCapConvert.Should().NotBe(null);
            retValue.Take(155).Last().ConvertCurrency.Should().Be("GBP");
        }
        public void GetCurrency_UsingJPYAnd200_Return200Entries()
        {
            ICoinmarketcapClient m_Sut = new CoinmarketcapClient();
            var retValue = m_Sut.GetCurrencies(200, "JPY");

            retValue.Count().Should().Be(200);
            retValue.First().PriceConvert.Should().NotBeNullOrEmpty();
            retValue.First().MarketCapConvert.Should().NotBeNullOrEmpty();
            retValue.First().Volume24Convert.Should().NotBeNullOrEmpty();
            retValue.First().ConvertCurrency.Should().Be("JPY");

            retValue.Last().PriceConvert.Should().NotBeNullOrEmpty();
            retValue.Last().MarketCapConvert.Should().NotBeNullOrEmpty();
            retValue.Last().Volume24Convert.Should().NotBeNullOrEmpty();
            retValue.Last().ConvertCurrency.Should().Be("JPY");
        }
        public void GetCurrency_UsingGBP_ReturnAllCurrencyWithConverted()
        {
            ICoinmarketcapClient m_Sut = new CoinmarketcapClient();
            var retValue = m_Sut.GetCurrencies("GBP");

            retValue.Count().Should().BeGreaterThan(900);
            retValue.First().PriceConvert.Should().NotBeNullOrEmpty();
            retValue.First().MarketCapConvert.Should().NotBeNullOrEmpty();
            retValue.First().Volume24Convert.Should().NotBeNullOrEmpty();
            retValue.First().ConvertCurrency.Should().Be("GBP");

            retValue.Take(155).Last().PriceConvert.Should().NotBeNullOrEmpty();
            retValue.Take(155).Last().MarketCapConvert.Should().NotBeNullOrEmpty();
            retValue.Take(155).Last().Volume24Convert.Should().NotBeNullOrEmpty();
            retValue.Take(155).Last().ConvertCurrency.Should().Be("GBP");
        }
        public void GetCurrencyBySlugList_StratisIrisnet_ReturnBitcoinDetail()
        {
            //StraTis-> test with upper and lower case
            ICoinmarketcapClient m_Sut        = new CoinmarketcapClient(API_KEY);
            List <Currency>      currencyList = m_Sut.GetCurrencyBySlugList(new[] { "StraTis", "irisnet" }).ToList();

            currencyList[0].Name.Should().Be("Stratis");
            currencyList[0].Symbol.Should().Be("STRAT");
            currencyList[0].Price.Should().NotBe(null);
            currencyList[0].MarketCapConvert.Should().NotBe(null);

            currencyList[1].Name.Should().Be("IRISnet");
            currencyList[1].Symbol.Should().Be("IRIS");
            currencyList[1].Price.Should().NotBe(null);
            currencyList[1].MarketCapConvert.Should().NotBe(null);
        }
Exemple #18
0
        static void UpdateCurrencies()
        {
            int      attempts                 = 0;
            TimeSpan attemptLength            = default(TimeSpan);
            IEnumerable <Currency> currencies = null;

            do
            {
                attempts++;
                var task = new Task(() =>
                {
                    try
                    {
                        DateTime start            = DateTime.Now;
                        ICoinmarketcapClient cmcc = new CoinmarketcapClient();
                        currencies    = cmcc.GetCurrencies(100000);
                        DateTime end  = DateTime.Now;
                        attemptLength = end - start;
                    }
                    catch
                    {
                    }
                });
                task.Start();

                //TODO: This hangs on occasion

                task.Wait(1000);
            } while (currencies == null);
            Currencies = currencies;

            if (attempts > 1)
            {
                // This get annoying
                //new MessageBox.MessageBoxService().ShowMessage($"CoinMarket Took {attempts} attempts to get the data. Success took {attemptLength.TotalSeconds} seconds.", "Coinmarket took multiple attempts to retrieve data.", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Exclamation);
            }
        }
Exemple #19
0
 public static void Main()
 {
     ICoinmarketcapClient client = new CoinmarketcapClient();
     var currencies = client.GetCurrencies(50);
 }