Skip to content

Commit 845e1ac

Browse files
author
Wasin Waeosri
committed
change logs:
1. create README.md 2. create requirements.txt
1 parent 4d31287 commit 845e1ac

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Elektron WebSocket API MRN Example with Python
2+
- Last update: July 2019
3+
- Environment: Windows and Linux OS
4+
- Compiler: Python
5+
- Prerequisite: ADS and ADH servers version 3.2.1 and above, MRN service
6+
7+
## Overview
8+
9+
This example shows how to writing an application to subscribe Machine Readable News (MRN) using [Elektron WebSocket API](https://developers.refinitiv.com/elektron/websocket-api) from Thomson Reuters Enterprise Platform (TREP). The example just connects to TREP via a WebSocket connection, then subscribes and display MRN News data in a console. The project are implemented with Python language, but the main concept for consuming and assembling MRN News messages are the same for all technologies.
10+
11+
*Note:* The news message is in UTF-8 JSON string format. Some news messages that contains 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+
13+
## Machine Readable News Overview
14+
15+
Refinitiv 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.
16+
17+
### MRN Data model
18+
MRN is published over Elektron 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, in order to reduce bandwidth and message size.
19+
20+
A FRAGMENT field has a different data type based on a connection:
21+
* RSSL connection: BUFFER type
22+
* WebSocket connection: Base64 string
23+
24+
The data goes through the following series of transformations:
25+
26+
1. The core content data is a UTF-8 JSON string
27+
2. This JSON string is compressed using gzip
28+
3. The compressed JSON is split into a number of fragments (BUFFER or Base64 string) which each fit into a single update message
29+
4. The data fragments are added to an update message as the FRAGMENT field value in a FieldList envelope
30+
31+
Therefore, in order to parse the core content data, the application will need to reverse this process. The WebSocket application also need to convert a received Base64 string in a FRAGMENT field to bytes data before further process this field.
32+
33+
If you are not familiar with MRN concept, please visit the following resources which will give you a full explanation of the MRN data behavior and how to process it:
34+
* [Webinar Recording: Introduction to Machine Readable News](https://developers.refinitiv.com/news#news-accordion-nid-12045)
35+
* [Introduction to Machine Readable News (MRN) with Elektron Message API (EMA)](https://developers.refinitiv.com/article/introduction-machine-readable-news-mrn-elektron-message-api-ema).
36+
* [Machine Readable News (MRN) & N2_UBMS Comparison and Migration Guide](https://developers.refinitiv.com/article/machine-readable-news-mrn-n2_ubms-comparison-and-migration-guide).
37+
38+
## Prerequisite
39+
This example requires the following dependencies softwares and libraries.
40+
1. TREP server (both ADS and ADH) 3.2.x with WebSocket connection and MRN Service.
41+
2. [Python](https://www.python.org/) compiler and runtime
42+
3. Python's [requests 2.x](https://pypi.org/project/requests/) library.
43+
4. Python's [websocket-client](https://pypi.org/project/websocket-client/) library (*version 0.49 or greater*).
44+
45+
*Note:*
46+
- The Python example has been qualified with Python versions 3.6.5.
47+
- Please refer to the [pip installation guide page](https://pip.pypa.io/en/stable/installing/) if your environment does not have the [pip tool](https://pypi.org/project/pip/) installed.
48+
- If your environment already have a websocket-client library installed, you can use ```pip list``` command to verify a library version, then use ```pip install --upgrade websocket-client``` command to upgrade websocket-client library.
49+
- It is not advisable to change the ADH/ADS configuration, if you are not familiar with the configuration procedures. Please consult your Market Data administrator for any questions regarding TREP-MRN service configuration.
50+
51+
## Application Files
52+
This example project contains the following files and folders
53+
1. *mrn_console_app.py*: The example application file
54+
2. *requirements.txt*: The application dependencies configurationf file
55+
3. LICENSE.md: Project's license file
56+
4. README.md: Project's README file
57+
58+
## How to run this console example
59+
60+
Please be informed that your TREP server (ADS and ADH) should have a Service that contain MRN data.
61+
62+
1. Unzip or download the example project folder into a directory of your choice.
63+
2. Run ```$> pip install -r requestments.txt``` in a console to install all the dependencies libraries.
64+
3. Then you can run mrn_console_app.py application with the following command
65+
```
66+
$> python mrn_console_app.py --hostname <ADS server IP Address/Hostname> --port <WebSocket Port> --item <MRN RIC> --service <ADS Contribution Service name>
67+
```
68+
69+
## References
70+
* [Refinitiv Elektron SDK Family page](https://developers.refinitiv.com/elektron) on the [Refinitiv Developer Community](https://developers.thomsonreuters.com/) web site.
71+
* [Refinitiv Elektron WebSocket API page](https://developers.refinitiv.com/websocket-api).
72+
* [Developer Webinar Recording: Introduction to Electron WebSocket API](https://www.youtube.com/watch?v=CDKWMsIQfaw).
73+
* [Machine Readable News (MRN) & N2_UBMS Comparison and Migration Guide](https://developers.refinitiv.com/article/machine-readable-news-mrn-n2_ubms-comparison-and-migration-guide).
74+
* [Introduction to Machine Readable News (MRN) with Elektron Message API (EMA)](https://developers.refinitiv.com/article/introduction-machine-readable-news-mrn-elektron-message-api-ema).
75+
* [Refinitiv-API-Samples/Example.WebSocketAPI.Javascript.NewsMonitor](https://github.com/Refinitiv-API-Samples/Example.WebSocketAPI.Javascript.NewsMonitor).
76+
77+
For any question related to this example or Elektron WebSocket API, please use the Developer Community [Q&A Forum](https://community.developers.refinitiv.com/spaces/152/websocket-api.html).

requirements.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
autopep8==1.4.4
2+
certifi==2019.6.16
3+
chardet==3.0.4
4+
idna==2.8
5+
pycodestyle==2.5.0
6+
requests==2.22.0
7+
six==1.12.0
8+
urllib3==1.25.3
9+
websocket-client==0.56.0

0 commit comments

Comments
 (0)