Skip to content

Commit 6f7d177

Browse files
committed
Added additional samples in content layer
1 parent cf14b61 commit 6f7d177

16 files changed

Lines changed: 901 additions & 286 deletions

‎.vscode/launch.json‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
{
2-
"version": "0.2.0",
3-
"configurations": [
4-
{
5-
"name": "Current TS File",
6-
"type": "node",
7-
"request": "launch",
8-
"args": ["${relativeFile}"],
9-
"runtimeArgs": ["-r", "ts-node/register"],
10-
"cwd": "${workspaceRoot}",
11-
"protocol": "inspector",
12-
"internalConsoleOptions": "openOnSessionStart",
13-
"sourceMaps": true,
14-
"outputCapture": "std"
15-
}
16-
]
17-
}
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Current TS File",
6+
"type": "node",
7+
"request": "launch",
8+
"args": ["${relativeFile}"],
9+
"runtimeArgs": ["-r", "ts-node/register"],
10+
"cwd": "${workspaceRoot}",
11+
"protocol": "inspector",
12+
"internalConsoleOptions": "openOnSessionStart",
13+
"sourceMaps": true,
14+
"outputCapture": "std"
15+
}
16+
]
17+
}

‎LICENSE‎

Lines changed: 201 additions & 201 deletions
Large diffs are not rendered by default.

