Decide to Sell Shares with Historical Data Using Tick History from Refinitiv
This example shows how to connect to Tick History from Refinitiv™ and trigger a sell decision for a single Reuters® Instrument Code (RIC) using the closing 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 historical data for the IBM® security. Using the history
function,
retrieve the closing price from November 6, 2017, through November 7,
2017.
sec = ["IBM.N","Ric"]; fields = ["Last"]; startdate = datetime('11/06/2017','InputFormat','MM/dd/yyyy'); enddate = datetime('11/07/2017','InputFormat','MM/dd/yyyy'); d = history(c,sec,fields,startdate,enddate);
2×1 timetable Time Last __________ ______ 2017/11/06 150.84 2017/11/07 151.35
Assume a price threshold of $150. Determine if the closing price is greater
than $150. Set the sell indicator sellnow
to
true
when the threshold is met.
sellnow = (d.Last > 150);
Use the sell indicator to create a sell order of IBM shares in the trading system of your choice.