public void GetHistoricalRAW(string code, string outputFilename) { if (!outputFilename.EndsWith(".csv")) { outputFilename += ".csv"; // ensure our filename ends with ".csv" } // The call returns a stream based on the returnFormat // (i.e. json stream if returnFormat = ReturnFormat.Json, // xml stream if returnFormat = ReturnFormat.Xml, // csv stream if returnFormat = ReturnFormat.Csv) // Let use Get time-series data api as an example Console.Write("Retrieving Quandl data ... "); var qc = new MyQuandlCode(code); var csvStream = m_client.Timeseries.GetDataAsync(qc.DatabaseCode, qc.DatasetCode, ReturnFormat.Csv); csvStream.Wait(); Console.WriteLine("Done."); try { using (var fs = File.Create(outputFilename)) { csvStream.Result.CopyTo(fs); } Console.WriteLine("Data written to file: '{0}'", outputFilename); } finally { csvStream.Dispose(); csvStream = null; } }
public Quandl.NET.Model.Response.TimeseriesDataResponse GetHistorical(string code, DateTime?_dt1 = null, DateTime?_dt2 = null) { DateTime dt1, dt2; if (_dt1 == null || _dt2 == null) { dt1 = m_defaultDt1; dt2 = m_defaultDt2; } else { dt1 = _dt1.Value; dt2 = _dt2.Value; } Console.Write("Retrieving Quandl data {0} to {1} ... ", dt1.ToShortDateString(), dt2.ToShortDateString()); var qc = new MyQuandlCode(code); var data = m_client.Timeseries.GetDataAsync(qc.DatabaseCode, qc.DatasetCode, startDate: dt1, endDate: dt2); data.Wait(); Console.WriteLine("Done."); // EXAMPLE WITH FILTERING /*var data = await client.Timeseries.GetDataAsync("WIKI", "FB", * columnIndex: 4, * startDate: new DateTime(2014, 1, 1), * endDate: new DateTime(2014, 12, 31), * collapse: Collapse.Monthly, * transform: Transform.Rdiff);*/ return(data.Result); }