‎README.md‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
# TypeScript examples for the Refinitiv Data Library
2-
3-
## Summary
4-
5-
The following series of examples demonstrate how to programmatically access content residing within the Refinitiv Data Platform (RDP) using a single, ease of use API called the Refinitiv Data Library for TypeScript. The platform refers to the layer of data services providing both streaming and non-streaming content serving different clients, from the simple desktop interface to the enterprise application.
6-
7-
The Refinitiv Data Library is structured as a stack of interfaces and libraries designed to foster the adoption of our platform by both financial coders and professional developers to programmatically access financial content. Based on this stack of interfaces, the examples defined within this section have been organized as follows:
8-
9-
## Content
10-
11-
The Content examples target higher-level abstractions representing financial items like Pricing, News, Historical Data, etc. The Content layer can easily be used by both professional developers and financial coders. It provides great flexibility for commonly used financial objects.
12-
13-
14-
## Delivery
15-
16-
The Delivery examples target the interfaces defined within the lowest abstraction layer of the library. The examples provide core level services including logging and WebSocket customization. In addition, different delivery service examples such as Request/Reply data endpoints, real-time streaming and interfaces supporting queuing capabilities offered for news headlines, stories and research message services.
17-
18-
Please see [Refinitiv Developers Community](https://developers.refinitiv.com/) for step by step tutorials on how to use these samples.
1+
# TypeScript examples for the Refinitiv Data Library
2+
3+
## Summary
4+
5+
The following series of examples demonstrate how to programmatically access content residing within the Refinitiv Data Platform (RDP) using a single, ease of use API called the Refinitiv Data Library for TypeScript. The platform refers to the layer of data services providing both streaming and non-streaming content serving different clients, from the simple desktop interface to the enterprise application.
6+
7+
The Refinitiv Data Library is structured as a stack of interfaces and libraries designed to foster the adoption of our platform by both financial coders and professional developers to programmatically access financial content. Based on this stack of interfaces, the examples defined within this section have been organized as follows:
8+
9+
## Content
10+
11+
The Content examples target higher-level abstractions representing financial items like Pricing, News, Historical Data, etc. The Content layer can easily be used by both professional developers and financial coders. It provides great flexibility for commonly used financial objects.
12+
13+
14+
## Delivery
15+
16+
The Delivery examples target the interfaces defined within the lowest abstraction layer of the library. The examples provide core level services including logging and WebSocket customization. In addition, different delivery service examples such as Request/Reply data endpoints, real-time streaming and interfaces supporting queuing capabilities offered for news headlines, stories and research message services.
17+
18+
Please see [Refinitiv Developers Community](https://developers.refinitiv.com/) for step by step tutorials on how to use these samples.

‎rdplibconfig.prod.json‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
{
2-
"logs": {
3-
"level": "warn",
4-
"filter": "*",
5-
"transports": {
6-
"console": {
7-
"enabled": true
8-
},
9-
"file": {
10-
"enabled": false,
11-
"name": "rdlib"
12-
}
13-
}
14-
}
15-
}
1+
{
2+
"logs": {
3+
"level": "warn",
4+
"filter": "*",
5+
"transports": {
6+
"console": {
7+
"enabled": true
8+
},
9+
"file": {
10+
"enabled": false,
11+
"name": "rdlib"
12+
}
13+
}
14+
}
15+
}

‎session.config.json‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
{
2-
"sessions": {
3-
"default": "platform",
4-
5-
"platform": {
6-
"rdpUser": "<RDP Machine ID>",
7-
"rdpPassword": "<RDP Password>",
8-
"appKey": "<RDP Application Key>"
9-
},
10-
11-
"desktop": {
12-
"appKey": "<Desktop Application Key>"
13-
},
14-
15-
"container": {
16-
"appKey": "<Application Key>"
17-
}
18-
}
19-
}
1+
{
2+
"sessions": {
3+
"default": "platform",
4+
5+
"platform": {
6+
"rdpUser": "<RDP Machine ID>",
7+
"rdpPassword": "<RDP Password>",
8+
"appKey": "<RDP Application Key>"
9+
},
10+
11+
"desktop": {
12+
"appKey": "<Desktop Application Key>"
13+
},
14+
15+
"container": {
16+
"appKey": "<Application Key>"
17+
}
18+
}
19+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// tslint:disable: no-console
2+
// tslint:disable-next-line: no-implicit-dependencies
3+
4+
// **********************************************************************************************************************
5+
// historical-pricing-events
6+
// The HistoricalPricing Events example demonstrates how to capture trade tick-based data.
7+
//
8+
// Note: To configure settings for your environment, modify the session.config json file
9+
// **********************************************************************************************************************
10+
11+
import { HistoricalPricing } from '@refinitiv-data/data';
12+
import { getSession } from '../../Common/session';
13+
14+
const session = getSession();
15+
16+
(async () => {
17+
try {
18+
console.log('Opening the session...');
19+
// open the session
20+
await session.open();
21+
console.log('Session open, sending data request');
22+
23+
// retrieve tick pricing events, default 20 rows of data. Specified trades only and specific columns of data.
24+
const request1 = HistoricalPricing.Events.Definition({
25+
universe: 'IBM.N',
26+
eventTypes: ['trade'],
27+
fields: ['DATE_TIME', 'EVENT_TYPE', 'TRDPRC_1', 'TRDVOL_1']
28+
});
29+
30+
const response1 = await request1.getData(session);
31+
32+
if(response1.data.table) {
33+
console.log('Historical Trade events');
34+
console.table(response1.data.table);
35+
}
36+
else {
37+
console.log('No data received');
38+
}
39+
}
40+
catch (err) {
41+
console.log(err);
42+
}
43+
finally {
44+
session.close();
45+
}
46+
})();
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// tslint:disable: no-console
2+
// tslint:disable-next-line: no-implicit-dependencies
3+
4+
// **********************************************************************************************************************
5+
// historical-pricing-summaries
6+
// The HistoricalPricing Summaries example demonstrates both intraday and interday data retrievals from the platform.
7+
//
8+
// Note: To configure settings for your environment, modify the session.config json file
9+
// **********************************************************************************************************************
10+
11+
import { HistoricalPricing } from '@refinitiv-data/data';
12+
import { getSession } from '../../Common/session';
13+
14+
const session = getSession();
15+
16+
(async () => {
17+
try {
18+
console.log('Opening the session...');
19+
// open the session
20+
await session.open();
21+
console.log('Session open, sending data request');
22+
23+
// retrieve Intraday Summaries with 1-minute interval. Specify to capture only 12 rows.
24+
const request1 = HistoricalPricing.Summaries.Definition({
25+
universe: 'IBM.N',
26+
interval: HistoricalPricing.Summaries.IntradayInterval.ONE_MINUTE,
27+
fields: ['TRDPRC_1', 'HIGH_1', 'LOW_1', 'OPEN_PRC', 'NUM_MOVES'],
28+
count: 12
29+
});
30+
31+
const response1 = await request1.getData(session);
32+
33+
if(response1.data.table) {
34+
console.log('Historical pricing intraday summaries');
35+
console.table(response1.data.table);
36+
}
37+
else {
38+
console.log('No data received');
39+
}
40+
41+
// retrieve Interday Summaries with 1-day interval and all the fields
42+
const request2 = HistoricalPricing.Summaries.Definition({
43+
universe: 'IBM.N',
44+
interval: HistoricalPricing.Summaries.InterdayInterval.DAILY,
45+
count: 5
46+
});
47+
48+
const response2 = await request2.getData(session);
49+
50+
if(response2.data.table) {
51+
console.log('Historical pricing interday summaries');
52+
console.table(response2.data.table);
53+
}
54+
else {
55+
console.log('No data received');
56+
}
57+
}
58+
catch (err) {
59+
console.log(err);
60+
}
61+
finally {
62+
session.close();
63+
}
64+
})();
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// tslint:disable:no-console
2+
// tslint:disable-next-line: no-implicit-dependencies
3+
4+
// **********************************************************************************************************************
5+
// pricing-snapshot
6+
// The following example demonstrates a basic use case of the Pricing interface to retrieve a snapshot of prices from
7+
// the platform. The interface supports the ability to specify a list of items and the fields for each to retrieve.
8+
//
9+
// Note: To configure settings for your environment, modify the session.config json file
10+
// **********************************************************************************************************************
11+
12+
import { Pricing } from '@refinitiv-data/data';
13+
import { getSession } from '../../Common/session';
14+
15+
const session = getSession();
16+
17+
(async () => {
18+
try {
19+
console.log('Opening the session...');
20+
// open the session
21+
await session.open();
22+
console.log('Session open, sending data request');
23+
24+
// specify a list of items and fields to retrieve a snapshot of prices
25+
const pricingDefinition = Pricing.Definition({
26+
universe: ['EUR=', 'CAD=', 'GBP='],
27+
fields: ['DSPLY_NAME', 'BID', 'ASK', 'OPEN_PRC', 'PCTCHNG'],
28+
extendedParams: {
29+
QoS: {
30+
Rate: 'TimeConflated',
31+
RateInfo: 10000
32+
}
33+
}
34+
});
35+
36+
const stream = pricingDefinition.getStream(session);
37+
// open the stream in snapshot mode
38+
await stream.open({withUpdates: false});
39+
40+
// print all the fields of one item
41+
console.log('\nEUR=, all fields: ');
42+
console.table(stream.getFields('EUR='));
43+
44+
// print one field
45+
console.log('\nCAD=, BID field value = ', stream.getFieldValue('CAD=', 'BID'));
46+
47+
// print multiple fields
48+
console.log('\nGBP=, multiple fields value: ');
49+
console.table(stream.getFields('GBP=', ['DSPLY_NAME', 'BID', 'ASK']));
50+
}
51+
catch (err) {
52+
console.log(err);
53+
}
54+
finally {
55+
await session.close();
56+
}
57+
})();
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// tslint:disable:no-console
2+
// tslint:disable-next-line: no-implicit-dependencies
3+
4+
// **********************************************************************************************************************
5+
// pricing-streamingCache
6+
// The following example demonstrates the basic usage of the Streaming Cache interfaces. When defining a streaming cache,
7+
// users can optionally pull out live prices from the cache at their leisure. The interface will automatically manage
8+
// streaming updates as market conditions change and keep the internal cache fresh.
9+
//
10+
// Note: To configure settings for your environment, modify the session.config json file
11+
// **********************************************************************************************************************
12+
13+
import { Pricing } from '@refinitiv-data/data';
14+
import { getSession } from '../../Common/session';
15+
16+
const session = getSession();
17+
18+
(async () => {
19+
try {
20+
console.log('Opening the session...');
21+
// open the session
22+
await session.open();
23+
console.log('Session open, sending data request');
24+
25+
// specify a list of items and fields to retrieve a snapshot of prices
26+
const pricingDefinition = Pricing.Definition({
27+
universe: ['EUR=', 'CAD=', 'GBP='],
28+
fields: ['DSPLY_NAME', 'BID', 'ASK', 'OPEN_PRC', 'PCTCHNG'],
29+
extendedParams: {
30+
QoS: {
31+
Rate: 'TimeConflated',
32+
RateInfo: 10000
33+
}
34+
}
35+
});
36+
37+
const stream = pricingDefinition.getStream(session);
38+
// open the stream in streaming mode
39+
await stream.open();
40+
41+
if(stream.state) {
42+
for(let i = 0; i < 5; i++) {
43+
// get and print data from the stream every 5 second
44+
console.table(
45+
{
46+
'EUR=': stream.getFields('EUR='),
47+
'CAD=': stream.getFields('CAD='),
48+
'GBP=': stream.getFields('GBP=')
49+
});
50+
await new Promise(res => setTimeout(res, 5000));
51+
}
52+
}
53+
54+
// close the open stream
55+
await stream.close();
56+
}
57+
catch (err) {
58+
console.log(err);
59+
}
60+
finally {
61+
await session.close();
62+
}
63+
})();

0 commit comments

Comments
 (0)