public static string GetDataAsXml(StaticFuture sf_, DateTime startDate_, DateTime endDate_, TZ timezone_, int freqNum_, DataFrequencyType freqType_) { Constructs.ConstructGen<double> con = null; if (estimateReturnRowCount(startDate_, endDate_, freqNum_, freqType_) > _maxReturnRowCount) return XmlStringForGenericTableErrorMessage(string.Format("Call would exceed max row return row count of {0}", _maxReturnRowCount)); using (var db = new DBHelper()) { con = GetHistData(sf_, startDate_, endDate_, timezone_, freqNum_, freqType_, db); } if (con == null) return null; return con.Dates.Select(x => new { Date = x.ToString("dd-MMM-yyyy HH:mm"), Price = con.GetValue(x, 0) }).ToGenericTableXml(); }
private static Constructs.ConstructGen<double> GetHistData(StaticFuture sf_, DateTime startDate_, DateTime endDate_, TZ timezone_, int freqNum_, DataFrequencyType freqType_, DBHelper db_) { var retriever = DataRetrievers.RetrieverBase.GetRetriever(timezone_, freqType_, startDate_, endDate_); var rawData = retriever.GetData(db_, sf_); if (rawData == null || rawData.Dates == null || rawData.Dates.Count == 0) return null; SLog.log.Debug(string.Format("RawDataCount from Database: {0}", rawData.Dates.Count.ToString())); var timespan = getTimespan(freqType_, freqNum_); var filled = rawData.GetSubsetOnTimespan(startDate_, timespan); SLog.log.Debug(string.Format("After fillout, datacount is: {0}", filled.Dates.Count.ToString())); if (filled.NeedsToSortKeys()) filled.SortKeys(); return filled; }