|
1 | 1 | # Machine Readable News Example with LSEG Data Library for Python |
2 | 2 |
|
3 | | -- Last update: June 2025 |
| 3 | +- Last update: May 2026 |
4 | 4 | - Compiler: Python |
5 | 5 | - Prerequisite: The Real-Time Distribution System or The Real-Time -- Optimized credentials (V1) with MRN service |
6 | 6 |
|
7 | 7 | This example shows how developers may use the [LSEG Data Library for Python](https://developers.lseg.com/en/api-catalog/lseg-data-platform/lseg-data-library-for-python) Delivery layer feature to subscribe to the Machine Readable News (MRN) from LSEG Real-Time Distribution System (RTDS) and LSEG Real-Time Optimized (RTO). The example just connects to LSEG Real-Time platform via a WebSocket connection, then subscribes and displays MRN News data in a console. |
8 | 8 |
|
9 | | -**Note:** The news message is in UTF-8 JSON string format. Some news messages that contain special Unicode character may not be able to show in Windows OS console (cmd, git bash, powershell, etc) due to the OS limitation. Those messages will be print as ```UnicodeEncodeError exception. Cannot decode Unicode character``` message in a console instead. |
| 9 | +**Note:** |
| 10 | + |
| 11 | +- The news message is in UTF-8 JSON string format. Some news messages that contain special Unicode character may not be able to show in Windows OS console (cmd, git bash, powershell, etc) due to the OS limitation. Those messages will be print as ```UnicodeEncodeError exception. Cannot decode Unicode character``` message in a console instead. |
| 12 | +- This project demonstrates with the Data Library for Python edition. However, the MRN data parsing and assembling concept can be used with the Data Library for TypeScript edition too. |
10 | 13 |
|
11 | 14 | ## <a id="prerequisite"></a> Prerequisite |
12 | 15 |
|
@@ -46,6 +49,34 @@ This project is based on Data Library Python versions **2.1.1**. |
46 | 49 |
|
47 | 50 | Machine Readable News (MRN) is an advanced service for automating the consumption and systematic analysis of news. It delivers deep historical news archives, ultra-low latency structured news and news analytics directly to your applications. This enables algorithms to exploit the power of news to seize opportunities, capitalize on market inefficiencies, and manage event risk. |
48 | 51 |
|
| 52 | +## Note For .NET Developers |
| 53 | + |
| 54 | +If you are .NET developers, the [Data Library for .NET](https://developers.lseg.com/en/api-catalog/lseg-data-platform/lseg-data-library-for-net) provides a ready-to-use `MachineReadableNews` object for you. An application can get the MRN streaming news data without extra code like the [Python](https://developers.lseg.com/en/api-catalog/lseg-data-platform/lseg-data-library-for-python) and [TypeScript](https://developers.lseg.com/en/api-catalog/lseg-data-platform/lseg-data-library-for-typescript) editions. |
| 55 | + |
| 56 | +Example: |
| 57 | + |
| 58 | +```c# |
| 59 | +var definition = MachineReadableNews.Definition(); |
| 60 | + |
| 61 | +// Set the datafeed then retrieve a streaming object. |
| 62 | +using (var stream = mrn.NewsDatafeed(feed).GetStream()) |
| 63 | +{ |
| 64 | + // Define our real-time processing then open the stream... |
| 65 | + stream |
| 66 | + .OnError((err, s) => { }) |
| 67 | + .OnStatus((status, s) => { }) |
| 68 | + .OnNewsStory((newsItem, s) => { }) |
| 69 | + .OnNewsAnalyticsAssets((newsItem, s) => { }) |
| 70 | + .OnNewsAnalyticsEvents((newsItem, s) => { }) |
| 71 | + .Open(); |
| 72 | + |
| 73 | + Console.ReadLine(); |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +You can see more detail on the [Data Library for .NET - 2.3.06-News-MRN](https://github.com/LSEG-API-Samples/Example.DataLibrary.DotNet/tree/lseg-data-examples/src/2.%20Content/2.3-News/2.3.06-News-MRN) example. |
| 78 | + |
| 79 | + |
49 | 80 | ### <a id="mrn_data_model"></a>MRN Data model |
50 | 81 |
|
51 | 82 | MRN is published over the Real-Time platform using an Open Message Model (OMM) envelope in News Text Analytics domain messages. The Real-time News content set is made available over MRN_STORY RIC. The content data is contained in a FRAGMENT field that has been compressed and potentially fragmented across multiple messages, to reduce bandwidth and message size. |
|
0 commit comments