예제 #1
0
        public void TestCase2()
        {
            // Web url is: https://www.quandl.com/api/v1/datasets/WIKI/AAPL.csv?sort_order=asc&exclude_headers=true&rows=3&trim_start=2012-11-01&trim_end=2013-11-30&column=4&collapse=quarterly&transformation=rdiff

            DataField[] expectedDataFields = new DataField[] { new DataField("StockData", CommonTypes.DateTime), new DataField("PriceValue", CommonTypes.Double) };
            DataHeader expectedHeader = new DataHeader(expectedDataFields);

            List<DataRecord> expectedDataRecords = new List<DataRecord>
            {
                new DataRecord(new DateTime(2013, 3, 31), -0.16820266496096),
                new DataRecord(new DateTime(2013, 6, 30), -0.10421090679077),
                new DataRecord(new DateTime(2013, 9, 30), 0.2023049958389),
            };

            DataSet expectedDataSet = new DataSet(expectedHeader, expectedDataRecords);

            QuandlDataProvider provider = new QuandlDataProvider();

            Dictionary<string, string> dataPathParams = new Dictionary<string, string>()
            {
                { "DatabaseCode", "WIKI" },
                { "TableCode", "AAPL" },
                { "FormatCode", "CSV" },
            };

            Dictionary<string, object> dataQueryParams = new Dictionary<string,object>
            {
                { "DatabaseCode", "WIKI" },
                { "TableCode", "AAPL" },
                { "FormatCode", FileType.CSV },
                { "AuthToken", null },
                { "TrimStart", new DateTime(2012, 11, 1)},
                { "TrimEnd", new DateTime(2013, 11, 30) },
                { "SortOrder", SortOrder.Ascending },
                { "ExcludeHeader", true },
                { "ExcludeData", null },
                { "Rows", 3},
                { "Column", 4},
                { "Frequency", CollapseType.Quarterly },
                { "Calculation", TransformationType.Rdiff }
            };

            // TODO: Make it typed

            DataPath dataPath = new DataPath(dataPathParams);
            DataQuery dataQuery = new DataQuery(dataQueryParams);

            DataRequest request = new DataRequest(dataPath, dataQuery);

            DataSet actualDataSet = provider.ReadData(request);

            AreEqual(expectedDataSet, actualDataSet);
        }
예제 #2
0
 public DataRequest(DataPath path, DataQuery query)
 {
     this.Path = path;
     this.Query = query;
 }