Skip to content

Commit 1d86f22

Browse files
author
Wasin Waeosri
committed
1. Update README.md
2. Add comment to notebook file
1 parent bac7ff5 commit 1d86f22

2 files changed

Lines changed: 251 additions & 63 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Contributing your data to Thomson Reuters with Elektron WebSocket API
1+
# Contributing your data to Refinitiv with Elektron WebSocket API
22
- Last update: July 2019
33
- Environment: Windows and Linux OS
44
- Compiler: Python

notebook_python/trcc_posting_notebook.ipynb

Lines changed: 250 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,57 @@
11
{
22
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Contributing your data to Refinitiv with Elektron WebSocket API\n",
8+
"\n",
9+
"\n",
10+
"\n",
11+
"## TRCC Overview\n",
12+
"\n",
13+
"The Thomson Reuters Contribution Channel (TRCC) is a new service for on-boarding content to the Refinitiv. Depending on the client's needs, access to the service will be fulfilled by one or more of the following products: Contributions Channel for TREP, Contributions Channel for Elektron API, Contributions Channel for Spreadsheet. TRCC aims for replacing the legacy Market Link IP (MLIP) system.\n",
14+
"\n",
15+
"Data Contribution is a means to send your pricing data directly to Refinitiv , from where it can fan out globally. Leading market participants, such as banks and brokers, use Refinitiv to publish and distribute their information to the community of financial professions, in order to advertise their prices to clients and prospects.\n",
16+
"\n",
17+
"## Application Overview\n",
18+
"\n",
19+
"This example shows how to writing an application to contribute your data to TRCC using [Elektron WebSocket API](https://developers.refinitiv.com/elektron/websocket-api) through Thomson Reuters Enterprise Platform (TREP). The example just connects to TREP via a WebSocket connection, then sends an off-stream post to contribute item to TRCC server via that TREP.\n",
20+
"\n",
21+
"If you are not familiar with Elektron WebSocket API Posting concept, please visit [Contributing Data to TREP using the Websocket API](https://developers.refinitiv.com/article/contributing-data-trep-using-websocket-api) article which will give you a full explanation of the WebSocket API Posting mechanisms and process.\n",
22+
"\n",
23+
"## Contribution Setups\n",
24+
"\n",
25+
"The Elektron WebSocket API cannot connect to TRCC server directly (only Elektron SDK C++ and Java APIs support that feature). It requires TREP version 3.2.1 (and above) to take care of the JSON-OMM conversion, TRCC connection and login process for the WebSocket application.\n",
26+
"\n",
27+
"The TREP infrastructure connects to TRCC through the delivery direct network via Tunnel Stream Aggregator (TSA) adapter, which is a private network (TLS encrypted) between a client site and Refinitiv. The TSA adapter is already packaged with the ADH version 3.2, and needs to be configured. You can find more detail regarding the TREP-TRCC configurations in [Contributing your data to Thomson Reuters article](https://developers.refinitiv.com/article/contributing-your-data-thomson-reuters) page (*Contribution through TREP* section). \n"
28+
]
29+
},
30+
{
31+
"cell_type": "markdown",
32+
"metadata": {},
33+
"source": [
34+
"## Prerequisite\n",
35+
"\n",
36+
"This example requires the following dependencies softwares and libraries.\n",
37+
"1. TREP server (both ADS and ADH) 3.2.x with WebSocket connection.\n",
38+
"2. TRCC username, password and host list credentials. Please reach out to your Refinitiv sales associate to acquire TRCC access credentials.\n",
39+
"\n",
40+
"*Note:* The TRCC access credentials are required in the connection between ADH server and TRCC server only, not in the application level."
41+
]
42+
},
43+
{
44+
"cell_type": "markdown",
45+
"metadata": {},
46+
"source": [
47+
"## How to run this console example\n",
48+
"\n",
49+
"Please be informed that your TREP server (ADS and ADH) should be applied the TRCC configurations and TRCC contribution service should be \"Up\" before running an example. "
50+
]
51+
},
352
{
453
"cell_type": "code",
5-
"execution_count": null,
54+
"execution_count": 1,
655
"metadata": {},
756
"outputs": [],
857
"source": [
@@ -16,7 +65,7 @@
1665
},
1766
{
1867
"cell_type": "code",
19-
"execution_count": null,
68+
"execution_count": 2,
2069
"metadata": {},
2170
"outputs": [],
2271
"source": [
@@ -35,7 +84,7 @@
3584
},
3685
{
3786
"cell_type": "code",
38-
"execution_count": null,
87+
"execution_count": 9,
3988
"metadata": {},
4089
"outputs": [],
4190
"source": [
@@ -51,7 +100,7 @@
51100
},
52101
{
53102
"cell_type": "code",
54-
"execution_count": null,
103+
"execution_count": 10,
55104
"metadata": {},
56105
"outputs": [],
57106
"source": [
@@ -68,7 +117,7 @@
68117
},
69118
{
70119
"cell_type": "code",
71-
"execution_count": null,
120+
"execution_count": 11,
72121
"metadata": {},
73122
"outputs": [],
74123
"source": [
@@ -79,65 +128,26 @@
79128
]
80129
},
81130
{
82-
"cell_type": "code",
83-
"execution_count": null,
131+
"cell_type": "markdown",
84132
"metadata": {},
85-
"outputs": [],
86133
"source": [
87-
"# Create JSON Off-Stream Post message and sends it to ADS server.\n",
134+
"## Contribution Process\n",
88135
"\n",
89-
"def send_market_price_post(ws):\n",
90-
" \"\"\" Send a post message contains a market-price content to TRCC \"\"\"\n",
91-
"\n",
92-
" \"\"\" Contribution fields \"\"\"\n",
93-
" contribution_fields = {\n",
94-
" \"BID\": bid_value,\n",
95-
" \"ASK\": ask_value,\n",
96-
" \"PRIMACT_1\": primact_1_value\n",
97-
" }\n",
98-
"\n",
99-
" \"\"\" OMM Post msg Key \"\"\"\n",
100-
" mp_post_key = {\n",
101-
" \"Name\": post_item_name,\n",
102-
" \"Service\": service_name\n",
103-
" }\n",
104-
"\n",
105-
" \"\"\" OMM Post Payload \"\"\"\n",
106-
" contribution_payload_json = {\n",
107-
" \"ID\": 0,\n",
108-
" \"Type\": \"Update\",\n",
109-
" \"Domain\": \"MarketPrice\",\n",
110-
" \"Fields\": contribution_fields,\n",
111-
" \"Key\": {}\n",
112-
" }\n",
113-
"\n",
114-
" \"\"\" OMM Off-Stream Post message \"\"\"\n",
115-
" mp_post_json_offstream = {\n",
116-
" \"Domain\": \"MarketPrice\",\n",
117-
" \"Ack\": True,\n",
118-
" \"PostID\": post_id,\n",
119-
" \"PostUserInfo\": {\n",
120-
" \"Address\": position,\n",
121-
" \"UserID\": int(app_id)\n",
122-
" },\n",
123-
" \"Key\": {},\n",
124-
" \"Message\": {},\n",
125-
" \"Type\": \"Post\",\n",
126-
" \"ID\": login_id #Off-Stream post, sending the Post message on the Loing stream.\n",
127-
" }\n",
128-
"\n",
129-
" contribution_payload_json[\"Key\"] = mp_post_key\n",
130-
" mp_post_json_offstream[\"Key\"] = mp_post_key\n",
131-
" mp_post_json_offstream[\"Message\"] = contribution_payload_json\n",
132-
"\n",
133-
" ws.send(json.dumps(mp_post_json_offstream))\n",
134-
" print(\"SENT:\")\n",
135-
" print(json.dumps(mp_post_json_offstream, sort_keys=True, indent=2, separators=(',', ':')))\n"
136+
"The application requires the following steps to contribute data to TRCC via TREP:\n",
137+
"1. The application initiates WebSocket connection with ADS server.\n",
138+
"2. Application sends a OMM Login request message to ADS in JSON format.\n",
139+
"3. Once the application receives a Login Refresh message from ADS, the application can contribute data to TRCC via Off-Stream Post message.\n",
140+
"4. The Off-Stream Post message must have the following conditions:\n",
141+
" * The ```Ack``` attribute must be true\n",
142+
" * The message must contain the ```PostID``` attribute and value\n",
143+
" * The ```Key``` information which includes ```Name``` and ```Service``` attributes that refer to contribution RIC name and TRCC contribution service name\n",
144+
" * The ```Message``` payload must be an Update message type\n",
145+
" * The ```Message``` payload must contain the same ```Key``` information as the Post message"
136146
]
137147
},
138148
{
139149
"cell_type": "code",
140-
"execution_count": null,
150+
"execution_count": 12,
141151
"metadata": {},
142152
"outputs": [],
143153
"source": [
@@ -189,11 +199,178 @@
189199
" print(json.dumps(login_json, sort_keys=True, indent=2, separators=(',', ':')))"
190200
]
191201
},
202+
{
203+
"cell_type": "markdown",
204+
"metadata": {},
205+
"source": [
206+
"## Off-Stream Post\n",
207+
"\n",
208+
"In an off-stream post, the client application can send a post for an item via a Login stream, regardless of whether a data stream first exists. The route of the post is determined by the TREP (ADS and ADH) configuration."
209+
]
210+
},
192211
{
193212
"cell_type": "code",
194-
"execution_count": null,
213+
"execution_count": 13,
195214
"metadata": {},
196215
"outputs": [],
216+
"source": [
217+
"# Create JSON Off-Stream Post message and sends it to ADS server.\n",
218+
"\n",
219+
"def send_market_price_post(ws):\n",
220+
" \"\"\" Send a post message contains a market-price content to TRCC \"\"\"\n",
221+
"\n",
222+
" \"\"\" Contribution fields \"\"\"\n",
223+
" contribution_fields = {\n",
224+
" \"BID\": bid_value,\n",
225+
" \"ASK\": ask_value,\n",
226+
" \"PRIMACT_1\": primact_1_value\n",
227+
" }\n",
228+
"\n",
229+
" \"\"\" OMM Post msg Key \"\"\"\n",
230+
" mp_post_key = {\n",
231+
" \"Name\": post_item_name,\n",
232+
" \"Service\": service_name\n",
233+
" }\n",
234+
"\n",
235+
" \"\"\" OMM Post Payload \"\"\"\n",
236+
" contribution_payload_json = {\n",
237+
" \"ID\": 0,\n",
238+
" \"Type\": \"Update\",\n",
239+
" \"Domain\": \"MarketPrice\",\n",
240+
" \"Fields\": contribution_fields,\n",
241+
" \"Key\": {}\n",
242+
" }\n",
243+
"\n",
244+
" \"\"\" OMM Off-Stream Post message \"\"\"\n",
245+
" mp_post_json_offstream = {\n",
246+
" \"Domain\": \"MarketPrice\",\n",
247+
" \"Ack\": True,\n",
248+
" \"PostID\": post_id,\n",
249+
" \"PostUserInfo\": {\n",
250+
" \"Address\": position,\n",
251+
" \"UserID\": int(app_id)\n",
252+
" },\n",
253+
" \"Key\": {},\n",
254+
" \"Message\": {},\n",
255+
" \"Type\": \"Post\",\n",
256+
" \"ID\": login_id #Off-Stream post, sending the Post message on the Loing stream.\n",
257+
" }\n",
258+
"\n",
259+
" contribution_payload_json[\"Key\"] = mp_post_key\n",
260+
" mp_post_json_offstream[\"Key\"] = mp_post_key\n",
261+
" mp_post_json_offstream[\"Message\"] = contribution_payload_json\n",
262+
"\n",
263+
" ws.send(json.dumps(mp_post_json_offstream))\n",
264+
" print(\"SENT:\")\n",
265+
" print(json.dumps(mp_post_json_offstream, sort_keys=True, indent=2, separators=(',', ':')))\n"
266+
]
267+
},
268+
{
269+
"cell_type": "code",
270+
"execution_count": 14,
271+
"metadata": {},
272+
"outputs": [
273+
{
274+
"name": "stdout",
275+
"output_type": "stream",
276+
"text": [
277+
"Connecting to WebSocket ws://172.20.33.30:15000/WebSocket ...\n",
278+
"WebSocket successfully connected!\n",
279+
"SENT:\n",
280+
"{\n",
281+
" \"Domain\":\"Login\",\n",
282+
" \"ID\":1,\n",
283+
" \"Key\":{\n",
284+
" \"Elements\":{\n",
285+
" \"ApplicationId\":\"256\",\n",
286+
" \"Position\":\"10.42.68.162\"\n",
287+
" },\n",
288+
" \"Name\":\"root\"\n",
289+
" }\n",
290+
"}\n",
291+
"RECEIVED: \n",
292+
"[\n",
293+
" {\n",
294+
" \"Domain\":\"Login\",\n",
295+
" \"Elements\":{\n",
296+
" \"MaxMsgSize\":61430,\n",
297+
" \"PingTimeout\":30\n",
298+
" },\n",
299+
" \"ID\":1,\n",
300+
" \"Key\":{\n",
301+
" \"Elements\":{\n",
302+
" \"AllowSuspectData\":1,\n",
303+
" \"ApplicationId\":\"256\",\n",
304+
" \"ApplicationName\":\"ADS\",\n",
305+
" \"Position\":\"10.42.68.162\",\n",
306+
" \"ProvidePermissionExpressions\":1,\n",
307+
" \"ProvidePermissionProfile\":0,\n",
308+
" \"SingleOpen\":1,\n",
309+
" \"SupportBatchRequests\":7,\n",
310+
" \"SupportEnhancedSymbolList\":1,\n",
311+
" \"SupportOMMPost\":1,\n",
312+
" \"SupportOptimizedPauseResume\":1,\n",
313+
" \"SupportPauseResume\":1,\n",
314+
" \"SupportStandby\":1,\n",
315+
" \"SupportViewRequests\":1\n",
316+
" },\n",
317+
" \"Name\":\"root\"\n",
318+
" },\n",
319+
" \"State\":{\n",
320+
" \"Data\":\"Ok\",\n",
321+
" \"Stream\":\"Open\",\n",
322+
" \"Text\":\"Login accepted by host apis30.\"\n",
323+
" },\n",
324+
" \"Type\":\"Refresh\"\n",
325+
" }\n",
326+
"]\n",
327+
"Sending Off-Stream Post to TREP Server\n",
328+
"SENT:\n",
329+
"{\n",
330+
" \"Ack\":true,\n",
331+
" \"Domain\":\"MarketPrice\",\n",
332+
" \"ID\":1,\n",
333+
" \"Key\":{\n",
334+
" \"Name\":\"TRCCTEST12\",\n",
335+
" \"Service\":\"TRCC\"\n",
336+
" },\n",
337+
" \"Message\":{\n",
338+
" \"Domain\":\"MarketPrice\",\n",
339+
" \"Fields\":{\n",
340+
" \"ASK\":35.48,\n",
341+
" \"BID\":34.25,\n",
342+
" \"PRIMACT_1\":116.5\n",
343+
" },\n",
344+
" \"ID\":0,\n",
345+
" \"Key\":{\n",
346+
" \"Name\":\"TRCCTEST12\",\n",
347+
" \"Service\":\"TRCC\"\n",
348+
" },\n",
349+
" \"Type\":\"Update\"\n",
350+
" },\n",
351+
" \"PostID\":1,\n",
352+
" \"PostUserInfo\":{\n",
353+
" \"Address\":\"10.42.68.162\",\n",
354+
" \"UserID\":256\n",
355+
" },\n",
356+
" \"Type\":\"Post\"\n",
357+
"}\n",
358+
"RECEIVED: \n",
359+
"[\n",
360+
" {\n",
361+
" \"AckID\":1,\n",
362+
" \"ID\":1,\n",
363+
" \"Key\":{\n",
364+
" \"Name\":\"TRCCTEST12\",\n",
365+
" \"Service\":\"TRCC\"\n",
366+
" },\n",
367+
" \"Type\":\"Ack\"\n",
368+
" }\n",
369+
"]\n",
370+
"WebSocket Closed\n"
371+
]
372+
}
373+
],
197374
"source": [
198375
"# WebSocket connection process\n",
199376
"\n",
@@ -245,11 +422,22 @@
245422
]
246423
},
247424
{
248-
"cell_type": "code",
249-
"execution_count": null,
425+
"cell_type": "markdown",
250426
"metadata": {},
251-
"outputs": [],
252-
"source": []
427+
"source": [
428+
"## References\n",
429+
"* [Refinitiv Elektron SDK Family page](https://developers.refinitiv.com/elektron) on the [Refinitiv Developer Community](https://developers.thomsonreuters.com/) web site.\n",
430+
"* [Refinitiv Elektron WebSocket API page](https://developers.refinitiv.com/websocket-api).\n",
431+
"* [Developer Webinar Recording: Introduction to Electron WebSocket API](https://www.youtube.com/watch?v=CDKWMsIQfaw).\n",
432+
"* [Contributing Data to TREP using the Websocket API article](https://developers.refinitiv.com/article/contributing-data-trep-using-websocket-api).\n",
433+
"* [Contributing your data to Thomson Reuters article](https://developers.refinitiv.com/article/contributing-your-data-thomson-reuters).\n",
434+
"* [Refinitiv Elektron: RIC Search](https://developers.refinitiv.com/elektron/websocket-api/dev-tools?type=ric).\n",
435+
"* [Refinitiv Data Model Discovery page](https://refinitiv.fixspec.com/specserver/specs/reuters): Explore TR data models, content definitions and data update behaviors.\n",
436+
"* [EMA Java Tutorial - Posting data to TR Contribution Channel](https://developers.refinitiv.com/elektron/elektron-sdk-java/learning?content=41885&type=learning_material_item).\n",
437+
"* [EMA C++ Tutorial - Posting data to TR Contribution Channel](https://developers.refinitiv.com/elektron/elektron-sdk-cc/learning?content=26452&type=learning_material_item).\n",
438+
"\n",
439+
"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)."
440+
]
253441
}
254442
],
255443
"metadata": {

0 commit comments

Comments
 (0)