Example #1
0
        public void TestBLS_GetMultiple_PartialSuccess()
        {
            IQuotesSource source = CreateSource();

            IQuotesSourceGetQuotesParams getQuotesParams = source.CreateGetQuotesParams();

            getQuotesParams.Country = ConfigurationManager.AppSettings["BLS_COUNTRY"];
            getQuotesParams.Tickers.Add(ConfigurationManager.AppSettings["BLS_TICKER_CPI_NSA"]);
            getQuotesParams.Tickers.Add(ConfigurationManager.AppSettings["BLS_TICKER_INVALID"]);
            getQuotesParams.PeriodStart = DateTime.Parse("2019/1/1");
            getQuotesParams.PeriodEnd   = DateTime.Parse("2019/12/12");
            getQuotesParams.TimeFrame   = ETimeFrame.Monthly;

            IQuotesSourceGetQuotesResult getQuotesResult = source.GetQuotes(getQuotesParams);

            Assert.IsNotNull(getQuotesResult);
            Assert.IsTrue(getQuotesResult.Success);
            Assert.False(getQuotesResult.HasErrors, "Unexpected error occured");
            Assert.IsNotNull(getQuotesResult.QuotesData, "QuotesData object was not created");
            Assert.AreEqual(getQuotesResult.QuotesData.Count(), 1, "Unexpected quotes read");
            Assert.IsNotNull(getQuotesResult.QuotesData[0].Quotes, "Quotes array was not created");
            Assert.Greater(getQuotesResult.QuotesData[0].Quotes.Count(), 0, "Quotes were not read");
            Assert.IsNotNull(getQuotesResult.QuotesData[0].Metadata, "Metadata was not crated");
            Assert.Greater(getQuotesResult.QuotesData[0].Metadata.Values.Count, 0, "Metadata values were not read");
        }
Example #2
0
        public void TestBLS_GetMultiple_Success()
        {
            IQuotesSource source = CreateSource();

            IQuotesSourceGetQuotesParams getQuotesParams = source.CreateGetQuotesParams();

            getQuotesParams.Country = ConfigurationManager.AppSettings["BLS_COUNTRY"];
            getQuotesParams.Tickers.Add(ConfigurationManager.AppSettings["BLS_TICKER_CPI_NSA"]);
            getQuotesParams.Tickers.Add(ConfigurationManager.AppSettings["BLS_TICKER_CPI_MEDICAL"]);
            getQuotesParams.PeriodStart = DateTime.Parse("2019/1/1");
            getQuotesParams.PeriodEnd   = DateTime.Parse("2019/12/12");
            getQuotesParams.TimeFrame   = ETimeFrame.Monthly;

            IQuotesSourceGetQuotesResult getQuotesResult = source.GetQuotes(getQuotesParams);

            Assert.IsNotNull(getQuotesResult);
            Assert.IsTrue(getQuotesResult.Success);
            Assert.False(getQuotesResult.HasErrors, "Unexpected error occured");
            Assert.IsNotNull(getQuotesResult.QuotesData, "QuotesData object was not created");
            for (int i = 0; i < getQuotesParams.Tickers.Count; ++i)
            {
                Assert.IsNotNull(getQuotesResult.QuotesData[i].Quotes, string.Format("{0} - Quotes array was not created", getQuotesParams.Tickers[i]));
                Assert.Greater(getQuotesResult.QuotesData[i].Quotes.Count(), 0, string.Format("{0} - Quotes were not read", getQuotesParams.Tickers[i]));
                Assert.IsNotNull(getQuotesResult.QuotesData[i].Metadata, string.Format("{0} - Metadata was not crated", getQuotesParams.Tickers[i]));
                Assert.Greater(getQuotesResult.QuotesData[i].Metadata.Values.Count, 0, string.Format("{0} - Metadata values were not read", getQuotesParams.Tickers[i]));
            }
        }
