This example shows how to connect to Tick History from Refinitiv™ and trigger a buy decision for a single Reuters® Instrument Code (RIC) using the trade price.
Create a Tick History from Refinitiv connection by using a user name and password. The appearance of the connection
c in the MATLAB® workspace indicates a successful connection.
username = 'username'; password = 'password'; c = trth(username,password);
Retrieve intraday data for the IBM® security. Using the
retrieve the trade price from November 6, 2017 through November 7, 2017.
sec = ["IBM.N","Ric"]; fields = ["Trade - Price"]; startdate = datetime('11/06/2017','InputFormat','MM/dd/yyyy'); enddate = datetime('11/07/2017','InputFormat','MM/dd/yyyy'); d = timeseries(c,sec,fields,startdate,enddate);
Display the first three rows of intraday data.
ans = 3×5 timetable Time x_RIC Domain GMTOffset Type Price ____________________ _______ ______________ _________ _______ ________ 06-Nov-2017 14:30:10 'IBM.N' 'Market Price' '-5' 'Trade' '151.68' 06-Nov-2017 14:30:10 'IBM.N' 'Market Price' '-5' 'Trade' '151.66' 06-Nov-2017 14:30:10 'IBM.N' 'Market Price' '-5' 'Trade' '151.73'
d is a timetable that contains these variables:
Transaction date and time
GMT time zone offset
Assume a price threshold of $160. Determine if the trade price is less than
$160. Set the buy indicator
when the threshold is met.
value = str2double(d.Price); buynow = (value < 160);
Use the buy indicator to create a buy order of IBM shares in the trading system of your choice.