Exemplo n.º 1
0
        public void QAVQTest(QAVTest test)
        {
            Avq.UrlContenResult = File.ReadAllText(AvTimeSeriesGlobalQuoteJsonTestFile);
            object actual = Avq.QAVQ(test.Symbol, info: test.Info);

            Assert.Equal(test.Expected, actual);
        }
Exemplo n.º 2
0
        public void QAVQWebTest(QAVTest test)
        {
            Avq.UrlContenResult = FfeWeb.GetHttpResponseContent($"https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol={test.Symbol}&apikey={test.ApiKey}");
            object actual = Avq.QAVQ(test.Symbol, info: test.Info);

            // If a date specific argument was given, then stock info may not available when trading date is on weekend or a public holiday.
            DateTime tradingDate = DateTime.Today.AddDays(test.DatePart);

            if (tradingDate.DayOfWeek == DayOfWeek.Saturday ||
                tradingDate.DayOfWeek == DayOfWeek.Sunday ||
                DateSystem.IsPublicHoliday(tradingDate, CountryCode.US))
            {
                // No quotes are available on the weekend or on public holidays.
                Assert.True(ExcelError.ExcelErrorNA.Equals(actual) ||
                            actual is DateTime ||
                            actual is string ||
                            actual is decimal);
            }
            else
            {
                switch (test.Info)
                {
                case "latest trading day":
                    Assert.IsType <DateTime>(actual);
                    break;

                case "change percent":
                    Assert.IsType <string>(actual);
                    break;

                default:
                    Assert.IsType <decimal>(actual);
                    break;
                }
            }
        }