Skip to content

Commit bc24711

Browse files
committed
Merge branch 'v2_rebrand' into master
1. Add prerequisite 2 Update rebrand
2 parents 6407b74 + 0801d0d commit bc24711

File tree

3 files changed

+557
-5332
lines changed

3 files changed

+557
-5332
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ mrn_other_example/
88

99
.ipynb_checkpoints
1010
*/.ipynb_checkpoints/*
11+
notebook/mrn_realtime_news_notebook_app.ipynb
12+
notebook/mrn_trna_notebook_app.ipynb
13+
notebook/images/trna_process.png
14+
notebook/images/trna_process_assemble.png

README.md

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1-
# Elektron WebSocket API MRN Example with Python
2-
- Last update: July 2019
1+
# WebSocket API Machine Readable News Example with Python
2+
- Last update: September 2020
33
- Environment: Windows and Linux OS
44
- Compiler: Python
55
- Prerequisite: ADS and ADH servers version 3.2.1 and above, MRN service
66

77
## Overview
88

9-
This example shows how to writing the [Elektron WebSocket API](https://developers.refinitiv.com/elektron/websocket-api) application to subscribe Machine Readable News (MRN) 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 or classic Jupyter Notebook. The project are implemented with Python language for both console and Jupyter Notebook applications, but the main concept for consuming and assembling MRN News messages are the same for all technologies.
9+
This example shows how to writing the [Websocket API for Pricing Streaming and Real-Time Service](https://developers.refinitiv.com/elektron/websocket-api) aka Websocket API application to subscribe Machine Readable News (MRN) from Refinitiv Real-Time Distribution System (ADH and ADS servers). The example just connects to Refinitiv Real-Time via a WebSocket connection, then subscribes and display MRN News data in a console or classic Jupyter Notebook. The project are implemented with Python language for both console and Jupyter Notebook applications, but the main concept for consuming and assembling MRN News messages are the same for all technologies.
1010

1111
Please see a full documentation of this example application in [this article](https://developers.refinitiv.com/article/introduction-machine-readable-news-elektron-websocket-api-refinitiv).
1212

1313
*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.
1414

15+
## Prerequisite
16+
17+
This example is focusing on the Refinitiv Machine Readable News (MRN) data processing only. I highly recommend you check the [WebSocket API Tutorials](https://developers.refinitiv.com/en/api-catalog/elektron/refinitiv-websocket-api/tutorials) page if you are not familiar with WebSocket API.
18+
19+
The Tutorials page provide a step by step guide (connect, login, request data, parse data, etc) for developers who interested in developing a WebSocket application to consume real-time data from Refinitiv Real-Time.
20+
1521
## Machine Readable News Overview
1622

1723
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.
1824

1925
### MRN Data model
20-
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.
26+
MRN is published over Refinitiv Real-Time 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.
2127

2228
A FRAGMENT field has a different data type based on a connection type:
23-
* RSSL connection (ESDK [C++](https://developers.refinitiv.com/elektron/elektron-sdk-cc)/[Java](https://developers.refinitiv.com/elektron/elektron-sdk-java)): BUFFER type
29+
* RSSL connection (RTSDK [C++](https://developers.refinitiv.com/elektron/elektron-sdk-cc)/[Java](https://developers.refinitiv.com/elektron/elektron-sdk-java)): BUFFER type
2430
* WebSocket connection: Base64 ascii string
2531

2632
The data goes through the following series of transformations:
@@ -36,13 +42,13 @@ Therefore, in order to parse the core content data, the application will need to
3642

3743
If you are not familiar with MRN concept, please visit the following resources which will give you a full explanation of the MRN data model and implementation logic:
3844
* [Webinar Recording: Introduction to Machine Readable News](https://developers.refinitiv.com/news#news-accordion-nid-12045)
39-
* [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).
40-
* [MRN Data Models and Elektron Implementation Guide](https://developers.refinitiv.com/elektron/elektron-sdk-java/docs?content=8736&type=documentation_item).
41-
* [Introduction to Machine Readable News with Elektron WebSocket API](https://developers.refinitiv.com/article/introduction-machine-readable-news-elektron-websocket-api-refinitiv).
45+
* [Introduction to Machine Readable News (MRN) with Enterprise Message API (EMA)](https://developers.refinitiv.com/article/introduction-machine-readable-news-mrn-elektron-message-api-ema).
46+
* [MRN Data Models and Refinitiv Real-Time SDK Implementation Guide](https://developers.refinitiv.com/elektron/elektron-sdk-java/docs?content=8736&type=documentation_item).
47+
* [Introduction to Machine Readable News with WebSocket API](https://developers.refinitiv.com/article/introduction-machine-readable-news-elektron-websocket-api-refinitiv).
4248

43-
## Prerequisite
49+
## Example Prerequisite
4450
This example requires the following dependencies softwares and libraries.
45-
1. TREP server (both ADS and ADH) 3.2.x with WebSocket connection and MRN Service.
51+
1. ADH and ADS servers version 3.2.x with WebSocket connection and MRN Service.
4652
2. [Python](https://www.python.org/) compiler and runtime
4753
3. Python's [requests 2.x](https://pypi.org/project/requests/) library.
4854
4. Python's [websocket-client](https://pypi.org/project/websocket-client/) library (*version 0.49 or greater*).
@@ -53,7 +59,7 @@ This example requires the following dependencies softwares and libraries.
5359
- The Python example has been qualified with Python versions 3.6.5 and Python 3.7.4 (Docker 19.03.1 - CentOS 7)
5460
- 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.
5561
- 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.
56-
- 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.
62+
- 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 ADS/ADH-MRN service configuration.
5763

5864

5965
## Application Files
@@ -67,7 +73,7 @@ This example project contains the following files and folders
6773

6874
## How to run this example
6975

70-
Please be informed that your TREP server (ADS and ADH) should have a Service that contain MRN data. The first step is unzip or download the example project folder into a directory of your choice, then choose how to run application based on your environment below.
76+
Please be informed that your ADS/ADH server should have a Service that contain MRN data. The first step is unzip or download the example project folder into a directory of your choice, then choose how to run application based on your environment below.
7177

7278
### A console example
7379
1. Go to project folder in console
@@ -76,7 +82,7 @@ Please be informed that your TREP server (ADS and ADH) should have a Service tha
7682
```
7783
$> python mrn_console_app.py --hostname <ADS server IP Address/Hostname> --port <WebSocket Port> --ric <MRN RIC name>
7884
```
79-
Optionally, the application subscribes ```MRN_STORY``` RIC code from TREP by default. You can pass your interested MRN RIC code to ```--ric``` parameter on the application command line. The supported MRN RIC codes are ```MRN_STORY```, ```MRN_TRNA```, ```MRN_TRNA_DOC``` and ```MRN_TRSI``` only. the application
85+
Optionally, the application subscribes ```MRN_STORY``` RIC code from ADS by default. You can pass your interested MRN RIC code to ```--ric``` parameter on the application command line. The supported MRN RIC codes are ```MRN_STORY```, ```MRN_TRNA```, ```MRN_TRNA_DOC``` and ```MRN_TRSI``` only. the application
8086
8187
### Docker example
8288
1. Go to project folder in console
@@ -89,18 +95,38 @@ Optionally, the application subscribes ```MRN_STORY``` RIC code from TREP by def
8995
$> docker run esdk_ws_mrn_python --hostname <ADS server IP Address/Hostname> --port <WebSocket Port> --ric <MRN RIC name>
9096
```
9197
### Classic Jupyter Notebook example
92-
1. Go to project's notebook folder in console
93-
2. Run the following command in a console to start classic Jupyter Notebook in the notebook folder.
98+
99+
Please be informed that Python [Ananconda](https://www.anaconda.com/distribution/) or [MiniConda](https://docs.conda.io/en/latest/miniconda.html) distribution/package manager is highly recommend for running Jupyter Notebook example.
100+
101+
1. Open Anaconda Prompt and go to project's folder
102+
2. Run the following command in a Anaconda Prompt to create Conda environment named *mrn_python_notebook* for the project.
103+
```
104+
(base) $>conda create --name mrn_python_notebook python=3.7
105+
```
106+
3. Once the environment is created, activate Conda environment named ```global_sale``` with this command in Anaconda Prompt
107+
```
108+
(base) $>conda activate mrn_python_notebook
109+
```
110+
4. In mrn_python_notebook environment, install the following prerequisite libraries
111+
```
112+
(mrn_python_notebook) $>conda install -c conda-forge notebook
113+
114+
(mrn_python_notebook) $>conda install -c conda-forge pandas
115+
116+
(mrn_python_notebook) $>pip install -r requestments.txt
117+
```
118+
5. Go to project's notebook folder in console
119+
6. Run the following command in a console to start classic Jupyter Notebook in the notebook folder.
94120
```
95-
$> jupyter notebook
121+
(mrn_python_notebook) $>jupyter notebook
96122
```
97-
3. Open *mrn_notebook_app.ipynb* Notebook document, then follow through each notebook cell.
123+
7. Open *mrn_notebook_app.ipynb* Notebook document, then follow through each notebook cell.
98124
99125
*Note:*
100126
- You can install a classic Jupyter Notebook on your local machine and then test the example on the machine. The alternate choice is a free Jupyter Notebook on cloud environment such as [Azure Notebook](https://notebooks.azure.com/) provided by Microsoft. You can find more details from [this tutorial](https://docs.microsoft.com/en-us/azure/notebooks/tutorial-create-run-jupyter-notebook). If you are not familiar with Jupyter Notebook, the following [tutorial](https://www.datacamp.com/community/tutorials/tutorial-jupyter-notebook) created by DataCamp may help.
101127
102128
## Example Results
103-
### Send MRN_STORY request to TREP
129+
### Send MRN_STORY request to ADS
104130
```
105131
SENT:
106132
{
@@ -191,14 +217,14 @@ News = {'altId': 'nIdw5d8Hwd', 'audiences': ['NP:CNRA', 'NP:IDXN'], 'body': 'Lap
191217
```
192218
193219
## References
194-
* [Refinitiv Elektron SDK Family page](https://developers.refinitiv.com/elektron) on the [Refinitiv Developer Community](https://developers.thomsonreuters.com/) web site.
195-
* [Refinitiv Elektron WebSocket API page](https://developers.refinitiv.com/websocket-api).
220+
* [Refinitiv Real-Time SDK Family page](https://developers.refinitiv.com/elektron) on the [Refinitiv Developer Community](https://developers.refinitiv.com/) web site.
221+
* [WebSocket API page](https://developers.refinitiv.com/websocket-api).
196222
* [Developer Webinar Recording: Introduction to Electron WebSocket API](https://www.youtube.com/watch?v=CDKWMsIQfaw).
197-
* [Introduction to Machine Readable News with Elektron WebSocket API](https://developers.refinitiv.com/article/introduction-machine-readable-news-elektron-websocket-api-refinitiv).
223+
* [Introduction to Machine Readable News with WebSocket API](https://developers.refinitiv.com/article/introduction-machine-readable-news-elektron-websocket-api-refinitiv).
198224
* [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).
199-
* [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).
200-
* [MRN Data Models and Elektron Implementation Guide](https://developers.refinitiv.com/elektron/elektron-sdk-java/docs?content=8736&type=documentation_item).
225+
* [Introduction to Machine Readable News (MRN) with Enterprise Message API (EMA)](https://developers.refinitiv.com/article/introduction-machine-readable-news-mrn-elektron-message-api-ema).
226+
* [MRN Data Models and Real-Time SDK Implementation Guide](https://developers.refinitiv.com/elektron/elektron-sdk-java/docs?content=8736&type=documentation_item).
201227
* [MRN WebSocket JavaScript example on GitHub](https://github.com/Refinitiv-API-Samples/Example.WebSocketAPI.Javascript.NewsMonitor).
202228
* [MRN WebSocket C# NewsViewer example on GitHub](https://github.com/Refinitiv-API-Samples/Example.WebSocketAPI.CSharp.MRNWebSocketViewer).
203229
204-
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).
230+
For any question related to this example or WebSocket API, please use the Developer Community [Q&A Forum](https://community.developers.refinitiv.com/spaces/152/websocket-api.html).

0 commit comments

Comments
 (0)