using System; using System.Globalization; using System.Net.Http; using System.Text.Json; // Print numbers with a dot, whatever the language of the machine CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; // Read NVDA's file (one GET, no key), naming your own project using var http = new HttpClient(); http.DefaultRequestHeaders.UserAgent.ParseAdd( "MyProject/1.0 (+https://example.com)"); using var doc = JsonDocument.Parse(await http.GetStringAsync( "https://tickerinside.com/api/v1/sec/nvda.json")); // The etf_ownership block holds the figure var own = doc.RootElement.GetProperty("etf_ownership"); // pct_lower_bound is null when no figure is published, and refused says why var pct = own.GetProperty("pct_lower_bound"); if (pct.ValueKind == JsonValueKind.Null) { Console.WriteLine("NVDA etf_ownership: no figure published, refused " + own.GetProperty("refused").GetString()); return; } Console.WriteLine($"NVDA etf_ownership: at least {pct.GetDouble()}% of its " + "shares held by covered US ETFs, basis " + own.GetProperty("basis").GetString()); // The shares counted, and the date of the count of shares outstanding // N0 puts a comma every three digits var held = own.GetProperty("shares_held").GetInt64(); var outstanding = own.GetProperty("shares_outstanding").GetInt64(); Console.WriteLine($"shares_held {held:N0} shares_outstanding {outstanding:N0} " + $"as of {own.GetProperty("shares_outstanding_as_of").GetString()}"); // The oldest and the newest holdings file behind the figure var dates = own.GetProperty("holdings_dates"); Console.WriteLine($"holdings dated {dates.GetProperty("oldest").GetString()} " + $"to {dates.GetProperty("newest").GetString()}"); // The line to print under the figure Console.WriteLine(own.GetProperty("cite_as").GetString());