/// <summary> /// Custom parsing of live results data /// </summary> /// <param name="jObject">Json representing LiveResults</param> /// <returns></returns> public static LiveAlgorithmResults CreateLiveResultsFromJObject(JObject jObject) { var liveAlgoResults = new LiveAlgorithmResults { Success = jObject["success"].Value <bool>() }; var success = jObject["success"].Value <bool>(); if (!success) { // Either there was an error in the running algrithm or the algorithm hasn't started liveAlgoResults.Errors = jObject.Last.Children().Select(error => error.ToString()).ToList(); return(liveAlgoResults); } liveAlgoResults.Success = true; liveAlgoResults.LiveResults = new LiveResultsData { Resolution = (Resolution)Enum.Parse(typeof(Resolution), jObject["LiveResults"]["resolution"].Value <string>(), true), Version = jObject["LiveResults"]["version"].Value <int>() }; // Results json var results = jObject["LiveResults"]["results"]; var isFrameworkAlgorithm = results["IsFrameworkAlgorithm"].Value <bool?>() ?? false; // Deserialize charting data var charts = results["Charts"]; var chartDictionary = new Dictionary <string, Chart>(); foreach (var chart in charts.Children()) { var newChart = new Chart(((JProperty)chart).Name) { Series = GetChartSeries(chart.First()["Series"]) }; chartDictionary.Add(newChart.Name, newChart); } // Live Results - At this time only that charting data can be returned from the api (9/30/2016) liveAlgoResults.LiveResults.Results = new LiveResult(isFrameworkAlgorithm, chartDictionary, new Dictionary <int, Order>(), new Dictionary <DateTime, decimal>(), new Dictionary <string, Holding>(), new CashBook(), new Dictionary <string, string>(), new Dictionary <string, string>() ); return(liveAlgoResults); }
/// <summary> /// Custom parsing of live results data /// </summary> /// <param name="jObject">Json representing LiveResults</param> /// <returns></returns> public static LiveAlgorithmResults CreateLiveResultsFromJObject(JObject jObject) { var liveAlgoResults = new LiveAlgorithmResults { Success = jObject["success"].Value<bool>() }; var success = jObject["success"].Value<bool>(); if (!success) { // Either there was an error in the running algrithm or the algorithm hasn't started liveAlgoResults.Errors = jObject.Last.Children().Select(error => error.ToString()).ToList(); return liveAlgoResults; } liveAlgoResults.Success = true; liveAlgoResults.LiveResults = new LiveResultsData { Resolution = (Resolution)Enum.Parse(typeof(Resolution), jObject["LiveResults"]["resolution"].Value<string>(), true), Version = jObject["LiveResults"]["version"].Value<int>() }; // Results json var results = jObject["LiveResults"]["results"]; // Deserialize charting data var charts = results["Charts"]; var chartDictionary = new Dictionary<string, Chart>(); foreach (var chart in charts.Children()) { var newChart = new Chart(((JProperty) chart).Name) { Series = GetChartSeries(chart.First()["Series"]) }; chartDictionary.Add(newChart.Name, newChart); } // Live Results - At this time only that charting data can be returned from the api (9/30/2016) liveAlgoResults.LiveResults.Results = new LiveResult(chartDictionary, new Dictionary < int, Order >(), new Dictionary < DateTime, decimal >(), new Dictionary < string, Holding > (), new Dictionary < string, string > (), new Dictionary < string, string >()); return liveAlgoResults; }