%% Elektron from Refinitiv Workflow Example

%   Copyright 2016-2019 The MathWorks, Inc.

% Using Elektron from Refinitiv EMA

% Add jar files for Elektron, path will depend on user's setup
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

% Create securities list in column vector
s = {'IBM.N','AAPL.O','GOOG.O','MSFT.O'}'; 

% Connect to Elektron
e = elektron('mw338','dELEKTRON_DD','111.222.333.444',14002);

% Get data for single security
d = getdata(e,'IBM.N');

% Update most recent trade price in realtime for list of securities
reqId = realtime(e,s,@(~,ev)elektronPriceTableListener(ev,s));

% Open price table
openvar('PriceTable')

% To stop realtime updates:
% delete(reqId.Listener)