Example #3
0
        public void SaveQuotes_Multiple_Success()
        {
            IQuotesSource source = CreateSource();
            IQuotesDal    dal    = PrepareQuotesDal();
            IQuotesDalSaveTimeseriesValuesParams saveParams = dal.CreateSaveTimeseriesValuesParams();

            string[] tickers =
            {
                ConfigurationManager.AppSettings["TickerSPY"],
                ConfigurationManager.AppSettings["TickerQQQ"]
            };

            IQuotesSourceGetQuotesParams getQuotesParams = source.CreateGetQuotesParams();

            foreach (var t in tickers)
            {
                getQuotesParams.Tickers.Add(t);
            }

            getQuotesParams.Country = ConfigurationManager.AppSettings["CountryUS"];

            getQuotesParams.PeriodStart = DateTime.Parse("2009/1/1");
            getQuotesParams.PeriodEnd   = DateTime.Parse("2019/1/1");
            getQuotesParams.TimeFrame   = ETimeFrame.Daily;

            IQuotesSourceGetQuotesResult getQuotesResult = source.GetQuotes(getQuotesParams);

            saveParams.Quotes.AddRange(getQuotesResult.QuotesData);

            IQuotesDalSaveTimeseriesValuesResult saveResult = dal.SaveTimeseriesValues(saveParams);

            Assert.IsTrue(saveResult.Success);
            Assert.IsTrue(!saveResult.HasWarnings, "Unexpected warnings while performing save");
            Assert.IsTrue(!saveResult.HasErrors, "Unexpected errors while performing save");
        }
        public void TestStooq_GetQuotesMonthly_InvalidTicker()
        {
            IQuotesSource source = CreateSource();

            IQuotesSourceGetQuotesParams getQuotesParams = source.CreateGetQuotesParams();

            getQuotesParams.Country = ConfigurationManager.AppSettings["STOOQ_COUNTRY"];
            getQuotesParams.Tickers.Add(ConfigurationManager.AppSettings["STOOQ_TICKER_INVALID"]);
            getQuotesParams.PeriodStart = DateTime.Parse("2009/1/1");
            getQuotesParams.PeriodEnd   = DateTime.Parse("2019/1/1");
            getQuotesParams.TimeFrame   = ETimeFrame.Monthly;

            IQuotesSourceGetQuotesResult getQuotesResult = source.GetQuotes(getQuotesParams);

            Assert.IsNotNull(getQuotesResult);
            Assert.IsFalse(getQuotesResult.Success);
            Assert.True(getQuotesResult.HasErrors, "No errors reported");
            Assert.IsNotNull(getQuotesResult.QuotesData, "QuotesData object was not created");
            Assert.AreEqual(getQuotesResult.QuotesData.Count(), 0, "Quotes object is not empty");
        }
        public void TestStooq_GetQuotesMonthly_Success()
        {
            IQuotesSource source = CreateSource();

            IQuotesSourceGetQuotesParams getQuotesParams = source.CreateGetQuotesParams();

            getQuotesParams.Country = ConfigurationManager.AppSettings["STOOQ_COUNTRY"];
            getQuotesParams.Tickers.Add(ConfigurationManager.AppSettings["STOOQ_TICKER_SPY"]);
            getQuotesParams.PeriodStart = DateTime.Parse("2009/1/1");
            getQuotesParams.PeriodEnd   = DateTime.Parse("2019/1/1");
            getQuotesParams.TimeFrame   = ETimeFrame.Monthly;

            IQuotesSourceGetQuotesResult getQuotesResult = source.GetQuotes(getQuotesParams);

            Assert.IsNotNull(getQuotesResult);
            Assert.IsTrue(getQuotesResult.Success);
            Assert.False(getQuotesResult.HasErrors, "Unexpected error occured");
            Assert.IsNotNull(getQuotesResult.QuotesData, "QuotesData object was not created");
            Assert.IsNotNull(getQuotesResult.QuotesData[0].Quotes, "Quotes array was not created");
            Assert.Greater(getQuotesResult.QuotesData[0].Quotes.Count(), 0, "Quotes were not read");
        }