Retrieve Datastream Web Services Historical Data
This example shows how to retrieve historical data from Datastream™ Web Services from Refinitiv™. You must have Datastream Web Services credentials. For credentials, contact Datastream Web Services from Refinitiv.
Create Datastream Web Services Connection
Create a Datastream Web Services connection using your user name and password.
c
is the datastreamws
connection object.
username = 'ABCDEF'; password = 'abcdef12345'; c = datastreamws(username,password);
Retrieve Monthly Historical Data
Adjust the display format to display currency.
format bank
Retrieve and display historical end-of-day price data from January 1, 2017, through
December 31, 2017. Specify the VOD
security and these fields:
Opening price
High price
Last closing price
Specify a monthly period. d
is a timetable with the date
in the first variable and the fields in the subsequent variables.
sec = "VOD"; fields = ["PO";"PH";"P"]; startdate = datetime('01-01-2017','InputFormat','MM-dd-yyyy'); enddate = datetime('12-31-2017','InputFormat','MM-dd-yyyy'); period = 'M'; d = history(c,sec,fields,startdate,enddate,period)
d = 12×3 timetable Time PO PH P ____________________ ______ ______ ______ 01-Jan-2017 00:00:00 NaN NaN 199.85 01-Feb-2017 00:00:00 196.85 197.25 193.00 01-Mar-2017 00:00:00 201.80 202.55 202.55 01-Apr-2017 00:00:00 209.00 209.10 206.65 01-May-2017 00:00:00 NaN NaN 199.05 01-Jun-2017 00:00:00 231.65 233.90 229.40 01-Jul-2017 00:00:00 217.65 219.20 218.70 01-Aug-2017 00:00:00 223.15 223.60 221.65 01-Sep-2017 00:00:00 221.25 221.95 219.50 01-Oct-2017 00:00:00 209.35 211.60 210.50 01-Nov-2017 00:00:00 217.00 222.30 218.95 01-Dec-2017 00:00:00 224.15 230.65 224.00
Retrieve Quarterly Historical Data
Retrieve and display historical end-of-day price data from January 1, 2017, through
December 31, 2017. Specify the VOD
security and these fields:
Opening price
High price
Last closing price
Specify a quarterly period. d
is a timetable with the
date in the first variable and the fields in the subsequent variables.
sec = "VOD"; fields = ["PO";"PH";"P"]; startdate = datetime('01-01-2017','InputFormat','MM-dd-yyyy'); enddate = datetime('12-31-2017','InputFormat','MM-dd-yyyy'); period = 'Q'; d = history(c,sec,fields,startdate,enddate,period)
d = 4×3 timetable Time PO PH P ____________________ ______ ______ ______ 01-Jan-2017 00:00:00 NaN NaN 199.85 01-Apr-2017 00:00:00 209.00 209.10 206.65 01-Jul-2017 00:00:00 217.65 219.20 218.70 01-Oct-2017 00:00:00 209.35 211.60 210.50
Use the monthly and quarterly prices for each field to make investment decisions for
the VOD
security.