Skip to content

Commit a9a04f4

Browse files
committed
rebranding, fix url and add batch to websocket example
1 parent 95caeb2 commit a9a04f4

File tree

4 files changed

+50
-36
lines changed

4 files changed

+50
-36
lines changed

.gitignore

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
chart.png
21
images/
3-
docs/TRKD_REST_with_Python_master.doc
42
note.txt
5-
test.py
63
market_price_edpgw_authentication.py
74
.vscode/
8-
interday_result.txt
9-
interday_result2.txt
10-
interday_result3.txt
11-
interday_result4.txt
125
notebook/test/
136
notebook/.ipynb_checkpoints
147
*/.ipynb_checkpoints/*
158
trkd_websocketexample.py
169
ERT_in_Cloud/
17-
docs_tr/
10+
internal_dev/

README.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
# RKD HTTP JSON with Python Example
2-
## Overview
3-
The [Refinitiv Knowledge Direct (RKD) API](https://developers.refinitiv.com/thomson-reuters-knowledge-direct-trkd) (formerly known as TRKD API) integrates into your website, trading platform, company intranet/extranet, advisory portal and mobile applications to provide up-to-date financial market data, news and analytics and powerful investment tools.
2+
- version: 1.5.5
3+
- Last update: May 2021
4+
- Environment: Windows, Linux
5+
- Compiler: Python
6+
- Prerequisite: [Demo prerequisite](#prerequisite)
7+
8+
## <a id="overview"></a>Overview
9+
The [Refinitiv Knowledge Direct (RKD) API](https://developers.refinitiv.com/en/api-catalog/refinitiv-knowledge-direct/refinitiv-knowledge-direct-api-rkd-api) (formerly known as TRKD API) integrates into your website, trading platform, company intranet/extranet, advisory portal and mobile applications to provide up-to-date financial market data, news and analytics and powerful investment tools.
410

511
RKD offers a wide range of Refinitiv' information and services delivered in a request-response scenario via web services using today's industry standard protocols (SOAP/XML and REST/JSON). Connectivity can be via HTTP and HTTPS, over the Internet or Delivery Direct. All data are snapshot (non-streaming) data.
612

713
This is an example project that shows how to implement RKD HTTP JSON client and RKD Streaming client with Python programming language. The project example are in both console and Jupyter Notebook applications.
814

915
*Note:* The Jupyter Notebook example does not contain all the same RKD services service as console examples yet. [TBD]
1016

11-
## Application Files
17+
## <a id="project_files"></a>Application Files
1218
This project contains the following example scripts for each RKD services
1319
- trkd_authen.py: An example application that shows how to authenticate with RKD service
1420
- trkd_quote.py: An example application that shows how to subscribe (all fields and specific fields) the Quote data from RKD service
@@ -27,7 +33,7 @@ This project contains the following example scripts for each RKD services
2733

2834
All source code and scripts are provided under the Apache 2.0 license. They are provided AS IS with no warranty or guarantee of fit for purpose. See the project's LICENSE.md for details.
2935

30-
## Prerequisite
36+
## <a id="prerequisite"></a>Prerequisite
3137
The following softwares are required to use this script
3238
- RKD API credentials. Please reach out to your Refinitiv sales associate to acquire RKD access credentials.
3339
- [Python 3](https://www.python.org/).
@@ -41,13 +47,13 @@ All scripts support Python 3 only and not compatible with Python 2.
4147
*Note:*
4248
- You can install 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.
4349

44-
## How to run the script
50+
## <a id="run_console"></a>How to run the script
4551
Run the script via the command line (or shell)
4652
```
4753
$>python <application>.py
4854
```
4955

50-
## Optional - How to install libraries for console examples
56+
## <a id="library_install"></a>Optional - How to install libraries for console examples
5157
The best way is via the pip package management tool
5258
1. export <Python_folder>\Scripts to your OS PATH environment
5359
2. call pip command to install requests
@@ -62,30 +68,30 @@ The best way is via the pip package management tool
6268

6369
*Note*: If you aim to use only RKD HTTP JSON services, you can just install requests library via a ```pip install requests``` command.
6470

65-
## Optional - How to install libraries for notebook examples
71+
## <a id="run_notebook"></a>Optional - How to install libraries for notebook examples
6672
Please follow the [classic Jupyter Notebook installation guide](https://jupyter.org/install) page.
6773

68-
## RDP and ERT in Cloud
74+
## <a id="rdp"></a>RDP and Refinitiv Real-Time - Optimized
6975

70-
You may consider the strategic [Refinitiv Data Platform (RDP)](https://developers.refinitiv.com/refinitiv-data-platform) web base APIs platform. RDP APIs give you seamless and holistic access to all of Refinitiv content such as Historical Pricing, Environmental Social and Governance (ESG), News, Research, etc and commingled with your own content, enriching, integrating and distributing the data through a single interface, delivered wherever you need it. The RDP APIs delivery mechanisms are following:
76+
You may consider the strategic [Refinitiv Data Platform (RDP)](https://developers.refinitiv.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-platform-apis) web base APIs platform. RDP APIs give you seamless and holistic access to all of Refinitiv content such as Historical Pricing, Environmental Social and Governance (ESG), News, Research, etc and commingled with your own content, enriching, integrating and distributing the data through a single interface, delivered wherever you need it. The RDP APIs delivery mechanisms are following:
7177
* Request - Response: RESTful web service (HTTP GET, POST, PUT or DELETE)
7278
* Alert: delivery is a mechanism to receive asynchronous updates (alerts) to a subscription.
7379
* Bulks: deliver substantial payloads, like the end of day pricing data for the whole venue.
7480
* Streaming: deliver real-time delivery of messages.
7581

76-
Please see [RDP API Overview page](https://developers.refinitiv.com/refinitiv-data-platform/refinitiv-data-platform-apis) for more detail.
82+
Please see [RDP APIs Overview page](https://developers.refinitiv.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-platform-apis) for more detail.
7783

78-
As part of RDP, [Elektron Real Time in Cloud (ERT in Cloud)](https://developers.thomsonreuters.com/elektron/websocket-api/quick-start?content=45253&type=quick_start) gives you access to best in class Real Time market data delivered in the cloud. ERT in Cloud is a new delivery mechanism for RDP, using the AWS (Amazon Web Services) cloud. Once a connection to RDP is established using ERT in Cloud, data can be retrieved using [Elektron WebSocket API](https://developers.thomsonreuters.com/websocket-api) (the same as RKD Streaming Service).
84+
As part of RDP, [Refinitiv Real-Time - Optimized (RRTO)](https://developers.refinitiv.com/en/api-catalog/refinitiv-real-time-opnsrc/refinitiv-websocket-api/tutorials#connect-to-refinitiv-real-time-optimized) gives you access to best in class Real Time market data delivered in the cloud. RRTO is a new delivery mechanism for RDP, using the AWS (Amazon Web Services) cloud. Once a connection to RDP is established using RRTO, data can be retrieved using [WebSocket API](https://developers.refinitiv.com/en/api-catalog/refinitiv-real-time-opnsrc/refinitiv-websocket-api) (the same as RKD Streaming Service).
7985

80-
Key benefit of the strategic RDP and ERT in Cloud platform are the Cloud Delivery. The Platform is based on [Amazon AWS](https://aws.amazon.com/), the world class leading Cloud Provider for developers. The RDP and ERT in Cloud support output for multiple cloud vendors such as AWS, Azure, GCS, etc. for cloud-native or on-premise integration. The ERT in Cloud servers are hosted in multiple location world-wide which lets the application choose the closest server based on their region for full potential.
86+
Key benefit of the strategic RDP and RRTO platform are the Cloud Delivery. The Platform is based on [Amazon AWS](https://aws.amazon.com/), the world class leading Cloud Provider for developers. The RDP and RRTO support output for multiple cloud vendors such as AWS, Azure, GCS, etc. for cloud-native or on-premise integration. The RRTO servers are hosted in multiple location world-wide which lets the application choose the closest server based on their region for full potential.
8187

82-
## References
88+
## <a id="references"></a>References
8389
For further details, please check out the following resources:
84-
* [Refinitiv Knowledge Direct API page](https://developers.refinitiv.com/thomson-reuters-knowledge-direct-trkd) on the [Refinitiv Developers Community](https://developers.refinitiv.com/) web site.
85-
* [Refinitiv Knowledge Direct API Catalog](https://www.trkd.thomsonreuters.com/SupportSite/RequestBuilder/requestbuilder.aspx) web site.
86-
* [Elektron WebSocket API](https://developers.refinitiv.com/websocket-api) page on the [Refinitiv Developers Community](https://developers.refinitiv.com/) web site.
87-
* [Refinitiv Data Platform (RDP) APIs page](https://developers.refinitiv.com/refinitiv-data-platform).
88-
* [Refinitiv Data Platform (RDP) APIs Gateway page](https://api.refinitiv.com).
90+
* [Refinitiv Knowledge Direct API page](https://developers.refinitiv.com/en/api-catalog/refinitiv-knowledge-direct/refinitiv-knowledge-direct-api-rkd-api) on the [Refinitiv Developers Community](https://developers.refinitiv.com/) web site.
91+
* [Refinitiv Knowledge Direct API Catalog](https://support-portal.rkd.refinitiv.com/SupportSite/TestApi/Catalog) web site.
92+
* [WebSocket API](https://developers.refinitiv.com/websocket-api) page on the [Refinitiv Developers Community](https://developers.refinitiv.com/) web site.
93+
* [Refinitiv Data Platform (RDP) APIs page](https://developers.refinitiv.com/en/api-catalog/refinitiv-data-platform/refinitiv-data-platform-apis).
94+
* [Refinitiv Data Platform (RDP) APIs Gateway page](https://apidocs.refinitiv.com/Apps/ApiDocs).
8995

9096
## Release Note
9197
- Version 1: 6 Sep 2016
@@ -134,7 +140,10 @@ For further details, please check out the following resources:
134140
- version 1.5.2: October 2019
135141
- Update TRKD Interday and Intraday services operations.
136142
- version 1.5.3: May 2020
137-
- Update RDP and ERT in Cloud information.
143+
- Update RDP and Refinitiv Real-Time - Optimized information.
138144
- version 1.5.4: June 2020
139145
- Update API name and information.
140146
- Fix all typo errors
147+
- version 1.5.5: May 2021
148+
- Re-branding Product names and URLs.
149+
- add trkd_wsstreaming.py Batch support.

assetinfo.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

trkd_wsstreaming.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
logged_in = False
4242

4343
ric_name = 'EUR='
44+
rics_list = ['EUR=','THB=']
4445

4546
expire_time = 0
4647
time_to_relogin = 15 * 60 # 15 Minutes to Seconds
@@ -75,7 +76,7 @@ def CreateAuthorization(username, password, appid):
7576
##create authentication request URL, message and header
7677
authenMsg = {'CreateServiceToken_Request_1': { 'ApplicationID':appid, 'Username':username,'Password':password }}
7778
headers = {'content-type': 'application/json;charset=utf-8'}
78-
print('############### Sending Authentication request message to TRKD ###############')
79+
print('############### Sending Authentication request message to RKD ###############')
7980
authenResult = doSendRequest(trkd_authen_address, authenMsg, headers)
8081
if authenResult and authenResult.status_code == 200:
8182
print('Authentication success')
@@ -113,15 +114,16 @@ def process_message(message_json):
113114
print("SENT:")
114115
print(json.dumps(pong_json, sort_keys=True, indent=2, separators=(',', ':')))
115116

116-
# Process incoming Login Refresh message from RKD Elektron WebSocket Server
117+
# Process incoming Login Refresh message from RKD Real-Time WebSocket Server
117118
def process_login_response(message_json):
118119
""" Send item request """
119120
global logged_in
120121

121122
logged_in = True
122-
send_market_price_request(ric_name)
123+
send_market_price_request(ric_name) # send a single item request message
124+
#send_market_price_batch_request(rics_list) # send a batch items request message
123125

124-
# Send JSON OMM Market Price Request message to RKD Elektron WebSocket Server
126+
# Send JSON OMM Market Price Request message to RKD Real-Time WebSocket Server
125127
def send_market_price_request(ric_name):
126128
""" Create and send simple Market Price request """
127129
mp_req_json = {
@@ -134,7 +136,20 @@ def send_market_price_request(ric_name):
134136
print("SENT:")
135137
print(json.dumps(mp_req_json, sort_keys=True, indent=2, separators=(',', ':')))
136138

137-
# Send JSON OMM Login Request message to RKD Elektron WebSocket Server to initiate the OMM connection
139+
# Send JSON OMM Market Price Batch Request message to RKD Real-Time WebSocket Server
140+
def send_market_price_batch_request(rics_list):
141+
""" Create and send simple Market Price request """
142+
mp_req_json = {
143+
'ID': 2,
144+
'Key': {
145+
'Name': rics_list,
146+
},
147+
}
148+
web_socket_app.send(json.dumps(mp_req_json))
149+
print("SENT:")
150+
print(json.dumps(mp_req_json, sort_keys=True, indent=2, separators=(',', ':')))
151+
152+
# Send JSON OMM Login Request message to RKD Real-Time WebSocket Server to initiate the OMM connection
138153
def send_login_request(is_refresh_token=False):
139154
""" Generate a login request from command line data (or defaults) and send """
140155
login_json = {
@@ -164,7 +179,7 @@ def send_login_request(is_refresh_token=False):
164179
print("SENT:")
165180
print(json.dumps(login_json, sort_keys=True, indent=2, separators=(',', ':')))
166181

167-
# Receive every messages from RKD Elektron WebSocket Server
182+
# Receive every messages from RKD Real-Time WebSocket Server
168183
def on_message(_, message):
169184
""" Called when message received, parse message into JSON for processing """
170185
print("RECEIVED: ")

0 commit comments

Comments
 (0)