Example #1
0
        public void ImportByYahoo()
        {
            var importer = new YahooFinanceImporter();
            var candle   = importer.ImportAsync("^GSPC", new DateTime(2017, 1, 3), new DateTime(2017, 1, 4)).Result.First(); // Endtime stock history exclusive

            Assert.AreEqual(candle.Open, 2251.570068m);
            Assert.AreEqual(candle.High, 2263.879883m);
            Assert.AreEqual(candle.Low, 2245.129883m);
            Assert.AreEqual(candle.Close, 2257.830078m);
            Assert.AreEqual(candle.Volume, 3_770_530_000);
        }
Example #2
0
        public void CultureNotBeingSetCauseYahooImporterToFail()
        {
            CultureInfo.CurrentCulture = new CultureInfo("en-us");
            var importer = new YahooFinanceImporter();
            var candle   = importer.ImportAsync("^GSPC", new DateTime(2017, 1, 3), new DateTime(2017, 1, 4)).Result.First(); // Endtime stock history exclusive

            Assert.AreEqual(candle.Open, 2251.570068m);

            /// Argentina's culture. Just to give a culture that use , and . in the opposite way from  United States
            /// and 3.000 means three thousands.
            CultureInfo.CurrentCulture = new CultureInfo("es-ar");
            importer = new YahooFinanceImporter();
            candle   = importer.ImportAsync("^GSPC", new DateTime(2017, 1, 3), new DateTime(2017, 1, 4)).Result.First(); // Endtime stock history exclusive
            /// Actual value is 2251.570068m but if you don't set the culture to the right one the call to yahoo brings
            /// wrong numbers.
            Assert.AreEqual(candle.Open, 2251570068m);
        }