Example #1
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 #2
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 #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_CanImport_Single_Fail()
        {
            IQuotesSource source = CreateSource();

            IQuotesSourceCanImportParams canImportParams = source.CreateCanImportParams();

            canImportParams.Tickers.Add(ConfigurationManager.AppSettings["STOOQ_TICKER_INVALID"]);


            IQuotesSourceCanImportResult canImportResult = source.CanImport(canImportParams);

            Assert.IsNotNull(canImportResult);
            Assert.IsFalse(canImportResult.Success);
            Assert.False(canImportResult.HasErrors, "Unexpected error occured");
            Assert.IsNotNull(canImportResult.Tickers);
            Assert.AreEqual(canImportResult.Tickers.Count, 0, "Invalid number of tickers returned");
        }
        public void TestStooq_CanImport_Single_Success()
        {
            IQuotesSource source = CreateSource();

            IQuotesSourceCanImportParams canImportParams = source.CreateCanImportParams();

            canImportParams.Tickers.Add(ConfigurationManager.AppSettings["SEC_AAPL_CODE"]);


            IQuotesSourceCanImportResult canImportResult = source.CanImport(canImportParams);

            Assert.IsNotNull(canImportResult);
            Assert.IsTrue(canImportResult.Success);
            Assert.False(canImportResult.HasErrors, "Unexpected error occured");
            Assert.IsNotNull(canImportResult.Tickers);
            Assert.AreEqual(canImportResult.Tickers.Count, 1, "Invalid number of tickers returned");
            Assert.AreEqual(canImportResult.Tickers[0], ConfigurationManager.AppSettings["SEC_AAPL_CODE"], "Expected tickers were not returned");
        }
        public void TestStooq_CanImport_Multiple_PartialSuccess()
        {
            IQuotesSource source = CreateSource();

            IQuotesSourceCanImportParams canImportParams = source.CreateCanImportParams();

            canImportParams.Tickers.Add(ConfigurationManager.AppSettings["SEC_AAPL_CODE"]);
            canImportParams.Tickers.Add(ConfigurationManager.AppSettings["STOOQ_TICKER_INVALID"]);


            IQuotesSourceCanImportResult canImportResult = source.CanImport(canImportParams);

            Assert.IsNotNull(canImportResult);
            Assert.IsTrue(canImportResult.Success);
            Assert.False(canImportResult.HasErrors, "Unexpected error occured");
            Assert.IsNotNull(canImportResult.Tickers);
            Assert.AreEqual(canImportResult.Tickers.Count, 1, "Invalid number of tickers returned");
            Assert.Contains(ConfigurationManager.AppSettings["SEC_AAPL_CODE"], canImportResult.Tickers.ToArray(), "Expected ticker AAPL was not returned");
        }
        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");
        }
Example #8
0
        public void TestCFTC_CanImport_Multiple_Success()
        {
            IQuotesSource source = CreateSource();

            IQuotesSourceCanImportParams canImportParams = source.CreateCanImportParams();

            canImportParams.Tickers.Add(ConfigurationManager.AppSettings["CFTC_TICKER_COT_FINFUT"]);
            canImportParams.Tickers.Add(ConfigurationManager.AppSettings["CFTC_TICKER_COT_FINFUTOPT"]);
            canImportParams.Tickers.Add(ConfigurationManager.AppSettings["CFTC_TICKER_COT_CMDTSFUT"]);
            canImportParams.Tickers.Add(ConfigurationManager.AppSettings["CFTC_TICKER_COT_CMDTSFUTOPT"]);


            IQuotesSourceCanImportResult canImportResult = source.CanImport(canImportParams);

            Assert.IsNotNull(canImportResult);
            Assert.IsTrue(canImportResult.Success);
            Assert.False(canImportResult.HasErrors, "Unexpected error occured");
            Assert.IsNotNull(canImportResult.Tickers);
            Assert.AreEqual(canImportResult.Tickers.Count, 4, "Invalid number of tickers returned");
        }
        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");
        }