Skip to content

Commit e1f1fa0

Browse files
committed
Update readme
Update code comment Update requirements.txt
1 parent 4f61c45 commit e1f1fa0

File tree

3 files changed

+46
-25
lines changed

3 files changed

+46
-25
lines changed

README.md

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
**Important Note**:
1111

12-
- If you are using the Wealth solution (*Pricing Streaming Optimized Service* or *Pricing Streaming Service*), the products currently support Authentication Version 1 only (**As of May 2024**). Please contact your LSEG representative to verify if you are using Wealth or RTO solution.
13-
- For RTO customers, please be informed that the Authentication Version 1 is currently limited support. Please refer to [PCN207737](https://my.refinitiv.com/content/mytr/en/product-notifications/details.html?id=PCN207737) and [PCN208969](https://my.refinitiv.com/content/mytr/en/product-notifications/details.html?id=PCN208969) documents for more detail.
12+
- If you are using the Wealth solution (*Pricing Streaming Optimized Service* or *Pricing Streaming Service*), the products currently support Version 1 Authentication only (**As of May 2024**). Please contact your LSEG representative to verify if you are using Wealth or RTO solution.
13+
- For RTO customers, please be informed that the Version 1 Authentication is currently limited support. Please refer to [PCN207737](https://my.refinitiv.com/content/mytr/en/product-notifications/details.html?id=PCN207737) and [PCN208969](https://my.refinitiv.com/content/mytr/en/product-notifications/details.html?id=PCN208969) documents for more detail.
1414

1515
This example shows how developers may use the [Websocket API for Pricing Streaming and Real-Time Service](https://developers.lseg.com/en/api-catalog/refinitiv-real-time-opnsrc/refinitiv-websocket-api) aka Websocket API application to subscribe 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 or classic Jupyter Notebook. The project is 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.
1616

@@ -20,13 +20,13 @@ Please see the full documentation of this example application in [this article](
2020

2121
**Update (As of June 2024)**:
2222

23-
- The RTO console example (Authentication Version 1): Please check my colleague's [LSEG-API-Samples/Example.WebSocketAPI.Python.MRN.RTO](https://github.com/LSEG-API-Samples/Example.WebSocketAPI.Python.MRN.RTO) GitHub Repository.
24-
- The RTO notebook example (Authentication Version 1): *mrn_notebook_app_rto_v1.ipynb* notebook file.
23+
- The RTO console example (Version 1 Authentication): Please check my colleague's [LSEG-API-Samples/Example.WebSocketAPI.Python.MRN.RTO](https://github.com/LSEG-API-Samples/Example.WebSocketAPI.Python.MRN.RTO) GitHub Repository.
24+
- The RTO notebook example (Version 1 Authentication): *mrn_notebook_app_rto_v1.ipynb* notebook file.
2525
- Special thanks to Neeranat Junsuriyawong from the Solutions Consultant team for the contribution to this RTO notebook example.
26-
- The RTO console example (Authentication Version 2): *mrn_console_rto_v2.py* file
26+
- The RTO console example (Version 2 Authentication): *mrn_console_rto_v2.py* file
2727
- The deployed Real-Time Distribution System (RTDS) examples are *mrn_console_rtds.py* console application and *mrn_notebook_app_rtds.ipynb* notebook files.
2828

29-
You can find more information about the Authentication Version 2 from the following resources:
29+
You can find more information about the Version 2 Authentication from the following resources:
3030

3131
- [Account authorization V1 to V2 migration cheat sheet](https://developers.lseg.com/en/article-catalog/article/account-authorization-v1-to-v2-migration-cheat-sheet) article.
3232
- [Getting Started with Version 2 Authentication for Real-Time - Optimized: Overview](https://developers.lseg.com/en/article-catalog/article/getting-started-with-version-2-authentication-for-refinitiv-real) article.
@@ -90,11 +90,11 @@ This example requires the following dependencies software and libraries.
9090
This example project contains the following files and folders
9191

9292
1. *mrn_console_rtds.py*: The example console application for the deployed RTDS connection file
93-
2. *mrn_console_rto_v2.py*: The example console application for the RTO Authentication Version 2 connection file
94-
3. *.env.example*: The example ```.env``` file for the RTO Authentication Version 2 connection.
93+
2. *mrn_console_rto_v2.py*: The example console application for the RTO Version 2 Authentication connection file
94+
3. *.env.example*: The example ```.env``` file for the RTO Version 2 Authentication connection.
9595
4. *notebook_python/mrn_notebook_app.ipynb*: The example Jupyter Notebook application for the deployed RTDS connection file
96-
5. *notebook_python/mrn_notebook_app_rto.ipynb*: The example Jupyter Notebook application for the RTO Authentication Version 1 connection file
97-
6. *notebook_python/.env.example*: The example ```.env``` file for the RTO Authentication Version 1 connection notebook.
96+
5. *notebook_python/mrn_notebook_app_rto.ipynb*: The example Jupyter Notebook application for the RTO Version 1 Authentication connection file
97+
6. *notebook_python/.env.example*: The example ```.env``` file for the RTO Version 1 Authentication connection notebook.
9898
7. *Dockerfile*: The example application Dockerfile
9999
8. *requirements.txt*: The application dependencies configuration file
100100
9. LICENSE.md: Project's license file
@@ -189,7 +189,7 @@ Please be informed that your Real-Time Advanced Data Hub and Real-Time Advanced
189189

190190
4. The application subscribes to ```MRN_STORNY``` RIC code from Real-Time Advanced Distribution Server 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.
191191

192-
### <a id="rto_jupyter"></a>RTO Authentication Version 1 Jupyter Notebook example
192+
### <a id="rto_jupyter"></a>RTO Version 1 Authentication Jupyter Notebook example
193193

194194
Please be informed that your RTO access credentials should have a permission to request MRN data.
195195

@@ -203,7 +203,7 @@ Please be informed that your RTO access credentials should have a permission to
203203
3. Go to the project's notebook folder. and create a file name ```.env``` with the following content.
204204

205205
```ini
206-
# RTO Authentication Version 1 Credentials
206+
# RTO Version 1 Authentication Credentials
207207
RTO_USERNAME=<Your RTO Machine-ID>
208208
RTO_PASSWORD=<Your RTO Password>
209209
RTO_CLIENTID=<Your RTO App Key>
@@ -222,18 +222,41 @@ Please be informed that your RTO access credentials should have a permission to
222222

223223
5. Open *mrn_notebook_app_rto_v1.ipynb* Notebook document, then follow through each notebook cell.
224224

225-
### <a id="rto_console"></a>RTO Authentication Version 1 Console Example
225+
### <a id="rto_console"></a>RTO Version 1 Authentication Console Example
226226

227227
Please check my colleague's [LSEG-API-Samples/Example.WebSocketAPI.Python.MRN.RTO](https://github.com/LSEG-API-Samples/Example.WebSocketAPI.Python.MRN.RTO) GitHub Repository.
228228

229-
Alternatively, the *mrn_trna_console_rto.py* example of the [LSEG-API-Samples/Example.WebSocketAPI.Python.TRNA](https://github.com/LSEG-API-Samples/Example.WebSocketAPI.Python.MRN.TRNA) project also supports the MRN consumer with RTO (Authentication Version 1), but it subscribes to ```MRN_TRNA``` RIC code from the RTO by default.
229+
Alternatively, the *mrn_trna_console_rto.py* example of the [LSEG-API-Samples/Example.WebSocketAPI.Python.TRNA](https://github.com/LSEG-API-Samples/Example.WebSocketAPI.Python.MRN.TRNA) project also supports the MRN consumer with RTO (Version 1 Authentication), but it subscribes to ```MRN_TRNA``` RIC code from the RTO by default.
230230

231-
### <a id="rtds_console_docker"></a>Bonus: RTO Authentication Version 2 console Docker example
231+
### <a id="rto_v2_console"></a>RTO Version 2 Authentication Console Example
232232

233233
1. Create a file name ```.env``` at the root folder of the project and then add the following content to a file
234234

235235
```ini
236-
## Authentication Version 2
236+
## Version 2 Authentication
237+
CLIENT_ID=CLIENT_ID_V2
238+
CLIENT_SECRET=CLIENT_SECRET_V2
239+
```
240+
2. Activate MRN_RTO environment with this command in Anaconda Prompt
241+
242+
```bash
243+
(base) $>conda activate MRN_RTO
244+
```
245+
246+
3. Then you can run mrn_console_rto_v2.py application with the following command
247+
248+
```bash
249+
(MRN_RTO) $> python mrn_console_rto_v2.py --ric <MRN_STORY by default>
250+
```
251+
252+
4. The application subscribes to ```MRN_STORY``` RIC code from RTO 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.
253+
254+
### <a id="rtds_console_docker"></a>Bonus: RTO Version 2 Authentication console Docker example
255+
256+
1. Create a file name ```.env``` at the root folder of the project and then add the following content to a file
257+
258+
```ini
259+
## Version 2 Authentication
237260
CLIENT_ID=CLIENT_ID_V2
238261
CLIENT_SECRET=CLIENT_SECRET_V2
239262
```

mrn_console_rto_v2.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,11 @@ def connect(self):
284284
subprotocols=['tr_json2'])
285285
# Event loop
286286
if not self.wst:
287-
#print(str(datetime.now()) + " " + self.session_name + ": Connecting WebSocket to " + ws_address + "...")
288287
print(f'{str(datetime.now())} {str(self.session_name)}: Connecting WebSocket to {ws_address} ...')
289288
self.wst = threading.Thread(target=self.web_socket_app.run_forever, kwargs={'sslopt': {'check_hostname': False}})
290289
self.wst.daemon = True
291290
self.wst.start()
292291
elif self.reconnecting and not self.force_disconnected:
293-
#print(str(datetime.now()) + " " + self.session_name + ": Reconnecting WebSocket to " + ws_address + "...")
294292
print(f'{str(datetime.now())} {str(self.session_name)}: Reconnecting WebSocket to {ws_address} ...')
295293
self.web_socket_app.run_forever()
296294

@@ -492,8 +490,8 @@ def print_commandline_usage_and_exit(exit_code):
492490
if not auth_token:
493491
print('Failed initial authentication with Delivery Platform. Exiting...')
494492
sys.exit(1)
495-
496-
tokenTS = time.time()
493+
# get an access token receiving time, used for connection logic
494+
tokenTS = time.time()
497495

498496
# If hostname is specified, use it for the connection
499497
if hostName != '':
@@ -522,10 +520,10 @@ def print_commandline_usage_and_exit(exit_code):
522520
if session1.reconnecting:
523521
curTS = time.time()
524522
if (int(expire_time) < 600):
525-
deltaTime = float(expire_time) * 0.05
523+
DELTA_TIME = float(expire_time) * 0.05
526524
else:
527-
deltaTime = 300
528-
if (int(curTS) >= int(float(tokenTS) + float(expire_time) - float(deltaTime))):
525+
DELTA_TIME = 300
526+
if (int(curTS) >= int(float(tokenTS) + float(expire_time) - float(DELTA_TIME))):
529527
auth_token, expire_time = get_auth_token()
530528
tokenTS = time.time()
531529
else:

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ jwcrypto==1.5.6
88
pip-system-certs==4.0
99
pycparser==2.22
1010
python-dotenv==1.0.1
11-
requests==2.31.0
11+
requests==2.32.3
1212
typing_extensions==4.12.0
13-
urllib3==2.2.1
13+
urllib3==2.2.2
1414
websocket-client==1.8.0
1515
wrapt==1.16.0

0 commit comments

Comments
 (0)