private IContainer ExecuteEx() { YQLQuery query = new YQLQuery(); query. Select(Arguments.First(a => (a.Id() == "criterias")).Get <String>()). From(Register.Instance.Get("TABLE", "QUOTES")). Where().In("symbol", Arguments.First(a => (a.Id() == "symbols")).Get <String>()); DownloadRessourceHandler <String> dl = new DownloadRessourceHandler <String>(); String result = dl.Acquire( new Uri(Helper.FormatQuery(Register.Instance.Get("URL", "PUBLIC_API"), query.Yield(), Register.Instance.Get("URL", "TABLES"))), Helper.HandleStream); XDocument doc = XDocument.Parse(result); if (!OperationHelper.IsValidYQLResponse(doc)) { return(OperationHelper.HandleErrors(doc)); } foreach (XElement element in doc.XPathSelectElements("/*/*/quote")) { IContainer container = (IContainer)Activator.CreateInstance(Result.GetType()); foreach (XElement property in element.XPathSelectElements("child::*")) { container.RegisterProperty <String>(property.Name.LocalName, property.Value); } Result.RegisterProperty <IContainer>(element.Attribute("symbol").Value, container); } Result.RegisterProperty <String>("script", result); return(Result); }
private IContainer ExecuteEx() { YQLQuery query = new YQLQuery(); query. Select("*"). From("csv"). Where("url", Register.Instance.Get("URL", "HISTORIC_API") + Arguments.First(a => (a.Id() == "symbol")).Get <String>()).And("columns", "Date,Open,High,Low,Close,Volume,AdjClose"); DownloadRessourceHandler <String> dl = new DownloadRessourceHandler <String>(); String url = Helper.FormatQuery(Register.Instance.Get("URL", "PUBLIC_API"), query.Yield(), Register.Instance.Get("URL", "TABLES")); String result = dl.Acquire( new Uri(Helper.FormatQuery(Register.Instance.Get("URL", "PUBLIC_API"), query.Yield(), Register.Instance.Get("URL", "TABLES"))), Helper.HandleStream); XDocument doc = XDocument.Parse(result); if (!OperationHelper.IsValidYQLResponse(doc)) { return(OperationHelper.HandleErrors(doc)); } Result.RegisterProperty <String>("symbol", Arguments.First(a => (a.Id() == "symbol")).Get <String>()); foreach (XElement element in doc.XPathSelectElements("/*/results/*")) { IContainer container = (IContainer)Activator.CreateInstance(Result.GetType()); Boolean header = true; foreach (XElement child in element.XPathSelectElements("child::*")) { if (!header) { container.RegisterProperty <String>(child.Name.LocalName, child.Value); } header = false; } Result.RegisterProperty <IContainer>(element.Element("Date").Value, container); } Result.RegisterProperty <String>("script", result); return(Result); }