// DisplayHeadlineAndStory
 // Interrogate the response to pull out the story text.
 private static void DisplayStory(IEndpointResponse response)
 {
     if (response.IsSuccess)
     {
         Console.Write($"{Environment.NewLine}Story: ");
         Console.WriteLine(response.Data?.Raw["newsItem"]?["contentSet"]?["inlineData"]?[0]?["$"]);
     }
     else
     {
         Console.WriteLine($"Failed to retrieve data: {response.HttpStatus}");
     }
 }
示例#2
0
 private static void Display(IEndpointResponse response)
 {
     if (response.IsSuccess)
     {
         Console.WriteLine(response.Data.Raw);
     }
     else
     {
         Console.WriteLine(response.Status);
     }
     Console.Write("\nHit <enter> to continue...");
     Console.ReadLine();
 }
        // Retrieve the story ID from the first headline
        private static string GetStoryId(IEndpointResponse response)
        {
            string storyId = null;

            if (response.IsSuccess)
            {
                var data = response.Data?.Raw["data"] as JArray;

                // Retrieve the first headline, if available
                storyId = data?[0]?["storyId"]?.ToString();
            }

            return(storyId);
        }
示例#4
0
        // DisplayResult
        // The following code segment interrogates the response returned from the platform.  If the request was successful, simple details
        // related to the pricing data is displayed.  Otherwise, status details outlining failure reasons are presented.
        static void DisplayResult(IEndpointResponse response)
        {
            if (response.IsSuccess)
            {
                // Retrieve the data elements from the response and display how many rows of historical pricing content came back.
                var data = response.Data?.Raw[0]?["data"] as JArray;
                Console.WriteLine($"Timeseries data response: {response.Data?.Raw}{Environment.NewLine}A total of {data?.Count} elements returned.");
            }
            else
            {
                Console.WriteLine($"Failed to retrieve data: {response.Status}");
            }

            Console.Write("Hit enter to continue..."); Console.ReadLine();
        }
        static void DisplayResponse(IEndpointResponse response)
        {
            if (response.IsSuccess)
            {
                Console.WriteLine(response.Data.Raw["universe"]);
                Console.WriteLine(response.Data.Raw["data"]);
            }
            else
            {
                Console.WriteLine(response.Status);
            }

            Console.WriteLine("Enter to continue...");
            Console.ReadLine();
        }
        // ExtractValues
        // The main Greek measurement used to drive our hedging is the Delta Percent value.  Based on the data response from our request
        // we pull out the output fields and extract the Delta value which will be used to drive our hedge.
        private static IList <IDictionary <string, JToken> > ExtractValues(IEndpointResponse response)
        {
            IList <IDictionary <string, JToken> > table = new List <IDictionary <string, JToken> >();

            if (response.IsSuccess)
            {
                var data    = response.Data.Raw as JObject;
                var headers = data["headers"] as JArray;

                foreach (var option in data["data"])
                {
                    var result = new Dictionary <string, JToken>();

                    // Iterate through the headers and pull out the corresponding values
                    var index = 0;
                    foreach (var header in headers)
                    {
                        result.Add(header["name"].ToString(), option[index++]);
                    }

                    if (String.IsNullOrWhiteSpace(result["ErrorMessage"].ToString()))
                    {
                        table.Add(result);
                    }
                    else
                    {
                        Console.WriteLine($"Issue with Option. {option}");
                    }
                }
            }
            else
            {
                Console.WriteLine(response.Status);
            }

            return(table);
        }