Beispiel #1
0
        public void TestRequestOneEntry()
        {
            global::YahooFinanceIntegration.YahooFinanceIntegration wrapper = new global::YahooFinanceIntegration.YahooFinanceIntegration();
            IMarketData     data;
            MarketDataQuery query = new MarketDataQuery();

            query.Ticker         = "GOOG";
            query.Date           = new DateTime(2011, 1, 31);
            query.MarketDataType = typeof(Scalar).ToString();
            query.Field          = "open";

            Status status = wrapper.GetMarketData(query, out data);

            Assert.That(!status.HasErrors, status.ErrorMessage);
            Assert.AreEqual(data.TimeStamp, new DateTime(2011, 1, 31));
            Assert.That(data is Scalar);
            Assert.AreEqual((data as Scalar).Value, 603, 1);

            query.Field = "close";

            status = wrapper.GetMarketData(query, out data);

            Assert.That(!status.HasErrors, status.ErrorMessage);
            Assert.AreEqual(data.TimeStamp, new DateTime(2011, 1, 31));
            Assert.That(data is Scalar);
            Assert.AreEqual((data as Scalar).Value, 600, 1);
        }
Beispiel #2
0
        public void TestConnectivity()
        {
            global::YahooFinanceIntegration.YahooFinanceIntegration wrapper = new global::YahooFinanceIntegration.YahooFinanceIntegration();
            Status status = wrapper.TestConnectivity();

            Assert.That(!status.HasErrors, status.ErrorMessage);
        }
Beispiel #3
0
        public void TestTickerList()
        {
            global::YahooFinanceIntegration.YahooFinanceIntegration wrapper = new global::YahooFinanceIntegration.YahooFinanceIntegration();
            List <ISymbolDefinition> data = new List <ISymbolDefinition>(wrapper.SupportedTickers("G"));

            // Check the actual elements.
            Assert.IsTrue(data.Exists(x => (x.Name == "G" && x.Description == "Yahoo! Finance Equity")));
            Assert.IsTrue(data.Exists(x => (x.Name == "GOOG" && x.Description == "Yahoo! Finance Equity")));
            Assert.IsTrue(data.Exists(x => (x.Name == "GE" && x.Description == "Yahoo! Finance Equity")));
            Assert.IsTrue(data.Exists(x => (x.Name == "GLD" && x.Description == "Yahoo! Finance ETF")));
        }
Beispiel #4
0
        public void TestGetCallPriceMarketData()
        {
            var wrapper = new global::YahooFinanceIntegration.YahooFinanceIntegration();

            MarketDataQuery query = new MarketDataQuery();

            query.Ticker         = "GOOG";
            query.Date           = new DateTime(2011, 1, 31);
            query.MarketDataType = typeof(Fairmat.MarketData.CallPriceMarketData).ToString();
            query.Field          = "close";

            IMarketData data;
            var         status = wrapper.GetMarketData(query, out data);

            Assert.IsFalse(status.HasErrors);
        }
Beispiel #5
0
        public void TestRequestMultipleEntryCurrencyConversion()
        {
            global::YahooFinanceIntegration.YahooFinanceIntegration wrapper = new global::YahooFinanceIntegration.YahooFinanceIntegration();
            IMarketData[]   data;
            DateTime[]      dates;
            MarketDataQuery query = new MarketDataQuery();

            query.Ticker         = "GOOG";
            query.Date           = new DateTime(2011, 1, 31);
            query.MarketDataType = typeof(Scalar).ToString();
            query.Field          = "open";
            query.Market         = "EU";

            Status status = wrapper.GetTimeSeries(query, new DateTime(2011, 2, 1), out dates, out data);

            Assert.That(!status.HasErrors, status.ErrorMessage);
            Assert.AreEqual(2, data.Length);
            Assert.AreEqual(2, dates.Length);

            Assert.AreEqual(new DateTime(2011, 2, 1), data[1].TimeStamp);
            Assert.AreEqual(new DateTime(2011, 1, 31), data[0].TimeStamp);
            Assert.That(data[0] is Scalar);
            Assert.That(data[1] is Scalar);

            Assert.AreEqual(441, (data[1] as Scalar).Value, 1);
            Assert.AreEqual(446, (data[0] as Scalar).Value, 1);

            query.Field = "close";

            status = wrapper.GetTimeSeries(query, new DateTime(2011, 2, 1), out dates, out data);

            Assert.That(!status.HasErrors, status.ErrorMessage);
            Assert.AreEqual(2, data.Length);
            Assert.AreEqual(2, dates.Length);

            Assert.AreEqual(new DateTime(2011, 2, 1), data[1].TimeStamp);
            Assert.AreEqual(new DateTime(2011, 1, 31), data[0].TimeStamp);
            Assert.That(data[0] is Scalar);
            Assert.That(data[1] is Scalar);

            Assert.AreEqual(446, (data[1] as Scalar).Value, 1);
            Assert.AreEqual(444, (data[0] as Scalar).Value, 1);
        }