Decide to Buy Shares Using Thomson Reuters Elektron Current Data

This example shows how to connect to Thomson Reuters Elektron® and trigger a buy decision for a single RIC using the current Thomson Reuters Elektron last trade price.

To access the code for this example, enter edit ElektronWorkflow.m.

Create Thomson Reuters Elektron Connection

Add Thomson Reuters Elektron JAR files to the dynamic Java® class path. Find these JAR files in the installation folder. Here, the installation folder is i:\Elektron.

javaaddpath i:\Elektron\ansipage.jar
javaaddpath i:\Elektron\ema-javadoc.jar
javaaddpath i:\Elektron\ema.jar
javaaddpath i:\Elektron\jdacsUpalib.jar
javaaddpath i:\Elektron\upa.jar
javaaddpath i:\Elektron\upaValueAdd.jar
javaaddpath i:\Elektron\upaValueAddCache.jar
javaaddpath i:\Elektron\commons-configuration-1.10.jar
javaaddpath i:\Elektron\commons-lang-2.6.jar
javaaddpath i:\Elektron\commons-logging-1.2.jar
javaaddpath i:\Elektron\org.apache.commons.collections.jar
javaaddpath i:\Elektron\slf4j-api-1.7.12.jar
javaaddpath i:\Elektron\slf4j-jdk14-1.7.12.jar

Alternatively, add these JAR files to the static Java class path. For details about dynamic and static class paths, see Java Class Path (MATLAB).

Connect to Thomson Reuters Elektron using the user name and service name.

c is an elektron object.

username = 'username';
servicename = 'servicename';

c = elektron(username,servicename);

Retrieve Current Data for Single Security

Retrieve current data for the IBM® security.

d is a table that contains the current data. The variables are:

  • FieldId — Thomson Reuters Elektron field identifier

  • DataType — Thomson Reuters Elektron data type of the Thomson Reuters Elektron field

  • Name — Thomson Reuters Elektron field name

  • Value — Current Thomson Reuters Elektron data value

s = 'IBM.N';
d = getdata(c,s)
d = 

    FieldId    DataType        Name                 Value          
    _______    ________    ____________    ________________________
    [    1]    [18]        "PROD_PERM"     ["62"                  ]
    [    2]    [18]        "RDNDISPLAY"    ["64"                  ]
    [    3]    [31]        "DSPLY_NAME"    ["DELAYED-15INTL B"    ]
...

Make Investment Decision to Buy Shares

Assume a price threshold of $175. Determine if the last trade price is less than $175. Set the buy indicator buynow to true when the threshold is met. Find the Thomson Reuters Elektron last trade price by the field identifier 6.

for i = 1:height(d)
    field = cell2mat(d.FieldId(i)); % Convert cell array value to numeric
    value = cell2mat(d.Value(i));
    if (field == 6)                 % Find last trade price
        if (value < 175)            % Trigger buy price threshold
            buynow = true;
        end
    end
end

Use the buy indicator to create a buy order for IBM shares in the trading system of your choice.

Close Thomson Reuters Elektron Connection

close(c)

See Also

| |

Related Topics

External Websites