LSEG Data Library for .NET

Machine Readable News (MRN) Definition

Using this definition, we can retrieve real-time news headlines, stories, news analytics about companies and their assets and macroeconomic events. Machine Readable News data is retrieved using streams. The streams can be setup with callbacks for different events like incoming data (stream inserts or updates), the stream status and in case any errors are encountered.

    var definition = MachineReadableNews.Definition();

    // Set the datafeed then retrieve a streaming object.
    using (var stream = mrn.NewsDatafeed(feed).GetStream())
    {
        // A token can be provided to end the ongoing task after a certain period
        var tokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(10));

        // Define our real-time processing then open the stream...
        stream
            .OnError((err, s) => { })
            .OnStatus((status, s) => { })
            .OnNewsStory((newsItem, s) => { })
            .OnNewsAnalyticsAssets((newsItem, s) => { })
            .OnNewsAnalyticsEvents((newsItem, s) => { })
            .Open(tokenSource.Token);

        Console.ReadLine();
    }