Decide to Buy Shares with Intraday Data Using Tick History from Refinitiv
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
object 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 timeseries
function,
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.
head(d,3)
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
RIC
Domain
GMT time zone offset
Transaction type
Price
Assume a price threshold of $160. Determine if the trade price is less than
$160. Set the buy indicator buynow
to true
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.